From 478869c79368d1b3884aa16ec41e4684d2ce7523 Mon Sep 17 00:00:00 2001 From: yoneyan Date: Mon, 15 Aug 2022 22:11:53 +0900 Subject: [PATCH] [change] #110 --- src/App.tsx | 2 - src/api/Payment.ts | 101 -------------- src/components/Dashboard/Dashboard.tsx | 9 -- src/interface.ts | 13 -- src/pages/Order/Order.tsx | 177 ------------------------- 5 files changed, 302 deletions(-) delete mode 100644 src/pages/Order/Order.tsx diff --git a/src/App.tsx b/src/App.tsx index b712988..bf5675a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,7 +5,6 @@ import SignIn from './pages/Login/SignIn'; import Group from "./pages/Group/Group"; import Dashboard from "./pages/Dashboard/Dashboard"; import Notice from './pages/Notice/Notice'; -import Order from "./pages/Order/Order"; import GroupDetail from './pages/Group/GroupDetail/GroupDetail'; import SupportDetail from "./pages/Support/SupportDetail/SupportDetail"; import Support from "./pages/Support/Support"; @@ -33,7 +32,6 @@ export default class App extends React.Component { }/> }/> }/> - }/> }/> }/> }/> diff --git a/src/api/Payment.ts b/src/api/Payment.ts index 5d0cd5c..b78947c 100644 --- a/src/api/Payment.ts +++ b/src/api/Payment.ts @@ -1,107 +1,6 @@ import axios from "axios"; import {restfulApiConfig} from "./Config"; -import {PaymentDetailData} from "../interface"; -export function Post(data: PaymentDetailData): Promise<{ error: string; data: any }> { - return axios.post(restfulApiConfig.apiURL + "/payment", data, { - headers: { - 'Content-Type': 'application/json', - ACCESS_TOKEN: sessionStorage.getItem('AccessToken')!, - } - }).then(res => { - return { - error: "", - data: res.data.service - }; - }).catch(err => { - console.log(err); - return { - error: "[" + err.response.status + "] " + err.response.data.error, - data: null - }; - }) -} - -export function Delete(id: number): Promise<{ error: string; data: any }> { - return axios.delete(restfulApiConfig.apiURL + "/payment/" + id, { - headers: { - 'Content-Type': 'application/json', - ACCESS_TOKEN: sessionStorage.getItem('AccessToken')!, - } - }).then(res => { - return { - error: "", - data: res.data.service - }; - }).catch(err => { - console.log(err); - return { - error: "[" + err.response.status + "] " + err.response.data.error, - data: null - }; - }) -} - -export function Put(id: number, data: PaymentDetailData): Promise<{ error: string; data: any }> { - return axios.put(restfulApiConfig.apiURL + "/payment/" + id, data, { - headers: { - 'Content-Type': 'application/json', - ACCESS_TOKEN: sessionStorage.getItem('AccessToken')!, - } - }).then(res => { - return { - error: "", - data: res.data.service - }; - }).catch(err => { - console.log(err); - return { - error: err, - data: null - }; - }) -} - -export function GetAll(): Promise<{ error: string, data: any }> { - return axios.get(restfulApiConfig.apiURL + "/payment", { - headers: { - 'Content-Type': 'application/json', - ACCESS_TOKEN: sessionStorage.getItem('AccessToken')!, - } - }).then(res => { - console.log(res.data); - return { - error: "", - data: res.data.payment - }; - }).catch(err => { - console.log(err); - return { - error: "[" + err.response.status + "] " + err.response.data.error, - data: null - }; - }) -} - -export function Refund(id: number): Promise<{ error: string; data: any }> { - return axios.post(restfulApiConfig.apiURL + "/payment/" + id + "/refund", {}, { - headers: { - 'Content-Type': 'application/json', - ACCESS_TOKEN: sessionStorage.getItem('AccessToken')!, - } - }).then(res => { - return { - error: "", - data: res.data.service - }; - }).catch(err => { - console.log(err); - return { - error: "[" + err.response.status + "] " + err.response.data.error, - data: null - }; - }) -} export function PostSubscribe(groupID: number, plan: string): Promise<{ error: string; data: any }> { return axios.post(restfulApiConfig.apiURL + "/group/" + groupID + "/payment/subscribe", {plan}, { diff --git a/src/components/Dashboard/Dashboard.tsx b/src/components/Dashboard/Dashboard.tsx index f063d5e..9f0b2d0 100644 --- a/src/components/Dashboard/Dashboard.tsx +++ b/src/components/Dashboard/Dashboard.tsx @@ -147,9 +147,6 @@ export default function Dashboard(props: any) { const GroupPage = () => { navigate("/dashboard/group"); } - const OrderPage = () => { - navigate("/dashboard/order"); - } const SupportPage = () => { navigate("/dashboard/support"); } @@ -223,12 +220,6 @@ export default function Dashboard(props: any) { - - - - - - diff --git a/src/interface.ts b/src/interface.ts index 71cb4ab..b3e133b 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -47,19 +47,6 @@ export interface UserDetailData { tokens?: TokenDetailData[] } -export interface PaymentDetailData { - ID: number, - CreatedAt: string, - UpdatedAt: string, - group?: GroupDetailData, - is_membership: boolean, - paid: boolean, - refund: boolean, - fee: number, - payment_intent_id: string, - comment: string, -} - export interface TokenDetailData { CreatedAt: string, ID: number, diff --git a/src/pages/Order/Order.tsx b/src/pages/Order/Order.tsx deleted file mode 100644 index f412963..0000000 --- a/src/pages/Order/Order.tsx +++ /dev/null @@ -1,177 +0,0 @@ -import React, {useEffect, useState} from 'react'; -import Dashboard from "../../components/Dashboard/Dashboard"; -import {StyledCard, StyledInputBase, StyledPaperRootInput, StyledTypographyTitle} from "../Dashboard/styles" -import { - PaymentDetailData -} from "../../interface"; -import {useSnackbar} from "notistack"; -import {GetAll, Refund} from "../../api/Payment"; -import { - Button, - CardActions, - CardContent, Chip, - FormControl, - FormControlLabel, - Radio, - RadioGroup, - Typography -} from "@mui/material"; - -export default function Order() { - const [payments, setPayments] = useState(); - const [initPayments, setInitPayments] = useState(); - const {enqueueSnackbar} = useSnackbar(); - // 1:有効 2:無効 - const [value, setValue] = React.useState(1); - const [money, setSumMoney] = React.useState(0); - const [reload, setReload] = React.useState(true); - - useEffect(() => { - if (reload) { - GetAll().then(res => { - if (res.error === "") { - console.log(res); - setPayments(res.data); - setInitPayments(res.data); - let money = 0; - for (const tmp of res.data) { - money += tmp.fee - } - setSumMoney(money); - } else { - enqueueSnackbar("" + res.error, {variant: "error"}); - } - }) - } - setReload(false); - }, [reload]); - - const handleChange = (event: React.ChangeEvent) => { - setValue(Number(event.target.value)) - }; - - const checkPayment = (payment: PaymentDetailData) => { - if (value === 1) { - return payment.paid; - } else if (value === 2) { - return !payment.paid; - } else { - return true; - } - } - - const handleFilter = (search: string) => { - let tmp: PaymentDetailData[]; - if (initPayments != null) { - if (search === "") { - tmp = initPayments; - } else { - tmp = initPayments?.filter((payment: PaymentDetailData) => { - return payment.payment_intent_id.toLowerCase().includes(search.toLowerCase()) - }); - } - setPayments(tmp); - } - }; - - const handleRefundProcess = (id: number) => { - Refund(id).then(res => { - if (res.error === "") { - console.log(res.data); - enqueueSnackbar('Request Success', {variant: "success"}); - setReload(true); - } else { - enqueueSnackbar(String(res.error), {variant: "error"}); - } - }) - }; - - return ( - -

合計金額: {money}円

- - { - handleFilter(event.target.value) - }} - /> - - - - } label="支払済"/> - } label="未払い"/> - - - { - payments?.filter(payment => checkPayment(payment)).map((payment: PaymentDetailData) => ( - - - - ID: {payment.ID} ({payment.payment_intent_id}) - - - { - payment.is_membership && -
- {payment.group?.org} ({payment.group?.org_en}) -
- } -
-
- { - payment.is_membership && - - } - { - !payment.is_membership && - - } -    - { - !payment.refund && payment.paid && - - } - { - !payment.refund && !payment.paid && - - } - { - payment.refund && payment.paid && - - } -

- {payment.fee}円 -
- - - -
- )) - } -
- ); -}