2026-09-21 16:38:24 +03:30
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import type { BillingAccountDto, BillingPlanCode } from '@mento/shared';
|
2026-10-06 19:54:38 +03:30
|
|
|
|
import {
|
|
|
|
|
|
BILLING_PLAN_CODES,
|
|
|
|
|
|
BILLING_PLAN_LABELS,
|
|
|
|
|
|
isPermanentBillingPlan,
|
|
|
|
|
|
} from '@mento/shared';
|
2026-09-21 16:38:24 +03:30
|
|
|
|
import { toFaDigits } from '@/lib/jalali';
|
|
|
|
|
|
|
|
|
|
|
|
defineProps<{
|
|
|
|
|
|
billing?: BillingAccountDto | null;
|
|
|
|
|
|
busyId: string;
|
|
|
|
|
|
userId: string;
|
|
|
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
|
|
|
apply: [planCode: BillingPlanCode];
|
|
|
|
|
|
}>();
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<div class="billing">
|
|
|
|
|
|
<strong>اشتراک مالک</strong>
|
|
|
|
|
|
<p v-if="billing" class="muted">
|
|
|
|
|
|
{{ BILLING_PLAN_LABELS[billing.planCode] }}
|
|
|
|
|
|
· {{ billing.status }}
|
2026-10-06 19:54:38 +03:30
|
|
|
|
· {{ isPermanentBillingPlan(billing.planCode) ? 'بدون انقضا' : `${toFaDigits(billing.daysRemaining)} روز` }}
|
2026-09-21 16:38:24 +03:30
|
|
|
|
· سقف محیط {{ toFaDigits(billing.maxOrganizations) }}
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p v-else class="muted">هنوز پلن ندارد — یکی از پلنها را اعمال کنید.</p>
|
|
|
|
|
|
<div class="plan-row">
|
|
|
|
|
|
<button
|
|
|
|
|
|
v-for="code in BILLING_PLAN_CODES.filter((c) => c !== 'custom')"
|
|
|
|
|
|
:key="code"
|
|
|
|
|
|
class="btn btn-ghost"
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
:disabled="busyId === `plan-${userId}-${code}`"
|
|
|
|
|
|
@click="emit('apply', code)"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ BILLING_PLAN_LABELS[code] }}
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.billing {
|
|
|
|
|
|
margin-bottom: 0.85rem;
|
|
|
|
|
|
padding: 0.75rem;
|
|
|
|
|
|
border-radius: 12px;
|
|
|
|
|
|
background: #f8fafc;
|
|
|
|
|
|
border: 1px solid var(--line);
|
|
|
|
|
|
display: grid;
|
|
|
|
|
|
gap: 0.45rem;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.muted {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
color: var(--muted);
|
|
|
|
|
|
font-size: 0.88rem;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.plan-row {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
gap: 0.4rem;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|