بلاک‌ها · حساب کاربری
ری‌اکت ۱۹ و Next.js با پیاده‌سازی دسترس‌پذیری داخلی دیگویو ۳ با Composition APISvelte ۵ با runesانگولار با signals و دایرکتیوهای standaloneجتپک کامپوز با KotliniOS — هنوز پورت نشده

صورتحساب و اشتراک

پیش‌نمایش تمام‌صفحه

پلنِ فعلی روی کارتِ برند با تمدید، ارتقا و لغو با تأیید؛ مصرفِ هر سهمیه با هشدارِ نزدیک به سقف؛ کارتِ بانکیِ ماسک‌شده و تاریخچهٔ فاکتورها با وضعیت، پرداختِ دوباره و دانلود.

۱. نصب کامپوننت‌ها

این بلاک از ۱۰ آیتم دیگ استفاده می‌کند: alert-dialogbadgebuttoncardcontrol-sizeiconspersianprogresstabletoast

پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add https://docs.digdesign.ir/r/alert-dialog.json https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/card.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/progress.json https://docs.digdesign.ir/r/table.json https://docs.digdesign.ir/r/toast.json
pnpm dlx digdesign@latest add https://docs.digdesign.ir/r/alert-dialog.json https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/card.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/progress.json https://docs.digdesign.ir/r/table.json https://docs.digdesign.ir/r/toast.json
yarn dlx digdesign@latest add https://docs.digdesign.ir/r/alert-dialog.json https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/card.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/progress.json https://docs.digdesign.ir/r/table.json https://docs.digdesign.ir/r/toast.json
bunx --bun digdesign@latest add https://docs.digdesign.ir/r/alert-dialog.json https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/card.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/progress.json https://docs.digdesign.ir/r/table.json https://docs.digdesign.ir/r/toast.json
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add alert-dialog badge button card control-size persian progress table toast --framework vue
pnpm dlx digdesign@latest add alert-dialog badge button card control-size persian progress table toast --framework vue
yarn dlx digdesign@latest add alert-dialog badge button card control-size persian progress table toast --framework vue
bunx --bun digdesign@latest add alert-dialog badge button card control-size persian progress table toast --framework vue
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add button --framework svelte
pnpm dlx digdesign@latest add button --framework svelte
yarn dlx digdesign@latest add button --framework svelte
bunx --bun digdesign@latest add button --framework svelte
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add alert-dialog badge button card control-size icons persian progress table toast --framework angular
pnpm dlx digdesign@latest add alert-dialog badge button card control-size icons persian progress table toast --framework angular
yarn dlx digdesign@latest add alert-dialog badge button card control-size icons persian progress table toast --framework angular
bunx --bun digdesign@latest add alert-dialog badge button card control-size icons persian progress table toast --framework angular
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add alert-dialog badge button card control-size persian progress table toast --framework android
pnpm dlx digdesign@latest add alert-dialog badge button card control-size persian progress table toast --framework android
yarn dlx digdesign@latest add alert-dialog badge button card control-size persian progress table toast --framework android
bunx --bun digdesign@latest add alert-dialog badge button card control-size persian progress table toast --framework android

۲. کد صفحه

کد را در صفحهٔ پروژه‌تان بگذارید (React: app/<route>/page.tsx) و متن‌ها، داده و هندلرها را با محصول خودتان عوض کنید. با سوییچر فریم‌ورک کدِ همین صفحه در فریم‌ورک دیگر را ببینید.

billing.tsx
"use client"

import * as React from "react"

import { CheckIcon, CreditCardIcon, DownloadIcon, FlashIcon } from "@/components/icons"
import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { Progress } from "@/components/ui/progress"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { toast } from "@/components/ui/toast"
import { formatCurrency, formatJalali, toFaDigits } from "@/lib/persian"

const USAGE = [
  { label: "اعضای تیم", used: 4, limit: 5, unit: "نفر" },
  { label: "پروژه‌ها", used: 7, limit: 10, unit: "پروژه" },
  { label: "فضای ذخیره‌سازی", used: 17.4, limit: 20, unit: "گیگابایت" },
]

const INVOICES = [
  { id: "1405-0718", date: "2026-10-01", amount: 490_000, status: "paid" as const },
  { id: "1405-0612", date: "2026-09-01", amount: 490_000, status: "paid" as const },
  { id: "1405-0507", date: "2026-08-01", amount: 490_000, status: "failed" as const },
  { id: "1405-0405", date: "2026-07-01", amount: 290_000, status: "paid" as const },
]

/**
 * صورتحساب و اشتراک: پلنِ فعلی روی کارتِ وارونهٔ برند با تمدید و ارتقا، مصرفِ
 * هر سهمیه با هشدارِ نزدیک به سقف، روشِ پرداخت و تاریخچهٔ فاکتورها با وضعیت و
 * دانلود. لغوِ اشتراک فقط با تأییدِ دوباره.
 */
