Skip to content

Commit

Permalink
refactor: async loading and cleaner component name
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper Nykänen committed Nov 8, 2023
1 parent cbba275 commit 75748c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions site/src/components/station_dropdown_menu/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Locale } from '~/types/common'

import dynamic from 'next/dynamic'
import Link from 'next/link'
import { shallow } from 'zustand/shallow'

import { DialogTrigger } from '@radix-ui/react-dialog'
import {
Arrow,
CheckboxItem,
Expand All @@ -12,7 +14,7 @@ import {
Root,
Trigger
} from '@radix-ui/react-dropdown-menu'
import { DialogTrigger } from '@radix-ui/react-dialog'

import React from 'react'

import CirclesHorizontal from '~/components/icons/circles_horizontal.svg'
Expand All @@ -25,8 +27,13 @@ import { useFavorites } from '~/hooks/use_favorites'
import { googleMapsDirections } from '~/utils/services'
import translate from '~/utils/translate'

import { DialogProvider } from '../dialog'
import { FilterTrain } from './filter_train'
const DialogProvider = dynamic(() =>
import('../dialog').then(mod => mod.DialogProvider)
)
const TrainsFilterDialog = dynamic(() =>
import('./trains_filter_dialog').then(mod => mod.TrainsFilterDialog)
)

import { useFilters } from '~/hooks/use_filters'

type StationShortCode = string
Expand Down Expand Up @@ -141,7 +148,10 @@ export const StationDropdownMenu = (props: StationDropdownMenuProps) => {
</Item>
</Content>
</Portal>
<FilterTrain locale={props.locale} onSubmit={() => setOpen(false)} />
<TrainsFilterDialog
locale={props.locale}
onSubmit={() => setOpen(false)}
/>
</DialogProvider>
</Root>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Props = {
onSubmit: (values: typeof initialValues) => void
}

export const FilterTrain = (props: Props) => {
export const TrainsFilterDialog = (props: Props) => {
const { locale } = props

const [isReset, setIsReset] = React.useState(false)
Expand Down

0 comments on commit 75748c7

Please sign in to comment.