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