diff --git a/frontend/src/hooks/useOus/index.tsx b/frontend/src/hooks/useOus/index.tsx index 64c12dba296b0065935a9415892ecd6c21f672e7..01459176acb55d3eeada3c9271b7ffc640d6b0b8 100644 --- a/frontend/src/hooks/useOus/index.tsx +++ b/frontend/src/hooks/useOus/index.tsx @@ -22,5 +22,25 @@ function useOus(): OuData[] { return ous } +export const enSort = (a: OuData, b: OuData) => { + if (a.en > b.en) { + return 1 + } + if (b.en > a.en) { + return -1 + } + return 0 +} + +export const nbSort = (a: OuData, b: OuData) => { + if (a.nb > b.nb) { + return 1 + } + if (b.nb > a.nb) { + return -1 + } + return 0 +} + export type { OuData } export default useOus diff --git a/frontend/src/routes/sponsor/register/stepPersonForm.tsx b/frontend/src/routes/sponsor/register/stepPersonForm.tsx index ca85cbc8165395f479f865d5eea931546d003ec7..f4bb3a4e09ef8ce895c76914ce32f0b9714d318e 100644 --- a/frontend/src/routes/sponsor/register/stepPersonForm.tsx +++ b/frontend/src/routes/sponsor/register/stepPersonForm.tsx @@ -11,7 +11,7 @@ import { } from '@mui/material' import { Controller, SubmitHandler, useForm } from 'react-hook-form' import { DatePicker } from '@mui/lab' -import React, { +import { forwardRef, Ref, useEffect, @@ -21,7 +21,7 @@ import React, { import { useTranslation } from 'react-i18next' import { RegisterFormData } from './formData' import { PersonFormMethods } from './personFormMethods' -import useOus, { OuData } from '../../../hooks/useOus' +import useOus, { enSort, nbSort } from '../../../hooks/useOus' import useRoleTypes, { RoleTypeData } from '../../../hooks/useRoleTypes' import { isValidEmail } from '../../../utils' @@ -51,26 +51,6 @@ const StepPersonForm = forwardRef( return a.name_en.localeCompare(b.name_en) } - const enSort = (a: OuData, b: OuData) => { - if (a.en > b.en) { - return 1 - } - if (b.en > a.en) { - return -1 - } - return 0 - } - - const nbSort = (a: OuData, b: OuData) => { - if (a.nb > b.nb) { - return 1 - } - if (b.nb > a.nb) { - return -1 - } - return 0 - } - const submit: SubmitHandler<RegisterFormData> = (data) => { nextHandler(data) }