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
+9 -9
View File
@@ -13,7 +13,7 @@ import { api } from '../lib/api';
import type { ApiResponse, PaginatedResponse } from '../lib/api';
import type { SmsWalletBalance, SmsWalletLog, SmsSettings } from '../types';
import { usePaymentConfig } from '../hooks/usePaymentConfig';
import { formatRial, formatNumber, formatDateTime } from '../lib/utils';
import { formatRial, formatNumber, formatDateTime, tomanToRial } from '../lib/utils';
import Modal from '../components/ui/Modal';
import Pagination from '../components/ui/Pagination';
import SearchableSelect from '../components/ui/SearchableSelect';
@@ -21,7 +21,7 @@ import PageHeader from '../components/ui/PageHeader';
import FeatureGate from '../components/ui/FeatureGate';
const chargeSchema = z.object({
amount_rials: z.coerce.number().min(10000, 'حداقل مبلغ ۱۰,۰۰۰ ریال است'),
amount_rials: z.coerce.number().min(1000, 'حداقل مبلغ ۱٬۰۰۰ تومان است'),
});
type ChargeForm = z.infer<typeof chargeSchema>;
@@ -70,7 +70,7 @@ function SmsWalletPageInner() {
const chargeMutation = useMutation({
mutationFn: ({ amount_rials }: ChargeForm) =>
api.post<{ data: { payment_url: string } }>('/api/v1/sms/wallet/charge', {
gateway, amount_rials,
gateway, amount_rials: tomanToRial(amount_rials),
frontend_address: `${window.location.origin}${window.location.pathname}`,
}),
onSuccess: (res: any) => {
@@ -525,18 +525,18 @@ function SmsWalletPageInner() {
)}
<div className="field">
<label>مبلغ (ریال)</label>
<label>مبلغ (تومان)</label>
<input
{...chargeForm.register('amount_rials')}
type="number" min={10000}
placeholder="500000" dir="ltr"
type="number" min={1000}
placeholder="50000" dir="ltr"
/>
{chargeForm.formState.errors.amount_rials && (
<span className="field-error">{chargeForm.formState.errors.amount_rials.message}</span>
)}
</div>
{watchAmount && Number(watchAmount) >= 10000 && (
{watchAmount && Number(watchAmount) >= 1000 && (
<div style={{
background: isTestMode ? 'var(--warning-bg)' : 'var(--primary-soft)',
border: `1px solid ${isTestMode ? 'var(--warning)' : 'color-mix(in oklch, var(--primary) 40%, transparent)'}`,
@@ -544,8 +544,8 @@ function SmsWalletPageInner() {
fontSize: 13, color: isTestMode ? 'var(--warning)' : 'var(--primary)', fontWeight: 500,
}}>
{isTestMode
? `پرداخت آزمایشی ${formatRial(Number(watchAmount))}`
: `پرداخت ${formatRial(Number(watchAmount))} از طریق ${gateway === 'mellat' ? 'بانک ملت' : 'سپ'}`
? `پرداخت آزمایشی ${formatRial(tomanToRial(Number(watchAmount)))}`
: `پرداخت ${formatRial(tomanToRial(Number(watchAmount)))} از طریق ${gateway === 'mellat' ? 'بانک ملت' : 'سپ'}`
}
</div>
)}