Skip to content
Snippets Groups Projects
Commit 8e0d623b authored by Minseo Lee's avatar Minseo Lee
Browse files

Merge branch 'order' into 'main'

feat: order exitbtn add

See merge request ajou-pay/client-user!6
parents 05578025 9c44fc2f
No related branches found
No related tags found
No related merge requests found
...@@ -24,13 +24,14 @@ const HistoryPage: GFC = ({ connector }) => { ...@@ -24,13 +24,14 @@ const HistoryPage: GFC = ({ connector }) => {
} }
})(); })();
}, []); }, []);
return ( return (
<div> <div>
{ {
model && model.map((d, i) => ( model && model.map((d, i) => (
<OrderBox waitingCount={d.waitingCount} name={'menu_name'} <OrderBox waitingCount={d.waitingCount} items={d.items}
price={d.totalPrice} status={d.status} shop={'shop_name'} price={d.totalPrice} status={d.status} shop={d.shop.name}
takeout={d.takeout} key={`orderbox-${i}`} takeout={d.takeout} key={`orderbox-${i}`} connector={connector}
/> />
)) ))
} }
......
...@@ -2,10 +2,10 @@ import type { HistoryPageModel } from "./type"; ...@@ -2,10 +2,10 @@ import type { HistoryPageModel } from "./type";
const HISTORY_PAGE_DUMMY: HistoryPageModel = [ const HISTORY_PAGE_DUMMY: HistoryPageModel = [
{ {
_id: "656bb8c3fd1861cb6fa562fa", "_id": "656bb8c3fd1861cb6fa562fa",
userId: "656b8ec725f8b6df24ab910c", "userId": "656b8ec725f8b6df24ab910c",
shopId: 3, "shopId": 3,
items: [ "items": [
{ {
"menuId": "6562292377dd1a645a7e960a", "menuId": "6562292377dd1a645a7e960a",
"quantity": 2 "quantity": 2
...@@ -15,12 +15,20 @@ const HISTORY_PAGE_DUMMY: HistoryPageModel = [ ...@@ -15,12 +15,20 @@ const HISTORY_PAGE_DUMMY: HistoryPageModel = [
"quantity": 1 "quantity": 1
} }
], ],
paymentMethod: "MONEY", "paymentMethod": "MONEY",
waitingCount: 39, "waitingCount": 39,
takeout: true, "takeout": true,
totalPrice: 22000, "totalPrice": 22000,
createdTime: "2023-12-02T23:07:47.000Z", "createdTime": "2023-12-02T23:07:47.000Z",
status: "Pending" "status": "Pending",
"shop": {
"_id": "3",
"name": "행복돈까스",
"icon": "https://git.ajou.ac.kr/ajou-pay/jj-s3/-/raw/main/logo/%ED%96%89%EB%B3%B5%EB%8F%88%EA%B9%8C%EC%8A%A4.png?ref_type=heads",
"location": "구학생회관 1층",
"openStatus": true,
"waitingOrderCount": 56
}
}, },
{ {
"_id": "656bb9dafd1861cb6fa56304", "_id": "656bb9dafd1861cb6fa56304",
...@@ -41,7 +49,15 @@ const HISTORY_PAGE_DUMMY: HistoryPageModel = [ ...@@ -41,7 +49,15 @@ const HISTORY_PAGE_DUMMY: HistoryPageModel = [
"takeout": true, "takeout": true,
"totalPrice": 36500, "totalPrice": 36500,
"createdTime": "2023-12-02T23:12:26.000Z", "createdTime": "2023-12-02T23:12:26.000Z",
"status": "Ready" "status": "Pending",
"shop": {
"_id": "3",
"name": "행복돈까스",
"icon": "https://git.ajou.ac.kr/ajou-pay/jj-s3/-/raw/main/logo/%ED%96%89%EB%B3%B5%EB%8F%88%EA%B9%8C%EC%8A%A4.png?ref_type=heads",
"location": "구학생회관 1층",
"openStatus": true,
"waitingOrderCount": 56
}
} }
]; ];
......
enum StatusType { import type { MainPageData } from "../../main-page/config/type";
"Pending",
"Preparing",
"Ready",
"Completed"
}
interface HistoryPageData { interface HistoryPageData {
_id : string; _id : string;
userId : string; userId : string;
shopId : number; shopId : number;
shop : MainPageData;
items : Array<{ items : Array<{
menuId: string; menuId: string;
quantity: number; quantity: number;
...@@ -22,6 +17,18 @@ interface HistoryPageData { ...@@ -22,6 +17,18 @@ interface HistoryPageData {
status: string; status: string;
} }
interface ItemData {
menuId: string;
quantity: number;
}
type HistoryPageModel = HistoryPageData[]; type HistoryPageModel = HistoryPageData[];
type ItemModel = ItemData[];
export type { HistoryPageModel, HistoryPageData }; export type {
HistoryPageModel,
HistoryPageData,
ItemModel,
ItemData
};
import { useEffect, useState } from "react";
import { ALERT } from "../../../../common/constants";
import { moneyFormatter } from "../../../../common/utils/fomat"; import { moneyFormatter } from "../../../../common/utils/fomat";
import S from "./OrderBox.module.css"; import S from "./OrderBox.module.css";
import type Connector from "../../../../common/instances/Connector";
import type { MenuPageData } from "../../../menu-page/config/type";
import type { HistoryPageData } from "../../config/type"; import type { HistoryPageData } from "../../config/type";
import type { FC } from "react"; import type { FC } from "react";
interface Props { interface Props {
name : string;
shop : string; shop : string;
items : HistoryPageData['items'];
waitingCount : HistoryPageData['waitingCount']; waitingCount : HistoryPageData['waitingCount'];
price : HistoryPageData['totalPrice']; price : HistoryPageData['totalPrice'];
takeout : HistoryPageData['takeout']; takeout : HistoryPageData['takeout'];
status : HistoryPageData['status']; status : HistoryPageData['status'];
connector : Connector;
} }
const OrderBox : FC<Props> = ({ name, shop, waitingCount, price, takeout, status }) => { const OrderBox : FC<Props> = ({ shop, items, waitingCount, price, takeout, status, connector }) => {
const [_name, setName] = useState<string>('');
useEffect(() => {
void (async () => {
try{
const response = await connector.get<MenuPageData>(`/menu/${items[0].menuId}`);
setName(response.name);
} catch {
alert(ALERT.REQ_FAIL);
}
})();
}, []);
const title = () => {
let quantity = 0;
items?.forEach((d) => {
quantity += d.quantity;
});
return`${_name} 포함 ${quantity}개`;
};
const setStatus = () => { const setStatus = () => {
switch (status) { switch (status) {
...@@ -34,12 +60,12 @@ const OrderBox : FC<Props> = ({ name, shop, waitingCount, price, takeout, status ...@@ -34,12 +60,12 @@ const OrderBox : FC<Props> = ({ name, shop, waitingCount, price, takeout, status
<div className={S['container']}> <div className={S['container']}>
<span className={S['number']}>{waitingCount}</span> <span className={S['number']}>{waitingCount}</span>
<div className={S['text-box']}> <div className={S['text-box']}>
<span className={S['title']}>{name}</span> <span className={S['title']}>{title()}</span>
<span>{shop}</span> <span>{shop}</span>
<span className={S['pickup']}>{takeout ? '포장' : '매장'}</span> <span className={S['pickup']}>{takeout ? '포장' : '매장'}</span>
<span>{_status}</span> <span>{_status}</span>
<span className={S['price']}>{moneyFormatter(price)}</span>
</div> </div>
<span className={S['price']}>{moneyFormatter(price)}</span>
</div> </div>
); );
}; };
......
import { useEffect } from "react"; import { useEffect } from "react";
import ExitButton from "../module/ExitButton";
const CancelPage = () => { const CancelPage = () => {
useEffect(() => { useEffect(() => {
localStorage.removeItem('payment_id'); localStorage.removeItem('payment_id');
}, []); }, []);
return (<div>cancel</div>); return (
<div>
<ExitButton text="결제를 취소하셨습니다"/>
</div>
);
}; };
export default CancelPage; export default CancelPage;
import { useEffect } from "react"; import { useEffect } from "react";
import ExitButton from "../module/ExitButton";
const FailPage = () => { const FailPage = () => {
useEffect(() => { useEffect(() => {
localStorage.removeItem('payment_id'); localStorage.removeItem('payment_id');
}, []); }, []);
return ( return (
<div>fail</div> <div>
<ExitButton text="결제가 실패했습니다."/>
</div>
); );
}; };
......
.container {
width: 100vw;
height: 100vh;
margin-top: calc(-1*var(--header-height));
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 8px;
}
.text {
font-size: 20px;
margin: 30px;
}
.btn-area {
width: 100%;
display: flex;
justify-content: center;
gap: 16px;
}
.btn-area button {
width: calc(40% - 8px);
height: 36px;
border-radius: 8px;
}
.btn {
border: none;
background-color: var(--brand-color);
color: white;
}
import { useNavigate } from "react-router-dom";
import APP_ROUTE from "../../../_app/config/route";
import S from './ExitButton.module.css';
import type { FC } from "react";
interface props {
text: string;
}
const ExitButton: FC<props> = ({ text }) => {
const navigate = useNavigate();
const handleGotoMain = () => {
navigate(APP_ROUTE.MAIN);
};
const handleGotoHistory = () => {
navigate(APP_ROUTE.HISTORY);
};
return (
<div className={S['container']} >
<span className={S['text']}>{text}</span>
<div className={S['btn-area']}>
<button className={S['btn']} onClick={handleGotoMain}>홈 화면으로</button>
<button className={S['btn']} onClick={handleGotoHistory}>주문 내역으로</button>
</div>
</div>
);
};
export default ExitButton;
...@@ -2,6 +2,7 @@ import { useEffect } from "react"; ...@@ -2,6 +2,7 @@ import { useEffect } from "react";
import { useLocation } from "react-router-dom"; import { useLocation } from "react-router-dom";
import { getQueryStrings } from "../../../common/utils/query"; import { getQueryStrings } from "../../../common/utils/query";
import ExitButton from "../module/ExitButton";
import type { OrderApprovePostModel } from "./config/type"; import type { OrderApprovePostModel } from "./config/type";
import type { GFC } from "../../../common/types/fc"; import type { GFC } from "../../../common/types/fc";
...@@ -31,7 +32,7 @@ const SuccessPage: GFC = ({ connector }) => { ...@@ -31,7 +32,7 @@ const SuccessPage: GFC = ({ connector }) => {
return ( return (
<div> <div>
Success! <ExitButton text="결제가 완료되었습니다."/>
</div> </div>
); );
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment