Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
chore: add trim for state
Browse files Browse the repository at this point in the history
  • Loading branch information
habib-deriv committed Feb 4, 2024
1 parent 9a56690 commit 1dee84f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/features/hooks/use-states-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ export type ResidenceType = {
value: string
}

const isAlphanumeric = (str: string): boolean => /^[a-zA-Z0-9]+$/.test(str)

const formatStatesList = (states) => {
if (!states.length) {
return []
}

return states?.map(
({ text }) =>
typeof text !== undefined && {
return states.reduce((acc, { text }) => {
if (text && isAlphanumeric(text)) {
acc.push({
name: text,
display_name: text,
},
)
})
}
return acc
}, [])
}

export const useStatesList = (country_code) => {
Expand Down

0 comments on commit 1dee84f

Please sign in to comment.