Skip to content

Commit

Permalink
Dev -> Main (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
poco111 committed Nov 24, 2023
2 parents 4650ffd + 9724c67 commit 41facd5
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 16 deletions.
17 changes: 12 additions & 5 deletions fe/src/pages/AuthPage/AuthPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ export const AuthPage = () => {
const userInfoData = await getGithubLoginToken(queryCode);
if (!userInfoData) {
return;
} // TODO: 에러처리
}

const token = userInfoData.data.token;
const memberInfo = userInfoData.data.memberInfo;
console.log(memberInfo);
localStorage.setItem('loginToken', token);
userInfoDispatch &&
userInfoDispatch({
Expand Down Expand Up @@ -72,10 +73,16 @@ export const AuthPage = () => {
},
});

localStorage.setItem(
USER_INFO_KEY,
JSON.stringify(userInfoData.memberInfo)
);
userInfoDispatch &&
userInfoDispatch({
type: 'SET_USER_SELECTED_LOCATION',
payload: {
locationIdx: userLocationInfo.data.main.locationIdx,
town: userLocationInfo.data.main.town,
},
});

localStorage.setItem(USER_INFO_KEY, JSON.stringify(memberInfo));

navigate('/');
};
Expand Down
8 changes: 4 additions & 4 deletions fe/src/pages/DetailsPage/DetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const DetailsPage = () => {
const param = useParams();
const itemIdxStr = param.itemIdx;
const navigate = useNavigate();
const { pathname } = useLocation();
const prevPathname = useLocation().state;

const [details, setDetails] = useState<ItemDetail | null>(null);
const [loading, setLoading] = useState(true);
Expand Down Expand Up @@ -140,7 +140,6 @@ export const DetailsPage = () => {
onClick: () => {
changeStatusItemsAPI(Number(itemIdxStr), '판매완료');
setStatusDropdownOpen(false);
navigate(pathname, { replace: true });
window.location.reload();
},
},
Expand Down Expand Up @@ -176,7 +175,7 @@ export const DetailsPage = () => {
leftBtn: (
<NavbarBtn
icon="arrowLeft"
path="back"
path={prevPathname}
color="accentText"
></NavbarBtn>
),
Expand Down Expand Up @@ -260,7 +259,8 @@ export const DetailsPage = () => {
state: 'default',
color: 'systemDefault',
name: '게시글 수정',
onClick: () => navigate(`/edit/${itemIdxStr}`),
onClick: () =>
navigate(`/edit/${itemIdxStr}`, { state: prevPathname }),
},
{
shape: 'large',
Expand Down
1 change: 0 additions & 1 deletion fe/src/pages/HomePage/HomeList/HomeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const Contents = ({
);
return { ...data, pages: newPages };
},
staleTime: 10000,
cacheTime: 12000,
}
);
Expand Down
9 changes: 9 additions & 0 deletions fe/src/pages/LoginPage/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ export const LoginPage = () => {
},
});

userInfoDispatch &&
userInfoDispatch({
type: 'SET_USER_SELECTED_LOCATION',
payload: {
locationIdx: userLocationInfo.data.main.locationIdx,
town: userLocationInfo.data.main.town,
},
});

localStorage.setItem(
USER_INFO_KEY,
JSON.stringify(userInfoData.memberInfo)
Expand Down
5 changes: 3 additions & 2 deletions fe/src/pages/SalesHistoryPage/SalesHistoryPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as S from './SalesHistoryPageStyle';
import { useContext, useEffect, useState } from 'react';
import { Navigate, useNavigate } from 'react-router-dom';
import { Navigate, useLocation, useNavigate } from 'react-router-dom';
import { Layout, ListItem, Loading } from '@components/commons';
import { useFetch } from '@hooks/useFetch/useFetch';
import { getSalesItemsAPI } from '@services/items/items';
Expand All @@ -11,6 +11,7 @@ import { UserInfoContext } from '@stores/UserContext';

export const SalesHistoryPage = () => {
const navigate = useNavigate();
const { pathname } = useLocation();
const [status, setStatus] = useState<ItemStatus>('판매중');
const [{ data, error, loading }, fetch] = useFetch(
getSalesItemsAPI.bind(null, status),
Expand Down Expand Up @@ -51,7 +52,7 @@ export const SalesHistoryPage = () => {
{...item}
moreBtn={true}
onClick={() => {
navigate(`/item/${item.itemIdx}`);
navigate(`/item/${item.itemIdx}`, { state: pathname });
}}
></ListItem>
));
Expand Down
7 changes: 3 additions & 4 deletions fe/src/pages/WritePage/WritePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import { getAllLocationData } from '@services/locations/locations';

export const WritePage = ({ type }: { type: 'write' | 'edit' }) => {
const navigate = useNavigate();
const { pathname } = useLocation();
const { itemIdx } = useParams();
const prevPathName = useLocation().state;

const [title, setTitle] = useState<string>('');
const [categoryState] = useFetch(getCategoryAPI, [], true);
Expand Down Expand Up @@ -133,12 +133,12 @@ export const WritePage = ({ type }: { type: 'write' | 'edit' }) => {
? !uploadState.data && uploadState.error
? setDialogOpen(false)
: navigate(`/item/${uploadState.data?.itemIdx}`, {
state: pathname,
state: prevPathName,
})
: editState.error
? setDialogOpen(false)
: navigate(`/item/${itemIdx}`, {
state: pathname,
state: prevPathName,
});
};

Expand Down Expand Up @@ -216,7 +216,6 @@ export const WritePage = ({ type }: { type: 'write' | 'edit' }) => {
navbarOptions: {
title: '내 물건 팔기',
leftBtn: <NavbarBtn text="닫기" path="back" />,
/* path 수정하기 기존 유입 경로 넣기 */
rightBtn: (
<Button
title="완료"
Expand Down
4 changes: 4 additions & 0 deletions fe/src/stores/UserContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export const reducer = (state: UserInfo, { type, payload }) => {
locationIdx: null,
town: null,
},
selectedLocation: {
locationIdx: null,
town: null,
},
};
default:
throw new Error('user state: 타입이 지정되지 않았어요.');
Expand Down

0 comments on commit 41facd5

Please sign in to comment.