diff --git a/src/api/auth.ts b/src/api/auth.ts
index 49d9628..deec527 100644
--- a/src/api/auth.ts
+++ b/src/api/auth.ts
@@ -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 = {
diff --git a/src/api/customer.ts b/src/api/customer.ts
index a6b87d5..6b987a5 100644
--- a/src/api/customer.ts
+++ b/src/api/customer.ts
@@ -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;
diff --git a/src/api/season-ticket-contract.ts b/src/api/season-ticket-contract.ts
index def2f53..65501c9 100644
--- a/src/api/season-ticket-contract.ts
+++ b/src/api/season-ticket-contract.ts
@@ -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;
+};
diff --git a/src/pages/common/Page404.tsx b/src/pages/common/Page404.tsx
index bda62cd..8b33b68 100644
--- a/src/pages/common/Page404.tsx
+++ b/src/pages/common/Page404.tsx
@@ -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;
}
diff --git a/src/pages/dashboard/contract/detail.tsx b/src/pages/dashboard/contract/detail.tsx
index a038d7f..1c33598 100644
--- a/src/pages/dashboard/contract/detail.tsx
+++ b/src/pages/dashboard/contract/detail.tsx
@@ -198,6 +198,30 @@ export default function ContractDetail() {
+
+
+
+
+
+
diff --git a/src/pages/dashboard/user/upload-other-license-images.tsx b/src/pages/dashboard/contract/upload-other-license-images.tsx
similarity index 65%
rename from src/pages/dashboard/user/upload-other-license-images.tsx
rename to src/pages/dashboard/contract/upload-other-license-images.tsx
index 6be39c0..25b5732 100644
--- a/src/pages/dashboard/user/upload-other-license-images.tsx
+++ b/src/pages/dashboard/contract/upload-other-license-images.tsx
@@ -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 アップロードしました;
+ return (
+
+ アップロードしました
+
+
+
+
+ );
}
return (
+
+
+
- {user?.other_license_images_upload_datetime ?? "-"}
+ {selectedseasonTicketContract.student_license_images_upload_datetime ??
+ "-"}
@@ -123,7 +173,7 @@ export default function OtherLicenseImagesUpload() {
)}
-
diff --git a/src/pages/dashboard/user/upload-student-license-images.tsx b/src/pages/dashboard/contract/upload-student-license-images.tsx
similarity index 64%
rename from src/pages/dashboard/user/upload-student-license-images.tsx
rename to src/pages/dashboard/contract/upload-student-license-images.tsx
index 48e4e68..31fb670 100644
--- a/src/pages/dashboard/user/upload-student-license-images.tsx
+++ b/src/pages/dashboard/contract/upload-student-license-images.tsx
@@ -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 アップロードしました;
+ return (
+
+ アップロードしました
+
+ {
+ navigate(-1);
+ }}
+ >
+ 戻る
+
+
+
+ );
}
return (
+
+ {
+ navigate(-1);
+ }}
+ >
+ 戻る
+
+
- {user?.student_license_images_upload_datetime ?? "-"}
+ {selectedseasonTicketContract.student_license_images_upload_datetime ??
+ "-"}
@@ -120,7 +170,7 @@ export default function StudentLicenseImagesUpload() {
)}
-
+
送信
diff --git a/src/pages/dashboard/user/detail.tsx b/src/pages/dashboard/user/detail.tsx
index cfbf417..43286fa 100644
--- a/src/pages/dashboard/user/detail.tsx
+++ b/src/pages/dashboard/user/detail.tsx
@@ -31,24 +31,6 @@ export default function UserDetail() {
Email変更
口座情報変更
- {
- navigateWhenChanged(
- getPath(PageID.DASHBOARD_USER_STUDENT_LICENSE_IMAGES_UPLOAD)
- );
- }}
- >
- 学生証アップロード
-
- {
- navigateWhenChanged(
- getPath(PageID.DASHBOARD_USER_OTHER_LICENSE_IMAGES_UPLOAD)
- );
- }}
- >
- 障害者手帳アップロード
-
);
}
diff --git a/src/routes/path.ts b/src/routes/path.ts
index 3fe4647..230bc36 100644
--- a/src/routes/path.ts
+++ b/src/routes/path.ts
@@ -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",
diff --git a/src/routes/sub/dashboard.tsx b/src/routes/sub/dashboard.tsx
index d09a66d..ef01196 100644
--- a/src/routes/sub/dashboard.tsx
+++ b/src/routes/sub/dashboard.tsx
@@ -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: ,
},
- {
- pageId: PageID.DASHBOARD_USER_STUDENT_LICENSE_IMAGES_UPLOAD,
- element: ,
- },
- {
- pageId: PageID.DASHBOARD_USER_OTHER_LICENSE_IMAGES_UPLOAD,
- element: ,
- },
+
{
pageId: PageID.DASHBOARD_ASK,
element: ,
@@ -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: ,
},
+ {
+ pageId: PageID.DASHBOARD_USER_STUDENT_LICENSE_IMAGES_UPLOAD,
+ element: ,
+ },
+ {
+ pageId: PageID.DASHBOARD_USER_OTHER_LICENSE_IMAGES_UPLOAD,
+ element: ,
+ },
];
return allChildren.map(({ pageId, ...others }) => ({
...others,