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:
@@ -5,7 +5,7 @@ import { z } from 'zod';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { api } from '../lib/api';
|
||||
import type { ApiResponse } from '../lib/api';
|
||||
import { formatDateTime } from '../lib/utils';
|
||||
import { formatDateTime, rialToToman, tomanToRial } from '../lib/utils';
|
||||
import {
|
||||
Cog6ToothIcon, ClockIcon, CalculatorIcon, CreditCardIcon, ChatBubbleLeftRightIcon,
|
||||
MagnifyingGlassIcon, CheckCircleIcon, ExclamationTriangleIcon, EyeIcon, EyeSlashIcon,
|
||||
@@ -62,9 +62,10 @@ const toForm = (s: Partial<Settings>): FormValues => ({
|
||||
upgrade_commission_percent: s.upgrade_commission_percent ?? '20',
|
||||
tax_enabled: s.tax_enabled ?? '0',
|
||||
tax_percent: s.tax_percent ?? '10',
|
||||
sms_panel_fee_rials: s.sms_panel_fee_rials ?? '1500000',
|
||||
sms_price_rials: s.sms_price_rials ?? '500',
|
||||
appointment_fee_rials: s.appointment_fee_rials ?? '150000',
|
||||
// ذخیره ریال است؛ در فرم به تومان نمایش/ویرایش میشود.
|
||||
sms_panel_fee_rials: String(rialToToman(Number(s.sms_panel_fee_rials ?? 1500000))),
|
||||
sms_price_rials: String(rialToToman(Number(s.sms_price_rials ?? 500))),
|
||||
appointment_fee_rials: String(rialToToman(Number(s.appointment_fee_rials ?? 150000))),
|
||||
payment_test_mode: s.payment_test_mode ?? '0',
|
||||
mellat_enabled: s.mellat_enabled ?? '1',
|
||||
mellat_sandbox: s.mellat_sandbox ?? '0',
|
||||
@@ -189,7 +190,13 @@ export default function SettingsPage() {
|
||||
return () => clearTimeout(t);
|
||||
}, [savedFlash]);
|
||||
|
||||
const onSubmit = (values: FormValues) => mutation.mutate(values);
|
||||
const onSubmit = (values: FormValues) => mutation.mutate({
|
||||
...values,
|
||||
// فرم به تومان است؛ برای ذخیره به ریال تبدیل کن.
|
||||
sms_panel_fee_rials: String(tomanToRial(Number(values.sms_panel_fee_rials))),
|
||||
sms_price_rials: String(tomanToRial(Number(values.sms_price_rials))),
|
||||
appointment_fee_rials: String(tomanToRial(Number(values.appointment_fee_rials))),
|
||||
});
|
||||
|
||||
// Ctrl/Cmd+S saves
|
||||
useEffect(() => {
|
||||
@@ -371,16 +378,16 @@ export default function SettingsPage() {
|
||||
)}
|
||||
|
||||
<div className="settings-grid" style={{ marginTop: 18 }}>
|
||||
<Field label="مبلغ هر نوبت" hint="مبلغی که بیمار هنگام رزرو آنلاین پرداخت میکند. ۱۵۰٬۰۰۰ ریال = ۱۵٬۰۰۰ تومان.">
|
||||
<Field label="مبلغ هر نوبت" hint="مبلغی که بیمار هنگام رزرو آنلاین پرداخت میکند (تومان).">
|
||||
<div className="input-suffix">
|
||||
<input {...register('appointment_fee_rials')} type="number" min={0} dir="ltr" className="input" style={{ maxWidth: 200 }} placeholder="150000" />
|
||||
<span className="suf">ریال</span>
|
||||
<input {...register('appointment_fee_rials')} type="number" min={0} dir="ltr" className="input" style={{ maxWidth: 200 }} placeholder="15000" />
|
||||
<span className="suf">تومان</span>
|
||||
</div>
|
||||
</Field>
|
||||
<Field label="هزینه ثابت پنل پیامک" hint="از مبلغ هر تراکنش کسر میشود. ۱٬۵۰۰٬۰۰۰ ریال = ۱۵۰٬۰۰۰ تومان.">
|
||||
<Field label="هزینه ثابت پنل پیامک" hint="از مبلغ هر تراکنش کسر میشود (تومان).">
|
||||
<div className="input-suffix">
|
||||
<input {...register('sms_panel_fee_rials')} type="number" min={0} dir="ltr" className="input" style={{ maxWidth: 200 }} placeholder="1500000" />
|
||||
<span className="suf">ریال</span>
|
||||
<input {...register('sms_panel_fee_rials')} type="number" min={0} dir="ltr" className="input" style={{ maxWidth: 200 }} placeholder="150000" />
|
||||
<span className="suf">تومان</span>
|
||||
</div>
|
||||
</Field>
|
||||
</div>
|
||||
@@ -468,8 +475,8 @@ export default function SettingsPage() {
|
||||
: <><ExclamationTriangleIcon style={{ width: 18, height: 18, color: 'var(--danger)' }} /><span style={{ color: 'var(--danger)' }}>تنظیمنشده — مقدار KAVENEGAR_API_KEY را در فایل env قرار دهید</span></>}
|
||||
</div>
|
||||
</Field>
|
||||
<Field label="هزینه هر پیامک" hint="مبلغ کسرشده از کیف پول به ازای هر پیامک ارسالی (ریال). مبنای محاسبهٔ تعداد پیامک از موجودی.">
|
||||
<input {...register('sms_price_rials')} type="number" min={0} dir="ltr" className="input" style={{ maxWidth: 200 }} placeholder="500" />
|
||||
<Field label="هزینه هر پیامک" hint="مبلغ کسرشده از کیف پول به ازای هر پیامک ارسالی (تومان). مبنای محاسبهٔ تعداد پیامک از موجودی.">
|
||||
<input {...register('sms_price_rials')} type="number" min={0} dir="ltr" className="input" style={{ maxWidth: 200 }} placeholder="50" />
|
||||
</Field>
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user