| @@ -4,8 +4,6 @@ import { getUrl } from "./url"; | |||
| export type Me = { | |||
| customer_name: string; | |||
| email: string; | |||
| student_license_images_upload_datetime: string | null; | |||
| other_license_images_upload_datetime: string | null; | |||
| }; | |||
| type MeResponse = { | |||
| @@ -1,40 +1,6 @@ | |||
| import { ApiId, HttpMethod, makeFormData, makeParam, request } from "api"; | |||
| import { getUrl } from "./url"; | |||
| // -------学生証アップロード--------------- | |||
| export type UploadStudentLicenseImagesRequest = { | |||
| images: File[]; | |||
| }; | |||
| export const uploadStudentLicenseImages = async ( | |||
| param: UploadStudentLicenseImagesRequest | |||
| ) => { | |||
| const sendData = makeFormData(param); | |||
| const res = await request({ | |||
| url: getUrl(ApiId.UPLOAD_STUDENT_LICENSE_IMAGES), | |||
| method: HttpMethod.POST, | |||
| data: sendData, | |||
| multipart: true, | |||
| }); | |||
| return res; | |||
| }; | |||
| // -------その他証明証アップロード--------------- | |||
| export type OtherLicenseImagesRequest = { | |||
| images: File[]; | |||
| }; | |||
| export const uploadOtherLicenseImages = async ( | |||
| param: OtherLicenseImagesRequest | |||
| ) => { | |||
| const sendData = makeFormData(param); | |||
| const res = await request({ | |||
| url: getUrl(ApiId.UPLOAD_OTHER_LICENSE_IMAGES), | |||
| method: HttpMethod.POST, | |||
| data: sendData, | |||
| multipart: true, | |||
| }); | |||
| return res; | |||
| }; | |||
| // -------Email変更手続き開始--------------- | |||
| export type StartChangeEmailRequest = { | |||
| new_email: string; | |||
| @@ -1,4 +1,11 @@ | |||
| import { APICommonResponse, ApiId, HttpMethod, makeParam, request } from "api"; | |||
| import { | |||
| APICommonResponse, | |||
| ApiId, | |||
| HttpMethod, | |||
| makeFormData, | |||
| makeParam, | |||
| request, | |||
| } from "api"; | |||
| import { getUrl } from "./url"; | |||
| export type SeasonTicketContract = { | |||
| @@ -11,6 +18,8 @@ export type SeasonTicketContract = { | |||
| contract_start_date: string | null; | |||
| contract_end_date: string | null; | |||
| contract_amount: number; | |||
| student_license_images_upload_datetime: string | null; | |||
| other_license_images_upload_datetime: string | null; | |||
| revision: number; | |||
| }; | |||
| @@ -137,3 +146,39 @@ export const orderUpdateVehicleInfo = async ( | |||
| }); | |||
| return res; | |||
| }; | |||
| // -------学生証アップロード--------------- | |||
| export type UploadStudentLicenseImagesRequest = { | |||
| images: File[]; | |||
| season_ticket_contract_record_no: string; | |||
| }; | |||
| export const uploadStudentLicenseImages = async ( | |||
| param: UploadStudentLicenseImagesRequest | |||
| ) => { | |||
| const sendData = makeFormData(param); | |||
| const res = await request({ | |||
| url: getUrl(ApiId.UPLOAD_STUDENT_LICENSE_IMAGES), | |||
| method: HttpMethod.POST, | |||
| data: sendData, | |||
| multipart: true, | |||
| }); | |||
| return res; | |||
| }; | |||
| // -------その他証明証アップロード--------------- | |||
| export type OtherLicenseImagesRequest = { | |||
| images: File[]; | |||
| season_ticket_contract_record_no: string; | |||
| }; | |||
| export const uploadOtherLicenseImages = async ( | |||
| param: OtherLicenseImagesRequest | |||
| ) => { | |||
| const sendData = makeFormData(param); | |||
| const res = await request({ | |||
| url: getUrl(ApiId.UPLOAD_OTHER_LICENSE_IMAGES), | |||
| method: HttpMethod.POST, | |||
| data: sendData, | |||
| multipart: true, | |||
| }); | |||
| return res; | |||
| }; | |||
| @@ -4,19 +4,21 @@ import useAuth from "hooks/useAuth"; | |||
| import useNavigateCustom from "hooks/useNavigateCustom"; | |||
| import { useEffect } from "react"; | |||
| import { getPath } from "routes/path"; | |||
| import { useLocation } from "react-router-dom"; | |||
| export default function Page404() { | |||
| const { navigateWhenChanged } = useNavigateCustom(); | |||
| const { pathname } = useLocation(); | |||
| const { authenticated, initialized } = useAuth(); | |||
| useEffect(() => { | |||
| if (!initialized) return; | |||
| if (authenticated) { | |||
| console.log("404 to dashboard"); | |||
| console.log(pathname, "404 to dashboard"); | |||
| navigateWhenChanged(getPath(PageID.DASHBOARD_OVERVIEW)); | |||
| return; | |||
| } else { | |||
| console.log("404 to login"); | |||
| console.log(pathname, "404 to login"); | |||
| navigateWhenChanged(getPath(PageID.LOGIN)); | |||
| return; | |||
| } | |||
| @@ -198,6 +198,30 @@ export default function ContractDetail() { | |||
| <Box> | |||
| <Button variant="contained">車両情報変更申請</Button> | |||
| </Box> | |||
| <Box> | |||
| <Button | |||
| variant="contained" | |||
| onClick={() => { | |||
| navigateWhenChanged( | |||
| getPath(PageID.DASHBOARD_USER_STUDENT_LICENSE_IMAGES_UPLOAD) | |||
| ); | |||
| }} | |||
| > | |||
| 学生証画像アップロード | |||
| </Button> | |||
| </Box> | |||
| <Box> | |||
| <Button | |||
| variant="contained" | |||
| onClick={() => { | |||
| navigateWhenChanged( | |||
| getPath(PageID.DASHBOARD_USER_OTHER_LICENSE_IMAGES_UPLOAD) | |||
| ); | |||
| }} | |||
| > | |||
| 障がい者手帳画像アップロード | |||
| </Button> | |||
| </Box> | |||
| </Stack> | |||
| </Paper> | |||
| </Stack> | |||
| @@ -3,18 +3,21 @@ import { HasChildren } from "@types"; | |||
| import { | |||
| uploadOtherLicenseImages, | |||
| uploadStudentLicenseImages, | |||
| } from "api/customer"; | |||
| } from "api/season-ticket-contract"; | |||
| import RequireChip from "components/chip/RequireChip"; | |||
| import { FormProvider } from "components/hook-form"; | |||
| 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"; | |||
| import { PageID, TabID } from "pages"; | |||
| import { useEffect, useState } from "react"; | |||
| import { useEffect, useMemo, useState } from "react"; | |||
| import { useForm } from "react-hook-form"; | |||
| import { getPath } from "routes/path"; | |||
| type AreaBoxProps = { | |||
| label: string; | |||
| @@ -44,7 +47,9 @@ export default function OtherLicenseImagesUpload() { | |||
| TabID.NONE | |||
| ); | |||
| const { user } = useAuth(); | |||
| const { navigateWhenChanged, navigate } = useNavigateCustom(); | |||
| const { selectedseasonTicketContract, initialized } = | |||
| useSeasonTicketContractContext(); | |||
| const [done, setDone] = useState(false); | |||
| const { error } = useSnackbarCustom(); | |||
| @@ -72,9 +77,18 @@ export default function OtherLicenseImagesUpload() { | |||
| const file2 = form.watch("file2"); | |||
| const file3 = form.watch("file3"); | |||
| const canSend = useMemo(() => { | |||
| return file1.length !== 0; | |||
| }, [file1]); | |||
| const handleSubmit = (data: FormProps) => { | |||
| if (!selectedseasonTicketContract) return; | |||
| const files = [...file1, ...file2, ...file3]; | |||
| callUploadOtherLicenseImages({ images: files }); | |||
| callUploadOtherLicenseImages({ | |||
| images: files, | |||
| season_ticket_contract_record_no: | |||
| selectedseasonTicketContract.season_ticekt_contract_record_no ?? "", | |||
| }); | |||
| }; | |||
| useEffect(() => { | |||
| @@ -93,20 +107,56 @@ export default function OtherLicenseImagesUpload() { | |||
| } | |||
| }, [file1, file2, file3]); | |||
| useEffect(() => { | |||
| if (initialized && !selectedseasonTicketContract) { | |||
| navigateWhenChanged( | |||
| getPath(PageID.DASHBOARD_SEASON_TICKET_CONTRACT_LIST) | |||
| ); | |||
| } | |||
| }, [initialized, selectedseasonTicketContract]); | |||
| useEffect(() => { | |||
| setHeaderTitle("障害者手帳アップロード"); | |||
| setTabs(null); | |||
| }, []); | |||
| if (!selectedseasonTicketContract) { | |||
| return null; | |||
| } | |||
| if (done) { | |||
| return <Box>アップロードしました</Box>; | |||
| return ( | |||
| <Stack spacing={2}> | |||
| <Box>アップロードしました</Box> | |||
| <Box> | |||
| <Button | |||
| onClick={() => { | |||
| navigate(-1); | |||
| }} | |||
| > | |||
| 戻る | |||
| </Button> | |||
| </Box> | |||
| </Stack> | |||
| ); | |||
| } | |||
| return ( | |||
| <FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}> | |||
| <Stack spacing={2}> | |||
| <Box> | |||
| <Button | |||
| onClick={() => { | |||
| navigate(-1); | |||
| }} | |||
| > | |||
| 戻る | |||
| </Button> | |||
| </Box> | |||
| <AreaBox label="前回アップロード日時"> | |||
| <Typography> | |||
| {user?.other_license_images_upload_datetime ?? "-"} | |||
| {selectedseasonTicketContract.student_license_images_upload_datetime ?? | |||
| "-"} | |||
| </Typography> | |||
| </AreaBox> | |||
| <AreaBox label="1枚目"> | |||
| @@ -123,7 +173,7 @@ export default function OtherLicenseImagesUpload() { | |||
| </AreaBox> | |||
| )} | |||
| <Box> | |||
| <Button type="submit" variant="contained"> | |||
| <Button type="submit" variant="contained" disabled={!canSend}> | |||
| 送信 | |||
| </Button> | |||
| </Box> | |||
| @@ -1,17 +1,20 @@ | |||
| import { Box, Button, Stack, Typography } from "@mui/material"; | |||
| import { HasChildren } from "@types"; | |||
| import { uploadStudentLicenseImages } from "api/customer"; | |||
| import { uploadStudentLicenseImages } from "api/season-ticket-contract"; | |||
| import RequireChip from "components/chip/RequireChip"; | |||
| import { FormProvider } from "components/hook-form"; | |||
| 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"; | |||
| import { PageID, TabID } from "pages"; | |||
| import { useEffect, useState } from "react"; | |||
| import { useEffect, useMemo, useState } from "react"; | |||
| import { useForm } from "react-hook-form"; | |||
| import { getPath } from "routes/path"; | |||
| type AreaBoxProps = { | |||
| label: string; | |||
| @@ -41,7 +44,9 @@ export default function StudentLicenseImagesUpload() { | |||
| TabID.NONE | |||
| ); | |||
| const { user } = useAuth(); | |||
| const { navigateWhenChanged, navigate } = useNavigateCustom(); | |||
| const { selectedseasonTicketContract, initialized } = | |||
| useSeasonTicketContractContext(); | |||
| const [done, setDone] = useState(false); | |||
| const { error } = useSnackbarCustom(); | |||
| @@ -69,9 +74,18 @@ export default function StudentLicenseImagesUpload() { | |||
| const file2 = form.watch("file2"); | |||
| const file3 = form.watch("file3"); | |||
| const canSend = useMemo(() => { | |||
| return file1.length !== 0; | |||
| }, [file1]); | |||
| const handleSubmit = (data: FormProps) => { | |||
| if (!selectedseasonTicketContract) return; | |||
| const files = [...file1, ...file2, ...file3]; | |||
| callUploadStudentLicenseImages({ images: files }); | |||
| callUploadStudentLicenseImages({ | |||
| images: files, | |||
| season_ticket_contract_record_no: | |||
| selectedseasonTicketContract.season_ticekt_contract_record_no ?? "", | |||
| }); | |||
| }; | |||
| useEffect(() => { | |||
| @@ -90,20 +104,56 @@ export default function StudentLicenseImagesUpload() { | |||
| } | |||
| }, [file1, file2, file3]); | |||
| useEffect(() => { | |||
| if (initialized && !selectedseasonTicketContract) { | |||
| navigateWhenChanged( | |||
| getPath(PageID.DASHBOARD_SEASON_TICKET_CONTRACT_LIST) | |||
| ); | |||
| } | |||
| }, [initialized, selectedseasonTicketContract]); | |||
| useEffect(() => { | |||
| setHeaderTitle("学生証画像アップロード"); | |||
| setTabs(null); | |||
| }, []); | |||
| if (!selectedseasonTicketContract) { | |||
| return null; | |||
| } | |||
| if (done) { | |||
| return <Box>アップロードしました</Box>; | |||
| return ( | |||
| <Stack spacing={2}> | |||
| <Box>アップロードしました</Box> | |||
| <Box> | |||
| <Button | |||
| onClick={() => { | |||
| navigate(-1); | |||
| }} | |||
| > | |||
| 戻る | |||
| </Button> | |||
| </Box> | |||
| </Stack> | |||
| ); | |||
| } | |||
| return ( | |||
| <FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}> | |||
| <Stack spacing={2}> | |||
| <Box> | |||
| <Button | |||
| onClick={() => { | |||
| navigate(-1); | |||
| }} | |||
| > | |||
| 戻る | |||
| </Button> | |||
| </Box> | |||
| <AreaBox label="前回アップロード日時"> | |||
| <Typography> | |||
| {user?.student_license_images_upload_datetime ?? "-"} | |||
| {selectedseasonTicketContract.student_license_images_upload_datetime ?? | |||
| "-"} | |||
| </Typography> | |||
| </AreaBox> | |||
| <AreaBox label="1枚目"> | |||
| @@ -120,7 +170,7 @@ export default function StudentLicenseImagesUpload() { | |||
| </AreaBox> | |||
| )} | |||
| <Box> | |||
| <Button type="submit" variant="contained"> | |||
| <Button type="submit" variant="contained" disabled={!canSend}> | |||
| 送信 | |||
| </Button> | |||
| </Box> | |||
| @@ -31,24 +31,6 @@ export default function UserDetail() { | |||
| Email変更 | |||
| </Button> | |||
| <Button>口座情報変更</Button> | |||
| <Button | |||
| onClick={() => { | |||
| navigateWhenChanged( | |||
| getPath(PageID.DASHBOARD_USER_STUDENT_LICENSE_IMAGES_UPLOAD) | |||
| ); | |||
| }} | |||
| > | |||
| 学生証アップロード | |||
| </Button> | |||
| <Button | |||
| onClick={() => { | |||
| navigateWhenChanged( | |||
| getPath(PageID.DASHBOARD_USER_OTHER_LICENSE_IMAGES_UPLOAD) | |||
| ); | |||
| }} | |||
| > | |||
| 障害者手帳アップロード | |||
| </Button> | |||
| </Stack> | |||
| ); | |||
| } | |||
| @@ -47,13 +47,13 @@ const PATHS_DASHBOARD = { | |||
| [makePathKey( | |||
| PageID.DASHBOARD_SEASON_TICKET_CONTRACT_UPDATE_VEHICLE_INFO_ORDER | |||
| )]: "/dashboard/contract/update-vehicle-info-order", | |||
| [makePathKey(PageID.DASHBOARD_USER_STUDENT_LICENSE_IMAGES_UPLOAD)]: | |||
| "/dashboard/contract/upload/student-license", | |||
| [makePathKey(PageID.DASHBOARD_USER_OTHER_LICENSE_IMAGES_UPLOAD)]: | |||
| "/dashboard/contract/upload/other-license", | |||
| [makePathKey(PageID.DASHBOARD_RECEIPT_DOWNLOAD)]: | |||
| "/dashboard/receipt/download", | |||
| [makePathKey(PageID.DASHBOARD_USER_DETAIL)]: "/dashboard/user/detail", | |||
| [makePathKey(PageID.DASHBOARD_USER_STUDENT_LICENSE_IMAGES_UPLOAD)]: | |||
| "/dashboard/user/upload/student-license", | |||
| [makePathKey(PageID.DASHBOARD_USER_OTHER_LICENSE_IMAGES_UPLOAD)]: | |||
| "/dashboard/user/upload/other-license", | |||
| [makePathKey(PageID.DASHBOARD_ASK)]: "/dashboard/ask", | |||
| [makePathKey(PageID.DASHBOARD_USER_CHANGE_EMAIL_START)]: | |||
| "/dashboard/change/email/start", | |||
| @@ -23,12 +23,7 @@ export default function DashboardRoutes(): RouteObject[] { | |||
| const UserDetail = Loadable( | |||
| lazy(() => import("pages/dashboard/user/detail")) | |||
| ); | |||
| const StudentLicenseImagesUpload = Loadable( | |||
| lazy(() => import("pages/dashboard/user/upload-student-license-images")) | |||
| ); | |||
| const OtherLicenseImagesUpload = Loadable( | |||
| lazy(() => import("pages/dashboard/user/upload-other-license-images")) | |||
| ); | |||
| const Ask = Loadable(lazy(() => import("pages/dashboard/other/ask"))); | |||
| const ChangeEmailStart = Loadable( | |||
| lazy(() => import("pages/dashboard/user/change-email-start")) | |||
| @@ -51,14 +46,7 @@ export default function DashboardRoutes(): RouteObject[] { | |||
| pageId: PageID.DASHBOARD_USER_DETAIL, | |||
| element: <UserDetail />, | |||
| }, | |||
| { | |||
| pageId: PageID.DASHBOARD_USER_STUDENT_LICENSE_IMAGES_UPLOAD, | |||
| element: <StudentLicenseImagesUpload />, | |||
| }, | |||
| { | |||
| pageId: PageID.DASHBOARD_USER_OTHER_LICENSE_IMAGES_UPLOAD, | |||
| element: <OtherLicenseImagesUpload />, | |||
| }, | |||
| { | |||
| pageId: PageID.DASHBOARD_ASK, | |||
| element: <Ask />, | |||
| @@ -89,6 +77,14 @@ export default function DashboardRoutes(): RouteObject[] { | |||
| const TerminateOrder = Loadable( | |||
| lazy(() => import("pages/dashboard/contract/terminate-order")) | |||
| ); | |||
| const StudentLicenseImagesUpload = Loadable( | |||
| lazy( | |||
| () => import("pages/dashboard/contract/upload-student-license-images") | |||
| ) | |||
| ); | |||
| const OtherLicenseImagesUpload = Loadable( | |||
| lazy(() => import("pages/dashboard/contract/upload-other-license-images")) | |||
| ); | |||
| const allChildren = [ | |||
| { | |||
| @@ -107,6 +103,14 @@ export default function DashboardRoutes(): RouteObject[] { | |||
| pageId: PageID.DASHBOARD_SEASON_TICKET_CONTRACT_TERMINATE_ORDER, | |||
| element: <TerminateOrder />, | |||
| }, | |||
| { | |||
| pageId: PageID.DASHBOARD_USER_STUDENT_LICENSE_IMAGES_UPLOAD, | |||
| element: <StudentLicenseImagesUpload />, | |||
| }, | |||
| { | |||
| pageId: PageID.DASHBOARD_USER_OTHER_LICENSE_IMAGES_UPLOAD, | |||
| element: <OtherLicenseImagesUpload />, | |||
| }, | |||
| ]; | |||
| return allChildren.map(({ pageId, ...others }) => ({ | |||
| ...others, | |||