Skip to content

Commit 22bab1d

Browse files
authored
Merge pull request #32 from hhbb0081/test
Feat: 재고관리 & 마이페이지 api 연결
2 parents 1401944 + b1da08b commit 22bab1d

File tree

18 files changed

+218
-204
lines changed

18 files changed

+218
-204
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ WDS_SOCKET_PORT=0
44
NODE_PATH=src/
55
REACT_APP_API_ROOT=http://localhost:8080
66
REACT_APP_HOME_URL=http://localhost:3000
7-
REACT_APP_API_URL=http://readyvery.com/api/v1
7+
REACT_APP_API_URL=http://readyvery.com
88
REACT_APP_KAKAO_LOGIN=http://localhost:8080/oauth2/authorization/kakao

src/App.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ function App() {
2424
const NewMyPage = Auth(Mypage, true);
2525

2626
const expiredTime = 1000 * 60 * 60 * 24;
27+
// const expiredTime = 65000;
2728
useInterval(() => {
28-
if (
29-
cookies.refreshToken !== "undefined" &&
30-
cookies.refreshToken !== undefined &&
31-
cookies.refreshToken
32-
) {
29+
// console.log(cookies.refreshToken);
30+
// if (
31+
// cookies.refreshToken !== "undefined" &&
32+
// cookies.refreshToken !== undefined &&
33+
// cookies.refreshToken
34+
// ) {
35+
if(cookies.accessToken){
3336
const config = {
3437
withCredentials: true,
3538
};
@@ -43,9 +46,12 @@ function App() {
4346
}
4447
})
4548
.catch((err) => {
49+
console.log(err);
50+
alert("토큰이 만료되었습니다. 로그인을 진행해주세요.");
4651
navigate("/");
4752
});
48-
}
53+
}
54+
// }
4955
}, expiredTime - 60000);
5056
return (
5157
<div className="App">

src/Atom/status.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from "axios";
22
import { atom, selector } from "recoil";
3+
import { Refresh } from "../hoc/handleRefresh";
34

45
export const storeState = atom({
56
key: "storeState", // 전역적으로 고유한 값
@@ -19,7 +20,10 @@ export const isAuthenticatedState = atom({
1920
export const getAuthenticatedSelector = selector({
2021
key: "auth/get",
2122
get: async ({ get }) => {
22-
return get(isAuthenticatedState);
23+
const tokenResult = Refresh();
24+
if(tokenResult){
25+
return "재발급 성공";
26+
} else { return "토큰 유효"; }
2327
},
2428

2529
set: ({ set }) => {

src/components/views/Chart/Chart.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function Chart ({ data }) {
1010
indexBy="day"
1111
margin={{ top: 20, right: 0, bottom: 30, left: 30 }}
1212
padding={0.5}
13-
width={812}
13+
width={710}
1414
height={390}
1515
valueScale={{ type: 'linear' }}
1616
indexScale={{ type: 'band', round: true }}

src/components/views/Header/Header.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
bottom: 0;
1313
left: 0;
1414
right: 0;
15-
min-width: 73.75rem;
16-
/* min-width: 64rem; */
15+
/* min-width: 73.75rem; */
16+
width: 64rem;
17+
max-width: 64rem;
1718
height: 5.5rem;
1819
background-color: #2e2d2d;
1920
z-index: 101;

src/components/views/Inven/InvenBox.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const InvenBox = ({handleModal, invenProps: {category, name, soldOut}}) => {
66
{!soldOut ? (
77
<div className="mainInven-category-checkbox" onClick={handleModal}></div>
88
) : (
9-
<div className="mainInven-category-checkbox selected"></div>
9+
<div className="mainInven-category-checkbox selected" onClick={handleModal}></div>
1010
)}
1111
</span>
1212
<span className="mainInven-category-content__span2">{category}</span>

src/components/views/NavBar/NavBar.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.navbar {
22
width: 8.875rem;
33
/* height: 46.25rem; */
4-
height: 45.75rem;
5-
/* height: 42.5rem; */
4+
/* height: 45.75rem; */
5+
height: 42.5rem;
66
background-color: #2e2d2d;
77

88
display: flex;

src/hoc/auth.jsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,24 @@ function Auth(SpecificComponent, option) {
1010
const navigate = useNavigate();
1111
const location = useLocation();
1212
const userInfo = useRecoilValue(getUserSelector);
13+
// const tokenInfo = useRecoilValue(getAuthenticatedSelector);
1314
const setIsLoggedIn = useSetRecoilState(loginState);
1415
const [cookies] = useCookies(["accessToken"]);
1516

1617
useEffect(() => {
17-
const isAuth = window.localStorage.getItem("isAuthenticated");
18+
console.log(userInfo);
19+
// console.log(tokenInfo);
20+
console.log(window.localStorage.getItem("isAuthenticated"));
21+
console.log(cookies?.accessToken);
22+
// const isAuth = window.localStorage.getItem("isAuthenticated");
1823
if (userInfo === "404" && location.pathname !== "/") {
1924
navigate("/");
2025
} else {
21-
if (!isAuth && cookies?.accessToken) {
26+
// if(userInfo !== "404"){
27+
// const tokenInfo = useRecoilValue(getAuthenticatedSelector);
28+
// console.log(tokenInfo);
29+
// }
30+
if (!window.localStorage.getItem("isAuthenticated") && cookies?.accessToken) {
2231
// 첫 로그인 시
2332
window.localStorage.setItem("isAuthenticated", true);
2433
setIsLoggedIn({

src/hoc/handleRefresh.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import axios from "axios";
22
import moment from "moment";
3+
import { useCookies } from "react-cookie";
34
import { useRecoilState } from 'recoil';
45
import { loginState } from '../Atom/status';
56

@@ -8,6 +9,7 @@ const Refresh = async () => {
89
const apiUrl = process.env.REACT_APP_API_ROOT;
910
const [loginInfo, setLoginInfo] = useRecoilState(loginState);
1011
const expireAt = loginInfo.expiredTime;
12+
const [cookies] = useCookies(["accessToken"]);
1113
console.log("만료확인");
1214

1315
// 토큰이 만료되었다면
@@ -26,9 +28,12 @@ const Refresh = async () => {
2628
);
2729
console.log("재발급 성공", res);
2830
setLoginInfo({
31+
accessToken: cookies,
2932
expiredTime: moment().add(1, "hour").format("yyyy-MM-DD HH:mm:ss")
3033
});
31-
}
34+
35+
return true;
36+
} else {return false;}
3237
};
3338

3439
const refreshErrorHandle = () => {

src/pages/Home/Home.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.inven-wrapper{
2+
display: flex;
3+
}
4+
5+
nav{
6+
width: 8.875rem;
7+
/* height: 46.25rem; */
8+
/* height: 42.5rem; */
9+
height: 45.75rem;
10+
z-index: 1;
11+
}
12+
13+
main{
14+
width: calc(100vw - 8.875rem);
15+
}

src/pages/Home/MainHome.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.Main-Box {
22
width: 100%; /* 너비 설정 */
33
height: 95%; /* 높이 설정 */
4-
padding: 5% 0% 0% 0%;
4+
/* padding: 5% 0% 0% 0%; */
55
}
66

77
.status-header {

src/pages/Inventory/MainInven.css

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
.mainInven-title__wrapper{
77
display: flex;
88
height: 5.0625rem;
9-
width: 100%;
10-
min-width: calc(73.75rem - 8.875rem);
9+
/* width: 100%; */
10+
width: 55.125rem;
11+
/* min-width: calc(73.75rem - 8.875rem); */
12+
min-width: calc(64rem - 8.875rem);
1113
background-color: #4F4F4F;
1214
border-bottom: 0.5rem solid #d82356;
1315
position: relative;
@@ -24,38 +26,45 @@
2426

2527
.mainInven-title__span1{
2628
width: 15%;
27-
min-width: 8.3125rem;
29+
/* min-width: 8.3125rem; */
30+
min-width: 8.26875rem;
2831
}
2932

3033
.mainInven-title__span2__wrapper{
3134
width: 25%;
32-
min-width: 17.8125rem;
35+
/* min-width: 17.8125rem; */
36+
min-width: 13.78125rem;
3337
display: flex;
3438
justify-content: space-between;
3539
}
3640

37-
.mainInven-title__span2{
38-
/* width: 25%; */
39-
}
40-
4141
.mainInven-title__span3{
4242
width: 60%;
4343
/* min-width: 39.625rem; */
44+
min-width: 33.075rem;
45+
46+
white-space: nowrap;
4447
}
4548

4649
.mainInven-category__modal{
4750
position: absolute;
48-
left: calc((100vw - 8.875rem) * 0.275);
51+
/* left: calc((100vw - 8.875rem) * 0.275); */
52+
top: 10rem;
53+
left: 17.14375rem;
54+
/* left: 0; */
4955
display: flex;
5056
flex-direction: column;
51-
width: 17.1875rem;
57+
/* width: 17.1875rem; */
58+
width: 13.78125rem;
59+
height: 37.4375rem;
5260
border-radius: 0 0 0.625rem 0.625rem;
5361
background-color: #4F4F4F;
5462
z-index: 0;
63+
overflow-y: auto;
5564
}
5665

5766
.mainInven-category__modal span{
58-
width: 17.1875rem;
67+
width: 13.78125rem;
5968
height: 3.0625rem;
6069
line-height: 3.0625rem;
6170
font-size: 1.5625rem;
@@ -71,8 +80,11 @@
7180
}
7281

7382
.mainInven-category-content__wrapper{
74-
width: 100%;
75-
height: calc(45.75rem - 5.0625rem);
83+
/* width: 100%; */
84+
width: calc(64rem - 8.875rem);
85+
/* height: calc(48rem - 5.5rem); */
86+
/* height: calc(45.75rem - 5.0625rem); */
87+
height: 37.4375rem;
7688
/* height: calc(46.25rem - 5.0625rem); */
7789
/* height: calc(42.5rem - 5.0625rem); */
7890
overflow-y: auto;
@@ -92,7 +104,8 @@
92104
display: flex;
93105

94106
width: 100%;
95-
min-width: calc(73.75rem - 8.875rem);
107+
/* min-width: calc(73.75rem - 8.875rem); */
108+
min-width: calc(64rem - 8.875rem);
96109
height: 3.6875rem;
97110
border-bottom: #dadada solid 0.125rem;
98111
}
@@ -123,7 +136,7 @@
123136

124137
.mainInven-category-content__span1{
125138
width: 15%;
126-
min-width: 8.3125rem;
139+
min-width: 8.26875rem;
127140

128141
display: flex;
129142
justify-content: center;
@@ -132,20 +145,21 @@
132145

133146
.mainInven-category-content__span2{
134147
width: 25%;
135-
min-width: 17.8125rem;
148+
min-width: 13.78125rem;
136149

137150
white-space: nowrap;
138151
}
139152

140153
.mainInven-category-content__span3{
141154
width: 60%;
142-
min-width: 39.625rem;
155+
/* min-width: 39.625rem; */
156+
min-width: 33.075rem;
143157

144158
white-space: nowrap;
145159
}
146160

147161
/* 모달 */
148-
.modal-wrapper{
162+
.inven-modal-wrapper{
149163
position: absolute;
150164
top: 5.5rem;
151165
bottom: 0;
@@ -157,7 +171,7 @@
157171
display: flex;
158172
}
159173

160-
.modal-box{
174+
.inven-modal-box{
161175
position: absolute;
162176
top: calc(50% - 12.15625rem);
163177
left: calc(50% - 17.1875rem);
@@ -170,32 +184,32 @@
170184
padding: 2.0625rem 3.25rem;
171185
}
172186

173-
.modal-close__wrapper{
187+
.inven-modal-close__wrapper{
174188
display: flex;
175189
justify-content: flex-end;
176190
}
177191

178-
.modal-box-img__wrapper{
192+
.inven-modal-box-img__wrapper{
179193
height: 30%;
180194
}
181195

182-
.modal-box-txt__wrapper{
196+
.inven-modal-box-txt__wrapper{
183197
height: 30%;
184198
}
185199

186-
.modal-box-txt{
200+
.inven-modal-box-txt{
187201
font-size: 1.5625rem;
188202
font-family: "SemiBold";
189203
}
190204

191-
.modal-box-close-btn__wrapper{
205+
.inven-modal-box-close-btn__wrapper{
192206
display: flex;
193207
flex-direction: column;
194208
justify-content: flex-end;
195209
height: 30%;
196210
}
197211

198-
.modal-box-close-btn{
212+
.inven-modal-box-close-btn{
199213
width: 19.375rem;
200214
height: 3.125rem;
201215
margin: 0 auto;

0 commit comments

Comments
 (0)