Release 2025-05-19
This commit is contained in:
60
web/src/constants/attributeCategories.ts
Normal file
60
web/src/constants/attributeCategories.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
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>[]
|
||||
)
|
||||
Reference in New Issue
Block a user