feat(currency): update currency display to toman in admin panel; implement conversion functions for rial to toman and vice versa

This commit is contained in:
hamed
2026-07-03 10:31:17 +03:30
parent 34d521434f
commit 6dbbeb1c70
11 changed files with 200 additions and 58 deletions
@@ -3,7 +3,7 @@ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from 'sonner';
import { api } from '../lib/api';
import type { ApiResponse } from '../lib/api';
import { formatRial, formatDate } from '../lib/utils';
import { formatRial, formatDate, tomanToRial } from '../lib/utils';
import Pagination from '../components/ui/Pagination';
interface WalletBalance { balance_rials: number }
@@ -81,11 +81,12 @@ export default function RepresentationSettlementPage() {
});
const submit = () => {
const n = Number(amount);
const n = Number(amount); // تومان
if (!n || n <= 0) { toast.error('مبلغ نامعتبر است'); return; }
if (n > balance) { toast.error('مبلغ بیشتر از موجودی قابل برداشت است'); return; }
const rial = tomanToRial(n);
if (rial > balance) { toast.error('مبلغ بیشتر از موجودی قابل برداشت است'); return; }
if (!ibanId) { toast.error('انتخاب شماره شبا الزامی است'); return; }
createMut.mutate({ amount_rials: n, iban_id: ibanId });
createMut.mutate({ amount_rials: rial, iban_id: ibanId });
};
const cards = [
@@ -125,7 +126,7 @@ export default function RepresentationSettlementPage() {
) : (
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
<input
type="number" min={0} dir="ltr" value={amount} placeholder="مبلغ به ریال"
type="number" min={0} dir="ltr" value={amount} placeholder="مبلغ به تومان"
onChange={(e) => setAmount(e.target.value)}
style={{ width: 200, height: 38, padding: '0 12px', borderRadius: 'var(--r-sm)', border: '1px solid var(--border)', background: 'var(--surface)', color: 'var(--text)', fontSize: 13.5, boxSizing: 'border-box' }}
/>