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

پرداخت قبض با نوع قبض، شناسهٔ قبض و پرداخت، و خلاصهٔ مبلغ.

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

این بلاک از ۱۰ آیتم دیگ استفاده می‌کند: buttoncardcontrol-sizeiconslabelpersianseparatortext-fieldtoasttoggle-group

پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add 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/label.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/separator.json https://docs.digdesign.ir/r/text-field.json https://docs.digdesign.ir/r/toast.json https://docs.digdesign.ir/r/toggle-group.json
pnpm dlx digdesign@latest add 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/label.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/separator.json https://docs.digdesign.ir/r/text-field.json https://docs.digdesign.ir/r/toast.json https://docs.digdesign.ir/r/toggle-group.json
yarn dlx digdesign@latest add 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/label.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/separator.json https://docs.digdesign.ir/r/text-field.json https://docs.digdesign.ir/r/toast.json https://docs.digdesign.ir/r/toggle-group.json
bunx --bun digdesign@latest add 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/label.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/separator.json https://docs.digdesign.ir/r/text-field.json https://docs.digdesign.ir/r/toast.json https://docs.digdesign.ir/r/toggle-group.json
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add button card control-size label persian separator text-field toast toggle-group --framework vue
pnpm dlx digdesign@latest add button card control-size label persian separator text-field toast toggle-group --framework vue
yarn dlx digdesign@latest add button card control-size label persian separator text-field toast toggle-group --framework vue
bunx --bun digdesign@latest add button card control-size label persian separator text-field toast toggle-group --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 button card control-size icons input label persian separator text-field toast toggle-group --framework angular
pnpm dlx digdesign@latest add button card control-size icons input label persian separator text-field toast toggle-group --framework angular
yarn dlx digdesign@latest add button card control-size icons input label persian separator text-field toast toggle-group --framework angular
bunx --bun digdesign@latest add button card control-size icons input label persian separator text-field toast toggle-group --framework angular
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add button card control-size label persian separator text-field toast toggle-group --framework android
pnpm dlx digdesign@latest add button card control-size label persian separator text-field toast toggle-group --framework android
yarn dlx digdesign@latest add button card control-size label persian separator text-field toast toggle-group --framework android
bunx --bun digdesign@latest add button card control-size label persian separator text-field toast toggle-group --framework android

۲. کد صفحه

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

bill-payment.tsx
"use client"

import * as React from "react"

import { CheckIcon, ShareIcon } from "@/components/icons"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { Label } from "@/components/ui/label"
import { Separator } from "@/components/ui/separator"
import { TextField } from "@/components/ui/text-field"
import { toast } from "@/components/ui/toast"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { formatCurrency, formatJalaliDateTime, toFaDigits } from "@/lib/persian"

const BILL_TYPES = [
  // لوگوی هر اداره در public/logos/organizations
  { value: "water", label: "آب", logo: "water" },
  { value: "power", label: "برق", logo: "power" },
  { value: "gas", label: "گاز", logo: "gas" },
  { value: "phone", label: "تلفن", logo: "telecom" },
]

