Line data Source code
1 : import type {
2 : WorkspacePlanSummary,
3 : WorkspaceWithRole
4 : } from '@comfyorg/ingest-types'
5 :
6 : type PlanStatus = WorkspacePlanSummary['status']
7 :
8 2355 : const STATUS_KEY = {
9 : no_plan: 'profileMenu.planStatus.noPlan',
10 : paused: 'profileMenu.planStatus.paused',
11 : payment_due: 'profileMenu.planStatus.paymentDue',
12 : ended: 'profileMenu.planStatus.ended'
13 : } as const satisfies Record<Exclude<PlanStatus, 'active'>, string>
14 :
15 : /** The plan part of the menu header line: the served status, else the served plan name, else nothing. */
16 20 : export function profileMenuPlanLabel(
17 : summary: WorkspacePlanSummary | undefined,
18 : translate: (key: string) => string
19 : ): string | null {
20 20 : if (!summary) return null
21 0 : if (summary.status === 'active') return summary.plan_name
22 0 : return translate(STATUS_KEY[summary.status])
23 : }
24 :
25 : /** i18n key for each served workspace role. */
26 2355 : export const PROFILE_MENU_ROLE_KEY = {
27 : owner: 'workspaceSwitcher.roleOwner',
28 : member: 'workspaceSwitcher.roleMember'
29 : } as const satisfies Record<WorkspaceWithRole['role'], string>
|