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

67 lines
1.6 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-05-22 11:10:18 +00:00
import type BadgeSmall from '../components/BadgeSmall.astro'
2025-05-19 10:23:36 +00:00
import type { CommentStatus } from '@prisma/client'
2025-05-22 11:10:18 +00:00
import type { ComponentProps } from 'astro/types'
2025-05-19 10:23:36 +00:00
type CommentStatusInfo<T extends string | null | undefined = string> = {
id: T
icon: string
label: string
2025-05-22 11:10:18 +00:00
color: ComponentProps<typeof BadgeSmall>['color']
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>[]
)