Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/lib/services/userProfileService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { USERS_API } from '@/constants/api';
import useAuthStore from '@/stores/useAuthStore';

import { services } from './servicesClient';
import { GetUserInfo } from './userService';

interface UserProfileInput {
name: string;
Expand All @@ -15,5 +17,16 @@ export const registerUserProfile = async (
) => {
const res = await services.put(USERS_API.ME(userId), data);

const userInfoRes = await GetUserInfo(userId);

const { setAuth, accessToken } = useAuthStore.getState();

if (accessToken) {
setAuth({
accessToken,
user: userInfoRes.item,
});
}

return res.data.item;
};
6 changes: 6 additions & 0 deletions src/pages/_app.page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AppProps } from 'next/app';
import Head from 'next/head';

import { NextPage } from 'next';
import { ReactElement, ReactNode } from 'react';
Expand All @@ -21,6 +22,11 @@ const App = ({ Component, pageProps }: AppPropsWithLayout) => {

return getLayout(
<>
<Head>
<title>
더줄게 | 세상의 모든 알바! 일자리 & 아르바이트 구인 구직 사이트
</title>
</Head>
<GlobalStyle />
<Component {...pageProps} />
<Toaster />
Expand Down
9 changes: 8 additions & 1 deletion src/pages/_document.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ import { Head, Html, Main, NextScript } from 'next/document';
const Document = () => {
return (
<Html lang="ko">
<Head />
<Head>
<meta
name="description"
content="세상의 모든 알바! 일자리 & 아르바이트 구인 구직 사이트"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/thejulgeFavicon.ico" />
</Head>
<body>
<Main />
<NextScript />
Expand Down
28 changes: 13 additions & 15 deletions src/pages/index.page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import Head from 'next/head';
import { GetServerSideProps } from 'next';

const Home = () => {
return (
<>
<Head>
<title>
더줄게 | 세상의 모든 알바! 일자리 & 아르바이트 구인 구직 사이트
</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/thejulgeFavicon.ico" />
</Head>
</>
);
import { STORE_ROUTES } from '@/constants/routes';

export const getServerSideProps: GetServerSideProps = async () => {
return {
redirect: {
destination: STORE_ROUTES.ROOT,
permanent: false,
},
};
};

export default Home;
export default function Home() {
return null;
}
46 changes: 20 additions & 26 deletions src/pages/myStore/store/[id].page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import withAuthentication from '@/components/hoc/withAuthentication';
import { IMAGES_API, SHOPS_API, USERS_API } from '@/constants/api';
import { MY_STORE_ROUTES } from '@/constants/routes';
import { services } from '@/lib/services/servicesClient';
import { GetUserInfo } from '@/lib/services/userService';
import StoreImgComponent from '@/pages/myStore/store/_components/storeimg';
import useAuthStore from '@/stores/useAuthStore';

Expand All @@ -23,7 +24,8 @@ const StoreRegisterPage = () => {

const router = useRouter();
const user = useAuthStore(s => s.user);
const setShop = useAuthStore(s => s.setShop);
const setAuth = useAuthStore(s => s.setAuth);
const accessToken = useAuthStore(s => s.accessToken);

// 가게 이름
const [storeName, setStoreName] = useState('');
Expand Down Expand Up @@ -162,32 +164,17 @@ const StoreRegisterPage = () => {
imageUrl: imgFile,
originalHourlyPay: Number(pay),
})
.then(res => {
const {
id,
name,
address1,
address2,
category,
description,
imageUrl,
originalHourlyPay,
} = res.data.item;
.then(async () => {
const userInfoRes = await GetUserInfo(user?.id as string);

if (accessToken) {
setAuth({
accessToken,
user: userInfoRes.item,
});
}

handleOpen();
setShop({
item: {
id,
name,
address1,
address2,
category,
description,
imageUrl,
originalHourlyPay,
},
});
router.push(MY_STORE_ROUTES.ROOT);
})
.catch(error => {
console.log('등록에 실패하였습니다.', error);
Expand Down Expand Up @@ -290,7 +277,14 @@ const StoreRegisterPage = () => {
<Modal open={open} onClose={handleClose}>
<S.ModalBox>
<S.ModalText>수정이 완료되었습니다.</S.ModalText>
<S.ModalButton onClick={handleClose}>확인</S.ModalButton>
<S.ModalButton
onClick={() => {
handleClose();
router.push(MY_STORE_ROUTES.ROOT);
}}
>
확인
</S.ModalButton>
</S.ModalBox>
</Modal>
</S.Section>
Expand Down
27 changes: 24 additions & 3 deletions src/pages/myStore/store/new.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import withAuthentication from '@/components/hoc/withAuthentication';
import { IMAGES_API, NOTICES_API, SHOPS_API, USERS_API } from '@/constants/api';
import { MY_STORE_ROUTES } from '@/constants/routes';
import { services } from '@/lib/services/servicesClient';
import { GetUserInfo } from '@/lib/services/userService';
import StoreImgComponent from '@/pages/myStore/store/_components/storeimg';
import StoreImgFileComponent from '@/pages/myStore/store/_components/storeimg2';
import useAuthStore from '@/stores/useAuthStore';

import * as S from './new.style';

Expand All @@ -21,6 +23,10 @@ const StoreRegisterPage = () => {
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

const setAuth = useAuthStore(s => s.setAuth);
const accessToken = useAuthStore(s => s.accessToken);
const user = useAuthStore(s => s.user);

const router = useRouter();
const jobId = router.query.jobId;

Expand Down Expand Up @@ -172,9 +178,17 @@ const StoreRegisterPage = () => {
imageUrl: imgFile,
originalHourlyPay: Number(pay),
})
.then(() => {
.then(async () => {
const userInfoRes = await GetUserInfo(user?.id as string);

if (accessToken) {
setAuth({
accessToken,
user: userInfoRes.item,
});
}

handleOpen();
router.push(MY_STORE_ROUTES.JOBS.DETAIL(jobId as string));
})
.catch(error => {
console.log('등록에 실패하였습니다.', error);
Expand Down Expand Up @@ -279,7 +293,14 @@ const StoreRegisterPage = () => {
<Modal open={open} onClose={handleClose}>
<S.ModalBox>
<S.ModalText>등록이 완료되었습니다.</S.ModalText>
<S.ModalButton onClick={handleClose}>확인</S.ModalButton>
<S.ModalButton
onClick={() => {
handleClose();
router.push(MY_STORE_ROUTES.ROOT);
}}
>
확인
</S.ModalButton>
</S.ModalBox>
</Modal>
</S.Section>
Expand Down
6 changes: 5 additions & 1 deletion src/pages/store/[shopId]/[noticeId]/index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ const StoreDetailPage = () => {
const handleClick = async () => {
if (!user?.id) {
setLoginModalOpen(true);
return;
}

if (!user.bio && !user.name && !user.phone && !user.address) {
setProfileModalOpen(true);
return;
}

Expand Down Expand Up @@ -181,7 +185,7 @@ const StoreDetailPage = () => {
alt="식당 이미지"
fill
style={{ objectFit: 'cover' }}
onError={e => {
onError={() => {
setImage(DefaultImage);
}}
/>
Expand Down
Loading