|
|
@@ -1,17 +1,29 @@ |
|
|
import { Box, Button, Stack, Typography } from "@mui/material"; |
|
|
|
|
|
|
|
|
import { |
|
|
|
|
|
Box, |
|
|
|
|
|
Button, |
|
|
|
|
|
Stack, |
|
|
|
|
|
Table, |
|
|
|
|
|
TableBody, |
|
|
|
|
|
TableCell, |
|
|
|
|
|
TableRow, |
|
|
|
|
|
Typography, |
|
|
|
|
|
} from "@mui/material"; |
|
|
import { HasChildren } from "@types"; |
|
|
import { HasChildren } from "@types"; |
|
|
import { |
|
|
import { |
|
|
orderChangePaymentInterval, |
|
|
|
|
|
reOrderSticker, |
|
|
|
|
|
|
|
|
getChangePlanOrderParams, |
|
|
|
|
|
orderChangePlan, |
|
|
} from "api/season-ticket-contract"; |
|
|
} from "api/season-ticket-contract"; |
|
|
|
|
|
import TextFieldEx from "components/form/TextFieldEx"; |
|
|
import { FormProvider, RHFTextField } from "components/hook-form"; |
|
|
import { FormProvider, RHFTextField } from "components/hook-form"; |
|
|
|
|
|
import RHFSelect, { SelectOptionProps } from "components/hook-form/RHFSelect"; |
|
|
|
|
|
import StackRow from "components/stack/StackRow"; |
|
|
import { useSeasonTicketContractContext } from "contexts/dashboard/SeasonTicketContractContext"; |
|
|
import { useSeasonTicketContractContext } from "contexts/dashboard/SeasonTicketContractContext"; |
|
|
import useAPICall from "hooks/useAPICall"; |
|
|
import useAPICall from "hooks/useAPICall"; |
|
|
import useDashboard from "hooks/useDashBoard"; |
|
|
import useDashboard from "hooks/useDashBoard"; |
|
|
import useNavigateCustom from "hooks/useNavigateCustom"; |
|
|
import useNavigateCustom from "hooks/useNavigateCustom"; |
|
|
import useSnackbarCustom from "hooks/useSnackbarCustom"; |
|
|
import useSnackbarCustom from "hooks/useSnackbarCustom"; |
|
|
import { PageID, TabID } from "pages"; |
|
|
import { PageID, TabID } from "pages"; |
|
|
import { useEffect, useState } from "react"; |
|
|
|
|
|
|
|
|
import { useEffect, useMemo, useState } from "react"; |
|
|
import { useForm } from "react-hook-form"; |
|
|
import { useForm } from "react-hook-form"; |
|
|
import { getPath } from "routes/path"; |
|
|
import { getPath } from "routes/path"; |
|
|
|
|
|
|
|
|
@@ -28,7 +40,8 @@ function AreaBox({ label, children }: AreaBoxProps) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type FormProps = { |
|
|
type FormProps = { |
|
|
upload1: File[]; |
|
|
|
|
|
|
|
|
plan_name: string; |
|
|
|
|
|
memo: string; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
export default function ChangPaymentIntervalOrder() { |
|
|
export default function ChangPaymentIntervalOrder() { |
|
|
@@ -39,7 +52,8 @@ export default function ChangPaymentIntervalOrder() { |
|
|
|
|
|
|
|
|
const form = useForm<FormProps>({ |
|
|
const form = useForm<FormProps>({ |
|
|
defaultValues: { |
|
|
defaultValues: { |
|
|
upload1: [], |
|
|
|
|
|
|
|
|
plan_name: "", |
|
|
|
|
|
memo: "", |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@@ -50,24 +64,45 @@ export default function ChangPaymentIntervalOrder() { |
|
|
const { selectedseasonTicketContract, backToDetailHome } = |
|
|
const { selectedseasonTicketContract, backToDetailHome } = |
|
|
useSeasonTicketContractContext(); |
|
|
useSeasonTicketContractContext(); |
|
|
|
|
|
|
|
|
const [done, setDone] = useState(false); |
|
|
|
|
|
|
|
|
const [mode, setMode] = useState<"input" | "confirm" | "done">("input"); |
|
|
|
|
|
|
|
|
|
|
|
const [plans, setPlans] = useState<string[]>([]); |
|
|
|
|
|
|
|
|
|
|
|
const planOptions: SelectOptionProps[] = useMemo(() => { |
|
|
|
|
|
return plans.map((planName) => ({ |
|
|
|
|
|
value: planName, |
|
|
|
|
|
label: planName, |
|
|
|
|
|
})); |
|
|
|
|
|
}, [plans]); |
|
|
|
|
|
|
|
|
|
|
|
const { callAPI: callGetChangePlanOrderParams } = useAPICall({ |
|
|
|
|
|
apiMethod: getChangePlanOrderParams, |
|
|
|
|
|
backDrop: true, |
|
|
|
|
|
onSuccess: ({ data }) => { |
|
|
|
|
|
setPlans(data); |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
const { callAPI: callOrderChangePaymentInterval } = useAPICall({ |
|
|
|
|
|
apiMethod: orderChangePaymentInterval, |
|
|
|
|
|
|
|
|
const { callAPI: callOrderChangePlan } = useAPICall({ |
|
|
|
|
|
apiMethod: orderChangePlan, |
|
|
backDrop: true, |
|
|
backDrop: true, |
|
|
onSuccess: () => { |
|
|
onSuccess: () => { |
|
|
setDone(true); |
|
|
|
|
|
|
|
|
setMode("done"); |
|
|
}, |
|
|
}, |
|
|
onFailed: () => { |
|
|
onFailed: () => { |
|
|
error("依頼失敗しました"); |
|
|
error("依頼失敗しました"); |
|
|
}, |
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const handleSubmit = (data: FormProps) => { |
|
|
|
|
|
callOrderChangePaymentInterval({ |
|
|
|
|
|
|
|
|
const handleSubmit = () => { |
|
|
|
|
|
setMode("confirm"); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const send = () => { |
|
|
|
|
|
callOrderChangePlan({ |
|
|
season_ticket_contract_record_no: |
|
|
season_ticket_contract_record_no: |
|
|
selectedseasonTicketContract?.season_ticekt_contract_record_no ?? "", |
|
|
selectedseasonTicketContract?.season_ticekt_contract_record_no ?? "", |
|
|
...data, |
|
|
|
|
|
|
|
|
...form.getValues(), |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
@@ -81,13 +116,18 @@ export default function ChangPaymentIntervalOrder() { |
|
|
navigateWhenChanged( |
|
|
navigateWhenChanged( |
|
|
getPath(PageID.DASHBOARD_SEASON_TICKET_CONTRACT_LIST) |
|
|
getPath(PageID.DASHBOARD_SEASON_TICKET_CONTRACT_LIST) |
|
|
); |
|
|
); |
|
|
|
|
|
} else { |
|
|
|
|
|
callGetChangePlanOrderParams({ |
|
|
|
|
|
season_ticket_contract_record_no: |
|
|
|
|
|
selectedseasonTicketContract.season_ticekt_contract_record_no ?? "", |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
}, [selectedseasonTicketContract]); |
|
|
}, [selectedseasonTicketContract]); |
|
|
|
|
|
|
|
|
if (selectedseasonTicketContract === null) { |
|
|
if (selectedseasonTicketContract === null) { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
if (done) { |
|
|
|
|
|
|
|
|
if (mode === "done") { |
|
|
return ( |
|
|
return ( |
|
|
<Box sx={{ mt: 1 }}> |
|
|
<Box sx={{ mt: 1 }}> |
|
|
<Stack spacing={2}> |
|
|
<Stack spacing={2}> |
|
|
@@ -100,6 +140,58 @@ export default function ChangPaymentIntervalOrder() { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mode === "confirm") { |
|
|
|
|
|
return ( |
|
|
|
|
|
<Box sx={{ mt: 1 }}> |
|
|
|
|
|
<Stack spacing={2}> |
|
|
|
|
|
<Box> |
|
|
|
|
|
<Typography>下記内容で申請を行います。</Typography> |
|
|
|
|
|
</Box> |
|
|
|
|
|
<Box> |
|
|
|
|
|
<Table size="small"> |
|
|
|
|
|
<TableBody> |
|
|
|
|
|
<TableRow> |
|
|
|
|
|
<TableCell>変更先プラン</TableCell> |
|
|
|
|
|
<TableCell> |
|
|
|
|
|
<TextFieldEx |
|
|
|
|
|
multiline |
|
|
|
|
|
value={form.getValues("plan_name")} |
|
|
|
|
|
readOnly |
|
|
|
|
|
fullWidth |
|
|
|
|
|
/> |
|
|
|
|
|
</TableCell> |
|
|
|
|
|
</TableRow> |
|
|
|
|
|
<TableRow> |
|
|
|
|
|
<TableCell>備考</TableCell> |
|
|
|
|
|
<TableCell> |
|
|
|
|
|
<TextFieldEx |
|
|
|
|
|
multiline |
|
|
|
|
|
value={form.getValues("memo")} |
|
|
|
|
|
readOnly |
|
|
|
|
|
fullWidth |
|
|
|
|
|
/> |
|
|
|
|
|
</TableCell> |
|
|
|
|
|
</TableRow> |
|
|
|
|
|
</TableBody> |
|
|
|
|
|
</Table> |
|
|
|
|
|
</Box> |
|
|
|
|
|
<StackRow spacing={2}> |
|
|
|
|
|
<Button |
|
|
|
|
|
onClick={() => { |
|
|
|
|
|
setMode("input"); |
|
|
|
|
|
}} |
|
|
|
|
|
> |
|
|
|
|
|
戻る |
|
|
|
|
|
</Button> |
|
|
|
|
|
<Button onClick={send} variant="contained"> |
|
|
|
|
|
送信 |
|
|
|
|
|
</Button> |
|
|
|
|
|
</StackRow> |
|
|
|
|
|
</Stack> |
|
|
|
|
|
</Box> |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}> |
|
|
<FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}> |
|
|
<Box sx={{ mt: 1 }}> |
|
|
<Box sx={{ mt: 1 }}> |
|
|
@@ -108,6 +200,22 @@ export default function ChangPaymentIntervalOrder() { |
|
|
<Button onClick={backToDetailHome}>戻る</Button> |
|
|
<Button onClick={backToDetailHome}>戻る</Button> |
|
|
</Box> |
|
|
</Box> |
|
|
|
|
|
|
|
|
|
|
|
<AreaBox label="変更先プラン"> |
|
|
|
|
|
<RHFSelect name="plan_name" options={planOptions} size="small" /> |
|
|
|
|
|
</AreaBox> |
|
|
|
|
|
|
|
|
|
|
|
<AreaBox label="備考"> |
|
|
|
|
|
<Typography variant="body2"> |
|
|
|
|
|
ご不明点等がございましたらご入力ください。お電話またはメールにて回答させていただきます。 |
|
|
|
|
|
</Typography> |
|
|
|
|
|
<RHFTextField |
|
|
|
|
|
name="memo" |
|
|
|
|
|
size="small" |
|
|
|
|
|
multiline |
|
|
|
|
|
minRows={3} |
|
|
|
|
|
maxRows={10} |
|
|
|
|
|
/> |
|
|
|
|
|
</AreaBox> |
|
|
<Box> |
|
|
<Box> |
|
|
<Button variant="contained" type="submit"> |
|
|
<Button variant="contained" type="submit"> |
|
|
確定 |
|
|
確定 |
|
|
|