handleOperation()}
>
- {isOperation ? (
+ {!storeStatus ? (
) : (
diff --git a/src/hooks/Main/useFetchStoreStatus.jsx b/src/hooks/Main/useFetchStoreStatus.jsx
new file mode 100644
index 0000000..e8ab399
--- /dev/null
+++ b/src/hooks/Main/useFetchStoreStatus.jsx
@@ -0,0 +1,34 @@
+import { useEffect } from "react";
+import { useSetRecoilState } from "recoil";
+import { storeContextState } from "../../Atom/status";
+import commonApis from "../../util/commonApis";
+
+const apiUrl = `/store/sales`;
+
+const useFetchStoreStatus = () => {
+ const setStoreStatus = useSetRecoilState(storeContextState);
+ const token = localStorage.getItem("accessToken");
+ const config = {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ };
+ const fetchData = async () => {
+ commonApis
+ .get(apiUrl, config)
+ .then((res) => {
+ if (res.status === 200) {
+ setStoreStatus(res.data.status);
+ return res.data.status;
+ }
+ })
+ .catch((err) => console.log(err));
+ };
+ useEffect(() => {
+ fetchData();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+ return;
+};
+
+export default useFetchStoreStatus;
diff --git a/src/hooks/Main/useStoreStatusChange.jsx b/src/hooks/Main/useStoreStatusChange.jsx
new file mode 100644
index 0000000..71693c0
--- /dev/null
+++ b/src/hooks/Main/useStoreStatusChange.jsx
@@ -0,0 +1,40 @@
+import { message } from "antd";
+import { useSetRecoilState } from "recoil";
+import { storeContextState } from "../../Atom/status";
+import commonApis from "../../util/commonApis";
+
+const apiUrl = `/store/sales`;
+
+const useStoreStatusChange = () => {
+ const token = localStorage.getItem("accessToken");
+ const setStoreStatus = useSetRecoilState(storeContextState);
+
+ const storeStatusChange = async (status) => {
+ console.log('status: ', status);
+ const body ={
+ status: status
+ };
+ const config = {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ };
+ try {
+ const response = await commonApis.post(
+ apiUrl, body, config
+ );
+ if(response.status === 200){
+ message.success("영업 상태 변경 완료되었습니다.");
+ setStoreStatus(response.data.status);
+ } else {
+ message.error("영업 상태 변경 실패하였습니다.");
+ }
+ } catch (error) {
+ console.log(error);
+ message.error("영업 상태 변경 중 오류가 발생하였습니다.");
+ }
+ }
+ return storeStatusChange;
+};
+
+export default useStoreStatusChange;
From 0208c89d71b7b2e04fd90352dc61a36228b274da Mon Sep 17 00:00:00 2001
From: happppi <102276917+hhbb0081@users.noreply.github.com>
Date: Mon, 25 Mar 2024 01:07:24 +0900
Subject: [PATCH 2/4] =?UTF-8?q?Feat:=20=EC=8B=AC=EC=82=AC=20=EB=B0=98?=
=?UTF-8?q?=EB=A0=A4=20=ED=9B=84=20=EC=9E=AC=EC=8B=A0=EC=B2=AD=20api=20?=
=?UTF-8?q?=EC=97=B0=EB=8F=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/hooks/useRejectEntry.jsx | 26 +++++++++++++++++++
.../JudgeResultsRejectPage.jsx | 12 ++++++++-
2 files changed, 37 insertions(+), 1 deletion(-)
create mode 100644 src/hooks/useRejectEntry.jsx
diff --git a/src/hooks/useRejectEntry.jsx b/src/hooks/useRejectEntry.jsx
new file mode 100644
index 0000000..d035d0a
--- /dev/null
+++ b/src/hooks/useRejectEntry.jsx
@@ -0,0 +1,26 @@
+import { message } from "antd";
+import commonApis from "../util/commonApis";
+
+const apiUrl = `/ceo/entry/reject`;
+
+const useRejectEntry = () => {
+ const token = localStorage.getItem("accessToken");
+ const config = {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ };
+ const rejectEntry = () => {
+ commonApis
+ .get(`${apiUrl}`, config)
+ .then((res) => {
+ if (res.status === 200 && res.data.success) {
+ message.success(res.data.message);
+ }
+ })
+ .catch((err) => console.log(err));
+ };
+ return rejectEntry;
+};
+
+export default useRejectEntry;
diff --git a/src/pages/Signup/JudgeResults/JudgeResultsReject/JudgeResultsRejectPage.jsx b/src/pages/Signup/JudgeResults/JudgeResultsReject/JudgeResultsRejectPage.jsx
index 388943c..9f9b4e9 100644
--- a/src/pages/Signup/JudgeResults/JudgeResultsReject/JudgeResultsRejectPage.jsx
+++ b/src/pages/Signup/JudgeResults/JudgeResultsReject/JudgeResultsRejectPage.jsx
@@ -3,6 +3,7 @@ import { useNavigate } from "react-router-dom";
import Container from "../../../../components/login/Container/Container";
import RedButton from "../../../../components/login/redButton/RedButton";
import { IMAGES } from "../../../../constants/images";
+import useRejectEntry from "../../../../hooks/useRejectEntry";
import "./JudgeResultsRejectPage.css";
function JudgeResultsRejectPage() {
const navigate = useNavigate();
@@ -23,6 +24,15 @@ function JudgeResultsRejectPage() {
window.removeEventListener("resize", handleResize);
};
}, []);
+
+ const rejectEntry = useRejectEntry();
+
+ const handleReject = () => {
+ // 심사 반려 -> 재신청
+ rejectEntry();
+ navigate("/signup/auth/results");
+ };
+
return (
- navigate("/signup/auth/results")}>
+
재신청하기
From 3a7f82da0dfa6d0cdf43e4cf55ac4639acf7bf7b Mon Sep 17 00:00:00 2001
From: happppi <102276917+hhbb0081@users.noreply.github.com>
Date: Mon, 25 Mar 2024 01:07:49 +0900
Subject: [PATCH 3/4] =?UTF-8?q?Fix:=20=ED=86=A0=ED=81=B0=20=EB=A7=8C?=
=?UTF-8?q?=EB=A3=8C=EC=8B=9C=EA=B0=84=20=EB=8B=A8=EC=9C=84=20=EC=88=98?=
=?UTF-8?q?=EC=A0=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/Login/LoginPage.jsx | 2 +-
src/util/commonApis.jsx | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/pages/Login/LoginPage.jsx b/src/pages/Login/LoginPage.jsx
index 2867b09..c8d7b91 100644
--- a/src/pages/Login/LoginPage.jsx
+++ b/src/pages/Login/LoginPage.jsx
@@ -77,7 +77,7 @@ function LoginPage() {
if (success) {
// 로그인 성공: Recoil에 AT와 만료시간 저장
localStorage.setItem("accessToken", response.data.accessToken);
- localStorage.setItem("expiredTime", moment().add(1, "minutes").format("yyyy-MM-DD HH:mm:ss")); // 만료시간 저장
+ localStorage.setItem("expiredTime", moment().add(1, "days").format("yyyy-MM-DD HH:mm:ss")); // 만료시간 저장
console.log("로그인 성공:", response.data);
message.success("로그인에 성공하셨습니다!");
diff --git a/src/util/commonApis.jsx b/src/util/commonApis.jsx
index 6853ea8..3ca31da 100644
--- a/src/util/commonApis.jsx
+++ b/src/util/commonApis.jsx
@@ -1,4 +1,5 @@
import axios from "axios";
+import moment from "moment";
const commonApis = axios.create({
baseURL: process.env.REACT_APP_API_ROOT + "/api/v1",
@@ -42,6 +43,7 @@ commonApis.interceptors.response.use(
console.log("access token 재설정!");
console.log(accessToken);
localStorage.setItem('accessToken', accessToken);
+ localStorage.setItem("expiredTime", moment().add(1, "days").format("yyyy-MM-DD HH:mm:ss"))
axios.defaults.headers.common.Authorization = "Bearer " + accessToken;
config.headers.common["Authorization"] = "Bearer " + accessToken;
}
From 1f3a2a10ae47768f77874ef0d0f848d5d9a01fb4 Mon Sep 17 00:00:00 2001
From: happppi <102276917+hhbb0081@users.noreply.github.com>
Date: Mon, 25 Mar 2024 01:08:18 +0900
Subject: [PATCH 4/4] =?UTF-8?q?Feat:=20=EB=A9=94=EC=9D=B8=ED=8E=98?=
=?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=82=AC=EC=9E=A5=EB=8B=98=20=EC=9D=B4?=
=?UTF-8?q?=EB=A6=84=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/hooks/Main/useFetchStoreName.jsx | 31 +++++++++++++++++++
src/pages/Main/MainPage.jsx | 45 +++++++++++++++++-----------
2 files changed, 59 insertions(+), 17 deletions(-)
create mode 100644 src/hooks/Main/useFetchStoreName.jsx
diff --git a/src/hooks/Main/useFetchStoreName.jsx b/src/hooks/Main/useFetchStoreName.jsx
new file mode 100644
index 0000000..3c661e1
--- /dev/null
+++ b/src/hooks/Main/useFetchStoreName.jsx
@@ -0,0 +1,31 @@
+import { useEffect, useState } from "react";
+import commonApis from "../../util/commonApis";
+
+const apiUrl = `/user/name`;
+
+const useFetchStoreName = () => {
+ const [info, setInfo] = useState("");
+ const token = localStorage.getItem("accessToken");
+ const config = {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ };
+ useEffect(() => {
+ const fetchData = async () => {
+ commonApis
+ .get(`${apiUrl}`, config)
+ .then((res) => {
+ if (res.status === 200) {
+ setInfo(res.data.name);
+ }
+ })
+ .catch((err) => console.log(err));
+ };
+ fetchData();
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+ return info;
+};
+
+export default useFetchStoreName;
diff --git a/src/pages/Main/MainPage.jsx b/src/pages/Main/MainPage.jsx
index 214b50c..fc4c902 100644
--- a/src/pages/Main/MainPage.jsx
+++ b/src/pages/Main/MainPage.jsx
@@ -1,32 +1,38 @@
import moment from "moment/moment";
+import { createContext, useEffect } from 'react';
import { Link } from "react-router-dom";
+import { useRecoilValue } from "recoil";
+import { storeContextState } from "../../Atom/status";
import right from "../../assets/icons/icon_right-line.png";
import MainButton from "../../components/views/Button/mainButton";
import Footer from "../../components/views/Footer/Footer";
import ResponsiveHeader from "../../components/views/Header/ResponsiveHeader";
import { IMAGES } from "../../constants/images";
+import useFetchStoreName from "../../hooks/Main/useFetchStoreName";
import useFatchWeekAndMonthOrderCount from "../../hooks/Sales/useFatchWeekAndMonthOrderCount";
import useFetchWeekTotalSales from "../../hooks/Sales/useFetchWeekTotalSales";
import "./MainPage.css";
+export const StatusContext = createContext();
+
const MainPage = () => {
const notices = [
- // {
- // id: 1,
- // title: "2024년 4월 넷째 주(4/21~4/27) 입금 안내",
- // date: "24-04-21",
- // },
- // {
- // id: 2,
- // title: "2024년 4월 셋째 주(4/14~4/20) 입금 안내",
- // date: "24-04-14",
- // },
- // {
- // id: 3,
- // title: "2024년 4월 둘째 주(4/7~4/13) 입금 안내",
- // date: "24-04-07",
- // },
- // { id: 4, title: "2024년 4월 첫째 주(4/1~4/6) 입금 안내", date: "24-04-01" },
+ {
+ id: 1,
+ title: "2024년 4월 넷째 주(4/21~4/27) 입금 안내",
+ date: "24-04-21",
+ },
+ {
+ id: 2,
+ title: "2024년 4월 셋째 주(4/14~4/20) 입금 안내",
+ date: "24-04-14",
+ },
+ {
+ id: 3,
+ title: "2024년 4월 둘째 주(4/7~4/13) 입금 안내",
+ date: "24-04-07",
+ },
+ { id: 4, title: "2024년 4월 첫째 주(4/1~4/6) 입금 안내", date: "24-04-01" },
];
// 현 날짜
const currentDate = {
@@ -36,7 +42,12 @@ const MainPage = () => {
const weekStart = currentDate.monday.format("YYYY-MM-DD");
const weekTotalSales = useFetchWeekTotalSales(weekStart);
const weekAndMonthOrderCount = useFatchWeekAndMonthOrderCount(weekStart);
+ const name = useFetchStoreName();
+ const storeStatus = useRecoilValue(storeContextState);
//객체 구성{totalWeekOrder, totalMonthOrder}
+
+ useEffect(() => {}, [storeStatus]);
+
return (
@@ -56,7 +67,7 @@ const MainPage = () => {
오늘도 준비된
- 오르다커피 사장님
+ {name} 사장님