Skip to content

Commit

Permalink
fix: formatBudget defined in two places (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevkevinpal authored Nov 8, 2023
1 parent 1b4ea7c commit 39819e6
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/components/AddContentModal/BudgetStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import CheckIcon from '~/components/Icons/CheckIcon'
import { Flex } from '~/components/common/Flex'
import { Text } from '~/components/common/Text'
import { useUserStore } from '~/stores/useUserStore'
import { colors } from '~/utils/colors'
import { formatBudget } from './utils'
import { colors, formatBudget } from '~/utils'

type Props = {
onClick: () => void
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddContentModal/LocationStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import styled from 'styled-components'
import { Flex } from '~/components/common/Flex'
import { Text } from '~/components/common/Text'
import { TextInput } from '~/components/common/TextInput'
import { colors } from '~/utils/colors'
import { colors } from '~/utils'
import { FormData } from '..'
import { validateLatitude, validateLongitude } from './utils'

Expand Down
6 changes: 1 addition & 5 deletions src/components/AddContentModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import { api } from '~/network/api'
import { useModal } from '~/stores/useModalStore'
import { useUserStore } from '~/stores/useUserStore'
import { SubmitErrRes } from '~/types'
import { colors } from '~/utils/colors'
import { getLSat } from '~/utils/getLSat'
import { payLsat } from '~/utils/payLsat'
import { updateBudget } from '~/utils/setBudget'
import { executeIfProd } from '~/utils/tests'
import { colors, getLSat, payLsat, updateBudget, executeIfProd } from '~/utils'
import { ToastMessage } from '../common/Toast/toastMessage'
import { BudgetStep } from './BudgetStep'
import { LocationStep } from './LocationStep'
Expand Down
14 changes: 1 addition & 13 deletions src/components/AddSourceModal/BudgetStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CheckIcon from '~/components/Icons/CheckIcon'
import { Flex } from '~/components/common/Flex'
import { Text } from '~/components/common/Text'
import { useUserStore } from '~/stores/useUserStore'
import { colors } from '~/utils/colors'
import { formatBudget, colors } from '~/utils'

type Props = {
onClick: () => void
Expand All @@ -14,18 +14,6 @@ type Props = {
export const BudgetStep: FC<Props> = ({ onClick }) => {
const [budget] = useUserStore((s) => [s.budget])

function formatBudget(value: number | null) {
if (value === null) {
return '?'
}

const stringBudget = value.toLocaleString()

const splittedBudget = stringBudget.split(',')

return splittedBudget.join(' ')
}

return (
<Flex>
<Flex align="center" direction="row" justify="space-between" mb={20}>
Expand Down
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { assertNever } from './assertNever'
import { boost } from './boost'
import { colors } from './colors'
import { formatBudget } from './formatBudget'
import { formatDescription } from './formatDescription'
import { formatTimestamp } from './formatTimestamp'
import { getLSat } from './getLSat'
import { getSelectedNodeTimestamps } from './getSelectedNodeTimestamps'
import { getSuperficialNodeWeight } from './getSuperficialNodeWeight'
import { overrideConsole } from './logger'
import { media } from './media'
import { payLsat } from './payLsat'
import { saveConsumedContent, saveSearchTerm } from './relayHelper'
import { updateBudget } from './setBudget'
import { convertToChatMessage } from './stringToChatMessage'
import { executeIfTetsRunning, executeIfProd, addToGlobalForE2e, E2ETests } from './tests'
import { timeToMilliseconds } from './timeToMilliseconds'
import { useIsMatchBreakpoint } from './useIsMatchBreakpoint'
// import APP_VERSION from './versionHelper'
import { videoTimetoSeconds } from './videoTimetoSeconds'

export {
assertNever,
boost,
colors,
formatBudget,
formatDescription,
formatTimestamp,
getLSat,
getSelectedNodeTimestamps,
getSuperficialNodeWeight,
overrideConsole,
media,
payLsat,
saveConsumedContent,
saveSearchTerm,
updateBudget,
convertToChatMessage,
executeIfTetsRunning,
executeIfProd,
addToGlobalForE2e,
E2ETests,
timeToMilliseconds,
useIsMatchBreakpoint,
videoTimetoSeconds,
}

0 comments on commit 39819e6

Please sign in to comment.