Skip to content

Commit

Permalink
feat: 다른 시장 방문리스트 안뜨게
Browse files Browse the repository at this point in the history
  • Loading branch information
seokkkkkk committed Aug 5, 2024
1 parent b000afe commit 0b147f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/pages/MarketPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,13 @@ const MarketPage = () => {
return;
} else {
const dates = Object.keys(res.data.payload);
setVisitList(res.data.payload[dates[0]]);
const num = res.data.payload[dates[0]].length;
const totalVisitList = res.data.payload[dates[0]];
const marketVisitList = totalVisitList.filter(
(visit) =>
visit.marketId.toString() === marketId.toString()
);
setVisitList(marketVisitList);
const num = marketVisitList.length;
setVisitNum(num);
}
})
Expand Down
21 changes: 21 additions & 0 deletions src/utils/OrderRequest.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import ButtonModal from "components/Common/ButtonModal";
import Splash from "components/Common/Splash";
import useOrderStore from "hooks/useOrderStore";
import useSyluvAxios from "hooks/useSyluvAxios";
import OrderResult from "pages/OrderResult";
import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";

const OrderRequest = () => {
const { getGlobalOrderData } = useOrderStore();
const syluvAxios = useSyluvAxios();
const [data, setData] = useState(null);
const [result, setResult] = useState(null);
const [isLoading, setIsLoading] = useState(true);
const [isError, setIsError] = useState(false);
const navigate = useNavigate();

useEffect(() => {
setData(getGlobalOrderData());
Expand All @@ -31,6 +35,10 @@ const OrderRequest = () => {
.then((res) => {
setResult(res.data.payload);
setIsLoading(false);
})
.catch(() => {
setIsError(true);
setIsLoading(false);
});
}
}, [data]);
Expand All @@ -39,6 +47,19 @@ const OrderRequest = () => {
return <Splash />;
}

if (isError) {
return (
<ButtonModal
title="주문 요청에 실패했습니다."
subText="다시 시도해주세요."
left="홈으로 이동"
onLeftClick={() => navigate("/")}
right="장바구니로 이동"
onRightClick={() => navigate("/cart")}
/>
);
}

return <OrderResult />;
};
export default OrderRequest;

0 comments on commit 0b147f6

Please sign in to comment.