Files
kycnotme/web/src/constants/verificationStepStatus.ts
2025-05-23 21:50:03 +00:00

54 lines
1.3 KiB
TypeScript

import { makeHelpersForOptions } from '../lib/makeHelpersForOptions'
import { transformCase } from '../lib/strings'
import type BadgeSmall from '../components/BadgeSmall.astro'
import type { VerificationStepStatus } from '@prisma/client'
import type { ComponentProps } from 'astro/types'
type VerificationStepStatusInfo<T extends string | null | undefined = string> = {
value: T
label: string
icon: string
color: ComponentProps<typeof BadgeSmall>['color']
}
export const {
dataArray: verificationStepStatuses,
dataObject: verificationStepStatusesByValue,
getFn: getVerificationStepStatusInfo,
} = makeHelpersForOptions(
'value',
(value): VerificationStepStatusInfo<typeof value> => ({
value,
label: value ? transformCase(value, 'title') : String(value),
icon: 'ri:question-line',
color: 'gray',
}),
[
{
value: 'PASSED',
label: 'Passed',
icon: 'ri:verified-badge-fill',
color: 'green',
},
{
value: 'IN_PROGRESS',
label: 'In Progress',
icon: 'ri:loader-line',
color: 'yellow',
},
{
value: 'FAILED',
label: 'Failed',
icon: 'ri:alert-line',
color: 'red',
},
{
value: 'PENDING',
label: 'Pending',
icon: 'ri:time-line',
color: 'sky',
},
] as const satisfies VerificationStepStatusInfo<VerificationStepStatus>[]
)