Browse Source

証明証画像の保存先変更対応

develop
sosuke.iwabuchi 2 years ago
parent
commit
88b91e55a2
10 changed files with 210 additions and 89 deletions
  1. +0
    -2
      src/api/auth.ts
  2. +0
    -34
      src/api/customer.ts
  3. +46
    -1
      src/api/season-ticket-contract.ts
  4. +4
    -2
      src/pages/common/Page404.tsx
  5. +24
    -0
      src/pages/dashboard/contract/detail.tsx
  6. +57
    -7
      src/pages/dashboard/contract/upload-other-license-images.tsx
  7. +57
    -7
      src/pages/dashboard/contract/upload-student-license-images.tsx
  8. +0
    -18
      src/pages/dashboard/user/detail.tsx
  9. +4
    -4
      src/routes/path.ts
  10. +18
    -14
      src/routes/sub/dashboard.tsx

+ 0
- 2
src/api/auth.ts View File

@@ -4,8 +4,6 @@ import { getUrl } from "./url";
export type Me = { export type Me = {
customer_name: string; customer_name: string;
email: string; email: string;
student_license_images_upload_datetime: string | null;
other_license_images_upload_datetime: string | null;
}; };


type MeResponse = { type MeResponse = {


+ 0
- 34
src/api/customer.ts View File

@@ -1,40 +1,6 @@
import { ApiId, HttpMethod, makeFormData, makeParam, request } from "api"; import { ApiId, HttpMethod, makeFormData, makeParam, request } from "api";
import { getUrl } from "./url"; 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変更手続き開始--------------- // -------Email変更手続き開始---------------
export type StartChangeEmailRequest = { export type StartChangeEmailRequest = {
new_email: string; new_email: string;


+ 46
- 1
src/api/season-ticket-contract.ts View File

@@ -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"; import { getUrl } from "./url";


export type SeasonTicketContract = { export type SeasonTicketContract = {
@@ -11,6 +18,8 @@ export type SeasonTicketContract = {
contract_start_date: string | null; contract_start_date: string | null;
contract_end_date: string | null; contract_end_date: string | null;
contract_amount: number; contract_amount: number;
student_license_images_upload_datetime: string | null;
other_license_images_upload_datetime: string | null;
revision: number; revision: number;
}; };


@@ -137,3 +146,39 @@ export const orderUpdateVehicleInfo = async (
}); });
return res; 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
- 2
src/pages/common/Page404.tsx View File

@@ -4,19 +4,21 @@ import useAuth from "hooks/useAuth";
import useNavigateCustom from "hooks/useNavigateCustom"; import useNavigateCustom from "hooks/useNavigateCustom";
import { useEffect } from "react"; import { useEffect } from "react";
import { getPath } from "routes/path"; import { getPath } from "routes/path";
import { useLocation } from "react-router-dom";


export default function Page404() { export default function Page404() {
const { navigateWhenChanged } = useNavigateCustom(); const { navigateWhenChanged } = useNavigateCustom();
const { pathname } = useLocation();
const { authenticated, initialized } = useAuth(); const { authenticated, initialized } = useAuth();


useEffect(() => { useEffect(() => {
if (!initialized) return; if (!initialized) return;
if (authenticated) { if (authenticated) {
console.log("404 to dashboard");
console.log(pathname, "404 to dashboard");
navigateWhenChanged(getPath(PageID.DASHBOARD_OVERVIEW)); navigateWhenChanged(getPath(PageID.DASHBOARD_OVERVIEW));
return; return;
} else { } else {
console.log("404 to login");
console.log(pathname, "404 to login");
navigateWhenChanged(getPath(PageID.LOGIN)); navigateWhenChanged(getPath(PageID.LOGIN));
return; return;
} }


+ 24
- 0
src/pages/dashboard/contract/detail.tsx View File

@@ -198,6 +198,30 @@ export default function ContractDetail() {
<Box> <Box>
<Button variant="contained">車両情報変更申請</Button> <Button variant="contained">車両情報変更申請</Button>
</Box> </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> </Stack>
</Paper> </Paper>
</Stack> </Stack>


src/pages/dashboard/user/upload-other-license-images.tsx → src/pages/dashboard/contract/upload-other-license-images.tsx View File

@@ -3,18 +3,21 @@ import { HasChildren } from "@types";
import { import {
uploadOtherLicenseImages, uploadOtherLicenseImages,
uploadStudentLicenseImages, uploadStudentLicenseImages,
} from "api/customer";
} 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 { 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 useAPICall from "hooks/useAPICall"; import useAPICall from "hooks/useAPICall";
import useAuth from "hooks/useAuth"; import useAuth from "hooks/useAuth";
import useDashboard from "hooks/useDashBoard"; import useDashboard from "hooks/useDashBoard";
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";


type AreaBoxProps = { type AreaBoxProps = {
label: string; label: string;
@@ -44,7 +47,9 @@ export default function OtherLicenseImagesUpload() {
TabID.NONE TabID.NONE
); );


const { user } = useAuth();
const { navigateWhenChanged, navigate } = useNavigateCustom();
const { selectedseasonTicketContract, initialized } =
useSeasonTicketContractContext();


const [done, setDone] = useState(false); const [done, setDone] = useState(false);
const { error } = useSnackbarCustom(); const { error } = useSnackbarCustom();
@@ -72,9 +77,18 @@ export default function OtherLicenseImagesUpload() {
const file2 = form.watch("file2"); const file2 = form.watch("file2");
const file3 = form.watch("file3"); const file3 = form.watch("file3");


const canSend = useMemo(() => {
return file1.length !== 0;
}, [file1]);

const handleSubmit = (data: FormProps) => { const handleSubmit = (data: FormProps) => {
if (!selectedseasonTicketContract) return;
const files = [...file1, ...file2, ...file3]; const files = [...file1, ...file2, ...file3];
callUploadOtherLicenseImages({ images: files });
callUploadOtherLicenseImages({
images: files,
season_ticket_contract_record_no:
selectedseasonTicketContract.season_ticekt_contract_record_no ?? "",
});
}; };


useEffect(() => { useEffect(() => {
@@ -93,20 +107,56 @@ export default function OtherLicenseImagesUpload() {
} }
}, [file1, file2, file3]); }, [file1, file2, file3]);


useEffect(() => {
if (initialized && !selectedseasonTicketContract) {
navigateWhenChanged(
getPath(PageID.DASHBOARD_SEASON_TICKET_CONTRACT_LIST)
);
}
}, [initialized, selectedseasonTicketContract]);

useEffect(() => { useEffect(() => {
setHeaderTitle("障害者手帳アップロード"); setHeaderTitle("障害者手帳アップロード");
setTabs(null); setTabs(null);
}, []); }, []);

if (!selectedseasonTicketContract) {
return null;
}

if (done) { if (done) {
return <Box>アップロードしました</Box>;
return (
<Stack spacing={2}>
<Box>アップロードしました</Box>
<Box>
<Button
onClick={() => {
navigate(-1);
}}
>
戻る
</Button>
</Box>
</Stack>
);
} }


return ( return (
<FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}> <FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}>
<Stack spacing={2}> <Stack spacing={2}>
<Box>
<Button
onClick={() => {
navigate(-1);
}}
>
戻る
</Button>
</Box>
<AreaBox label="前回アップロード日時"> <AreaBox label="前回アップロード日時">
<Typography> <Typography>
{user?.other_license_images_upload_datetime ?? "-"}
{selectedseasonTicketContract.student_license_images_upload_datetime ??
"-"}
</Typography> </Typography>
</AreaBox> </AreaBox>
<AreaBox label="1枚目"> <AreaBox label="1枚目">
@@ -123,7 +173,7 @@ export default function OtherLicenseImagesUpload() {
</AreaBox> </AreaBox>
)} )}
<Box> <Box>
<Button type="submit" variant="contained">
<Button type="submit" variant="contained" disabled={!canSend}>
送信 送信
</Button> </Button>
</Box> </Box>

src/pages/dashboard/user/upload-student-license-images.tsx → src/pages/dashboard/contract/upload-student-license-images.tsx View File

@@ -1,17 +1,20 @@
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/customer";
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 { 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 useAPICall from "hooks/useAPICall"; import useAPICall from "hooks/useAPICall";
import useAuth from "hooks/useAuth"; import useAuth from "hooks/useAuth";
import useDashboard from "hooks/useDashBoard"; import useDashboard from "hooks/useDashBoard";
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";


type AreaBoxProps = { type AreaBoxProps = {
label: string; label: string;
@@ -41,7 +44,9 @@ export default function StudentLicenseImagesUpload() {
TabID.NONE TabID.NONE
); );


const { user } = useAuth();
const { navigateWhenChanged, navigate } = useNavigateCustom();
const { selectedseasonTicketContract, initialized } =
useSeasonTicketContractContext();


const [done, setDone] = useState(false); const [done, setDone] = useState(false);
const { error } = useSnackbarCustom(); const { error } = useSnackbarCustom();
@@ -69,9 +74,18 @@ export default function StudentLicenseImagesUpload() {
const file2 = form.watch("file2"); const file2 = form.watch("file2");
const file3 = form.watch("file3"); const file3 = form.watch("file3");


const canSend = useMemo(() => {
return file1.length !== 0;
}, [file1]);

const handleSubmit = (data: FormProps) => { const handleSubmit = (data: FormProps) => {
if (!selectedseasonTicketContract) return;
const files = [...file1, ...file2, ...file3]; const files = [...file1, ...file2, ...file3];
callUploadStudentLicenseImages({ images: files });
callUploadStudentLicenseImages({
images: files,
season_ticket_contract_record_no:
selectedseasonTicketContract.season_ticekt_contract_record_no ?? "",
});
}; };


useEffect(() => { useEffect(() => {
@@ -90,20 +104,56 @@ export default function StudentLicenseImagesUpload() {
} }
}, [file1, file2, file3]); }, [file1, file2, file3]);


useEffect(() => {
if (initialized && !selectedseasonTicketContract) {
navigateWhenChanged(
getPath(PageID.DASHBOARD_SEASON_TICKET_CONTRACT_LIST)
);
}
}, [initialized, selectedseasonTicketContract]);

useEffect(() => { useEffect(() => {
setHeaderTitle("学生証画像アップロード"); setHeaderTitle("学生証画像アップロード");
setTabs(null); setTabs(null);
}, []); }, []);

if (!selectedseasonTicketContract) {
return null;
}

if (done) { if (done) {
return <Box>アップロードしました</Box>;
return (
<Stack spacing={2}>
<Box>アップロードしました</Box>
<Box>
<Button
onClick={() => {
navigate(-1);
}}
>
戻る
</Button>
</Box>
</Stack>
);
} }


return ( return (
<FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}> <FormProvider methods={form} onSubmit={form.handleSubmit(handleSubmit)}>
<Stack spacing={2}> <Stack spacing={2}>
<Box>
<Button
onClick={() => {
navigate(-1);
}}
>
戻る
</Button>
</Box>
<AreaBox label="前回アップロード日時"> <AreaBox label="前回アップロード日時">
<Typography> <Typography>
{user?.student_license_images_upload_datetime ?? "-"}
{selectedseasonTicketContract.student_license_images_upload_datetime ??
"-"}
</Typography> </Typography>
</AreaBox> </AreaBox>
<AreaBox label="1枚目"> <AreaBox label="1枚目">
@@ -120,7 +170,7 @@ export default function StudentLicenseImagesUpload() {
</AreaBox> </AreaBox>
)} )}
<Box> <Box>
<Button type="submit" variant="contained">
<Button type="submit" variant="contained" disabled={!canSend}>
送信 送信
</Button> </Button>
</Box> </Box>

+ 0
- 18
src/pages/dashboard/user/detail.tsx View File

@@ -31,24 +31,6 @@ export default function UserDetail() {
Email変更 Email変更
</Button> </Button>
<Button>口座情報変更</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> </Stack>
); );
} }

+ 4
- 4
src/routes/path.ts View File

@@ -47,13 +47,13 @@ const PATHS_DASHBOARD = {
[makePathKey( [makePathKey(
PageID.DASHBOARD_SEASON_TICKET_CONTRACT_UPDATE_VEHICLE_INFO_ORDER PageID.DASHBOARD_SEASON_TICKET_CONTRACT_UPDATE_VEHICLE_INFO_ORDER
)]: "/dashboard/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)]: [makePathKey(PageID.DASHBOARD_RECEIPT_DOWNLOAD)]:
"/dashboard/receipt/download", "/dashboard/receipt/download",
[makePathKey(PageID.DASHBOARD_USER_DETAIL)]: "/dashboard/user/detail", [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_ASK)]: "/dashboard/ask",
[makePathKey(PageID.DASHBOARD_USER_CHANGE_EMAIL_START)]: [makePathKey(PageID.DASHBOARD_USER_CHANGE_EMAIL_START)]:
"/dashboard/change/email/start", "/dashboard/change/email/start",


+ 18
- 14
src/routes/sub/dashboard.tsx View File

@@ -23,12 +23,7 @@ export default function DashboardRoutes(): RouteObject[] {
const UserDetail = Loadable( const UserDetail = Loadable(
lazy(() => import("pages/dashboard/user/detail")) 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 Ask = Loadable(lazy(() => import("pages/dashboard/other/ask")));
const ChangeEmailStart = Loadable( const ChangeEmailStart = Loadable(
lazy(() => import("pages/dashboard/user/change-email-start")) lazy(() => import("pages/dashboard/user/change-email-start"))
@@ -51,14 +46,7 @@ export default function DashboardRoutes(): RouteObject[] {
pageId: PageID.DASHBOARD_USER_DETAIL, pageId: PageID.DASHBOARD_USER_DETAIL,
element: <UserDetail />, 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, pageId: PageID.DASHBOARD_ASK,
element: <Ask />, element: <Ask />,
@@ -89,6 +77,14 @@ export default function DashboardRoutes(): RouteObject[] {
const TerminateOrder = Loadable( const TerminateOrder = Loadable(
lazy(() => import("pages/dashboard/contract/terminate-order")) 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 = [ const allChildren = [
{ {
@@ -107,6 +103,14 @@ export default function DashboardRoutes(): RouteObject[] {
pageId: PageID.DASHBOARD_SEASON_TICKET_CONTRACT_TERMINATE_ORDER, pageId: PageID.DASHBOARD_SEASON_TICKET_CONTRACT_TERMINATE_ORDER,
element: <TerminateOrder />, 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 }) => ({ return allChildren.map(({ pageId, ...others }) => ({
...others, ...others,


Loading…
Cancel
Save