Skip to content

Commit fb8c71f

Browse files
committed
fix: return form
1 parent d89df5c commit fb8c71f

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

  • packages/admin/dashboard/src/routes/orders/order-create-return/components/return-create-form

packages/admin/dashboard/src/routes/orders/order-create-return/components/return-create-form/return-create-form.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ export const ReturnCreateForm = ({
9494
*/
9595
const { setIsOpen } = useStackedModal()
9696
const [isShippingPriceEdit, setIsShippingPriceEdit] = useState(false)
97-
const [customShippingAmount, setCustomShippingAmount] = useState(0)
97+
const [customShippingAmount, setCustomShippingAmount] = useState<{
98+
value: string
99+
float: number | null
100+
}>({
101+
value: "0",
102+
float: 0,
103+
})
98104
const [inventoryMap, setInventoryMap] = useState<
99105
Record<string, InventoryLevelDTO[]>
100106
>({})
@@ -671,10 +677,7 @@ export const ReturnCreateForm = ({
671677
if (actionId) {
672678
updateReturnShipping({
673679
actionId,
674-
custom_amount:
675-
typeof customShippingAmount === "string"
676-
? null
677-
: customShippingAmount,
680+
custom_amount: customShippingAmount.float,
678681
})
679682
}
680683
setIsShippingPriceEdit(false)
@@ -684,10 +687,13 @@ export const ReturnCreateForm = ({
684687
.symbol_native
685688
}
686689
code={order.currency_code}
687-
onValueChange={(value) =>
688-
setCustomShippingAmount(value ? parseFloat(value) : "")
690+
onValueChange={(value, name, values) =>
691+
setCustomShippingAmount({
692+
value: values?.value || "",
693+
float: values?.float || null,
694+
})
689695
}
690-
value={customShippingAmount}
696+
value={customShippingAmount.value}
691697
disabled={showPlaceholder}
692698
/>
693699
) : (

0 commit comments

Comments
 (0)