export default function BillingBlock() {
  return (
    <ControlSizeProvider size="xl" asChild>
      <main className="mx-auto flex w-full max-w-6xl flex-col gap-8 p-4 sm:p-6">
        <header className="flex flex-col gap-1">
          <h1 className="text-2xl font-bold">صورتحساب و اشتراک</h1>
          <p className="text-muted-foreground">پلن، مصرف و فاکتورهای حساب.</p>
        </header>

        <div className="grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1.3fr)_minmax(0,1fr)]">
          {/* پلنِ فعلی: کارتِ برند با رنگ‌های بازتعریف‌شده. */}
          <section
            aria-labelledby="billing-plan"
            className="relative flex flex-col gap-6 overflow-hidden rounded-xl bg-[var(--dig-violet-800)] p-6 text-[var(--dig-white)] sm:p-8 [--muted-foreground:var(--dig-violet-200)] [--primary-foreground:var(--dig-violet-800)] [--primary:var(--dig-white)]"
          >
            <span aria-hidden className="absolute -end-20 -top-20 size-64 rounded-full bg-[var(--dig-violet-700)]" />
            <div className="relative flex items-start justify-between gap-4">
              <div className="flex flex-col gap-2">
                <span className="text-sm text-muted-foreground">پلنِ فعلی</span>
                <h2 id="billing-plan" className="flex items-center gap-2 text-3xl font-black">
                  حرفه‌ای
                  <Badge className="bg-[var(--dig-amber-400)] text-[var(--dig-graphite-950)]">فعال</Badge>
                </h2>
              </div>
              <span aria-hidden className="flex size-12 items-center justify-center rounded-xl bg-[var(--dig-violet-600)] [&>svg]:size-6">
                <FlashIcon />
              </span>
            </div>
            <div className="relative flex items-baseline gap-2">
              <span className="text-4xl font-black tabular-nums">{formatCurrency(490_000).replace(" تومان", "")}</span>
              <span className="text-muted-foreground">تومان / ماه</span>
            </div>
            <p className="relative text-sm text-muted-foreground">
              تمدیدِ خودکار در {formatJalali(new Date("2026-11-01"), "long")} · ۵ عضو، ۱۰ پروژه، ۲۰ گیگابایت
            </p>
            <div className="relative mt-2 flex flex-wrap gap-3">
              <Button>ارتقا به سازمانی</Button>
              <AlertDialog>
                <AlertDialogTrigger asChild>
                  <Button variant="outline" className="border-[var(--dig-violet-500)] bg-[var(--dig-violet-800)] text-[var(--dig-white)] hover:bg-[var(--dig-violet-700)] hover:text-[var(--dig-white)]">
                    لغوِ اشتراک
                  </Button>
                </AlertDialogTrigger>
                <ControlSizeProvider size="xl" asChild>
                  <AlertDialogContent>
                    <AlertDialogHeader>
                      <AlertDialogTitle>اشتراک لغو شود؟</AlertDialogTitle>
                      <AlertDialogDescription>
                        تا {formatJalali(new Date("2026-11-01"), "long")} همهٔ امکانات فعال می‌ماند؛ بعد از آن حساب به پلنِ پایه برمی‌گردد و پروژه‌های اضافه فقط‌خواندنی می‌شوند.
                      </AlertDialogDescription>
                    </AlertDialogHeader>
                    <AlertDialogFooter>
                      <AlertDialogCancel>منصرف شدم</AlertDialogCancel>
                      <AlertDialogAction variant="destructive" onClick={() => toast.success("اشتراک تا پایانِ دوره فعال می‌ماند و تمدید نمی‌شود.")}>
                        لغوِ اشتراک
                      </AlertDialogAction>
                    </AlertDialogFooter>
                  </AlertDialogContent>
                </ControlSizeProvider>
              </AlertDialog>
            </div>
          </section>

          {/* مصرف: هر سهمیه با نوار؛ نزدیک به سقف رنگِ هشدار و پیشنهادِ ارتقا. */}
          <Card>
            <CardHeader>
              <CardTitle className="text-base">مصرفِ این دوره</CardTitle>
              <CardDescription>تا {formatJalali(new Date("2026-11-01"), "long")}</CardDescription>
            </CardHeader>
            <CardContent className="flex flex-col gap-5">
              {USAGE.map((item) => {
                const percent = (item.used / item.limit) * 100
                const near = percent >= 85
                return (
                  <div key={item.label} className="flex flex-col gap-2">
                    <div className="flex items-baseline justify-between gap-2 text-sm">
                      <span className="font-medium">{item.label}</span>
                      <span className={near ? "font-semibold text-warning-subtle-foreground tabular-nums" : "text-muted-foreground tabular-nums"}>
                        {toFaDigits(item.used)} از {toFaDigits(item.limit)} {item.unit}
                      </span>
                    </div>
                    <Progress value={percent} color={near ? "warning" : "primary"} aria-label={`مصرفِ ${item.label}`} />
                  </div>
                )
              })}
              <p className="rounded-lg bg-[color-mix(in_oklab,var(--dig-amber-500)_10%,var(--background))] p-3 text-sm leading-6">
                فضای ذخیره‌سازی نزدیکِ سقف است؛ با پلنِ سازمانی نامحدود می‌شود.
              </p>
            </CardContent>
          </Card>
        </div>

        <div className="grid grid-cols-1 items-start gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]">
          <Card>
            <CardHeader>
              <CardTitle className="text-base">روشِ پرداخت</CardTitle>
            </CardHeader>
            <CardContent className="flex flex-col gap-4">
              {/* کارتِ بانکی: شمارهٔ ماسک‌شده و تاریخِ انقضا. */}
              <div className="flex aspect-[1.6/1] flex-col justify-between rounded-xl bg-linear-to-br from-[var(--dig-graphite-800)] to-[var(--dig-graphite-950)] p-5 text-[var(--dig-white)]">
                <div className="flex items-center justify-between">
                  <span className="text-sm font-semibold">بانکِ سکه</span>
                  <CreditCardIcon aria-hidden className="size-6 text-[var(--dig-neutral-400)]" />
                </div>
                <bdi dir="ltr" className="text-start text-lg tracking-widest tabular-nums">
                  {toFaDigits("6037 •••• •••• 4521")}
                </bdi>
                <div className="flex items-center justify-between text-xs text-[var(--dig-neutral-300)]">
                  <span>سارا محمدی</span>
                  <span className="tabular-nums">{toFaDigits("08/07")}</span>
                </div>
              </div>
              <p className="flex items-center gap-2 text-sm text-muted-foreground">
                <CheckIcon aria-hidden className="size-4 text-success-subtle-foreground" />
                برداشتِ خودکار برای تمدید فعال است.
              </p>
              <Button variant="outline" fullWidth>
                تغییرِ کارت
              </Button>
            </CardContent>
          </Card>

          <section aria-labelledby="billing-invoices" className="flex flex-col gap-4">
            <h2 id="billing-invoices" className="text-lg font-bold">
              فاکتورها
            </h2>
            <div>
              <Table stackOnMobile variant="card">
                <TableHeader>
                  <TableRow>
                    <TableHead>شمارهٔ فاکتور</TableHead>
                    <TableHead>تاریخ</TableHead>
                    <TableHead>مبلغ</TableHead>
                    <TableHead>وضعیت</TableHead>
                    <TableHead className="w-12 px-0">
                      <span className="sr-only">دانلود</span>
                    </TableHead>
                  </TableRow>
                </TableHeader>
                <TableBody>
                  {INVOICES.map((invoice) => (
                    <TableRow key={invoice.id}>
                      <TableCell className="font-medium tabular-nums">{toFaDigits(invoice.id)}</TableCell>
                      <TableCell>{formatJalali(new Date(invoice.date), "long")}</TableCell>
                      <TableCell className="tabular-nums">{formatCurrency(invoice.amount)}</TableCell>
                      <TableCell>
                        {invoice.status === "paid" ? (
                          <Badge variant="soft" color="success">
                            پرداخت‌شده
                          </Badge>
                        ) : (
                          <span className="flex items-center gap-2">
                            <Badge variant="soft" color="destructive">
                              ناموفق
                            </Badge>
                            <Button variant="link" className="h-auto p-0 text-sm">
                              پرداختِ دوباره
                            </Button>
                          </span>
                        )}
                      </TableCell>
                      <TableCell className="w-12 px-0 text-center">
                        <Button variant="ghost" size="icon" aria-label={`دانلودِ فاکتورِ ${toFaDigits(invoice.id)}`}>
                          <DownloadIcon />
                        </Button>
                      </TableCell>
                    </TableRow>
                  ))}
                </TableBody>
              </Table>
            </div>
          </section>
        </div>
      </main>
    </ControlSizeProvider>
  )
}
billing.vue
<script setup lang="ts">
import AlertDialog from "@/components/ui/AlertDialog.vue"
import AlertDialogAction from "@/components/ui/AlertDialogAction.vue"
import AlertDialogCancel from "@/components/ui/AlertDialogCancel.vue"
import AlertDialogContent from "@/components/ui/AlertDialogContent.vue"
import AlertDialogDescription from "@/components/ui/AlertDialogDescription.vue"
import AlertDialogFooter from "@/components/ui/AlertDialogFooter.vue"
import AlertDialogHeader from "@/components/ui/AlertDialogHeader.vue"
import AlertDialogTitle from "@/components/ui/AlertDialogTitle.vue"
import AlertDialogTrigger from "@/components/ui/AlertDialogTrigger.vue"
import Badge from "@/components/ui/Badge.vue"
import Button from "@/components/ui/Button.vue"
import Card from "@/components/ui/Card.vue"
import CardContent from "@/components/ui/CardContent.vue"
import CardDescription from "@/components/ui/CardDescription.vue"
import CardHeader from "@/components/ui/CardHeader.vue"
import CardTitle from "@/components/ui/CardTitle.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import Progress from "@/components/ui/Progress.vue"
import Table from "@/components/ui/Table.vue"
import TableBody from "@/components/ui/TableBody.vue"
import TableCell from "@/components/ui/TableCell.vue"
import TableHead from "@/components/ui/TableHead.vue"
import TableHeader from "@/components/ui/TableHeader.vue"
import TableRow from "@/components/ui/TableRow.vue"
import { toast } from "@/components/ui/Toast.vue"
import { DigIcon } from "@/lib/icons"
import { formatCurrency, formatJalali, toFaDigits } from "@/lib/persian"