export default function BillPaymentBlock() {
  const [type, setType] = React.useState("power")
  const [billId, setBillId] = React.useState("")
  const [paymentId, setPaymentId] = React.useState("")
  const [amount, setAmount] = React.useState<number | null>(null)
  const [loading, setLoading] = React.useState(false)
  const [paying, setPaying] = React.useState(false)
  const [receipt, setReceipt] = React.useState<{ tracking: string; date: Date } | null>(null)
  const typeLabel = BILL_TYPES.find((item) => item.value === type)?.label ?? ""

  async function pay() {
    setPaying(true)
    await new Promise((resolve) => setTimeout(resolve, 900))
    setPaying(false)
    setReceipt({ tracking: String(Math.floor(100_000_000 + Math.random() * 899_999_999)), date: new Date() })
  }

  function reset() {
    setReceipt(null)
    setAmount(null)
    setBillId("")
    setPaymentId("")
  }

  async function lookup(event: React.FormEvent<HTMLFormElement>) {
    event.preventDefault()
    setLoading(true)
    // مبلغ از شناسهٔ پرداخت درمی‌آید؛ این نمونه یک مبلغِ ثابت برمی‌گرداند.
    await new Promise((resolve) => setTimeout(resolve, 700))
    setLoading(false)
    setAmount(386_000)
  }

  return (
    <ControlSizeProvider size="xl" asChild>
      <main className="flex min-h-svh items-start justify-center bg-muted p-4 sm:items-center">
        <Card className="w-full max-w-md">
          {receipt && amount !== null ? (
            // نتیجه همان‌جا، داخلِ همین کارت: کاربر بی‌جابه‌جایی می‌بیند پرداخت شد و رسیدش را دارد.
            <div role="status" aria-live="polite" className="flex flex-col">
              <CardHeader className="items-center text-center">
                <span aria-hidden className="mx-auto flex size-14 items-center justify-center rounded-full bg-success text-[var(--dig-white)] [&>svg]:size-7">
                  <CheckIcon />
                </span>
                <CardTitle asChild>
                  <h1 className="mt-2">قبضِ {typeLabel} پرداخت شد</h1>
                </CardTitle>
                <CardDescription className="text-2xl font-black text-foreground tabular-nums">{formatCurrency(amount)}</CardDescription>
              </CardHeader>
              <CardContent>
                <dl className="flex flex-col gap-3 rounded-lg bg-subtle p-4 text-sm">
                  {[
                    ["کدِ پیگیری", toFaDigits(receipt.tracking)],
                    ["تاریخ", formatJalaliDateTime(receipt.date)],
                    ["شناسهٔ قبض", toFaDigits(billId)],
                    ["شناسهٔ پرداخت", toFaDigits(paymentId)],
                  ].map(([label, value]) => (
                    <div key={label} className="flex justify-between gap-3">
                      <dt className="text-muted-foreground">{label}</dt>
                      <dd className="font-medium tabular-nums">
                        <bdi>{value}</bdi>
                      </dd>
                    </div>
                  ))}
                </dl>
              </CardContent>
              <CardFooter className="grid grid-cols-2 gap-3">
                <Button variant="outline" onClick={() => toast.success("رسید برای اشتراک آماده شد.")}>
                  <ShareIcon />
                  اشتراکِ رسید
                </Button>
                <Button onClick={reset}>پرداختِ قبضِ دیگر</Button>
              </CardFooter>
            </div>
          ) : (
          <>
          <CardHeader>
            <CardTitle asChild>
              <h1>پرداخت قبض</h1>
            </CardTitle>
            <CardDescription>شناسه‌ها روی قبض کاغذی یا پیامک قبض آمده‌اند.</CardDescription>
          </CardHeader>
          <ControlSizeProvider size="xl">
            <form onSubmit={lookup}>
              <CardContent className="flex flex-col gap-4">
                <div className="flex flex-col gap-2">
                  <Label id="bill-type">نوع قبض</Label>
                  <ToggleGroup
                    type="single"
                    variant="segmented"
                    size="lg"
                    fullWidth
                    value={type}
                    onValueChange={(value) => value && setType(value as string)}
                    aria-labelledby="bill-type"
                  >
                    {BILL_TYPES.map((item) => (
                      <ToggleGroupItem key={item.value} value={item.value} className="gap-2">
                        {/* eslint-disable-next-line @next/next/no-img-element -- لوگوی کوچکِ ثابت */}
                        <img src={`/logos/organizations/${item.logo}.svg`} alt="" className="size-5" />
                        {item.label}
                      </ToggleGroupItem>
                    ))}
                  </ToggleGroup>
                </div>
                <TextField
                  label="شناسهٔ قبض"
                  name="billId"
                  inputMode="numeric"
                  dir="ltr"
                  maxLength={13}
                  value={billId}
                  onValueChange={(value) => {
                    setBillId(value)
                    setAmount(null)
                  }}
                  required
                />
                <TextField
                  label="شناسهٔ پرداخت"
                  name="paymentId"
                  inputMode="numeric"
                  dir="ltr"
                  maxLength={13}
                  value={paymentId}
                  onValueChange={(value) => {
                    setPaymentId(value)
                    setAmount(null)
                  }}
                  required
                />
                {amount !== null && (
                  <>
                    <Separator />
                    <div className="flex items-center justify-between gap-2">
                      <span className="text-sm text-muted-foreground">مبلغ قابل پرداخت</span>
                      <span className="text-lg font-semibold">{formatCurrency(amount)}</span>
                    </div>
                  </>
                )}
              </CardContent>
              <CardFooter>
                {amount === null ? (
                  <Button type="submit" fullWidth loading={loading} disabled={billId.length < 6 || paymentId.length < 6}>
                    استعلام مبلغ
                  </Button>
                ) : (
                  <Button type="button" fullWidth loading={paying} onClick={pay}>
                    پرداخت {formatCurrency(amount)}
                  </Button>
                )}
              </CardFooter>
            </form>
          </ControlSizeProvider>
          </>
          )}
        </Card>
      </main>
    </ControlSizeProvider>
  )
}
bill-payment.vue
<script setup lang="ts">
import { computed, ref } from "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 CardFooter from "@/components/ui/CardFooter.vue"
import CardHeader from "@/components/ui/CardHeader.vue"
import CardTitle from "@/components/ui/CardTitle.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import Label from "@/components/ui/Label.vue"
import Separator from "@/components/ui/Separator.vue"
import TextField from "@/components/ui/TextField.vue"
import { toast } from "@/components/ui/Toast.vue"
import ToggleGroup from "@/components/ui/ToggleGroup.vue"
import ToggleGroupItem from "@/components/ui/ToggleGroupItem.vue"
import { DigIcon } from "@/lib/icons"
import { formatCurrency, formatJalaliDateTime, toFaDigits } from "@/lib/persian"

