Files
kycnotme/web/src/constants/attributeCategories.ts
2025-05-19 10:10:06 +00:00

61 lines
1.5 KiB
TypeScript

import { makeHelpersForOptions } from '../lib/makeHelpersForOptions'
import { transformCase } from '../lib/strings'
import type { AttributeCategory } from '@prisma/client'
type AttributeCategoryInfo<T extends string | null | undefined = string> = {
value: T
slug: string
label: string
icon: string
classNames: {
icon: string
}
order: number
}
export const {
dataArray: attributeCategories,
dataObject: attributeCategoriesById,
getFn: getAttributeCategoryInfo,
getFnSlug: getAttributeCategoryInfoBySlug,
zodEnumBySlug: attributeCategoriesZodEnumBySlug,
zodEnumById: attributeCategoriesZodEnumById,
keyToSlug: attributeCategoryIdToSlug,
slugToKey: attributeCategorySlugToId,
} = makeHelpersForOptions(
'value',
(value): AttributeCategoryInfo<typeof value> => ({
value,
slug: value ? value.toLowerCase() : '',
label: value ? transformCase(value, 'title') : String(value),
icon: 'ri:shield-fill',
classNames: {
icon: 'text-current/60',
},
order: Infinity,
}),
[
{
value: 'PRIVACY',
slug: 'privacy',
label: 'Privacy',
icon: 'ri:shield-user-fill',
classNames: {
icon: 'text-blue-500',
},
order: 1,
},
{
value: 'TRUST',
slug: 'trust',
label: 'Trust',
icon: 'ri:shield-check-fill',
classNames: {
icon: 'text-green-500',
},
order: 2,
},
] as const satisfies AttributeCategoryInfo<AttributeCategory>[]
)