const USAGE = [
  { label: "اعضای تیم", used: 4, limit: 5, unit: "نفر" },
  { label: "پروژه‌ها", used: 7, limit: 10, unit: "پروژه" },
  { label: "فضای ذخیره‌سازی", used: 17.4, limit: 20, unit: "گیگابایت" },
]

const INVOICES = [
  { id: "1405-0718", date: "2026-10-01", amount: 490_000, status: "paid" as const },
  { id: "1405-0612", date: "2026-09-01", amount: 490_000, status: "paid" as const },
  { id: "1405-0507", date: "2026-08-01", amount: 490_000, status: "failed" as const },
  { id: "1405-0405", date: "2026-07-01", amount: 290_000, status: "paid" as const },
]

/**
 * صورتحساب و اشتراک: پلنِ فعلی روی کارتِ وارونهٔ برند با تمدید و ارتقا، مصرفِ
 * هر سهمیه با هشدارِ نزدیک به سقف، روشِ پرداخت و تاریخچهٔ فاکتورها با وضعیت و
 * دانلود. لغوِ اشتراک فقط با تأییدِ دوباره.
 */
const renewDate = new Date("2026-11-01")
</script>

<template>
  <ControlSize size="xl" as-child>
    <main class="mx-auto flex w-full max-w-6xl flex-col gap-8 p-4 sm:p-6">
      <header class="flex flex-col gap-1">
        <h1 class="text-2xl font-bold">صورتحساب و اشتراک</h1>
        <p class="text-muted-foreground">پلن، مصرف و فاکتورهای حساب.</p>
      </header>

      <div class="grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1.3fr)_minmax(0,1fr)]">
        <!-- پلنِ فعلی: کارتِ برند با رنگ‌های بازتعریف‌شده. -->
        <section
          aria-labelledby="billing-plan"
          class="relative flex flex-col gap-6 overflow-hidden rounded-xl bg-[var(--dig-violet-800)] p-6 text-[var(--dig-white)] sm:p-8 [--muted-foreground:var(--dig-violet-200)] [--primary-foreground:var(--dig-violet-800)] [--primary:var(--dig-white)]"
        >
          <span aria-hidden="true" class="absolute -end-20 -top-20 size-64 rounded-full bg-[var(--dig-violet-700)]" />
          <div class="relative flex items-start justify-between gap-4">
            <div class="flex flex-col gap-2">
              <span class="text-sm text-muted-foreground">پلنِ فعلی</span>
              <h2 id="billing-plan" class="flex items-center gap-2 text-3xl font-black">
                حرفه‌ای
                <Badge class="bg-[var(--dig-amber-400)] text-[var(--dig-graphite-950)]">فعال</Badge>
              </h2>
            </div>
            <span aria-hidden="true" class="flex size-12 items-center justify-center rounded-xl bg-[var(--dig-violet-600)] [&>svg]:size-6">
              <DigIcon name="flash" />
            </span>
          </div>
          <div class="relative flex items-baseline gap-2">
            <span class="text-4xl font-black tabular-nums">{{ formatCurrency(490_000).replace(" تومان", "") }}</span>
            <span class="text-muted-foreground">تومان / ماه</span>
          </div>
          <p class="relative text-sm text-muted-foreground">تمدیدِ خودکار در {{ formatJalali(renewDate, "long") }} · ۵ عضو، ۱۰ پروژه، ۲۰ گیگابایت</p>
          <div class="relative mt-2 flex flex-wrap gap-3">
            <Button>ارتقا به سازمانی</Button>
            <AlertDialog>
              <AlertDialogTrigger as-child>
                <Button variant="outline" class="border-[var(--dig-violet-500)] bg-[var(--dig-violet-800)] text-[var(--dig-white)] hover:bg-[var(--dig-violet-700)] hover:text-[var(--dig-white)]">لغوِ اشتراک</Button>
              </AlertDialogTrigger>
              <ControlSize size="xl" as-child>
                <AlertDialogContent>
                  <AlertDialogHeader>
                    <AlertDialogTitle>اشتراک لغو شود؟</AlertDialogTitle>
                    <AlertDialogDescription>
                      تا {{ formatJalali(renewDate, "long") }} همهٔ امکانات فعال می‌ماند؛ بعد از آن حساب به پلنِ پایه برمی‌گردد و پروژه‌های اضافه فقط‌خواندنی می‌شوند.
                    </AlertDialogDescription>
                  </AlertDialogHeader>
                  <AlertDialogFooter>
                    <AlertDialogCancel>منصرف شدم</AlertDialogCancel>
                    <AlertDialogAction variant="destructive" @click="toast.success('اشتراک تا پایانِ دوره فعال می‌ماند و تمدید نمی‌شود.')">لغوِ اشتراک</AlertDialogAction>
                  </AlertDialogFooter>
                </AlertDialogContent>
              </ControlSize>
            </AlertDialog>
          </div>
        </section>

        <!-- مصرف: هر سهمیه با نوار؛ نزدیک به سقف رنگِ هشدار و پیشنهادِ ارتقا. -->
        <Card>
          <CardHeader>
            <CardTitle class="text-base">مصرفِ این دوره</CardTitle>
            <CardDescription>تا {{ formatJalali(renewDate, "long") }}</CardDescription>
          </CardHeader>
          <CardContent class="flex flex-col gap-5">
            <div v-for="item in USAGE" :key="item.label" class="flex flex-col gap-2">
              <div class="flex items-baseline justify-between gap-2 text-sm">
                <span class="font-medium">{{ item.label }}</span>
                <span :class="(item.used / item.limit) * 100 >= 85 ? 'font-semibold text-warning-subtle-foreground tabular-nums' : 'text-muted-foreground tabular-nums'">
                  {{ toFaDigits(item.used) }} از {{ toFaDigits(item.limit) }} {{ item.unit }}
                </span>
              </div>
              <Progress :value="(item.used / item.limit) * 100" :color="(item.used / item.limit) * 100 >= 85 ? 'warning' : 'primary'" :aria-label="`مصرفِ ${item.label}`" />
            </div>
            <p class="rounded-lg bg-[color-mix(in_oklab,var(--dig-amber-500)_10%,var(--background))] p-3 text-sm leading-6">فضای ذخیره‌سازی نزدیکِ سقف است؛ با پلنِ سازمانی نامحدود می‌شود.</p>
          </CardContent>
        </Card>
      </div>

      <div class="grid grid-cols-1 items-start gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]">
        <Card>
          <CardHeader>
            <CardTitle class="text-base">روشِ پرداخت</CardTitle>
          </CardHeader>
          <CardContent class="flex flex-col gap-4">
            <!-- کارتِ بانکی: شمارهٔ ماسک‌شده و تاریخِ انقضا. -->
            <div class="flex aspect-[1.6/1] flex-col justify-between rounded-xl bg-linear-to-br from-[var(--dig-graphite-800)] to-[var(--dig-graphite-950)] p-5 text-[var(--dig-white)]">
              <div class="flex items-center justify-between">
                <span class="text-sm font-semibold">بانکِ سکه</span>
                <DigIcon name="credit-card" aria-hidden="true" class="size-6 text-[var(--dig-neutral-400)]" />
              </div>
              <bdi dir="ltr" class="text-start text-lg tracking-widest tabular-nums">{{ toFaDigits("6037 •••• •••• 4521") }}</bdi>
              <div class="flex items-center justify-between text-xs text-[var(--dig-neutral-300)]">
                <span>سارا محمدی</span>
                <span class="tabular-nums">{{ toFaDigits("08/07") }}</span>
              </div>
            </div>
            <p class="flex items-center gap-2 text-sm text-muted-foreground">
              <DigIcon name="check" aria-hidden="true" class="size-4 text-success-subtle-foreground" />
              برداشتِ خودکار برای تمدید فعال است.
            </p>
            <Button variant="outline" full-width>تغییرِ کارت</Button>
          </CardContent>
        </Card>

        <section aria-labelledby="billing-invoices" class="flex flex-col gap-4">
          <h2 id="billing-invoices" class="text-lg font-bold">فاکتورها</h2>
          <div>
            <Table stack-on-mobile variant="card">
              <TableHeader>
                <TableRow>
                  <TableHead>شمارهٔ فاکتور</TableHead>
                  <TableHead>تاریخ</TableHead>
                  <TableHead>مبلغ</TableHead>
                  <TableHead>وضعیت</TableHead>
                  <TableHead class="w-12 px-0">
                    <span class="sr-only">دانلود</span>
                  </TableHead>
                </TableRow>
              </TableHeader>
              <TableBody>
                <TableRow v-for="invoice in INVOICES" :key="invoice.id">
                  <TableCell class="font-medium tabular-nums">{{ toFaDigits(invoice.id) }}</TableCell>
                  <TableCell>{{ formatJalali(new Date(invoice.date), "long") }}</TableCell>
                  <TableCell class="tabular-nums">{{ formatCurrency(invoice.amount) }}</TableCell>
                  <TableCell>
                    <Badge v-if="invoice.status === 'paid'" variant="soft" color="success">پرداخت‌شده</Badge>
                    <span v-else class="flex items-center gap-2">
                      <Badge variant="soft" color="destructive">ناموفق</Badge>
                      <Button variant="link" class="h-auto p-0 text-sm">پرداختِ دوباره</Button>
                    </span>
                  </TableCell>
                  <TableCell class="w-12 px-0 text-center">
                    <Button variant="ghost" size="icon" :aria-label="`دانلودِ فاکتورِ ${toFaDigits(invoice.id)}`">
                      <DigIcon name="download" />
                    </Button>
                  </TableCell>
                </TableRow>
              </TableBody>
            </Table>
          </div>
        </section>
      </div>
    </main>
  </ControlSize>
