Line data Source code
1 5 : <template>
2 0 : <div
3 : :class="
4 : cn(
5 : 'flex flex-col gap-1 rounded-xl border border-card px-5 py-4',
6 : classes?.root
7 : )
8 : "
9 : data-testid="billing-auto-top-up-member-card"
10 : >
11 : <h3
12 : :class="
13 : cn(
14 : 'm-0 flex items-center gap-2 text-sm font-medium text-foreground',
15 : classes?.title
16 : )
17 : "
18 : >
19 : {{ copy.title }}
20 : <span
21 : v-if="memberView"
22 : :class="
23 : cn(
24 : 'flex items-center gap-1 text-xs font-normal',
25 : DANGER.has(memberView.status)
26 : ? 'text-destructive'
27 : : 'text-muted-foreground',
28 : classes?.status
29 : )
30 : "
31 : data-testid="billing-auto-top-up-status"
32 : >
33 : <span
34 : :class="cn('size-1.75 rounded-full', DOT[memberView.status])"
35 : aria-hidden="true"
36 : />
37 : {{ copy.status[memberView.status] }}
38 : </span>
39 : </h3>
40 : <p :class="cn('m-0 text-sm text-muted-foreground', classes?.body)">
41 : {{ memberView?.line ?? copy.body }}
42 : </p>
43 : </div>
44 : </template>
45 :
46 : <script setup lang="ts">
47 : import { computed } from 'vue'
48 :
49 : import { cn } from '@comfyorg/tailwind-utils'
50 :
51 : import type { AutoTopUpStatusLabel } from './autoTopUpCardView'
52 : import { autoTopUpMemberView } from './autoTopUpMemberView'
53 : import type {
54 : AutoTopUpMemberBlockCopy,
55 : AutoTopUpMemberView
56 : } from './autoTopUpMemberView'
57 :
58 0 : const DOT: Record<AutoTopUpStatusLabel, string> = {
59 : failed: 'bg-destructive',
60 : turnedOff: 'bg-destructive',
61 : off: 'bg-muted-foreground',
62 : onHold: 'bg-warning',
63 : limitReached: 'bg-warning',
64 : maximumReached: 'bg-warning',
65 : on: 'bg-success'
66 : }
67 :
68 0 : const DANGER: ReadonlySet<AutoTopUpStatusLabel> = new Set([
69 : 'failed',
70 : 'turnedOff'
71 : ])
72 :
73 : const { copy, view, locale, classes } = defineProps<{
74 : copy: AutoTopUpMemberBlockCopy
75 : view?: AutoTopUpMemberView | null
76 : locale: string
77 : classes?: Partial<Record<'root' | 'title' | 'status' | 'body', string>>
78 : }>()
79 :
80 0 : const memberView = computed(() => autoTopUpMemberView(view, copy, locale))
81 : </script>
|