diff --git a/src/api/contract.ts b/src/api/contract.ts
index 1e363ef..76cfb81 100644
--- a/src/api/contract.ts
+++ b/src/api/contract.ts
@@ -1,4 +1,4 @@
-import { APICommonResponse, ApiId, HttpMethod, request } from ".";
+import { APICommonResponse, ApiId, HttpMethod, makeParam, request } from ".";
import { getUrl } from "./url";
export type Contract = {
@@ -27,3 +27,18 @@ export const getContracts = async (data: ContractsRequest) => {
});
return res;
};
+
+// 契約新規登録 -----------------------
+export type ContractCreateRequest = {
+ name: string;
+ custom?: string;
+};
+
+export const createContract = async (data: ContractCreateRequest) => {
+ const res = await request({
+ url: getUrl(ApiId.CONTRACT_CREATE),
+ method: HttpMethod.POST,
+ data: makeParam(data),
+ });
+ return res;
+};
diff --git a/src/api/index.ts b/src/api/index.ts
index 94e6fb8..8c7faa5 100644
--- a/src/api/index.ts
+++ b/src/api/index.ts
@@ -32,6 +32,7 @@ export const ApiId = {
DOWNLOAD_RECEIPT_LETTER: id++,
CONTRACTS: id++,
+ CONTRACT_CREATE: id++,
USE_SUMMARY_YYYYMM: id++,
diff --git a/src/api/url.ts b/src/api/url.ts
index ad5d89d..cb3bfd1 100644
--- a/src/api/url.ts
+++ b/src/api/url.ts
@@ -23,6 +23,7 @@ const urls = {
[A.RECEIPT_ISSUING_ORDERS]: "receipt-issuing-orders",
[A.CONTRACTS]: "contracts",
+ [A.CONTRACT_CREATE]: "contract/create",
[A.USE_SUMMARY_YYYYMM]: "use-summary/yyyymm",
diff --git a/src/pages/dashboard/contract/create.tsx b/src/pages/dashboard/contract/create.tsx
index caea8a2..7e161cc 100644
--- a/src/pages/dashboard/contract/create.tsx
+++ b/src/pages/dashboard/contract/create.tsx
@@ -1,7 +1,42 @@
-import { Box } from "@mui/material";
+import {
+ Box,
+ Button,
+ Stack,
+ Step,
+ StepLabel,
+ Stepper,
+ Table,
+ TableBody,
+ TableCell,
+ TableRow,
+ Typography,
+} from "@mui/material";
+import { HasChildren } from "@types";
+import { createContract } from "api/contract";
import { PageID, TabID } from "codes/page";
+import { FormProvider, RHFTextField } from "components/hook-form";
+import useAPICall from "hooks/useAPICall";
import useDashboard from "hooks/useDashBoard";
-import { useEffect } from "react";
+import useSnackbarCustom from "hooks/useSnackbarCustom";
+import { useEffect, useMemo, useState } from "react";
+import { useForm } from "react-hook-form";
+
+type AreaBoxProps = {
+ title: string;
+} & HasChildren;
+function AreaBox({ title, children }: AreaBoxProps) {
+ return (
+
+ {title}
+ {children}
+
+ );
+}
+
+type FormProps = {
+ name: string;
+ custom: string;
+};
export default function ContractCreate() {
const { setHeaderTitle, setTabs } = useDashboard(
@@ -9,9 +44,116 @@ export default function ContractCreate() {
TabID.NONE
);
+ const { success, error } = useSnackbarCustom();
+
+ const [mode, setMode] = useState<"input" | "confirm" | "done">("input");
+
+ const step = useMemo(() => {
+ if (mode === "input") return 0;
+ if (mode === "confirm") return 1;
+ if (mode === "done") return 2;
+ return 0;
+ }, [mode]);
+
+ const form = useForm({
+ defaultValues: {
+ name: "",
+ custom: "",
+ },
+ });
+
+ const { callAPI } = useAPICall({
+ apiMethod: createContract,
+ backDrop: true,
+ onSuccess: () => {
+ success("登録しました");
+ setMode("done");
+ },
+ onFailed: () => {
+ error("失敗しました");
+ },
+ });
+
+ const handleSubmit = () => {
+ callAPI({
+ ...form.getValues(),
+ });
+ };
+
useEffect(() => {
setHeaderTitle("契約者作成");
setTabs(null);
}, []);
- return 契約者作成;
+ return (
+
+
+
+ 契約者情報入力
+
+
+ 確認
+
+
+ 完了
+
+
+ {mode === "input" && (
+ <>
+ {
+ setMode("confirm");
+ })}
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )}
+ {mode === "confirm" && (
+ <>
+
+ 登録内容確認
+
+
+
+ 契約者名
+ {form.getValues("name")}
+
+
+ カスタム識別子
+ {form.getValues("custom")}
+
+
+
+
+
+
+
+
+ >
+ )}
+ {mode === "done" && 登録しました。}
+
+ );
}