| @@ -198,6 +198,7 @@ export const orderChangePaymentInterval = async ( | |||
| export type UploadStudentLicenseImagesRequest = { | |||
| images: File[]; | |||
| season_ticket_contract_record_no: string; | |||
| expires_at: string; | |||
| }; | |||
| export const uploadStudentLicenseImages = async ( | |||
| param: UploadStudentLicenseImagesRequest | |||
| @@ -216,6 +217,7 @@ export const uploadStudentLicenseImages = async ( | |||
| export type OtherLicenseImagesRequest = { | |||
| images: File[]; | |||
| season_ticket_contract_record_no: string; | |||
| expires_at: string; | |||
| }; | |||
| export const uploadOtherLicenseImages = async ( | |||
| param: OtherLicenseImagesRequest | |||
| @@ -1,16 +1,14 @@ | |||
| import { yupResolver } from "@hookform/resolvers/yup"; | |||
| import { Box, Button, Stack, Typography } from "@mui/material"; | |||
| import { HasChildren } from "@types"; | |||
| import { | |||
| uploadOtherLicenseImages, | |||
| uploadStudentLicenseImages, | |||
| } from "api/season-ticket-contract"; | |||
| import { uploadOtherLicenseImages } from "api/season-ticket-contract"; | |||
| import RequireChip from "components/chip/RequireChip"; | |||
| import { FormProvider } from "components/hook-form"; | |||
| import RHFDatePicker from "components/hook-form/RHFDatePicker"; | |||
| import { RHFUpload } from "components/hook-form/RHFUpload"; | |||
| import StackRow from "components/stack/StackRow"; | |||
| import { useSeasonTicketContractContext } from "contexts/dashboard/SeasonTicketContractContext"; | |||
| import useAPICall from "hooks/useAPICall"; | |||
| import useAuth from "hooks/useAuth"; | |||
| import useDashboard from "hooks/useDashBoard"; | |||
| import useNavigateCustom from "hooks/useNavigateCustom"; | |||
| import useSnackbarCustom from "hooks/useSnackbarCustom"; | |||
| @@ -18,6 +16,8 @@ import { PageID, TabID } from "pages"; | |||
| import { useEffect, useMemo, useState } from "react"; | |||
| import { useForm } from "react-hook-form"; | |||
| import { getPath } from "routes/path"; | |||
| import { formatDateStr } from "utils/datetime"; | |||
| import { date, object } from "yup"; | |||
| type AreaBoxProps = { | |||
| label: string; | |||
| @@ -39,6 +39,7 @@ type FormProps = { | |||
| file1: File[]; | |||
| file2: File[]; | |||
| file3: File[]; | |||
| expires_at: Date | null; | |||
| }; | |||
| export default function OtherLicenseImagesUpload() { | |||
| @@ -47,8 +48,8 @@ export default function OtherLicenseImagesUpload() { | |||
| TabID.NONE | |||
| ); | |||
| const { navigateWhenChanged, navigate } = useNavigateCustom(); | |||
| const { selectedseasonTicketContract, initialized, backToDetailHome } = | |||
| const { navigateWhenChanged } = useNavigateCustom(); | |||
| const { selectedseasonTicketContract, initialized, backToDetailHome, fetch } = | |||
| useSeasonTicketContractContext(); | |||
| const [done, setDone] = useState(false); | |||
| @@ -59,7 +60,13 @@ export default function OtherLicenseImagesUpload() { | |||
| file1: [], | |||
| file2: [], | |||
| file3: [], | |||
| expires_at: null, | |||
| }, | |||
| resolver: yupResolver( | |||
| object().shape({ | |||
| expires_at: date().required("入力してください"), | |||
| }) | |||
| ), | |||
| }); | |||
| const { callAPI: callUploadOtherLicenseImages } = useAPICall({ | |||
| @@ -67,6 +74,7 @@ export default function OtherLicenseImagesUpload() { | |||
| backDrop: true, | |||
| onSuccess: () => { | |||
| setDone(true); | |||
| fetch(); | |||
| }, | |||
| onFailed: () => { | |||
| error("失敗しました"); | |||
| @@ -88,6 +96,7 @@ export default function OtherLicenseImagesUpload() { | |||
| images: files, | |||
| season_ticket_contract_record_no: | |||
| selectedseasonTicketContract.season_ticekt_contract_record_no ?? "", | |||
| expires_at: formatDateStr(data.expires_at), | |||
| }); | |||
| }; | |||
| @@ -160,6 +169,9 @@ export default function OtherLicenseImagesUpload() { | |||
| <RHFUpload name="file3" /> | |||
| </AreaBox> | |||
| )} | |||
| <AreaBox label="有効期限"> | |||
| <RHFDatePicker name="expires_at" size="small" /> | |||
| </AreaBox> | |||
| <Box> | |||
| <Button type="submit" variant="contained" disabled={!canSend}> | |||
| 送信 | |||
| @@ -1,8 +1,10 @@ | |||
| import { yupResolver } from "@hookform/resolvers/yup"; | |||
| import { Box, Button, Stack, Typography } from "@mui/material"; | |||
| import { HasChildren } from "@types"; | |||
| import { uploadStudentLicenseImages } from "api/season-ticket-contract"; | |||
| import RequireChip from "components/chip/RequireChip"; | |||
| import { FormProvider } from "components/hook-form"; | |||
| import RHFDatePicker from "components/hook-form/RHFDatePicker"; | |||
| import { RHFUpload } from "components/hook-form/RHFUpload"; | |||
| import StackRow from "components/stack/StackRow"; | |||
| import { useSeasonTicketContractContext } from "contexts/dashboard/SeasonTicketContractContext"; | |||
| @@ -15,6 +17,8 @@ import { PageID, TabID } from "pages"; | |||
| import { useEffect, useMemo, useState } from "react"; | |||
| import { useForm } from "react-hook-form"; | |||
| import { getPath } from "routes/path"; | |||
| import { formatDateStr } from "utils/datetime"; | |||
| import { date, object } from "yup"; | |||
| type AreaBoxProps = { | |||
| label: string; | |||
| @@ -36,6 +40,7 @@ type FormProps = { | |||
| file1: File[]; | |||
| file2: File[]; | |||
| file3: File[]; | |||
| expires_at: Date | null; | |||
| }; | |||
| export default function StudentLicenseImagesUpload() { | |||
| @@ -44,8 +49,8 @@ export default function StudentLicenseImagesUpload() { | |||
| TabID.NONE | |||
| ); | |||
| const { navigateWhenChanged, navigate } = useNavigateCustom(); | |||
| const { selectedseasonTicketContract, initialized, backToDetailHome } = | |||
| const { navigateWhenChanged } = useNavigateCustom(); | |||
| const { selectedseasonTicketContract, initialized, backToDetailHome, fetch } = | |||
| useSeasonTicketContractContext(); | |||
| const [done, setDone] = useState(false); | |||
| @@ -56,14 +61,22 @@ export default function StudentLicenseImagesUpload() { | |||
| file1: [], | |||
| file2: [], | |||
| file3: [], | |||
| expires_at: null, | |||
| }, | |||
| resolver: yupResolver( | |||
| object().shape({ | |||
| expires_at: date().required("入力してください"), | |||
| }) | |||
| ), | |||
| }); | |||
| const { callAPI: callUploadStudentLicenseImages } = useAPICall({ | |||
| apiMethod: uploadStudentLicenseImages, | |||
| backDrop: true, | |||
| form, | |||
| onSuccess: () => { | |||
| setDone(true); | |||
| fetch(); | |||
| }, | |||
| onFailed: () => { | |||
| error("失敗しました"); | |||
| @@ -85,6 +98,7 @@ export default function StudentLicenseImagesUpload() { | |||
| images: files, | |||
| season_ticket_contract_record_no: | |||
| selectedseasonTicketContract.season_ticekt_contract_record_no ?? "", | |||
| expires_at: formatDateStr(data.expires_at), | |||
| }); | |||
| }; | |||
| @@ -157,6 +171,9 @@ export default function StudentLicenseImagesUpload() { | |||
| <RHFUpload name="file3" /> | |||
| </AreaBox> | |||
| )} | |||
| <AreaBox label="有効期限"> | |||
| <RHFDatePicker name="expires_at" size="small" /> | |||
| </AreaBox> | |||
| <Box> | |||
| <Button type="submit" variant="contained" disabled={!canSend}> | |||
| 送信 | |||