Files
kycnotme/web/src/constants/commentStatus.ts

66 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-05-19 10:23:36 +00:00
import { makeHelpersForOptions } from '../lib/makeHelpersForOptions'
import { transformCase } from '../lib/strings'
2025-06-09 10:00:55 +00:00
import type { TailwindColor } from '../lib/colors'
2025-05-19 10:23:36 +00:00
import type { CommentStatus } from '@prisma/client'
type CommentStatusInfo<T extends string | null | undefined = string> = {
id: T
icon: string
label: string
2025-06-09 10:00:55 +00:00
color: TailwindColor
2025-05-19 10:23:36 +00:00
creativeWorkStatus: string | undefined
}
export const {
dataArray: commentStatus,
dataObject: commentStatusById,
getFn: getCommentStatusInfo,
} = makeHelpersForOptions(
'id',
(id): CommentStatusInfo<typeof id> => ({
id,
icon: 'ri:question-line',
label: id ? transformCase(id, 'title') : String(id),
2025-05-22 11:10:18 +00:00
color: 'gray',
2025-05-19 10:23:36 +00:00
creativeWorkStatus: undefined,
}),
[
{
id: 'PENDING',
icon: 'ri:question-line',
2025-05-22 11:10:18 +00:00
label: 'Unmoderated',
color: 'yellow',
2025-05-19 10:23:36 +00:00
creativeWorkStatus: 'Deleted',
},
{
id: 'HUMAN_PENDING',
icon: 'ri:question-line',
2025-05-22 11:10:18 +00:00
label: 'Unmoderated',
color: 'yellow',
2025-05-19 10:23:36 +00:00
creativeWorkStatus: 'Deleted',
},
{
id: 'VERIFIED',
2025-05-22 11:10:18 +00:00
icon: 'ri:verified-badge-fill',
2025-05-19 10:23:36 +00:00
label: 'Verified',
2025-05-22 11:10:18 +00:00
color: 'blue',
2025-05-19 10:23:36 +00:00
creativeWorkStatus: 'Verified',
},
{
id: 'REJECTED',
icon: 'ri:close-line',
label: 'Rejected',
2025-05-22 11:10:18 +00:00
color: 'red',
2025-05-19 10:23:36 +00:00
creativeWorkStatus: 'Deleted',
},
{
id: 'APPROVED',
icon: 'ri:check-line',
label: 'Approved',
2025-05-22 11:10:18 +00:00
color: 'green',
2025-05-19 10:23:36 +00:00
creativeWorkStatus: 'Active',
},
] as const satisfies CommentStatusInfo<CommentStatus>[]
)