This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
971e444
commit ec571b2
Showing
17 changed files
with
184 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useEffect, useMemo } from 'react' | ||
import useWS from '../../../components/hooks/useWS' | ||
|
||
export type ResidenceType = { | ||
text: string | ||
value: string | ||
} | ||
|
||
const formatStatesList = (states) => { | ||
if (!states.length) { | ||
return [] | ||
} | ||
|
||
return states?.map( | ||
({ text }) => | ||
typeof text !== undefined && { | ||
name: text, | ||
display_name: text, | ||
}, | ||
) | ||
} | ||
|
||
export const useStatesList = (country_code) => { | ||
const { send, data } = useWS('states_list') | ||
|
||
useEffect(() => { | ||
send({ states_list: country_code }) | ||
}, [country_code]) | ||
|
||
const states_list = useMemo(() => formatStatesList(data || []), [data]) | ||
return [states_list] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.