Release 2025-05-19
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
import { makeHelpersForOptions } from '../lib/makeHelpersForOptions'
|
||||
import { transformCase } from '../lib/strings'
|
||||
|
||||
import type BadgeSmall from '../components/BadgeSmall.astro'
|
||||
import type { ServiceUserRole } from '@prisma/client'
|
||||
import type { ComponentProps } from 'astro/types'
|
||||
|
||||
type ServiceUserRoleInfo<T extends string | null | undefined = string> = {
|
||||
value: T
|
||||
slug: string
|
||||
label: string
|
||||
icon: string
|
||||
order: number
|
||||
color: NonNullable<ComponentProps<typeof BadgeSmall>['color']>
|
||||
}
|
||||
|
||||
export const {
|
||||
dataArray: serviceUserRoles,
|
||||
dataObject: serviceUserRolesById,
|
||||
getFn: getServiceUserRoleInfo,
|
||||
} = makeHelpersForOptions(
|
||||
'value',
|
||||
(value): ServiceUserRoleInfo<typeof value> => ({
|
||||
value,
|
||||
slug: value ? value.toLowerCase() : '',
|
||||
label: value ? transformCase(value, 'title').replace('_', ' ') : String(value),
|
||||
icon: 'ri:user-3-line',
|
||||
order: Infinity,
|
||||
color: 'gray',
|
||||
}),
|
||||
[
|
||||
{
|
||||
value: 'OWNER',
|
||||
slug: 'owner',
|
||||
label: 'Owner',
|
||||
icon: 'ri:vip-crown-2-fill',
|
||||
order: 1,
|
||||
color: 'lime',
|
||||
},
|
||||
{
|
||||
value: 'ADMIN',
|
||||
slug: 'admin',
|
||||
label: 'Admin',
|
||||
icon: 'ri:shield-star-fill',
|
||||
order: 2,
|
||||
color: 'green',
|
||||
},
|
||||
{
|
||||
value: 'MODERATOR',
|
||||
slug: 'moderator',
|
||||
label: 'Moderator',
|
||||
icon: 'ri:glasses-2-line',
|
||||
order: 3,
|
||||
color: 'teal',
|
||||
},
|
||||
{
|
||||
value: 'SUPPORT',
|
||||
slug: 'support',
|
||||
label: 'Support',
|
||||
icon: 'ri:customer-service-2-fill',
|
||||
order: 4,
|
||||
color: 'blue',
|
||||
},
|
||||
{
|
||||
value: 'TEAM_MEMBER',
|
||||
slug: 'team_member',
|
||||
label: 'Team Member',
|
||||
icon: 'ri:team-fill',
|
||||
order: 5,
|
||||
color: 'cyan',
|
||||
},
|
||||
] as const satisfies ServiceUserRoleInfo<ServiceUserRole>[]
|
||||
)
|
||||
Reference in New Issue
Block a user