const BILL_TYPES = [
  // لوگوی هر اداره در public/logos/organizations
  { value: "water", label: "آب", logo: "water" },
  { value: "power", label: "برق", logo: "power" },
  { value: "gas", label: "گاز", logo: "gas" },
  { value: "phone", label: "تلفن", logo: "telecom" },
]

const type = ref("power")
const billId = ref("")
const paymentId = ref("")
const amount = ref<number | null>(null)
const loading = ref(false)
const paying = ref(false)
const receipt = ref<{ tracking: string; date: Date } | null>(null)
const typeLabel = computed(() => BILL_TYPES.find((item) => item.value === type.value)?.label ?? "")

async function pay() {
  paying.value = true
  await new Promise((resolve) => setTimeout(resolve, 900))
  paying.value = false
  receipt.value = { tracking: String(Math.floor(100_000_000 + Math.random() * 899_999_999)), date: new Date() }
}

function reset() {
  receipt.value = null
  amount.value = null
  billId.value = ""
  paymentId.value = ""
}

async function lookup() {
  loading.value = true
  // مبلغ از شناسهٔ پرداخت درمی‌آید؛ این نمونه یک مبلغِ ثابت برمی‌گرداند.
  await new Promise((resolve) => setTimeout(resolve, 700))
  loading.value = false
  amount.value = 386_000
}

function onTypeChange(value: string | string[] | undefined) {
  if (value) type.value = value as string
}

const receiptRows = computed(() =>
  receipt.value
    ? [
        ["کدِ پیگیری", toFaDigits(receipt.value.tracking)],
        ["تاریخ", formatJalaliDateTime(receipt.value.date)],
        ["شناسهٔ قبض", toFaDigits(billId.value)],
        ["شناسهٔ پرداخت", toFaDigits(paymentId.value)],
      ]
    : []
)
</script>