</template>

کدِ این بلاک هنوز برای Svelte نوشته نشده است.

این موارد هنوز برای Svelte آماده نیستند: alert-dialogbadgecardcontrol-sizepersianprogresstabletoastآیکون checkآیکون credit-cardآیکون downloadآیکون flash

کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="svelte" ایجنت آن را با کامپوننت‌های Svelte می‌سازد.

billing.ts
import { Component, ChangeDetectionStrategy } from "@angular/core"

import { DigControlSize } from "@/components/ui/control-size"
import { DigBadge } from "@/components/ui/badge"
import { DigIcon } from "@/lib/icons"
import { DigButton } from "@/components/ui/button"
import {
  DigAlertDialog,
  DigAlertDialogTrigger,
  DigAlertDialogContent,
  DigAlertDialogHeader,
  DigAlertDialogTitle,
  DigAlertDialogDescription,
  DigAlertDialogFooter,
  DigAlertDialogCancel,
  DigAlertDialogAction,
} from "@/components/ui/alert-dialog"
import { DigCard, DigCardHeader, DigCardTitle, DigCardDescription, DigCardContent } from "@/components/ui/card"
import { DigProgress } from "@/components/ui/progress"
import { DigTable, DigTableHeader, DigTableRow, DigTableHead, DigTableBody, DigTableCell } from "@/components/ui/table"
import { toast } from "@/components/ui/toast"
import { formatCurrency, formatJalali, toFaDigits } from "@/lib/persian"

