Skip to content

Commit

Permalink
fix dropdown display
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeKarow committed Jul 19, 2024
1 parent e9ee27b commit 55384e6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/ui/modals/CoverageArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@mantine/core'
import { useDisclosure } from '@mantine/hooks'
import { type TFunction, useTranslation } from 'next-i18next'
import { forwardRef, useEffect } from 'react'
import { forwardRef, useCallback, useEffect } from 'react'

import { trpc as api } from '~ui/lib/trpcClient'

Expand All @@ -19,7 +19,9 @@ import { useStyles } from './styles'
import { ModalTitle } from '../ModalTitle'

const reduceDistType = (data: { tsNs: string; tsKey: string }[] | undefined, t: TFunction) => {
if (!data) return ''
if (!data) {
return []
}
const valueSet = data.reduce((prev, curr) => {
const translated = t(curr.tsKey, { ns: curr.tsNs, count: 1 })
prev.add(translated)
Expand Down Expand Up @@ -86,13 +88,13 @@ const CoverageAreaModal = forwardRef<HTMLButtonElement, Props>(
item: reduceDistType(
dataDistrict?.map(({ govDistType }) => govDistType),
t
),
).join('/'),
}),
third: t('select.base', {
item: reduceDistType(
dataSubDist?.map(({ govDistType }) => govDistType),
t
),
).join('/'),
}),
}

Expand All @@ -108,7 +110,7 @@ const CoverageAreaModal = forwardRef<HTMLButtonElement, Props>(
})

const canAdd = !!selected.country
const handleAdd = () => {
const handleAdd = useCallback(() => {
if (selected.govDist || selected.subDist) {
const distToAdd = selected.subDist ?? selected.govDist
if (!distToAdd) {
Expand All @@ -121,7 +123,7 @@ const CoverageAreaModal = forwardRef<HTMLButtonElement, Props>(
} else if (selected.country) {
addServiceArea.mutate({ serviceArea, countryId: selected.country })
}
}
}, [addServiceArea, selected, serviceArea])

return (
<>
Expand Down

0 comments on commit 55384e6

Please sign in to comment.