<template>
  <ControlSize size="xl" as-child>
    <main class="flex min-h-svh items-start justify-center bg-muted p-4 sm:items-center">
      <Card class="w-full max-w-md">
        <!-- نتیجه همان‌جا، داخلِ همین کارت: کاربر بی‌جابه‌جایی می‌بیند پرداخت شد و رسیدش را دارد. -->
        <div v-if="receipt && amount !== null" role="status" aria-live="polite" class="flex flex-col">
          <CardHeader class="items-center text-center">
            <span aria-hidden="true" class="mx-auto flex size-14 items-center justify-center rounded-full bg-success text-[var(--dig-white)] [&>svg]:size-7">
              <DigIcon name="check" />
            </span>
            <CardTitle as-child>
              <h1 class="mt-2">قبضِ {{ typeLabel }} پرداخت شد</h1>
            </CardTitle>
            <CardDescription class="text-2xl font-black text-foreground tabular-nums">{{ formatCurrency(amount) }}</CardDescription>
          </CardHeader>
          <CardContent>
            <dl class="flex flex-col gap-3 rounded-lg bg-subtle p-4 text-sm">
              <div v-for="[label, value] in receiptRows" :key="label" class="flex justify-between gap-3">
                <dt class="text-muted-foreground">{{ label }}</dt>
                <dd class="font-medium tabular-nums">
                  <bdi>{{ value }}</bdi>
                </dd>
              </div>
            </dl>
          </CardContent>
          <CardFooter class="grid grid-cols-2 gap-3">
            <Button variant="outline" @click="toast.success('رسید برای اشتراک آماده شد.')">
              <DigIcon name="share" />
              اشتراکِ رسید
            </Button>
            <Button @click="reset">پرداختِ قبضِ دیگر</Button>
          </CardFooter>
        </div>
        <template v-else>
          <CardHeader>
            <CardTitle as-child>
              <h1>پرداخت قبض</h1>
            </CardTitle>
            <CardDescription>شناسه‌ها روی قبض کاغذی یا پیامک قبض آمده‌اند.</CardDescription>
          </CardHeader>
          <ControlSize size="xl">
            <form @submit.prevent="lookup">
              <CardContent class="flex flex-col gap-4">
                <div class="flex flex-col gap-2">
                  <Label id="bill-type">نوع قبض</Label>
                  <ToggleGroup type="single" variant="segmented" size="lg" full-width :value="type" aria-labelledby="bill-type" @update:value="onTypeChange">
                    <ToggleGroupItem v-for="item in BILL_TYPES" :key="item.value" :value="item.value" class="gap-2">
                      <img :src="`/logos/organizations/${item.logo}.svg`" alt="" class="size-5" />
                      {{ item.label }}
                    </ToggleGroupItem>
                  </ToggleGroup>
                </div>
                <TextField
                  label="شناسهٔ قبض"
                  name="billId"
                  inputmode="numeric"
                  dir="ltr"
                  maxlength="13"
                  :model-value="billId"
                  required
                  @update:model-value="(value) => { billId = String(value); amount = null }"
                />
                <TextField
                  label="شناسهٔ پرداخت"
                  name="paymentId"
                  inputmode="numeric"
                  dir="ltr"
                  maxlength="13"
                  :model-value="paymentId"
                  required
                  @update:model-value="(value) => { paymentId = String(value); amount = null }"
                />
                <template v-if="amount !== null">
                  <Separator />
                  <div class="flex items-center justify-between gap-2">
                    <span class="text-sm text-muted-foreground">مبلغ قابل پرداخت</span>
                    <span class="text-lg font-semibold">{{ formatCurrency(amount) }}</span>
                  </div>
                </template>
              </CardContent>
              <CardFooter>
                <Button v-if="amount === null" type="submit" full-width :loading="loading" :disabled="billId.length < 6 || paymentId.length < 6">استعلام مبلغ</Button>
                <Button v-else type="button" full-width :loading="paying" @click="pay">پرداخت {{ formatCurrency(amount) }}</Button>
              </CardFooter>
            </form>
          </ControlSize>
        </template>
      </Card>
    </main>
  </ControlSize>
</template>

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

این موارد هنوز برای Svelte آماده نیستند: cardcontrol-sizelabelpersianseparatortext-fieldtoasttoggle-groupآیکون checkآیکون share

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

bill-payment.ts
import { Component, ChangeDetectionStrategy, signal, computed } from "@angular/core"