const USAGE = [
  { label: "اعضای تیم", used: 4, limit: 5, unit: "نفر" },
  { label: "پروژه‌ها", used: 7, limit: 10, unit: "پروژه" },
  { label: "فضای ذخیره‌سازی", used: 17.4, limit: 20, unit: "گیگابایت" },
]

const INVOICES = [
  { id: "1405-0718", date: "2026-10-01", amount: 490_000, status: "paid" as const },
  { id: "1405-0612", date: "2026-09-01", amount: 490_000, status: "paid" as const },
  { id: "1405-0507", date: "2026-08-01", amount: 490_000, status: "failed" as const },
  { id: "1405-0405", date: "2026-07-01", amount: 290_000, status: "paid" as const },
]

const renewDate = new Date("2026-11-01")

@Component({
  selector: "dig-block-billing",
  imports: [
    DigControlSize,
    DigBadge,
    DigIcon,
    DigButton,
    DigAlertDialog,
    DigAlertDialogTrigger,
    DigAlertDialogContent,
    DigAlertDialogHeader,
    DigAlertDialogTitle,
    DigAlertDialogDescription,
    DigAlertDialogFooter,
    DigAlertDialogCancel,
    DigAlertDialogAction,
    DigCard,
    DigCardHeader,
    DigCardTitle,
    DigCardDescription,
    DigCardContent,
    DigProgress,
    DigTable,
    DigTableHeader,
    DigTableRow,
    DigTableHead,
    DigTableBody,
    DigTableCell,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <main digControlSize="xl" class="mx-auto flex w-full max-w-6xl flex-col gap-8 p-4 sm:p-6">
      <header class="flex flex-col gap-1">
        <h1 class="text-2xl font-bold">صورتحساب و اشتراک</h1>
        <p class="text-muted-foreground">پلن، مصرف و فاکتورهای حساب.</p>
      </header>

      <div class="grid grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1.3fr)_minmax(0,1fr)]">
        <!-- پلنِ فعلی: کارتِ برند با رنگ‌های بازتعریف‌شده. -->
        <section
          aria-labelledby="billing-plan"
          class="relative flex flex-col gap-6 overflow-hidden rounded-xl bg-[var(--dig-violet-800)] p-6 text-[var(--dig-white)] sm:p-8 [--muted-foreground:var(--dig-violet-200)] [--primary-foreground:var(--dig-violet-800)] [--primary:var(--dig-white)]"
        >
          <span
            aria-hidden="true"
            class="absolute -end-20 -top-20 size-64 rounded-full bg-[var(--dig-violet-700)]"
          ></span>
          <div class="relative flex items-start justify-between gap-4">
            <div class="flex flex-col gap-2">
              <span class="text-sm text-muted-foreground">پلنِ فعلی</span>
              <h2 id="billing-plan" class="flex items-center gap-2 text-3xl font-black">
                حرفه‌ای
                <span digBadge class="bg-[var(--dig-amber-400)] text-[var(--dig-graphite-950)]">فعال</span>
              </h2>
            </div>
            <span
              aria-hidden="true"
              class="flex size-12 items-center justify-center rounded-xl bg-[var(--dig-violet-600)] [&>svg]:size-6"
              ><svg digIcon="flash"></svg
            ></span>
          </div>
          <div class="relative flex items-baseline gap-2">
            <span class="text-4xl font-black tabular-nums">{{ formatCurrency(490_000).replace(" تومان", "") }}</span>
            <span class="text-muted-foreground">تومان / ماه</span>
          </div>
          <p class="relative text-sm text-muted-foreground">
            تمدیدِ خودکار در {{ formatJalali(renewDate, "long") }} · ۵ عضو، ۱۰ پروژه، ۲۰ گیگابایت
          </p>
          <div class="relative mt-2 flex flex-wrap gap-3">
            <button digButton type="button">ارتقا به سازمانی</button>
            <ng-container digAlertDialog
              ><button
                digAlertDialogTrigger
                digButton
                type="button"
                variant="outline"
                class="border-[var(--dig-violet-500)] bg-[var(--dig-violet-800)] text-[var(--dig-white)] hover:bg-[var(--dig-violet-700)] hover:text-[var(--dig-white)]"
              >
                لغوِ اشتراک
              </button>
              <div digControlSize="xl">
                <div digAlertDialogContent>
                  <div digAlertDialogHeader>
                    <h2 digAlertDialogTitle>اشتراک لغو شود؟</h2>
                    <p digAlertDialogDescription>
                      تا {{ formatJalali(renewDate, "long") }} همهٔ امکانات فعال می‌ماند؛ بعد از آن حساب به پلنِ پایه
                      برمی‌گردد و پروژه‌های اضافه فقط‌خواندنی می‌شوند.
                    </p>
                  </div>
                  <div digAlertDialogFooter>
                    <button digAlertDialogCancel>منصرف شدم</button>
                    <button
                      digAlertDialogAction
                      variant="destructive"
                      (click)="toast.success('اشتراک تا پایانِ دوره فعال می‌ماند و تمدید نمی‌شود.')"
                    >
                      لغوِ اشتراک
                    </button>
                  </div>
                </div>
              </div></ng-container
            >
          </div>
        </section>

        <!-- مصرف: هر سهمیه با نوار؛ نزدیک به سقف رنگِ هشدار و پیشنهادِ ارتقا. -->
        <div digCard>
          <div digCardHeader>
            <div digCardTitle class="text-base">مصرفِ این دوره</div>
            <div digCardDescription>تا {{ formatJalali(renewDate, "long") }}</div>
          </div>
          <div digCardContent class="flex flex-col gap-5">
            @for (item of USAGE; track item.label) {
              <div class="flex flex-col gap-2">
                <div class="flex items-baseline justify-between gap-2 text-sm">
                  <span class="font-medium">{{ item.label }}</span>
                  <span
                    [class]="
                      (item.used / item.limit) * 100 >= 85
                        ? 'font-semibold text-warning-subtle-foreground tabular-nums'
                        : 'text-muted-foreground tabular-nums'
                    "
                    >{{ toFaDigits(item.used) }} از {{ toFaDigits(item.limit) }} {{ item.unit }}</span
                  >
                </div>
                <div
                  digProgress
                  [value]="(item.used / item.limit) * 100"
                  [color]="(item.used / item.limit) * 100 >= 85 ? 'warning' : 'primary'"
                  [attr.aria-label]="\`مصرفِ \${item.label}\`"
                ></div>
              </div>
            }
            <p
              class="rounded-lg bg-[color-mix(in_oklab,var(--dig-amber-500)_10%,var(--background))] p-3 text-sm leading-6"
            >
              فضای ذخیره‌سازی نزدیکِ سقف است؛ با پلنِ سازمانی نامحدود می‌شود.
            </p>
          </div>
        </div>
      </div>

      <div class="grid grid-cols-1 items-start gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]">
        <div digCard>
          <div digCardHeader><div digCardTitle class="text-base">روشِ پرداخت</div></div>
          <div digCardContent class="flex flex-col gap-4">
            <!-- کارتِ بانکی: شمارهٔ ماسک‌شده و تاریخِ انقضا. -->
            <div
              class="flex aspect-[1.6/1] flex-col justify-between rounded-xl bg-linear-to-br from-[var(--dig-graphite-800)] to-[var(--dig-graphite-950)] p-5 text-[var(--dig-white)]"
            >
              <div class="flex items-center justify-between">
                <span class="text-sm font-semibold">بانکِ سکه</span>
                <svg digIcon="credit-card" aria-hidden="true" class="size-6 text-[var(--dig-neutral-400)]"></svg>
              </div>
              <bdi dir="ltr" class="text-start text-lg tracking-widest tabular-nums">{{
                toFaDigits("6037 •••• •••• 4521")
              }}</bdi>
              <div class="flex items-center justify-between text-xs text-[var(--dig-neutral-300)]">
                <span>سارا محمدی</span> <span class="tabular-nums">{{ toFaDigits("08/07") }}</span>
              </div>
            </div>
            <p class="flex items-center gap-2 text-sm text-muted-foreground">
              <svg digIcon="check" aria-hidden="true" class="size-4 text-success-subtle-foreground"></svg>
              برداشتِ خودکار برای تمدید فعال است.
            </p>
            <button digButton type="button" variant="outline" fullWidth>تغییرِ کارت</button>
          </div>
        </div>

        <section aria-labelledby="billing-invoices" class="flex flex-col gap-4">
          <h2 id="billing-invoices" class="text-lg font-bold">فاکتورها</h2>
          <div>
            <dig-table stackOnMobile variant="card"
              ><thead digTableHeader>
                <tr digTableRow>
                  <th digTableHead>شمارهٔ فاکتور</th>
                  <th digTableHead>تاریخ</th>
                  <th digTableHead>مبلغ</th>
                  <th digTableHead>وضعیت</th>
                  <th digTableHead class="w-12 px-0"><span class="sr-only">دانلود</span></th>
                </tr>
              </thead>
              <tbody digTableBody>
                @for (invoice of INVOICES; track invoice.id) {
                  <tr digTableRow>
                    <td digTableCell class="font-medium tabular-nums">{{ toFaDigits(invoice.id) }}</td>
                    <td digTableCell>{{ formatJalali(invoice.date, "long") }}</td>
                    <td digTableCell class="tabular-nums">{{ formatCurrency(invoice.amount) }}</td>
                    <td digTableCell>
                      @if (invoice.status === "paid") {
                        <span digBadge variant="soft" color="success">پرداخت‌شده</span>
                      } @else {
                        <span class="flex items-center gap-2"
                          ><span digBadge variant="soft" color="destructive">ناموفق</span>
                          <button digButton type="button" variant="link" class="h-auto p-0 text-sm">
                            پرداختِ دوباره
                          </button></span
                        >
                      }
                    </td>
                    <td digTableCell class="w-12 px-0 text-center">
                      <button
                        digButton
                        type="button"
                        variant="ghost"
                        size="icon"
                        [attr.aria-label]="\`دانلودِ فاکتورِ \${toFaDigits(invoice.id)}\`"
                      >
                        <svg digIcon="download"></svg>
                      </button>
                    </td>
                  </tr>
                }</tbody
            ></dig-table>
          </div>
        </section>
      </div>
    </main>
  `,
})
export class BillingBlock {
  readonly toast = toast

  readonly toFaDigits = toFaDigits

  readonly formatJalali = formatJalali

  readonly formatCurrency = formatCurrency

  readonly renewDate = renewDate

  readonly INVOICES = INVOICES

  readonly USAGE = USAGE
}

کدِ این بلاک هنوز برای Android نوشته نشده است.

همهٔ کامپوننت‌های لازم برای Android آماده‌اند؛ با MCP می‌توانید همین صفحه را از روی نسخهٔ React بسازید.

کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="android" ایجنت آن را با کامپوننت‌های Android می‌سازد.