Skip to content

Commit

Permalink
9주차 작업물 (#138)
Browse files Browse the repository at this point in the history
9주차 작업물
  • Loading branch information
Dobbymin authored Nov 1, 2024
2 parents 36d2bc6 + 34ef6d9 commit 72c62c8
Show file tree
Hide file tree
Showing 113 changed files with 1,043 additions and 576 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: ESLint test
name: ESLint & Build Test

on:
pull_request:
Expand All @@ -16,6 +16,11 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v4

- name: Install NodeJs
uses: actions/setup-node@v4
with:
node-version: 22

- name: Install Pnpm package manager
run: |
npm install -g pnpm
Expand All @@ -25,3 +30,6 @@ jobs:

- name: Lint Code
run: pnpm lint

- name: Build Test
run: pnpm run build
5 changes: 1 addition & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
steps:
- name: Checkout source code.
uses: actions/checkout@master
with:
submodules: true
token: ${{ secrets.ACTION_TOKEN }}

- name: Cache node modules
uses: actions/cache@v4
Expand Down Expand Up @@ -47,7 +44,7 @@ jobs:
run: pnpm lint

- name: Build
run: CI='' pnpm run build
run: pnpm run build

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
.vscode
.github
dist

pnpm-lock.yaml
13 changes: 2 additions & 11 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,9 @@

"<THIRD_PARTY_MODULES>",

"^@components/(.*)$",
"^@app/(.*)$",
"^@pages/(.*)$",
"^@hooks/(.*)$",
"^@assets/(.*)$",

"^@constants/(.*)$",
"^@utils/(.*)$",
"^@api/(.*)$",
"^@types/(.*)$",
"^@store/(.*)$",

"^@styles/(.*)$",
"^@shared/(.*)$",

"^(.*)/(.*)$"
],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@tanstack/react-query": "^5.51.11",
"axios": "^1.7.5",
"date-fns": "^4.1.0",
"dayjs": "^1.11.13",
"msw": "^2.3.5",
"react": "^18.3.1",
"react-datepicker": "^7.4.0",
Expand Down
14 changes: 11 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { Routes } from '@/app/routes';
import {
AllSeniorInfoProvider,
queryClient,
AuthProvider,
UserEmailProvider,
globalStyle,
SinittoInfoProvider,
} from '@/shared';
import { ChakraProvider } from '@chakra-ui/react';
import { Global } from '@emotion/react';
Expand All @@ -14,10 +15,12 @@ const App = () => {
<ChakraProvider>
<QueryClientProvider client={queryClient}>
<AllSeniorInfoProvider>
<AuthProvider>
<Global styles={globalStyle} />
<Routes />
</AuthProvider>
<SinittoInfoProvider>
<UserEmailProvider>
<Global styles={globalStyle} />
<Routes />
</UserEmailProvider>
</SinittoInfoProvider>
</AllSeniorInfoProvider>
</QueryClientProvider>
</ChakraProvider>
Expand Down
2 changes: 2 additions & 0 deletions src/app/routes/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ export const RouterPath = {
CALL_BACK_GUID_LINE: `:guideLineId`,
SENIOR_REGISTER: `/senior-register`,
SINITTO_REVIEW: `review`,

DUMMY_LOGIN: `/dummy`,
};
35 changes: 31 additions & 4 deletions src/app/routes/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import {
HelloCallReportPage,
SeniorRegisterPage,
CallBackListPage,
CallBackDetailPage, // SinittoGuideLinePage,
CallBackDetailPage,
SinittoGuideLinePage,
SinittoReviewPage,
HelloCallApplyPage,
GuardMainPage,
SinittoMainPage,
DummyRedirectPage,
} from '@/pages';
import { Layout } from '@/shared/components';

Expand Down Expand Up @@ -46,6 +48,16 @@ export const router = createBrowserRouter([
},
],
},
{
path: RouterPath.DUMMY_LOGIN,
element: <Layout title='더미 로그인 Redirect' />,
children: [
{
index: true,
element: <DummyRedirectPage />,
},
],
},
{
path: RouterPath.GUARD,
children: [
Expand Down Expand Up @@ -147,11 +159,26 @@ export const router = createBrowserRouter([
},
{
path: RouterPath.CALL_BACK_DETAIL,
element: <Layout title='요청 상세페이지' />,
children: [
{
index: true,
element: <CallBackDetailPage />,
path: '',
element: <Layout title='요청 상세페이지' />,
children: [
{
index: true,
element: <CallBackDetailPage />,
},
],
},
{
path: RouterPath.CALL_BACK_GUID_LINE,
element: <Layout title='요청 상세페이지' />,
children: [
{
index: true,
element: <SinittoGuideLinePage />,
},
],
},
],
},
Expand Down
File renamed without changes
File renamed without changes
57 changes: 57 additions & 0 deletions src/pages/common/dummy-redirect/DummyRedirectPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { RouterPath } from '@/app/routes';
import { Box, Text, Spinner, Heading } from '@chakra-ui/react';

export const DummyRedirectPage = () => {
const [statusMessage, setStatusMessage] = useState(
'유저 정보를 기다리고 있습니다...'
);
const [isLoading, setIsLoading] = useState(true);
const navigate = useNavigate();

useEffect(() => {
const params = new URLSearchParams(window.location.search);

const accessToken = params.get('accessToken');
const refreshToken = params.get('refreshToken');
const isSinitto = params.get('isSinitto');

if (accessToken && refreshToken && isSinitto) {
// 로컬 스토리지에 토큰 저장
localStorage.setItem('accessToken', accessToken);
localStorage.setItem('refreshToken', refreshToken);
localStorage.setItem('isSinitto', isSinitto);

// isSinitto 상태에 따른 메시지 설정
setStatusMessage(
isSinitto === 'true'
? '시니또 더미데이터로 로그인 중입니다. 페이지 이동 중...'
: '보호자 더미데이터로 로그인 중입니다. 페이지 이동 중...'
);

setTimeout(() => {
setIsLoading(false); // 로딩 완료
navigate(isSinitto === 'true' ? RouterPath.SINITTO : RouterPath.GUARD);
}, 2000);
} else {
console.error('Access or Refresh token not found in query parameters.');
setStatusMessage('[ERROR] 토큰이 존재하지 않습니다.');

setIsLoading(false);
}
}, [navigate]);

return (
<Box textAlign='center' mt='50px'>
<Heading as='h1' size='lg' mb='1rem'>
더미데이터 로그인
</Heading>
<Text fontSize='lg'>{statusMessage}</Text>
{(isLoading || statusMessage === '유저 정보를 기다리고 있습니다...') && (
<Spinner size='lg' mt='1rem' />
)}
</Box>
);
};
1 change: 1 addition & 0 deletions src/pages/common/dummy-redirect/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { DummyRedirectPage } from './DummyRedirectPage';
1 change: 1 addition & 0 deletions src/pages/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './dummy-redirect';
export * from './main';
export * from './redirect';
export * from './register';
8 changes: 5 additions & 3 deletions src/pages/common/main/components/login-button/LoginButton.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Link } from 'react-router-dom';

import Logo from '../../assets/kakao.svg';
import { KAKAO_AUTH_URL } from '@/shared/utils/env/config';
import Logo from '@/pages/assets/main/kakao.svg';
import { BASE_URI } from '@/shared/api';
import { Image, Text } from '@chakra-ui/react';
import styled from '@emotion/styled';

const LoginButton = () => {
const KAKAO_LOGIN = `${BASE_URI}/api/auth/oauth/kakao`;

return (
<Link to={KAKAO_AUTH_URL}>
<Link to={KAKAO_LOGIN}>
<KakaoLoginButton>
<Image src={Logo} alt='kakao-icon' />
<Text fontWeight='500'>카카오톡 로그인</Text>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/common/main/components/review-box/ReviewBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import StarIcon from '../../assets/star-icon.svg';
import StarIcon from '@/pages/assets/main/star-icon.svg';
import { Box, Image, Text } from '@chakra-ui/react';
import styled from '@emotion/styled';

Expand Down
1 change: 1 addition & 0 deletions src/pages/common/redirect/RedirectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const RedirectPage = () => {
const location = useLocation();

const code = new URLSearchParams(location.search).get('code');

if (!code) {
return <div>로그인을 다시 진행해주세요.</div>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom';

import { RouterPath } from '@/app/routes/path';
import { useGetKakaoCallback } from '@/pages';
import { useAuth } from '@/shared';
import { useUserEmail } from '@/shared';
import { Flex, Spinner, Text } from '@chakra-ui/react';

type Props = {
Expand All @@ -13,7 +13,7 @@ type Props = {
const RedirectSection = ({ code }: Props) => {
const navigate = useNavigate();

const { setEmail } = useAuth();
const { setEmail } = useUserEmail();

const { data } = useGetKakaoCallback(code);

Expand Down
6 changes: 2 additions & 4 deletions src/pages/common/register/RegisterPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { useForm } from 'react-hook-form';
import { RegisterFields, RegisterType, Tos } from './components';
import { useRegister } from './store/hooks';
import { FormValues } from './types';
import { parsePhoneNumber } from '@/shared';
import { BasicButton } from '@/shared/components';
import { useAuth } from '@/shared/provider/auth/Auth';
import { BasicButton, parsePhoneNumber, useUserEmail } from '@/shared';
import { Divider } from '@chakra-ui/react';
import styled from '@emotion/styled';

Expand All @@ -22,7 +20,7 @@ const RegisterPage = () => {
// 회원가입 처리
const mutation = useRegister();

const { email } = useAuth();
const { email } = useUserEmail();

const handleUserType = (id: string) => {
setUserType(id);
Expand Down
8 changes: 4 additions & 4 deletions src/pages/common/register/store/hooks/useRegister.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AxiosError } from 'axios';

import { registerUser, SignupApiResponse } from '../api';
import { RouterPath } from '@/app/routes/path';
import { authLocalStorage } from '@/shared/utils/storage';
import { authStorage } from '@/shared/utils/storage';
import { useMutation } from '@tanstack/react-query';

const useRegister = () => {
Expand All @@ -16,10 +16,10 @@ const useRegister = () => {
} else {
console.log(data);
if ('accessToken' in data) {
authLocalStorage.set(data.accessToken);
authLocalStorage.set(data.refreshToken);
authStorage.accessToken.set(data.accessToken);
authStorage.refreshToken.set(data.refreshToken);
alert('회원가입이 완료되었습니다.');
navigate(data.isSinitto === 'true' ? RouterPath.ROOT : RouterPath.ROOT);
navigate(data.isSinitto ? RouterPath.SINITTO : RouterPath.GUARD);
}
}
};
Expand Down
Loading

0 comments on commit 72c62c8

Please sign in to comment.