Line data Source code
1 : <template>
2 : <div :class="cn('flex flex-col gap-4 p-4', ui.body)">
3 : <div
4 : v-if="settings"
5 : :class="
6 : cn('flex flex-col gap-1 rounded-lg border border-solid p-3', ui.summary)
7 : "
8 : data-testid="add-credits-auto-top-up-on"
9 : >
10 : <span class="text-foreground">
11 : {{
12 : translate('autoTopUpOn.summary', {
13 : threshold: format.count(settings.threshold_credits),
14 : target: format.count(settings.target_credits)
15 : })
16 : }}
17 : </span>
18 : <span
19 : v-if="settings.monthly_budget_cents !== null"
20 : class="text-muted-foreground"
21 : >
22 : {{
23 : translate('autoTopUpOn.limit', {
24 : limit: format.dollars(settings.monthly_budget_cents)
25 : })
26 : }}
27 : </span>
28 : <span v-else class="text-muted-foreground">
29 : {{ translate('autoTopUpOn.noLimit') }}
30 : </span>
31 : </div>
32 : <p
33 : v-else
34 : class="m-0 text-muted-foreground"
35 : data-testid="add-credits-auto-top-up-failed"
36 : >
37 : {{ translate('autoTopUpFailed.body') }}
38 : </p>
39 : </div>
40 : <div :class="footerBarClass(ui, 'justify-end')">
41 : <AddCreditsBillingLink
42 : v-if="linkUrl"
43 : :to="linkUrl"
44 : :class="
45 : cn(
46 : buttonVariants({ variant: 'muted-textonly', size: 'lg' }),
47 : ui.secondary
48 : )
49 : "
50 : data-testid="add-credits-auto-top-up-link"
51 : @click="emit('openBilling')"
52 : >
53 : {{ translate(settings ? 'autoTopUp.manage' : 'autoTopUpOffer.setUp') }}
54 : <i class="icon-[lucide--arrow-up-right]" aria-hidden="true" />
55 : </AddCreditsBillingLink>
56 : <button
57 : type="button"
58 : :class="primaryActionClass(ui)"
59 : data-testid="add-credits-auto-top-up-done"
60 : @click="emit('close')"
61 : >
62 : {{ translate('autoTopUpOn.done') }}
63 : </button>
64 : </div>
65 : </template>
66 :
67 : <script setup lang="ts">
68 : import type {
69 : AddCreditsTranslate,
70 : AutoTopUpActivation
71 : } from '@comfyorg/account-core/billing'
72 : import { buttonVariants } from '@comfyorg/design-system/button.variants'
73 : import { cn } from '@comfyorg/tailwind-utils'
74 :
75 : import AddCreditsBillingLink from './AddCreditsBillingLink.vue'
76 : import type {
77 : AddCreditsBillingLinkTarget,
78 : AddCreditsFormat,
79 : AddCreditsUi
80 : } from './addCreditsPresentation'
81 : import { footerBarClass, primaryActionClass } from './addCreditsPresentation'
82 :
83 : const { settings, linkUrl, translate, format, ui } = defineProps<{
84 : settings?: AutoTopUpActivation
85 : linkUrl?: AddCreditsBillingLinkTarget
86 : translate: AddCreditsTranslate
87 : format: AddCreditsFormat
88 : ui: AddCreditsUi
89 : }>()
90 :
91 0 : const emit = defineEmits<{ close: []; openBilling: [] }>()
92 : </script>
|