Skip to content

Commit

Permalink
feat: add useLocale hook and use for all applications queries
Browse files Browse the repository at this point in the history
  • Loading branch information
thoreyjona committed Oct 10, 2024
1 parent df4b50b commit beeebf7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 6 additions & 0 deletions apps/native/app/src/hooks/use-locale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { usePreferencesStore } from '../stores/preferences-store'

export const useLocale = () => {
const locale = usePreferencesStore(({ locale }) => locale)
return locale === 'is-IS' ? 'is' : 'en'
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
} from '../../graphql/types/schema'
import { createNavigationOptionHooks } from '../../hooks/create-navigation-option-hooks'
import { useConnectivityIndicator } from '../../hooks/use-connectivity-indicator'
import { useLocale } from '../../hooks/use-locale'
import { ApplicationsList } from './components/applications-list'
import { usePreferencesStore } from '../../stores/preferences-store'

const { useNavigationOptions, getNavigationOptions } =
createNavigationOptionHooks(
Expand All @@ -33,7 +33,6 @@ export const ApplicationsCompletedScreen: NavigationFunctionComponent = ({
}) => {
useNavigationOptions(componentId)
const [refetching, setRefetching] = useState(false)
const { locale } = usePreferencesStore()

const applicationsRes = useListApplicationsQuery({
variables: {
Expand All @@ -44,7 +43,7 @@ export const ApplicationsCompletedScreen: NavigationFunctionComponent = ({
ApplicationResponseDtoStatusEnum.Approved,
],
},
locale: locale === 'is-IS' ? 'is' : 'en',
locale: useLocale(),
},
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
} from '../../graphql/types/schema'
import { createNavigationOptionHooks } from '../../hooks/create-navigation-option-hooks'
import { useConnectivityIndicator } from '../../hooks/use-connectivity-indicator'
import { useLocale } from '../../hooks/use-locale'
import { ApplicationsList } from './components/applications-list'
import { usePreferencesStore } from '../../stores/preferences-store'

const { useNavigationOptions, getNavigationOptions } =
createNavigationOptionHooks(
Expand All @@ -33,14 +33,13 @@ export const ApplicationsInProgressScreen: NavigationFunctionComponent = ({
}) => {
useNavigationOptions(componentId)
const [refetching, setRefetching] = useState(false)
const { locale } = usePreferencesStore()

const applicationsRes = useListApplicationsQuery({
variables: {
input: {
status: [ApplicationResponseDtoStatusEnum.Inprogress],
},
locale: locale === 'is-IS' ? 'is' : 'en',
locale: useLocale(),
},
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
} from '../../graphql/types/schema'
import { createNavigationOptionHooks } from '../../hooks/create-navigation-option-hooks'
import { useConnectivityIndicator } from '../../hooks/use-connectivity-indicator'
import { useLocale } from '../../hooks/use-locale'
import { ApplicationsList } from './components/applications-list'
import { usePreferencesStore } from '../../stores/preferences-store'

const { useNavigationOptions, getNavigationOptions } =
createNavigationOptionHooks(
Expand All @@ -33,14 +33,13 @@ export const ApplicationsIncompleteScreen: NavigationFunctionComponent = ({
}) => {
useNavigationOptions(componentId)
const [refetching, setRefetching] = useState(false)
const { locale } = usePreferencesStore()

const applicationsRes = useListApplicationsQuery({
variables: {
input: {
status: [ApplicationResponseDtoStatusEnum.Draft],
},
locale: locale === 'is-IS' ? 'is' : 'en',
locale: useLocale(),
},
})

Expand Down
7 changes: 2 additions & 5 deletions apps/native/app/src/screens/applications/applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import {
} from '../../graphql/types/schema'
import { createNavigationOptionHooks } from '../../hooks/create-navigation-option-hooks'
import { useConnectivityIndicator } from '../../hooks/use-connectivity-indicator'
import { useLocale } from '../../hooks/use-locale'
import { testIDs } from '../../utils/test-ids'
import { isIos } from '../../utils/devices'
import { ApplicationsPreview } from './components/applications-preview'
import { BottomTabsIndicator } from '../../components/bottom-tabs-indicator/bottom-tabs-indicator'
import { usePreferencesStore } from '../../stores/preferences-store'

const { useNavigationOptions, getNavigationOptions } =
createNavigationOptionHooks(
Expand Down Expand Up @@ -102,12 +102,9 @@ export const ApplicationsScreen: NavigationFunctionComponent = ({
const theme = useTheme()
const [refetching, setRefetching] = useState(false)
const [hiddenContent, setHiddenContent] = useState(isIos)
const { locale } = usePreferencesStore()

const queryLocale = locale === 'is-IS' ? 'is' : 'en'

const applicationsRes = useListApplicationsQuery({
variables: { locale: queryLocale },
variables: { locale: useLocale() },
})

const applications = useMemo(
Expand Down

0 comments on commit beeebf7

Please sign in to comment.