feat: convert deposit amounts from toman to rials in appointment handling
This commit is contained in:
@@ -20,7 +20,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import { toast } from "sonner";
|
||||
import type { ApiResponse } from "../lib/api";
|
||||
import { api } from "../lib/api";
|
||||
import { formatRial, tehranWallClockToUnix } from "../lib/utils";
|
||||
import { formatRial, tehranWallClockToUnix, rialToToman, tomanToRial } from "../lib/utils";
|
||||
import type { Appointment } from "../types";
|
||||
import AppointmentStatusDropdown from "./ui/AppointmentStatusDropdown";
|
||||
import Modal from "./ui/Modal";
|
||||
@@ -702,8 +702,8 @@ export function ReplaceAppointmentModal({
|
||||
const [depositRequired, setDepositRequired] = useState(
|
||||
!!a.deposit_required,
|
||||
);
|
||||
const [depositRials, setDepositRials] = useState(
|
||||
a.deposit_amount_rials ?? 0,
|
||||
const [depositToman, setDepositToman] = useState(
|
||||
rialToToman(a.deposit_amount_rials ?? 0),
|
||||
);
|
||||
const [note, setNote] = useState("");
|
||||
|
||||
@@ -719,7 +719,7 @@ export function ReplaceAppointmentModal({
|
||||
service_item_uuid: itemUuid,
|
||||
staff_uuid: staffUuid,
|
||||
deposit_required: depositRequired,
|
||||
deposit_amount_rials: depositRequired ? depositRials : null,
|
||||
deposit_amount_rials: depositRequired ? tomanToRial(depositToman) : null,
|
||||
...(note.trim() ? { note: note.trim() } : {}),
|
||||
...(status !== a.status ? { status } : {}),
|
||||
version: a.version,
|
||||
@@ -904,8 +904,8 @@ export function ReplaceAppointmentModal({
|
||||
<label style={label}>مبلغ بیعانه (تومان)</label>
|
||||
<div style={{ marginTop: 6 }}>
|
||||
<PriceInput
|
||||
value={depositRials}
|
||||
onChange={setDepositRials}
|
||||
value={depositToman}
|
||||
onChange={setDepositToman}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user