WIP jordan
This commit is contained in:
26
app/composables/useProviderContactEmails.ts
Normal file
26
app/composables/useProviderContactEmails.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import {
|
||||
emptyProviderContacts,
|
||||
PROVIDER_EMAIL_ROLE_LABEL,
|
||||
PROVIDER_EMAIL_ROLE_ORDER,
|
||||
type ProviderContactEmails,
|
||||
type ProviderEmailRole
|
||||
} from '~/types/provider-contacts'
|
||||
import { useLocalStorageRef } from '~/utils/useLocalStorageRef'
|
||||
|
||||
function storageKey(providerId: string) {
|
||||
return `policy-ui-provider-contacts-v1-${providerId}`
|
||||
}
|
||||
|
||||
export function useProviderContactEmails(providerId: string) {
|
||||
const emails = useLocalStorageRef(storageKey(providerId), emptyProviderContacts)
|
||||
|
||||
function label(r: ProviderEmailRole) {
|
||||
return PROVIDER_EMAIL_ROLE_LABEL[r]
|
||||
}
|
||||
|
||||
return {
|
||||
emails,
|
||||
roles: PROVIDER_EMAIL_ROLE_ORDER,
|
||||
label
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user