|
|
|
@@ -1,6 +1,7 @@ |
|
|
|
import { Box, Button, Stack, Typography } from "@mui/material"; |
|
|
|
import { HasChildren } from "@types"; |
|
|
|
import { |
|
|
|
getSeasonTicketContractTerminateOptions, |
|
|
|
orderSeasonTicketContractTerminate, |
|
|
|
reOrderSticker, |
|
|
|
} from "api/season-ticket-contract"; |
|
|
|
@@ -42,7 +43,7 @@ function AreaBox({ label, children, require }: AreaBoxProps) { |
|
|
|
} |
|
|
|
|
|
|
|
type FormProps = { |
|
|
|
date: Date | null; |
|
|
|
date: string; |
|
|
|
reason: string[]; |
|
|
|
other_reason: string; |
|
|
|
opinion: string; |
|
|
|
@@ -57,7 +58,7 @@ export default function TerminateOrder() { |
|
|
|
|
|
|
|
const form = useForm<FormProps>({ |
|
|
|
defaultValues: { |
|
|
|
date: null, |
|
|
|
date: "", |
|
|
|
reason: [], |
|
|
|
other_reason: "", |
|
|
|
opinion: "", |
|
|
|
@@ -71,6 +72,15 @@ export default function TerminateOrder() { |
|
|
|
|
|
|
|
const { selectedseasonTicketContract } = useSeasonTicketContractContext(); |
|
|
|
|
|
|
|
const [monthes, setMonthes] = useState<string[]>([]); |
|
|
|
|
|
|
|
const monthOptions: SelectOptionProps[] = useMemo(() => { |
|
|
|
return monthes.map((ele) => ({ |
|
|
|
value: ele, |
|
|
|
label: ele, |
|
|
|
})); |
|
|
|
}, [monthes]); |
|
|
|
|
|
|
|
const [done, setDone] = useState(false); |
|
|
|
|
|
|
|
const { callAPI: callOrderSeasonTicketContractTerminate } = useAPICall({ |
|
|
|
@@ -84,16 +94,21 @@ export default function TerminateOrder() { |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
const { callAPI: callGetSeasonTicketContractTerminateOptions } = useAPICall({ |
|
|
|
apiMethod: getSeasonTicketContractTerminateOptions, |
|
|
|
backDrop: true, |
|
|
|
onSuccess: ({ data }) => { |
|
|
|
setMonthes(data.monthes); |
|
|
|
}, |
|
|
|
}); |
|
|
|
|
|
|
|
const handleSubmit = (data: FormProps) => { |
|
|
|
console.log(data); |
|
|
|
|
|
|
|
if (selectedseasonTicketContract === null) return; |
|
|
|
const date = data.date; |
|
|
|
if (date === null) return; |
|
|
|
|
|
|
|
callOrderSeasonTicketContractTerminate({ |
|
|
|
...data, |
|
|
|
date, |
|
|
|
season_ticket_contract_record_no: |
|
|
|
selectedseasonTicketContract.season_ticekt_contract_record_no ?? "", |
|
|
|
reason: data.reason.join(","), |
|
|
|
@@ -126,7 +141,12 @@ export default function TerminateOrder() { |
|
|
|
navigateWhenChanged( |
|
|
|
getPath(PageID.DASHBOARD_SEASON_TICKET_CONTRACT_LIST) |
|
|
|
); |
|
|
|
return; |
|
|
|
} |
|
|
|
callGetSeasonTicketContractTerminateOptions({ |
|
|
|
season_ticket_contract_record_no: |
|
|
|
selectedseasonTicketContract.season_ticekt_contract_record_no ?? "", |
|
|
|
}); |
|
|
|
}, [selectedseasonTicketContract]); |
|
|
|
|
|
|
|
if (selectedseasonTicketContract === null) { |
|
|
|
@@ -166,7 +186,7 @@ export default function TerminateOrder() { |
|
|
|
</Box> |
|
|
|
|
|
|
|
<AreaBox label="解約希望日" require> |
|
|
|
<RHFDatePicker name="date" size="small" /> |
|
|
|
<RHFSelect name="date" size="small" options={monthOptions} /> |
|
|
|
</AreaBox> |
|
|
|
<AreaBox label="解約理由(複数選択可)" require> |
|
|
|
<Typography variant="body2"> |
|
|
|
|