import { DigControlSize } from "@/components/ui/control-size"
import {
  DigCard,
  DigCardHeader,
  DigCardTitle,
  DigCardDescription,
  DigCardContent,
  DigCardFooter,
} from "@/components/ui/card"
import { DigIcon } from "@/lib/icons"
import { DigButton } from "@/components/ui/button"
import { DigLabel } from "@/components/ui/label"
import { DigToggleGroup, DigToggleGroupItem } from "@/components/ui/toggle-group"
import { DigTextField } from "@/components/ui/text-field"
import { DigInput, DigInputField } from "@/components/ui/input"
import { DigSeparator } from "@/components/ui/separator"
import { FormsModule } from "@angular/forms"
import { toast } from "@/components/ui/toast"
import { formatCurrency, formatJalaliDateTime, toFaDigits } from "@/lib/persian"

const BILL_TYPES = [
  // لوگوی هر اداره در public/logos/organizations
  { value: "water", label: "آب", logo: "water" },
  { value: "power", label: "برق", logo: "power" },
  { value: "gas", label: "گاز", logo: "gas" },
  { value: "phone", label: "تلفن", logo: "telecom" },
]

@Component({
  selector: "dig-block-bill-payment",
  imports: [
    DigControlSize,
    DigCard,
    DigCardHeader,
    DigCardTitle,
    DigCardDescription,
    DigCardContent,
    DigCardFooter,
    DigIcon,
    DigButton,
    DigLabel,
    DigToggleGroup,
    DigToggleGroupItem,
    DigTextField,
    DigInput,
    DigInputField,
    DigSeparator,
    FormsModule,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <main digControlSize="xl" class="flex min-h-svh items-start justify-center bg-muted p-4 sm:items-center">
      <div digCard class="w-full max-w-md">
        <!-- نتیجه همان‌جا، داخلِ همین کارت: کاربر بی‌جابه‌جایی می‌بیند پرداخت شد و رسیدش را دارد. -->
        @if (receipt() && amount() !== null) {
          <div role="status" aria-live="polite" class="flex flex-col">
            <div digCardHeader class="items-center text-center">
              <span
                aria-hidden="true"
                class="mx-auto flex size-14 items-center justify-center rounded-full bg-success text-[var(--dig-white)] [&>svg]:size-7"
                ><svg digIcon="check"></svg
              ></span>
              <h1 digCardTitle class="mt-2">قبضِ {{ typeLabel() }} پرداخت شد</h1>
              <div digCardDescription class="text-2xl font-black text-foreground tabular-nums">
                {{ formatCurrency(amount() ?? 0) }}
              </div>
            </div>
            <div digCardContent>
              <dl class="flex flex-col gap-3 rounded-lg bg-subtle p-4 text-sm">
                @for (entry of receiptRows(); track entry[0]) {
                  @let label = entry[0];
                  @let value = entry[1];
                  <div class="flex justify-between gap-3">
                    <dt class="text-muted-foreground">{{ label }}</dt>
                    <dd class="font-medium tabular-nums">
                      <bdi>{{ value }}</bdi>
                    </dd>
                  </div>
                }
              </dl>
            </div>
            <div digCardFooter class="grid grid-cols-2 gap-3">
              <button digButton type="button" variant="outline" (click)="toast.success('رسید برای اشتراک آماده شد.')">
                <svg digIcon="share"></svg>
                اشتراکِ رسید
              </button>
              <button digButton type="button" (click)="reset()">پرداختِ قبضِ دیگر</button>
            </div>
          </div>
        } @else {
          <div digCardHeader>
            <h1 digCardTitle>پرداخت قبض</h1>
            <div digCardDescription>شناسه‌ها روی قبض کاغذی یا پیامک قبض آمده‌اند.</div>
          </div>
          <div digControlSize="xl">
            <form (submit)="$event.preventDefault(); lookup()">
              <div digCardContent class="flex flex-col gap-4">
                <div class="flex flex-col gap-2">
                  <label digLabel id="bill-type">نوع قبض</label>
                  <div
                    digToggleGroup
                    type="single"
                    variant="segmented"
                    size="lg"
                    fullWidth
                    [value]="type()"
                    aria-labelledby="bill-type"
                    (valueChange)="onTypeChange($event)"
                  >
                    @for (item of BILL_TYPES; track item.value) {
                      <button digToggleGroupItem [value]="item.value" class="gap-2">
                        <img [src]="\`/logos/organizations/\${item.logo}.svg\`" alt="" class="size-5" />
                        {{ item.label }}
                      </button>
                    }
                  </div>
                </div>
                <div digTextField label="شناسهٔ قبض" required>
                  <dig-input
                    ><input
                      digInput
                      name="billId"
                      inputmode="numeric"
                      dir="ltr"
                      maxlength="13"
                      [ngModel]="billId()"
                      [ngModelOptions]="{ standalone: true }"
                      (ngModelChange)="billId.set(string($event)); amount.set(null)"
                  /></dig-input>
                </div>
                <div digTextField label="شناسهٔ پرداخت" required>
                  <dig-input
                    ><input
                      digInput
                      name="paymentId"
                      inputmode="numeric"
                      dir="ltr"
                      maxlength="13"
                      [ngModel]="paymentId()"
                      [ngModelOptions]="{ standalone: true }"
                      (ngModelChange)="paymentId.set(string($event)); amount.set(null)"
                  /></dig-input>
                </div>
                @if (amount() !== null) {
                  <div digSeparator></div>
                  <div class="flex items-center justify-between gap-2">
                    <span class="text-sm text-muted-foreground">مبلغ قابل پرداخت</span>
                    <span class="text-lg font-semibold">{{ formatCurrency(amount() ?? 0) }}</span>
                  </div>
                }
              </div>
              <div digCardFooter>
                @if (amount() === null) {
                  <button
                    digButton
                    type="submit"
                    fullWidth
                    [loading]="loading()"
                    [disabled]="billId().length < 6 || paymentId().length < 6"
                  >
                    استعلام مبلغ
                  </button>
                } @else {
                  <button digButton type="button" fullWidth [loading]="paying()" (click)="pay()">
                    پرداخت {{ formatCurrency(amount() ?? 0) }}
                  </button>
                }
              </div>
            </form>
          </div>
        }
      </div>
    </main>
  `,
})
export class BillPaymentBlock {
  readonly string = String

  readonly toast = toast

  readonly formatCurrency = formatCurrency

  readonly BILL_TYPES = BILL_TYPES

  readonly type = signal("power")

  readonly billId = signal("")

  readonly paymentId = signal("")

  readonly amount = signal<number | null>(null)

  readonly loading = signal(false)

  readonly paying = signal(false)

  readonly receipt = signal<{ tracking: string; date: Date } | null>(null)

  readonly typeLabel = computed(() => BILL_TYPES.find((item) => item.value === this.type())?.label ?? "")

  async pay() {
    this.paying.set(true)
    await new Promise((resolve) => setTimeout(resolve, 900))
    this.paying.set(false)
    this.receipt.set({ tracking: String(Math.floor(100_000_000 + Math.random() * 899_999_999)), date: new Date() })
  }

  reset() {
    this.receipt.set(null)
    this.amount.set(null)
    this.billId.set("")
    this.paymentId.set("")
  }

  async lookup() {
    this.loading.set(true)
    // مبلغ از شناسهٔ پرداخت درمی‌آید؛ این نمونه یک مبلغِ ثابت برمی‌گرداند.
    await new Promise((resolve) => setTimeout(resolve, 700))
    this.loading.set(false)
    this.amount.set(386_000)
  }

  onTypeChange(value: string | string[] | undefined) {
    if (value) this.type.set(value as string)
  }

  readonly receiptRows = computed(() => {
    const current = this.receipt()
    return current
      ? [
          ["کدِ پیگیری", toFaDigits(current.tracking)],
          ["تاریخ", formatJalaliDateTime(current.date)],
          ["شناسهٔ قبض", toFaDigits(this.billId())],
          ["شناسهٔ پرداخت", toFaDigits(this.paymentId())],
        ]
      : []
  })
}

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

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

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