From 6a591bd339efe9b9ae05063025bf66cedfaaec5a Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Fri, 8 Sep 2023 17:21:09 +0900 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=89=95=E7=8A=B6=E6=B3=81=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.ts | 1 + src/api/season-ticket-contract.ts | 30 +++++++++++++++- src/api/url.ts | 1 + src/pages/dashboard/contract/detail.tsx | 48 +++++++++++++++++-------- 4 files changed, 65 insertions(+), 15 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index d55b0ae..f08ad44 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -15,6 +15,7 @@ export const ApiId = { LOGOUT: id++, SEASON_TICKET_CONTRACTS: id++, + PAYMENT_PLANS: id++, } as const; export type ApiId = (typeof ApiId)[keyof typeof ApiId]; diff --git a/src/api/season-ticket-contract.ts b/src/api/season-ticket-contract.ts index 65336d0..8d43fea 100644 --- a/src/api/season-ticket-contract.ts +++ b/src/api/season-ticket-contract.ts @@ -1,4 +1,4 @@ -import { APICommonResponse, ApiId, HttpMethod, request } from "api"; +import { APICommonResponse, ApiId, HttpMethod, makeParam, request } from "api"; import { getUrl } from "./url"; export type SeasonTicketContract = { @@ -13,6 +13,16 @@ export type SeasonTicketContract = { revision: number; }; +export type PaymentPlan = { + season_ticket_contract_record_no: string | null; + payment_type: string | null; + payment_method: string | null; + payment_plan_date: string | null; + payment_status: string | null; + revision: number; +}; + +// -------定期契約情報一覧取得--------------- type SeasonTicketContractsResponse = { data: SeasonTicketContract[]; } & APICommonResponse; @@ -24,3 +34,21 @@ export const getSeasonTicketContracts = async () => { }); return res; }; + +// -------入金予定結果一覧取得------------------ +type PaymentPlansRequest = { + season_ticket_contract_record_no: string; +}; + +type PaymentPlansResponse = { + data: PaymentPlan[]; +} & APICommonResponse; + +export const getPaymentPlans = async (data: PaymentPlansRequest) => { + const res = await request({ + url: getUrl(ApiId.PAYMENT_PLANS), + method: HttpMethod.GET, + data: new URLSearchParams(data), + }); + return res; +}; diff --git a/src/api/url.ts b/src/api/url.ts index 0d1477c..1859db4 100644 --- a/src/api/url.ts +++ b/src/api/url.ts @@ -7,6 +7,7 @@ const urls = { [A.LOGIN]: "login", [A.LOGOUT]: "logout", [A.SEASON_TICKET_CONTRACTS]: "season-ticket-contracts", + [A.PAYMENT_PLANS]: "season-ticket-contract/payment-plans", }; const prefixs = { diff --git a/src/pages/dashboard/contract/detail.tsx b/src/pages/dashboard/contract/detail.tsx index 41e1b21..80fb5ea 100644 --- a/src/pages/dashboard/contract/detail.tsx +++ b/src/pages/dashboard/contract/detail.tsx @@ -9,11 +9,13 @@ import { TableRow, Typography, } from "@mui/material"; +import { PaymentPlan, getPaymentPlans } from "api/season-ticket-contract"; import { useSeasonTicketContractContext } from "contexts/dashboard/SeasonTicketContractContext"; +import useAPICall from "hooks/useAPICall"; import useDashboard from "hooks/useDashBoard"; import useNavigateCustom from "hooks/useNavigateCustom"; import { PageID, TabID } from "pages"; -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import { useParams } from "react-router-dom"; import { getPath } from "routes/path"; @@ -34,6 +36,18 @@ export default function ContractDetail() { const { navigate, navigateWhenChanged } = useNavigateCustom(); + const [paymentPlans, setPaymentPlans] = useState([]); + + const { callAPI: callGetPaymentPlans } = useAPICall({ + apiMethod: getPaymentPlans, + backDrop: true, + onSuccess: ({ data }) => {}, + onFailed: () => { + select(null); + moveToList(); + }, + }); + const moveToList = () => { navigateWhenChanged(getPath(PageID.DASHBOARD_SEASON_TICKET_CONTRACT_LIST)); }; @@ -50,6 +64,11 @@ export default function ContractDetail() { }); if (target) { select(target); + + callGetPaymentPlans({ + season_ticket_contract_record_no: + target.season_ticekt_contract_record_no ?? "", + }); } else { select(null); moveToList(); @@ -92,21 +111,22 @@ export default function ContractDetail() { お支払い状況 - - 2023/09 - 未請求 - - - 2023/08 - 支払済み - - - 2023/07 - 支払済み - + {paymentPlans.map((ele, index) => { + return ( + + {ele.payment_plan_date} + {ele.payment_method} + {ele.payment_status} + + ); + })} + {paymentPlans.length === 0 && ( + + データなし + + )}
- 各種申請