From b252959e122b62db8fa463c881030242ab06d315 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 Oct 2024 19:16:07 +0900 Subject: [PATCH 01/57] =?UTF-8?q?Fix(call-back):=20=EC=BD=9C=EB=B0=B1=20?= =?UTF-8?q?=EB=8B=A8=EA=B1=B4=20=EC=A1=B0=ED=9A=8C=20api=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=82=AC=ED=95=AD=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../call-back/detail/CallBackDetailPage.tsx | 21 +++++-------------- .../detail/components/menu/CallbackMenu.tsx | 15 +++++++++---- src/shared/types/callback.response.ts | 2 ++ 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/pages/sinitto/call-back/detail/CallBackDetailPage.tsx b/src/pages/sinitto/call-back/detail/CallBackDetailPage.tsx index 2f8c70a1..847bc5df 100644 --- a/src/pages/sinitto/call-back/detail/CallBackDetailPage.tsx +++ b/src/pages/sinitto/call-back/detail/CallBackDetailPage.tsx @@ -1,7 +1,6 @@ import { useEffect } from 'react'; import { useParams, Outlet, useNavigate } from 'react-router-dom'; -import { useGetAccepted } from './api/hooks'; import { CallbackMenu } from './components'; import { GuideLineList } from './components/guide-line-list'; import { RouterPath } from '@/app/routes/path'; @@ -34,16 +33,6 @@ export const CallBackDetailPage = () => { } }, [isCallBackError, callBackError, navigate]); - const { - data: currentReq, - isLoading: iscurrentReqLoading, - isError: iscurrentReqError, - } = useGetAccepted(); - const accept = - iscurrentReqError || !currentReq - ? false - : currentReq.callbackId == Number(callBackId); - return ( <> @@ -59,11 +48,11 @@ export const CallBackDetailPage = () => { /> - {iscurrentReqLoading ? ( - - ) : ( - - )} + ) )} diff --git a/src/pages/sinitto/call-back/detail/components/menu/CallbackMenu.tsx b/src/pages/sinitto/call-back/detail/components/menu/CallbackMenu.tsx index 6d91951d..5bfd8e9f 100644 --- a/src/pages/sinitto/call-back/detail/components/menu/CallbackMenu.tsx +++ b/src/pages/sinitto/call-back/detail/components/menu/CallbackMenu.tsx @@ -7,14 +7,21 @@ import { } from '../../api/hooks'; import { PostAcceptMenu } from '../../components/menu/post-accept'; import { PreAcceptMenu } from '../../components/menu/pre-accept'; +import { RouterPath } from '@/app/routes/path'; +import { formatPhoneNumber } from '@/shared'; import { Spinner } from '@chakra-ui/react'; type MenuProps = { callBackId: number; accept: boolean; + phoneNumber: string; }; -export const CallbackMenu = ({ callBackId, accept }: MenuProps) => { +export const CallbackMenu = ({ + callBackId, + accept, + phoneNumber, +}: MenuProps) => { const navigate = useNavigate(); const { @@ -32,7 +39,7 @@ export const CallbackMenu = ({ callBackId, accept }: MenuProps) => { isSuccess: isCompleteSuccess, } = useCompleteCallback(); if (isCompleteSuccess) { - navigate('/call-back'); // TODO: 완료 이후 이동 페이지 지정 필요 + navigate(RouterPath.SINITTO); } const { @@ -41,7 +48,7 @@ export const CallbackMenu = ({ callBackId, accept }: MenuProps) => { isSuccess: isCancelSuccess, } = useCancelCallback(); if (isCancelSuccess) { - navigate('/call-back'); // TODO: 취소 이후 이동 페이지 지정 필요 + navigate(RouterPath.CALL_BACK_LIST); } const isLoading = isAcceptLoading || isCancelLoading || isCompleteLoading; @@ -52,7 +59,7 @@ export const CallbackMenu = ({ callBackId, accept }: MenuProps) => { completeCallback(callBackId)} handleCancle={() => cancelCallback(callBackId)} - phoneNumber='010-1234-5678' // TODO: api로 콜백 조회 시 response에 전화번호 추가 필요 + phoneNumber={formatPhoneNumber(phoneNumber)} /> ) : ( acceptCallback(callBackId)} /> diff --git a/src/shared/types/callback.response.ts b/src/shared/types/callback.response.ts index 715b3568..b0fae4fd 100644 --- a/src/shared/types/callback.response.ts +++ b/src/shared/types/callback.response.ts @@ -4,4 +4,6 @@ export type CallbackResponse = { postTime: string; status: string; seniorId: number; + isAssignedToSelf: boolean; + seniorPhoneNumber: string; }; From cedce2facf2196730ab6dcf91acfe52ba18f2bb7 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 16:04:44 +0900 Subject: [PATCH 02/57] =?UTF-8?q?!Hotfix:=20=EC=84=9C=EB=B2=84=20=EC=A3=BC?= =?UTF-8?q?=EC=86=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/api/instance/Instance.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/api/instance/Instance.tsx b/src/shared/api/instance/Instance.tsx index 5ab6ac81..73b263d7 100644 --- a/src/shared/api/instance/Instance.tsx +++ b/src/shared/api/instance/Instance.tsx @@ -6,7 +6,6 @@ import type { import axios from 'axios'; import { authLocalStorage } from '@/shared'; -import { BASE_URI } from '@/shared/utils/env/config'; import { QueryClient } from '@tanstack/react-query'; const initInstance = (config: AxiosRequestConfig): AxiosInstance => { @@ -25,6 +24,8 @@ const initInstance = (config: AxiosRequestConfig): AxiosInstance => { return instance; }; +export const BASE_URI = `http://sinitto.site:8080`; + export const fetchInstance = initInstance({ baseURL: BASE_URI, }); From 1175dab5200b9a15a0d5cf191fe73b2842740ae2 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:05:38 +0900 Subject: [PATCH 03/57] =?UTF-8?q?Deploy:=20build=20test=EC=9A=A9=20ci=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1fb9ff2a..4e77bb4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: ESLint test +name: ESLint & Build Test on: pull_request: @@ -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 @@ -25,3 +30,8 @@ jobs: - name: Lint Code run: pnpm lint + + - name: Build Test + run: | + echo "build를 진행하여 배포시 오류가 발생하는지 확인합니다." + pnpm run build From cd28e1bb2cddccb2b0c1d8865ea97d1fefe12ec2 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:06:03 +0900 Subject: [PATCH 04/57] =?UTF-8?q?Refactor(main):=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=ED=8C=8C=EC=9D=BC=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/{common/main/assets => assets/main}/kakao.svg | 0 src/pages/{common/main/assets => assets/main}/star-icon.svg | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/pages/{common/main/assets => assets/main}/kakao.svg (100%) rename src/pages/{common/main/assets => assets/main}/star-icon.svg (100%) diff --git a/src/pages/common/main/assets/kakao.svg b/src/pages/assets/main/kakao.svg similarity index 100% rename from src/pages/common/main/assets/kakao.svg rename to src/pages/assets/main/kakao.svg diff --git a/src/pages/common/main/assets/star-icon.svg b/src/pages/assets/main/star-icon.svg similarity index 100% rename from src/pages/common/main/assets/star-icon.svg rename to src/pages/assets/main/star-icon.svg From c9635c22d0347a5b9333fe6fcb7774a7f6b68a06 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:07:11 +0900 Subject: [PATCH 05/57] =?UTF-8?q?Remove:=20=EC=84=9C=EB=B8=8C=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/utils/env | 1 - 1 file changed, 1 deletion(-) delete mode 160000 src/shared/utils/env diff --git a/src/shared/utils/env b/src/shared/utils/env deleted file mode 160000 index 2a0f73d6..00000000 --- a/src/shared/utils/env +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2a0f73d6acd23a0ed6836adac4bb909fbea387a3 From c6e6358a2c46ca0baeaffabe0fbc2be025dddc2a Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:07:34 +0900 Subject: [PATCH 06/57] =?UTF-8?q?Deploy:=20=EC=84=9C=EB=B8=8C=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EA=B4=80=EB=A0=A8=20=EB=AA=85=EB=A0=B9=EC=96=B4=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4b9d9652..f9b70120 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 @@ -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 From 659215d3fd74bcca362673717409c5a81588617d Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:08:35 +0900 Subject: [PATCH 07/57] =?UTF-8?q?Fix(main):=20=EC=9D=B4=EB=AF=B8=EC=A7=80?= =?UTF-8?q?=20=ED=8C=8C=EC=9D=BC=20=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/main/components/review-box/ReviewBox.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/common/main/components/review-box/ReviewBox.tsx b/src/pages/common/main/components/review-box/ReviewBox.tsx index 6c11e89e..9140ea84 100644 --- a/src/pages/common/main/components/review-box/ReviewBox.tsx +++ b/src/pages/common/main/components/review-box/ReviewBox.tsx @@ -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'; From 244ee5cd05441e2489e037158467507ade2d37e3 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:09:03 +0900 Subject: [PATCH 08/57] =?UTF-8?q?Refactor(main):=20=EC=B9=B4=EC=B9=B4?= =?UTF-8?q?=EC=98=A4=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=ED=98=B8=EC=B6=9C=20=EA=B2=BD=EB=A1=9C=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 --- .../common/main/components/login-button/LoginButton.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/common/main/components/login-button/LoginButton.tsx b/src/pages/common/main/components/login-button/LoginButton.tsx index e9047756..96434b63 100644 --- a/src/pages/common/main/components/login-button/LoginButton.tsx +++ b/src/pages/common/main/components/login-button/LoginButton.tsx @@ -1,13 +1,14 @@ import { Link } from 'react-router-dom'; import Logo from '../../assets/kakao.svg'; -import { KAKAO_AUTH_URL } from '@/shared/utils/env/config'; +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 ( - + kakao-icon 카카오톡 로그인 From a985eee08474ede1521983cb05bdc065e7c67ccc Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:09:53 +0900 Subject: [PATCH 09/57] =?UTF-8?q?Fix:=20=EC=88=9C=ED=99=98=EC=B0=B8?= =?UTF-8?q?=EC=A1=B0=20=EB=B0=A9=EC=A7=80=EB=A5=BC=20=EC=9C=84=ED=95=B4=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/api/instance/Instance.tsx | 2 +- src/shared/api/instance/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/api/instance/Instance.tsx b/src/shared/api/instance/Instance.tsx index 73b263d7..f1e237b1 100644 --- a/src/shared/api/instance/Instance.tsx +++ b/src/shared/api/instance/Instance.tsx @@ -5,7 +5,7 @@ import type { } from 'axios'; import axios from 'axios'; -import { authLocalStorage } from '@/shared'; +import { authLocalStorage } from '../../utils/storage/authLocalStorage'; import { QueryClient } from '@tanstack/react-query'; const initInstance = (config: AxiosRequestConfig): AxiosInstance => { diff --git a/src/shared/api/instance/index.ts b/src/shared/api/instance/index.ts index 07aed276..370c34a5 100644 --- a/src/shared/api/instance/index.ts +++ b/src/shared/api/instance/index.ts @@ -1 +1 @@ -export { fetchInstance, queryClient } from './Instance'; +export { fetchInstance, BASE_URI, queryClient } from './Instance'; From fe3f4fcb8f312776514390e326c81f5aa550e50d Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:10:10 +0900 Subject: [PATCH 10/57] =?UTF-8?q?Fix:=20import=20order=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 --- .prettierrc.json | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index 5d767d36..85b9dd5b 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -24,18 +24,9 @@ "", - "^@components/(.*)$", + "^@app/(.*)$", "^@pages/(.*)$", - "^@hooks/(.*)$", - "^@assets/(.*)$", - - "^@constants/(.*)$", - "^@utils/(.*)$", - "^@api/(.*)$", - "^@types/(.*)$", - "^@store/(.*)$", - - "^@styles/(.*)$", + "^@shared/(.*)$", "^(.*)/(.*)$" ], From 4e4786dbf3c225f5744fcceb752483dd9d4bfbc7 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:16:58 +0900 Subject: [PATCH 11/57] =?UTF-8?q?Chore:=20pnpm-lock=ED=8C=8C=EC=9D=BC=20pr?= =?UTF-8?q?ettier=20=EA=B2=80=EC=82=AC=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.prettierignore b/.prettierignore index 6df85bca..1ed1aff2 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,3 +2,5 @@ node_modules .vscode .github dist + +pnpm-lock.yaml \ No newline at end of file From dd0150a483f4df3f8033f334fe7761e5cb2f1989 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:18:38 +0900 Subject: [PATCH 12/57] =?UTF-8?q?Remove:=20=EC=84=9C=EB=B8=8C=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EA=B4=80=EB=A0=A8=20=ED=8C=8C=EC=9D=BC=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5ba7349c..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "src/shared/utils/env"] - path = src/shared/utils/env - url = https://github.com/Dobbymin/sinitto-submodule.git From 1b1b662b236ca9dc0472d47d08622ef9322b0f73 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:24:25 +0900 Subject: [PATCH 13/57] =?UTF-8?q?Fix(storage):=20refreshToken=20=EC=98=B5?= =?UTF-8?q?=EC=85=98=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20authStorage=20?= =?UTF-8?q?=EB=AA=85=EC=B9=AD=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/utils/storage/authLocalStorage.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/shared/utils/storage/authLocalStorage.ts b/src/shared/utils/storage/authLocalStorage.ts index 345799bc..9d8337bc 100644 --- a/src/shared/utils/storage/authLocalStorage.ts +++ b/src/shared/utils/storage/authLocalStorage.ts @@ -1,5 +1,6 @@ type StorageKey = { accessToken?: string; + refreshToken?: string; }; const initStorage = ( @@ -23,4 +24,7 @@ const initStorage = ( return { get, set }; }; -export const authLocalStorage = initStorage('accessToken', localStorage); +export const authStorage = { + accessToken: initStorage('accessToken', localStorage), + refreshToken: initStorage('refreshToken', localStorage), +}; From 5a69d953ef284a38070a500f16da8429ea6b1133 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:24:47 +0900 Subject: [PATCH 14/57] =?UTF-8?q?Fix(point):=20=EC=A4=91=EB=B3=B5=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EB=AA=85=EC=B9=AD=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/api/point/point.api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/api/point/point.api.ts b/src/shared/api/point/point.api.ts index a2c0e80c..3a7860a4 100644 --- a/src/shared/api/point/point.api.ts +++ b/src/shared/api/point/point.api.ts @@ -34,7 +34,7 @@ export const chargePoint = async ( price: number ): Promise => { const response = await fetchInstance.put(`${pointApiPath}/charge`, { - price: price, + price, }); return response.data; }; From d66d9bd472b1ccfe257f2a25ba21bf5cf836a9a6 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:35:45 +0900 Subject: [PATCH 15/57] =?UTF-8?q?Fix(main):=20=EC=B9=B4=EC=B9=B4=EC=98=A4?= =?UTF-8?q?=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20icon=20=EA=B2=BD=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/main/components/login-button/LoginButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/common/main/components/login-button/LoginButton.tsx b/src/pages/common/main/components/login-button/LoginButton.tsx index 96434b63..4bdfe25b 100644 --- a/src/pages/common/main/components/login-button/LoginButton.tsx +++ b/src/pages/common/main/components/login-button/LoginButton.tsx @@ -1,6 +1,6 @@ import { Link } from 'react-router-dom'; -import Logo from '../../assets/kakao.svg'; +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'; From 1b8f3360873e9107cfa30f31a3f5bbb8c2ff2a64 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:36:35 +0900 Subject: [PATCH 16/57] =?UTF-8?q?Refactor:=20authStorage=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=82=AC=ED=95=AD=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/register/store/hooks/useRegister.ts | 6 +++--- src/shared/api/instance/Instance.tsx | 4 ++-- .../utils/storage/{authLocalStorage.ts => authStorage.ts} | 0 src/shared/utils/storage/index.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename src/shared/utils/storage/{authLocalStorage.ts => authStorage.ts} (100%) diff --git a/src/pages/common/register/store/hooks/useRegister.ts b/src/pages/common/register/store/hooks/useRegister.ts index 0a904678..aa0c38fe 100644 --- a/src/pages/common/register/store/hooks/useRegister.ts +++ b/src/pages/common/register/store/hooks/useRegister.ts @@ -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 = () => { @@ -16,8 +16,8 @@ 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); } diff --git a/src/shared/api/instance/Instance.tsx b/src/shared/api/instance/Instance.tsx index f1e237b1..f19891b5 100644 --- a/src/shared/api/instance/Instance.tsx +++ b/src/shared/api/instance/Instance.tsx @@ -5,7 +5,7 @@ import type { } from 'axios'; import axios from 'axios'; -import { authLocalStorage } from '../../utils/storage/authLocalStorage'; +import { authStorage } from '../../utils/storage/authStorage'; import { QueryClient } from '@tanstack/react-query'; const initInstance = (config: AxiosRequestConfig): AxiosInstance => { @@ -43,7 +43,7 @@ export const queryClient = new QueryClient({ fetchInstance.interceptors.request.use( (config: InternalAxiosRequestConfig) => { - const accessToken = authLocalStorage.get(); + const accessToken = authStorage.accessToken.get(); if (accessToken !== undefined) { config.headers['Content-Type'] = 'application/json'; config.headers.Authorization = `Bearer ${accessToken}`; diff --git a/src/shared/utils/storage/authLocalStorage.ts b/src/shared/utils/storage/authStorage.ts similarity index 100% rename from src/shared/utils/storage/authLocalStorage.ts rename to src/shared/utils/storage/authStorage.ts diff --git a/src/shared/utils/storage/index.ts b/src/shared/utils/storage/index.ts index cae91c62..ca30e68e 100644 --- a/src/shared/utils/storage/index.ts +++ b/src/shared/utils/storage/index.ts @@ -1 +1 @@ -export { authLocalStorage } from './authLocalStorage'; +export { authStorage } from './authStorage'; From 2f8a06ddfc62b62bf27e8e206bf8ce0b71c9bd2f Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 27 Oct 2024 23:53:42 +0900 Subject: [PATCH 17/57] =?UTF-8?q?Refactor:=20provider=20=EB=AA=85=EC=B9=AD?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EA=B2=BD=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 6 ++-- .../redirect-section/RedirectSection.tsx | 4 +-- src/pages/common/register/RegisterPage.tsx | 6 ++-- src/shared/provider/auth/Auth.tsx | 26 ---------------- src/shared/provider/auth/index.ts | 1 - src/shared/provider/index.ts | 2 +- src/shared/provider/user-email/index.ts | 5 ++++ src/shared/provider/user-email/user-email.tsx | 30 +++++++++++++++++++ 8 files changed, 43 insertions(+), 37 deletions(-) delete mode 100644 src/shared/provider/auth/Auth.tsx delete mode 100644 src/shared/provider/auth/index.ts create mode 100644 src/shared/provider/user-email/index.ts create mode 100644 src/shared/provider/user-email/user-email.tsx diff --git a/src/App.tsx b/src/App.tsx index 8830c383..47c997ff 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,7 +2,7 @@ import { Routes } from '@/app/routes'; import { AllSeniorInfoProvider, queryClient, - AuthProvider, + UserEmailProvider, globalStyle, } from '@/shared'; import { ChakraProvider } from '@chakra-ui/react'; @@ -14,10 +14,10 @@ const App = () => { - + - + diff --git a/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx b/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx index 73ed7dc8..c92496a1 100644 --- a/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx +++ b/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx @@ -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 = { @@ -13,7 +13,7 @@ type Props = { const RedirectSection = ({ code }: Props) => { const navigate = useNavigate(); - const { setEmail } = useAuth(); + const { setEmail } = useUserEmail(); const { data } = useGetKakaoCallback(code); diff --git a/src/pages/common/register/RegisterPage.tsx b/src/pages/common/register/RegisterPage.tsx index 86e72830..2f666aaa 100644 --- a/src/pages/common/register/RegisterPage.tsx +++ b/src/pages/common/register/RegisterPage.tsx @@ -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'; @@ -22,7 +20,7 @@ const RegisterPage = () => { // 회원가입 처리 const mutation = useRegister(); - const { email } = useAuth(); + const { email } = useUserEmail(); const handleUserType = (id: string) => { setUserType(id); diff --git a/src/shared/provider/auth/Auth.tsx b/src/shared/provider/auth/Auth.tsx deleted file mode 100644 index 491b27d9..00000000 --- a/src/shared/provider/auth/Auth.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { createContext, ReactNode, useContext, useState } from 'react'; - -type AuthInfo = { - email: string | null; - setEmail: (email: string) => void; -}; - -export const AuthContext = createContext(undefined); - -export const AuthProvider = ({ children }: { children: ReactNode }) => { - const [email, setEmail] = useState(null); - - return ( - - {children} - - ); -}; - -export const useAuth = () => { - const context = useContext(AuthContext); - if (!context) { - throw new Error('useAuth는 AuthProvider 내부에서 사용되어야 합니다.'); - } - return context; -}; diff --git a/src/shared/provider/auth/index.ts b/src/shared/provider/auth/index.ts deleted file mode 100644 index 7710b448..00000000 --- a/src/shared/provider/auth/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { AuthContext, AuthProvider, useAuth } from './Auth'; diff --git a/src/shared/provider/index.ts b/src/shared/provider/index.ts index 9476e32e..e68e6671 100644 --- a/src/shared/provider/index.ts +++ b/src/shared/provider/index.ts @@ -1,2 +1,2 @@ -export * from './auth'; +export * from './user-email'; export * from './senior-info'; diff --git a/src/shared/provider/user-email/index.ts b/src/shared/provider/user-email/index.ts new file mode 100644 index 00000000..ed85bf19 --- /dev/null +++ b/src/shared/provider/user-email/index.ts @@ -0,0 +1,5 @@ +export { + UserEmailContext, + UserEmailProvider, + useUserEmail, +} from './user-email'; diff --git a/src/shared/provider/user-email/user-email.tsx b/src/shared/provider/user-email/user-email.tsx new file mode 100644 index 00000000..fbe8b844 --- /dev/null +++ b/src/shared/provider/user-email/user-email.tsx @@ -0,0 +1,30 @@ +import { createContext, ReactNode, useContext, useState } from 'react'; + +type UserEmailInfo = { + email: string | null; + setEmail: (email: string) => void; +}; + +export const UserEmailContext = createContext( + undefined +); + +export const UserEmailProvider = ({ children }: { children: ReactNode }) => { + const [email, setEmail] = useState(null); + + return ( + + {children} + + ); +}; + +export const useUserEmail = () => { + const context = useContext(UserEmailContext); + if (!context) { + throw new Error( + 'useUserEmail는 UserEmailProvider 내부에서 사용되어야 합니다.' + ); + } + return context; +}; From dfbebcd1b93e4cfebeee7233fbbc287ad1d834a5 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Mon, 28 Oct 2024 00:11:42 +0900 Subject: [PATCH 18/57] =?UTF-8?q?Refactor:=20guide=20line=20button=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=20=EC=88=98=EC=A0=95=20=EB=B0=8F=20chakra=20?= =?UTF-8?q?ui=20=EC=88=98=EC=A0=95,=20handler=20=EB=AA=85=EC=B9=AD=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guide-line-button/GuideLineButton.tsx | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/shared/components/common/guide-line-button/GuideLineButton.tsx b/src/shared/components/common/guide-line-button/GuideLineButton.tsx index b7d72e28..01ff1026 100644 --- a/src/shared/components/common/guide-line-button/GuideLineButton.tsx +++ b/src/shared/components/common/guide-line-button/GuideLineButton.tsx @@ -4,19 +4,13 @@ import { IconArrow } from '@/pages/assets'; import { Box, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; -type GuideLineCategory = { - title: string; - id: string | null; - backgroundColor: string; -}; - type Props = { marginTop?: number; marginBottom?: number; seniorId?: number | null; }; -const GUIDE_LINE_CATEGORIES: GuideLineCategory[] = [ +const GUIDE_LINE_CATEGORIES = [ { title: '택시 호출하기', id: 'TAXI', @@ -37,7 +31,9 @@ const GUIDE_LINE_CATEGORIES: GuideLineCategory[] = [ id: null, backgroundColor: '#ff4d68', }, -]; +] as const; + +type GuideLineCategory = (typeof GUIDE_LINE_CATEGORIES)[number]; export const GuideLineButton = ({ marginTop, @@ -47,7 +43,7 @@ export const GuideLineButton = ({ const navigate = useNavigate(); const location = useLocation(); - const handleClick = (id: string | null) => { + const goToSinitto = (id: string | null) => { if (id === null) { alert('개발 예정입니다.'); return; @@ -69,12 +65,12 @@ export const GuideLineButton = ({ }; return ( - - {GUIDE_LINE_CATEGORIES.map((data) => ( + + {GUIDE_LINE_CATEGORIES.map((data: GuideLineCategory) => ( handleClick(data.id)} + onClick={() => goToSinitto(data.id)} > {data.title} @@ -82,14 +78,10 @@ export const GuideLineButton = ({ ))} - + ); }; -const Wrapper = styled(Box)` - width: 100%; -`; - const ButtonWrapper = styled.div<{ backgroundColor: string }>` width: 100%; height: 70px; From 133369205f6e45cb18eb54d86ccda595896da873 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Mon, 28 Oct 2024 00:15:22 +0900 Subject: [PATCH 19/57] =?UTF-8?q?deploy:=20ci=20-=20=EC=84=A4=EB=AA=85=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e77bb4c..ccebdc0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,6 +32,4 @@ jobs: run: pnpm lint - name: Build Test - run: | - echo "build를 진행하여 배포시 오류가 발생하는지 확인합니다." - pnpm run build + run: pnpm run build From ae4179e9d4d7624197edb43050398b646316436f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Oct 2024 02:44:12 +0900 Subject: [PATCH 20/57] =?UTF-8?q?Fix(call-back):=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81=20(type=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=B3=80=EA=B2=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/sinitto/call-back/list/api/callback-list.api.ts | 4 ++-- src/pages/sinitto/call-back/list/api/get-call-backs.api.ts | 4 ++-- .../sinitto/call-back/list/api/types/callbacks.response.ts | 2 +- src/pages/sinitto/call-back/list/api/types/index.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/sinitto/call-back/list/api/callback-list.api.ts b/src/pages/sinitto/call-back/list/api/callback-list.api.ts index c904b9ac..a4f20b49 100644 --- a/src/pages/sinitto/call-back/list/api/callback-list.api.ts +++ b/src/pages/sinitto/call-back/list/api/callback-list.api.ts @@ -1,4 +1,4 @@ -import { CallbacksResponse } from './types'; +import { CallbackListResponse } from './types'; import { fetchInstance } from '@/shared/api/instance'; const getCallbackListPath = '/api/callbacks'; @@ -12,7 +12,7 @@ export const CallbackListQueryKey = (page: number, size: number) => [ export const getCallbackList = async ( page: number, size: number -): Promise => { +): Promise => { const response = await fetchInstance.get(getCallbackListPath, { params: { pageable: { diff --git a/src/pages/sinitto/call-back/list/api/get-call-backs.api.ts b/src/pages/sinitto/call-back/list/api/get-call-backs.api.ts index 3bd83f9b..f8a12730 100644 --- a/src/pages/sinitto/call-back/list/api/get-call-backs.api.ts +++ b/src/pages/sinitto/call-back/list/api/get-call-backs.api.ts @@ -1,10 +1,10 @@ -import type { CallbacksResponse } from './types'; +import type { CallbackListResponse } from './types'; import { fetchInstance } from '@/shared/api/instance'; const getCallbacksPath = () => `/api/callbacks`; export const getCallbacks = async (page: number, size: number) => { - const response = await fetchInstance.get( + const response = await fetchInstance.get( getCallbacksPath(), { params: { diff --git a/src/pages/sinitto/call-back/list/api/types/callbacks.response.ts b/src/pages/sinitto/call-back/list/api/types/callbacks.response.ts index 020b7af0..47b1eb43 100644 --- a/src/pages/sinitto/call-back/list/api/types/callbacks.response.ts +++ b/src/pages/sinitto/call-back/list/api/types/callbacks.response.ts @@ -1,6 +1,6 @@ import { CallbackResponse } from '@/shared/types'; -export type CallbacksResponse = { +export type CallbackListResponse = { totalElements: number; totalPages: number; first: boolean; diff --git a/src/pages/sinitto/call-back/list/api/types/index.ts b/src/pages/sinitto/call-back/list/api/types/index.ts index 77c2c660..5ec35e62 100644 --- a/src/pages/sinitto/call-back/list/api/types/index.ts +++ b/src/pages/sinitto/call-back/list/api/types/index.ts @@ -1 +1 @@ -export type { CallbacksResponse } from './callbacks.response'; +export type { CallbackListResponse } from './callbacks.response'; From ecb4c576ae578f9749354def719ad9f9c91c88e1 Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Mon, 28 Oct 2024 03:15:59 +0900 Subject: [PATCH 21/57] =?UTF-8?q?Style:=20=EA=B0=80=EC=9D=B4=EB=93=9C?= =?UTF-8?q?=EB=9D=BC=EC=9D=B8,=20=EC=8B=9C=EB=8B=88=EC=96=B4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=94=94=EC=9E=90?= =?UTF-8?q?=EC=9D=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/guard/guide-line/GuideLinePage.tsx | 40 ++++++++++++------- .../guide-info-box/GuideLineInfo.tsx | 8 ++-- .../GuidelineRegisterBox.tsx | 16 ++------ .../guard/register/SeniorRegisterPage.tsx | 30 ++++++++++---- .../senior-info-box/SeniorInfo.tsx | 4 +- .../senior-register-box/SeniorRegisterBox.tsx | 9 ++--- 6 files changed, 62 insertions(+), 45 deletions(-) diff --git a/src/pages/guard/guide-line/GuideLinePage.tsx b/src/pages/guard/guide-line/GuideLinePage.tsx index 6d84b10e..9bc64097 100644 --- a/src/pages/guard/guide-line/GuideLinePage.tsx +++ b/src/pages/guard/guide-line/GuideLinePage.tsx @@ -2,7 +2,7 @@ import { useParams } from 'react-router-dom'; import { useGetSeniorAllGuidelines } from './api'; import { GuideLineInfo, GuidelineRegisterBox } from './components'; -import { Box, Flex } from '@chakra-ui/react'; +import { Box, Flex, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; export type GuideLineDetailParams = { @@ -29,14 +29,27 @@ export const GuideLinePage = () => { return ( - + + + + + 등록한 가이드라인 + + + 총 {guidelineData?.length}개 + + {guidelineData?.map((guideline) => ( { /> ))} - ); }; const Container = styled(Box)` position: relative; - height: 100vh; + display: flex; + flex-direction: column; + align-items: center; `; diff --git a/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx b/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx index e7e300f6..fe86945f 100644 --- a/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx +++ b/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx @@ -48,7 +48,7 @@ const GuideLineInfo = ({ guideline, refetch, seniorId }: Props) => { return ( {isEditing ? ( - + { display='flex' flexDir='row' w='100%' - maxW='300px' + maxW='370px' justifyContent='space-between' alignItems='center' cursor='pointer' @@ -136,7 +136,7 @@ const GuideLineInfoContainer = styled(Flex)` flex-direction: column; justify-content: center; width: 100%; - max-width: 330px; + max-width: 370px; height: auto; background-color: var(--color-secondary); border: 1px solid var(--color-secondary); @@ -153,7 +153,7 @@ const InfoText = styled(Text)` const InfoBox = styled(Box)` width: 100%; - max-width: 300px; + max-width: 330px; display: flex; flex-direction: row; justify-content: space-between; diff --git a/src/pages/guard/guide-line/components/guide-register-box/GuidelineRegisterBox.tsx b/src/pages/guard/guide-line/components/guide-register-box/GuidelineRegisterBox.tsx index 1770ec94..3f944da4 100644 --- a/src/pages/guard/guide-line/components/guide-register-box/GuidelineRegisterBox.tsx +++ b/src/pages/guard/guide-line/components/guide-register-box/GuidelineRegisterBox.tsx @@ -61,13 +61,8 @@ const GuidelineRegisterBox = ({ refetch, seniorId, guidelineType }: Props) => { export default GuidelineRegisterBox; const RegisterBox = styled(Box)` - position: absolute; - bottom: 0; width: 100%; height: auto; - min-height: 350px; - left: 50%; - transform: translateX(-50%); max-width: 370px; display: flex; flex-direction: column; @@ -75,29 +70,26 @@ const RegisterBox = styled(Box)` background-color: var(--color-white-gray); border: 1px solid var(--color-white-gray); border-radius: 15px; + margin-top: 0.25rem; `; const InputBox = styled(Box)` width: 300px; - height: 80px; - display: flex; - flex-direction: column; - margin: 0.5rem; - margin-bottom: 1rem; + margin: 0.2rem; `; const StyledButton = styled.button` - position: absolute; - bottom: 0.5rem; width: 300px; height: 40px; background-color: #c69090; + font-weight: bold; color: #ffffff; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background-color 0.3s; + margin-bottom: 10px; &:hover { background-color: #a67070; diff --git a/src/pages/guard/register/SeniorRegisterPage.tsx b/src/pages/guard/register/SeniorRegisterPage.tsx index 60847a8f..dcbc6643 100644 --- a/src/pages/guard/register/SeniorRegisterPage.tsx +++ b/src/pages/guard/register/SeniorRegisterPage.tsx @@ -1,7 +1,7 @@ import { useGetAllSeniorInfo } from '../mypage'; import { SeniorInfo } from './components'; import SeniorRegisterBox from './components/senior-register-box/SeniorRegisterBox'; -import { Box, Flex } from '@chakra-ui/react'; +import { Box, Flex, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; export const SeniorRegisterPage = () => { @@ -17,29 +17,45 @@ export const SeniorRegisterPage = () => { return ( - + + + + + 등록한 시니어 + + + 총 {seniors?.length}명 + + + {seniors?.map((senior) => ( ))} - ); }; const Container = styled(Box)` position: relative; - height: 100vh; display: flex; flex-direction: column; + align-items: center; `; const SeniorInfoContainer = styled(Flex)` - flex-grow: 1; - overflow-y: auto; - height: 70vh; + width: 100%; + max-width: 370px; flex-direction: column; align-items: center; + border-radius: 10px; `; export default SeniorRegisterPage; diff --git a/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx b/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx index 8d6ce92a..b6a65dc1 100644 --- a/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx +++ b/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx @@ -126,7 +126,7 @@ const SeniorInfo = ({ const SeniorInfoContainer = styled(Flex)` width: 100%; - max-width: 330px; + max-width: 370px; height: 5rem; min-height: 5rem; background-color: var(--color-secondary); @@ -143,7 +143,7 @@ const InfoText = styled(Text)` const InfoBox = styled(Box)` width: 100%; - max-width: 300px; + max-width: 350px; display: flex; flex-direction: row; justify-content: space-between; diff --git a/src/pages/guard/register/components/senior-register-box/SeniorRegisterBox.tsx b/src/pages/guard/register/components/senior-register-box/SeniorRegisterBox.tsx index 18144347..528258f0 100644 --- a/src/pages/guard/register/components/senior-register-box/SeniorRegisterBox.tsx +++ b/src/pages/guard/register/components/senior-register-box/SeniorRegisterBox.tsx @@ -48,7 +48,7 @@ const SeniorRegisterBox = ({ refetch }: { refetch: () => void }) => { })} /> - 시니어 등록 + 시니어 등록하기 ); }; @@ -56,11 +56,8 @@ const SeniorRegisterBox = ({ refetch }: { refetch: () => void }) => { export default SeniorRegisterBox; const RegisterBox = styled(Box)` - position: relative; width: 100%; height: auto; - left: 50%; - transform: translateX(-50%); max-width: 370px; display: flex; flex-direction: column; @@ -68,17 +65,19 @@ const RegisterBox = styled(Box)` background-color: var(--color-white-gray); border: 1px solid var(--color-white-gray); border-radius: 15px; + margin-top: 0.25rem; `; const InputBox = styled(Box)` width: 300px; - margin: 0.5rem; + margin: 0.2rem; `; const StyledButton = styled.button` width: 300px; height: 40px; background-color: #c69090; + font-weight: bold; color: #ffffff; border: none; border-radius: 5px; From 57695e64d1903954065227175079096fd55c48e1 Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Mon, 28 Oct 2024 03:34:45 +0900 Subject: [PATCH 22/57] =?UTF-8?q?Refactor=20:=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?=EB=AA=A8=EB=93=9C=EC=97=90=EC=84=9C=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=EC=B7=A8=EC=86=8C=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20confirm=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guide-info-box/GuideLineInfo.tsx | 61 +++++++++++++------ .../senior-info-box/SeniorInfo.tsx | 61 +++++++++++++------ 2 files changed, 88 insertions(+), 34 deletions(-) diff --git a/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx b/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx index fe86945f..626716ad 100644 --- a/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx +++ b/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx @@ -31,7 +31,7 @@ const GuideLineInfo = ({ guideline, refetch, seniorId }: Props) => { setIsMore(!isMore); }; - const handleEdit = () => { + const editGuideline = () => { editMutation.mutate({ seniorId: seniorId, type: guideline.type, @@ -41,8 +41,12 @@ const GuideLineInfo = ({ guideline, refetch, seniorId }: Props) => { setIsEditing(false); }; - const handleDelete = () => { - deleteMutation.mutate(guideline.id); + const deleteGuideline = () => { + const isConfirmed = window.confirm('정말 가이드라인을 삭제하시겠습니까?'); + + if (isConfirmed) { + deleteMutation.mutate(guideline.id); + } }; return ( @@ -74,21 +78,44 @@ const GuideLineInfo = ({ guideline, refetch, seniorId }: Props) => { - 저장 + + 저장 + + setIsEditing(false)} + fontSize='0.9rem' + fontWeight={700} + cursor='pointer' + color='var(--color-primary)' + > + 취소 + ) : ( @@ -106,13 +133,13 @@ const GuideLineInfo = ({ guideline, refetch, seniorId }: Props) => { {guideline.title} - setIsEditing(true)} w={4} h={4} /> + diff --git a/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx b/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx index b6a65dc1..b2145c65 100644 --- a/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx +++ b/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx @@ -28,11 +28,15 @@ const SeniorInfo = ({ const deleteMutation = useDeleteSeniorInfo(refetch); const editMutation = useEditSeniorInfo(refetch); - const handleDelete = () => { - deleteMutation.mutate(senior.seniorId); + const deleteSenior = () => { + const isConfirmed = window.confirm('정말 시니어를 삭제하시겠습니까?'); + + if (isConfirmed) { + deleteMutation.mutate(senior.seniorId); + } }; - const handleEdit = () => { + const editSenior = () => { editMutation.mutate({ seniorId: senior.seniorId, seniorInfo: { seniorName, seniorPhoneNumber }, @@ -73,21 +77,44 @@ const SeniorInfo = ({ - 저장 + + 저장 + + setIsEditing(false)} + fontSize='0.9rem' + fontWeight={700} + cursor='pointer' + color='var(--color-primary)' + > + 취소 + ) : ( @@ -110,7 +137,7 @@ const SeniorInfo = ({ h={4} ml={1} cursor='pointer' - onClick={handleDelete} + onClick={deleteSenior} /> From 8b4b5d55941653ff96bb4aeb59a0351e9c323e64 Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Mon, 28 Oct 2024 19:52:53 +0900 Subject: [PATCH 23/57] =?UTF-8?q?Feat(guard-main):=20=EB=B3=B4=ED=98=B8?= =?UTF-8?q?=EC=9E=90=20=ED=99=88=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EB=84=A4=EB=B9=84=EA=B2=8C=EC=9D=B4=EC=85=98=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../guideline-list/GuideLineList.tsx | 1 + .../guard-main/components/header/Header.tsx | 10 +++++++--- .../hello-call-apply/HelloCallApply.tsx | 20 ++++++++++++------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/pages/guard/guard-main/components/guideline-list/GuideLineList.tsx b/src/pages/guard/guard-main/components/guideline-list/GuideLineList.tsx index 80b063a0..e8b08216 100644 --- a/src/pages/guard/guard-main/components/guideline-list/GuideLineList.tsx +++ b/src/pages/guard/guard-main/components/guideline-list/GuideLineList.tsx @@ -38,4 +38,5 @@ const NoticeTitle = styled(Text)` const NoticeText = styled(Text)` color: var(--color-gray); + font-size: 20px; `; diff --git a/src/pages/guard/guard-main/components/header/Header.tsx b/src/pages/guard/guard-main/components/header/Header.tsx index 18c784e1..9ebbd697 100644 --- a/src/pages/guard/guard-main/components/header/Header.tsx +++ b/src/pages/guard/guard-main/components/header/Header.tsx @@ -1,5 +1,7 @@ import { ChangeEvent, Dispatch, SetStateAction } from 'react'; +import { Link } from 'react-router-dom'; +import { RouterPath } from '@/app/routes'; import IconList from '@/pages/assets/guard-main/list.svg'; import IconUser from '@/pages/assets/shared/user.svg'; import { HEADER_HEIGHT, useAllSeniorInfo } from '@/shared'; @@ -27,8 +29,8 @@ export const Header = ({ currentSenior, setCurrentSenior }: HeaderProps) => { bg='var(--color-secondary)' border={0} color='var(--color-black)' - borderRadius={5} - fontSize='lg' + borderRadius={20} + fontSize='sm' fontWeight='700' size='sm' value={currentSenior?.toString() || ''} @@ -40,7 +42,9 @@ export const Header = ({ currentSenior, setCurrentSenior }: HeaderProps) => { ))} - icon-user + + icon-user + ); diff --git a/src/pages/guard/guard-main/components/hello-call-apply/HelloCallApply.tsx b/src/pages/guard/guard-main/components/hello-call-apply/HelloCallApply.tsx index 6fa7a793..506997ee 100644 --- a/src/pages/guard/guard-main/components/hello-call-apply/HelloCallApply.tsx +++ b/src/pages/guard/guard-main/components/hello-call-apply/HelloCallApply.tsx @@ -1,3 +1,6 @@ +import { Link } from 'react-router-dom'; + +import { RouterPath } from '@/app/routes'; import { IconArrow } from '@/pages/assets'; import HelloCallImg from '@/pages/assets/shared/hello-call.png'; import { Button, Flex, Image, Text } from '@chakra-ui/react'; @@ -10,13 +13,15 @@ export const HelloCallApply = () => { 안부 전화 서비스를 이용해보세요. 다정한 시니또들이 대신 말 벗이 되어드립니다. - - - 안부 전화 서비스 - 신청하기 - - - + + + + 안부 전화 서비스 + 신청하기 + + + + @@ -38,6 +43,7 @@ const NoticeTitle = styled(Text)` const NoticeText = styled(Text)` color: var(--color-gray); + font-size: 20px; `; const ContentWrapper = styled(Flex)` From 3f4413aa58d75fa2a9f8159d202fa9f47a4a915c Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Mon, 28 Oct 2024 21:12:21 +0900 Subject: [PATCH 24/57] =?UTF-8?q?Refactor(custom-hook):=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81(custom-hook=20?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=BD=94=EB=93=9C=20=EB=B6=84=EB=A6=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 1 + src/pages/guard/guide-line/api/hooks/index.ts | 1 + .../guide-line/api/hooks/useGuidelineInfo.ts | 78 +++++++++++++++++++ .../guide-info-box/GuideLineInfo.tsx | 51 ++++++------ src/pages/guard/register/api/hooks/index.ts | 1 + .../guard/register/api/hooks/useSeniorInfo.ts | 69 ++++++++++++++++ .../senior-info-box/SeniorInfo.tsx | 43 +++++----- src/shared/api/point/point.api.ts | 2 +- .../components/features/header/Header.tsx | 4 +- src/shared/hooks/point/useChargePoint.ts | 4 +- 10 files changed, 196 insertions(+), 58 deletions(-) create mode 100644 src/pages/guard/guide-line/api/hooks/useGuidelineInfo.ts create mode 100644 src/pages/guard/register/api/hooks/useSeniorInfo.ts diff --git a/.eslintrc.json b/.eslintrc.json index 41f68a8c..3c659ee0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,6 +4,7 @@ "es2021": true }, "extends": [ + "@typescript-eslint/parser", "plugin:prettier/recommended", "plugin:@typescript-eslint/recommended", "plugin:react/recommended", diff --git a/src/pages/guard/guide-line/api/hooks/index.ts b/src/pages/guard/guide-line/api/hooks/index.ts index 9349033c..cd2ecd3d 100644 --- a/src/pages/guard/guide-line/api/hooks/index.ts +++ b/src/pages/guard/guide-line/api/hooks/index.ts @@ -3,3 +3,4 @@ export { useGetSeniorAllGuidelines } from './useGetSeniorAllGuideines'; export { useModifyGuideline } from './useModifyGuideline'; export { useAddGuideline } from './useAddGuideline'; export { useDeleteGuideline } from './useDeleteGuideline'; +export { useGuidelineInfo } from './useGuidelineInfo'; diff --git a/src/pages/guard/guide-line/api/hooks/useGuidelineInfo.ts b/src/pages/guard/guide-line/api/hooks/useGuidelineInfo.ts new file mode 100644 index 00000000..0a6df5a7 --- /dev/null +++ b/src/pages/guard/guide-line/api/hooks/useGuidelineInfo.ts @@ -0,0 +1,78 @@ +import { useState } from 'react'; + +import { ModifyGuidelineRequest } from '../modify-guideline.api'; +import { UseMutationResult } from '@tanstack/react-query'; + +type GuidelineInfo = { + id: number; + type: string; + title: string; + content: string; +}; + +type UseGuidelineInfoProps = { + guideline: GuidelineInfo; + seniorId: number; + editMutation: UseMutationResult; + deleteMutation: UseMutationResult; +}; + +type UseGuidelineInfoReturn = { + isMore: boolean; + isEditing: boolean; + guidelineTitle: string; + guidelineContent: string; + toggleContent: () => void; + setIsEditing: (value: boolean) => void; + setGuidelineTitle: (value: string) => void; + setGuidelineContent: (value: string) => void; + editGuideline: () => void; + deleteGuideline: () => void; +}; + +export const useGuidelineInfo = ({ + guideline, + seniorId, + editMutation, + deleteMutation, +}: UseGuidelineInfoProps): UseGuidelineInfoReturn => { + const [isMore, setIsMore] = useState(false); + const [isEditing, setIsEditing] = useState(false); + const [guidelineTitle, setGuidelineTitle] = useState(guideline.title); + const [guidelineContent, setGuidelineContent] = useState(guideline.content); + + const toggleContent = () => { + setIsMore(!isMore); + }; + + const editGuideline = () => { + editMutation.mutate({ + seniorId: seniorId, + type: guideline.type, + title: guidelineTitle, + content: guidelineContent, + }); + setIsEditing(false); + }; + + const deleteGuideline = () => { + const isConfirmed = window.confirm('정말 가이드라인을 삭제하시겠습니까?'); + + if (isConfirmed) { + deleteMutation.mutate(guideline.id); + } + }; + + return { + isMore, + isEditing, + guidelineTitle, + guidelineContent, + toggleContent, + setIsEditing, + setGuidelineTitle, + setGuidelineContent, + editGuideline, + deleteGuideline, + }; +}; diff --git a/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx b/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx index 626716ad..970bbea5 100644 --- a/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx +++ b/src/pages/guard/guide-line/components/guide-info-box/GuideLineInfo.tsx @@ -1,6 +1,8 @@ -import { useState } from 'react'; - -import { useDeleteGuideline, useModifyGuideline } from '@/pages/guard'; +import { + useDeleteGuideline, + useGuidelineInfo, + useModifyGuideline, +} from '@/pages/guard'; import { arrowIcon, deleteIcon, editIcon } from '@/shared/assets'; import { Box, Flex, Text, Image, Input } from '@chakra-ui/react'; import styled from '@emotion/styled'; @@ -19,35 +21,26 @@ type Props = { }; const GuideLineInfo = ({ guideline, refetch, seniorId }: Props) => { - const [isMore, setIsMore] = useState(false); - const [isEditing, setIsEditing] = useState(false); - const [guidelineTitle, setGuidelineTitle] = useState(guideline.title); - const [guidelineContent, setGuidelineContent] = useState(guideline.content); - const editMutation = useModifyGuideline(refetch, guideline.id); const deleteMutation = useDeleteGuideline(refetch, guideline.id); - const toggleContent = () => { - setIsMore(!isMore); - }; - - const editGuideline = () => { - editMutation.mutate({ - seniorId: seniorId, - type: guideline.type, - title: guidelineTitle, - content: guidelineContent, - }); - setIsEditing(false); - }; - - const deleteGuideline = () => { - const isConfirmed = window.confirm('정말 가이드라인을 삭제하시겠습니까?'); - - if (isConfirmed) { - deleteMutation.mutate(guideline.id); - } - }; + const { + isMore, + isEditing, + guidelineTitle, + guidelineContent, + toggleContent, + setIsEditing, + setGuidelineTitle, + setGuidelineContent, + editGuideline, + deleteGuideline, + } = useGuidelineInfo({ + guideline, + seniorId, + editMutation, + deleteMutation, + }); return ( diff --git a/src/pages/guard/register/api/hooks/index.ts b/src/pages/guard/register/api/hooks/index.ts index a772528f..5407c6ed 100644 --- a/src/pages/guard/register/api/hooks/index.ts +++ b/src/pages/guard/register/api/hooks/index.ts @@ -1,3 +1,4 @@ export { useAddSeniorInfo } from './useAddSeniorInfo'; export { useDeleteSeniorInfo } from './useDeleteSeniorInfo'; export { useEditSeniorInfo } from './useEditSeniorInfo'; +export { useSeniorInfo } from './useSeniorInfo'; diff --git a/src/pages/guard/register/api/hooks/useSeniorInfo.ts b/src/pages/guard/register/api/hooks/useSeniorInfo.ts new file mode 100644 index 00000000..c51245cf --- /dev/null +++ b/src/pages/guard/register/api/hooks/useSeniorInfo.ts @@ -0,0 +1,69 @@ +import { useState } from 'react'; + +import { SeniorRegisterValues as SeniorRegisterRequest } from '../types/senior-register.type'; +import { UseMutationResult } from '@tanstack/react-query'; + +type SeniorInfoType = { + seniorName: string; + seniorPhoneNumber: string; + seniorId: number; +}; + +type UseSeniorInfoProps = { + senior: SeniorInfoType; + deleteMutation: UseMutationResult; + editMutation: UseMutationResult< + string, + Error, + { seniorId: number; seniorInfo: SeniorRegisterRequest } + >; +}; + +type UseSeniorInfoReturn = { + isEditing: boolean; + seniorName: string; + seniorPhoneNumber: string; + setIsEditing: (value: boolean) => void; + setSeniorName: (value: string) => void; + setSeniorPhoneNumber: (value: string) => void; + deleteSenior: () => void; + editSenior: () => void; +}; + +export const useSeniorInfo = ({ + senior, + deleteMutation, + editMutation, +}: UseSeniorInfoProps): UseSeniorInfoReturn => { + const [isEditing, setIsEditing] = useState(false); + const [seniorName, setSeniorName] = useState(senior.seniorName); + const [seniorPhoneNumber, setSeniorPhoneNumber] = useState( + senior.seniorPhoneNumber + ); + + const deleteSenior = () => { + const isConfirmed = window.confirm('해당 시니어를 삭제하시겠습니까?'); + if (isConfirmed) { + deleteMutation.mutate(senior.seniorId); + } + }; + + const editSenior = () => { + editMutation.mutate({ + seniorId: senior.seniorId, + seniorInfo: { seniorName, seniorPhoneNumber }, + }); + setIsEditing(false); + }; + + return { + isEditing, + seniorName, + seniorPhoneNumber, + setIsEditing, + setSeniorName, + setSeniorPhoneNumber, + deleteSenior, + editSenior, + }; +}; diff --git a/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx b/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx index b2145c65..39840046 100644 --- a/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx +++ b/src/pages/guard/register/components/senior-info/senior-info-box/SeniorInfo.tsx @@ -1,6 +1,8 @@ -import { useState } from 'react'; - -import { useDeleteSeniorInfo, useEditSeniorInfo } from '../../../api'; +import { + useDeleteSeniorInfo, + useEditSeniorInfo, + useSeniorInfo, +} from '@/pages/guard'; import { formatPhoneNumber } from '@/shared'; import { deleteIcon, editIcon } from '@/shared/assets'; import { Box, Flex, Text, Image, Input } from '@chakra-ui/react'; @@ -19,30 +21,23 @@ const SeniorInfo = ({ senior: SeniorInfoType; refetch: () => void; }) => { - const [isEditing, setIsEditing] = useState(false); - const [seniorName, setSeniorName] = useState(senior.seniorName); - const [seniorPhoneNumber, setSeniorPhoneNumber] = useState( - senior.seniorPhoneNumber - ); - const deleteMutation = useDeleteSeniorInfo(refetch); const editMutation = useEditSeniorInfo(refetch); - const deleteSenior = () => { - const isConfirmed = window.confirm('정말 시니어를 삭제하시겠습니까?'); - - if (isConfirmed) { - deleteMutation.mutate(senior.seniorId); - } - }; - - const editSenior = () => { - editMutation.mutate({ - seniorId: senior.seniorId, - seniorInfo: { seniorName, seniorPhoneNumber }, - }); - setIsEditing(false); - }; + const { + isEditing, + seniorName, + seniorPhoneNumber, + setIsEditing, + setSeniorName, + setSeniorPhoneNumber, + deleteSenior, + editSenior, + } = useSeniorInfo({ + senior, + deleteMutation, + editMutation, + }); return ( => { // 포인트 인출 API export const withdrawPoint = async (price: number) => { const response = await fetchInstance.post(`${pointApiPath}/withdraw`, { - price: price, + price, }); return response.data; }; diff --git a/src/shared/components/features/header/Header.tsx b/src/shared/components/features/header/Header.tsx index e4d28c7c..22c08374 100644 --- a/src/shared/components/features/header/Header.tsx +++ b/src/shared/components/features/header/Header.tsx @@ -18,7 +18,7 @@ type Props = { const Header = ({ title, defaultBackPath = RouterPath.ROOT }: Props) => { const navigate = useNavigate(); - const handleBackClick = () => { + const goToBack = () => { if (window.history.length > 1) { navigate(-1); } else { @@ -28,7 +28,7 @@ const Header = ({ title, defaultBackPath = RouterPath.ROOT }: Props) => { return ( - + {title} diff --git a/src/shared/hooks/point/useChargePoint.ts b/src/shared/hooks/point/useChargePoint.ts index 2be690af..69c1b93a 100644 --- a/src/shared/hooks/point/useChargePoint.ts +++ b/src/shared/hooks/point/useChargePoint.ts @@ -9,8 +9,8 @@ export const useChargePoint = (): UseMutationResult< > => { return useMutation({ mutationFn: (price) => chargePoint(price), - onSuccess: (data: ChargePointResponse) => { - alert(data.depositMessage); + onSuccess: () => { + alert('포인트 충전 요청 완료했습니다.'); }, onError: (error: Error) => { console.error(error); From 986475a0a868a6b03fda513f5a05d51911127ddf Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 Oct 2024 01:29:14 +0900 Subject: [PATCH 25/57] =?UTF-8?q?Fix(call-back):=20=EC=BD=9C=EB=B0=B1=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EA=B0=80=EC=9D=B4=EB=93=9C=EB=9D=BC?= =?UTF-8?q?=EC=9D=B8=20=EC=A1=B0=ED=9A=8C=20api=20=EB=B0=8F=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/routes/index.tsx | 15 ++++++++++ .../guide-line/SinittoGuideLinePage.tsx | 29 +++++++------------ .../guide-line/api/get-guideline.api.ts | 9 +++--- .../guide-line/api/hooks/useGetGuideline.ts | 8 ++--- .../api/types/guideline.response.ts | 1 + .../components/container/Container.tsx | 2 +- .../guide-line/components/container/index.ts | 2 +- 7 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/app/routes/index.tsx b/src/app/routes/index.tsx index 1f07f52a..9b69d44c 100644 --- a/src/app/routes/index.tsx +++ b/src/app/routes/index.tsx @@ -153,6 +153,21 @@ export const router = createBrowserRouter([ }, ], }, + { + path: RouterPath.CALL_BACK_LIST, + element: , + children: [ + { + path: RouterPath.CALL_BACK_DETAIL, + children: [ + { + path: RouterPath.CALL_BACK_GUID_LINE, + element: , + }, + ], + }, + ], + }, { path: RouterPath.SINITTO_REVIEW, element: , diff --git a/src/pages/sinitto/guide-line/SinittoGuideLinePage.tsx b/src/pages/sinitto/guide-line/SinittoGuideLinePage.tsx index 5dfa173b..fd6e8856 100644 --- a/src/pages/sinitto/guide-line/SinittoGuideLinePage.tsx +++ b/src/pages/sinitto/guide-line/SinittoGuideLinePage.tsx @@ -3,12 +3,12 @@ import { useParams, useNavigate } from 'react-router-dom'; import { useGetGuideline } from './api/hooks'; import { GuidelineResponse } from './api/types'; +import { GuideLineContainer } from './components'; import { CATEGORIES } from './data'; import { Category } from './types'; import { RouterPath } from '@/app/routes/path'; -import { useGetCallback } from '@/shared/api/hooks'; import { handleCallbackError } from '@/shared/utils'; -import { Container, Spinner } from '@chakra-ui/react'; +import { Spinner } from '@chakra-ui/react'; import styled from '@emotion/styled'; type GuideLineParams = { @@ -22,32 +22,23 @@ export const SinittoGuideLinePage = () => { const guideLineInfo = CATEGORIES.find((item: Category) => item.id === guideLineId)?.name || null; - const { - data: callBack, - isLoading: isCallBackLoading, - isError: isCallBackError, - error: callBackError, - } = useGetCallback(callBackId); - const seniorId = - !isCallBackLoading && callBack ? callBack.seniorId : undefined; - const { data: guideLine, isLoading: isGuideLineLoading, isError: isGuideLineError, - } = useGetGuideline(Number(seniorId), guideLineId); + } = useGetGuideline(Number(callBackId), guideLineId); useEffect(() => { - if (isCallBackError) { - const errorMessage = handleCallbackError(callBackError); + if (isGuideLineError) { + const errorMessage = handleCallbackError(isGuideLineError); alert(errorMessage); navigate(RouterPath.CALL_BACK_LIST); } - }, [isCallBackError, callBackError, navigate]); + }, [isGuideLineError, isGuideLineError, navigate]); return ( - {isCallBackLoading || isGuideLineLoading ? ( + {isGuideLineLoading ? ( ) : ( <> @@ -61,9 +52,9 @@ export const SinittoGuideLinePage = () => { (guideLine.length == 0 ? (

등록된 가이드라인이 없습니다.

) : ( - guideLine.map((data: GuidelineResponse, index: number) => ( - ( + diff --git a/src/pages/sinitto/guide-line/api/get-guideline.api.ts b/src/pages/sinitto/guide-line/api/get-guideline.api.ts index 4bc12141..f3d4cbea 100644 --- a/src/pages/sinitto/guide-line/api/get-guideline.api.ts +++ b/src/pages/sinitto/guide-line/api/get-guideline.api.ts @@ -1,12 +1,13 @@ import type { GuidelineResponse } from './types'; import { fetchInstance } from '@/shared/api/instance'; -const getGuidelinesPath = (seniorId: number, type: string) => - `/api/guardguidelines/${seniorId}/${type}`; +const getGuidelinesPath = (callbackId: number, type: string) => + `/api/guardguidelines/sinitto/${callbackId}/${type}`; -export const getGuidelines = async (seniorId: number, type: string) => { +export const getGuidelines = async (callbackId: number, type: string) => { const response = await fetchInstance.get( - getGuidelinesPath(seniorId, type) + getGuidelinesPath(callbackId, type) ); + return response.data; }; diff --git a/src/pages/sinitto/guide-line/api/hooks/useGetGuideline.ts b/src/pages/sinitto/guide-line/api/hooks/useGetGuideline.ts index 57ffd458..a4a80d38 100644 --- a/src/pages/sinitto/guide-line/api/hooks/useGetGuideline.ts +++ b/src/pages/sinitto/guide-line/api/hooks/useGetGuideline.ts @@ -1,10 +1,10 @@ import { getGuidelines } from '../get-guideline.api'; import { useQuery } from '@tanstack/react-query'; -export const useGetGuideline = (seniorId: number, type: string) => { +export const useGetGuideline = (callbackId: number, type: string) => { return useQuery({ - queryKey: ['Guideline', seniorId, type], - queryFn: () => getGuidelines(seniorId, type), - enabled: !!seniorId && !!type, + queryKey: ['Guideline', callbackId, type], + queryFn: () => getGuidelines(callbackId, type), + enabled: !!callbackId && !!type, }); }; diff --git a/src/pages/sinitto/guide-line/api/types/guideline.response.ts b/src/pages/sinitto/guide-line/api/types/guideline.response.ts index d1c38418..99bd34f3 100644 --- a/src/pages/sinitto/guide-line/api/types/guideline.response.ts +++ b/src/pages/sinitto/guide-line/api/types/guideline.response.ts @@ -2,4 +2,5 @@ export type GuidelineResponse = { type: string; title: string; content: string; + id: number; }; diff --git a/src/pages/sinitto/guide-line/components/container/Container.tsx b/src/pages/sinitto/guide-line/components/container/Container.tsx index dbabdcec..c68a2d2d 100644 --- a/src/pages/sinitto/guide-line/components/container/Container.tsx +++ b/src/pages/sinitto/guide-line/components/container/Container.tsx @@ -5,7 +5,7 @@ type Props = { content: string; }; -export const Container = ({ title, content }: Props) => { +export const GuideLineContainer = ({ title, content }: Props) => { return ( {title} diff --git a/src/pages/sinitto/guide-line/components/container/index.ts b/src/pages/sinitto/guide-line/components/container/index.ts index b3999f02..bda3ec81 100644 --- a/src/pages/sinitto/guide-line/components/container/index.ts +++ b/src/pages/sinitto/guide-line/components/container/index.ts @@ -1 +1 @@ -export { Container } from './Container'; +export { GuideLineContainer } from './Container'; From 7a14ba1ba4ef5b0b63d7d71ca5729f2e25e504ef Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Tue, 29 Oct 2024 23:16:56 +0900 Subject: [PATCH 26/57] =?UTF-8?q?Feat(login):=20=EB=B0=B0=ED=8F=AC?= =?UTF-8?q?=EB=90=9C=20=EC=A3=BC=EC=86=8C=EB=A1=9C=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/main/MainPage.tsx | 4 +++- .../main/components/login-button/LoginButton.tsx | 12 ++++++++++-- .../components/redirect-section/RedirectSection.tsx | 10 +++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/pages/common/main/MainPage.tsx b/src/pages/common/main/MainPage.tsx index 5c7c0022..33eeb5db 100644 --- a/src/pages/common/main/MainPage.tsx +++ b/src/pages/common/main/MainPage.tsx @@ -3,6 +3,8 @@ import { Box, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; const MainPage = () => { + const ORIGIN_URI = window.location.origin; + return ( @@ -15,7 +17,7 @@ const MainPage = () => { - + ); diff --git a/src/pages/common/main/components/login-button/LoginButton.tsx b/src/pages/common/main/components/login-button/LoginButton.tsx index 4bdfe25b..0abbf706 100644 --- a/src/pages/common/main/components/login-button/LoginButton.tsx +++ b/src/pages/common/main/components/login-button/LoginButton.tsx @@ -5,8 +5,16 @@ 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`; +type Props = { + originURI: string; +}; + +const LoginButton = ({ originURI }: Props) => { + const FRONTEND_REDIRECT_URI = + 'http://sinitto.s3-website.ap-northeast-2.amazonaws.com/redirect'; + + const KAKAO_LOGIN = `${BASE_URI}/api/auth/oauth/kakao?redirect_uri=${FRONTEND_REDIRECT_URI}&origin=${originURI}`; + return ( diff --git a/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx b/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx index c92496a1..20f7de92 100644 --- a/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx +++ b/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx @@ -1,5 +1,5 @@ import { useEffect } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; import { RouterPath } from '@/app/routes/path'; import { useGetKakaoCallback } from '@/pages'; @@ -12,6 +12,9 @@ type Props = { const RedirectSection = ({ code }: Props) => { const navigate = useNavigate(); + const location = useLocation(); + + const origin = new URLSearchParams(location.search).get('origin'); const { setEmail } = useUserEmail(); @@ -31,10 +34,11 @@ const RedirectSection = ({ code }: Props) => { if (accessToken) { const path = data.isSinitto ? RouterPath.SINITTO : RouterPath.GUARD; - navigate(path); + // navigate(path); + window.location.href = `${origin}${path}`; } } - }, [data, navigate, setEmail]); + }, [data, navigate, setEmail, origin]); return ( Date: Wed, 30 Oct 2024 00:46:24 +0900 Subject: [PATCH 27/57] =?UTF-8?q?Fix(login):=20=EC=88=98=EC=A0=95=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EB=A1=A4=EB=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/main/MainPage.tsx | 4 +--- .../main/components/login-button/LoginButton.tsx | 11 ++--------- src/pages/common/redirect/RedirectPage.tsx | 1 + .../components/redirect-section/RedirectSection.tsx | 10 +++------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/pages/common/main/MainPage.tsx b/src/pages/common/main/MainPage.tsx index 33eeb5db..5c7c0022 100644 --- a/src/pages/common/main/MainPage.tsx +++ b/src/pages/common/main/MainPage.tsx @@ -3,8 +3,6 @@ import { Box, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; const MainPage = () => { - const ORIGIN_URI = window.location.origin; - return ( @@ -17,7 +15,7 @@ const MainPage = () => { - + ); diff --git a/src/pages/common/main/components/login-button/LoginButton.tsx b/src/pages/common/main/components/login-button/LoginButton.tsx index 0abbf706..cf0cf3c3 100644 --- a/src/pages/common/main/components/login-button/LoginButton.tsx +++ b/src/pages/common/main/components/login-button/LoginButton.tsx @@ -5,15 +5,8 @@ import { BASE_URI } from '@/shared/api'; import { Image, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; -type Props = { - originURI: string; -}; - -const LoginButton = ({ originURI }: Props) => { - const FRONTEND_REDIRECT_URI = - 'http://sinitto.s3-website.ap-northeast-2.amazonaws.com/redirect'; - - const KAKAO_LOGIN = `${BASE_URI}/api/auth/oauth/kakao?redirect_uri=${FRONTEND_REDIRECT_URI}&origin=${originURI}`; +const LoginButton = () => { + const KAKAO_LOGIN = `${BASE_URI}/api/auth/oauth/kakao`; return ( diff --git a/src/pages/common/redirect/RedirectPage.tsx b/src/pages/common/redirect/RedirectPage.tsx index d793cd3d..99ea9f90 100644 --- a/src/pages/common/redirect/RedirectPage.tsx +++ b/src/pages/common/redirect/RedirectPage.tsx @@ -6,6 +6,7 @@ const RedirectPage = () => { const location = useLocation(); const code = new URLSearchParams(location.search).get('code'); + if (!code) { return
로그인을 다시 진행해주세요.
; } diff --git a/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx b/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx index 20f7de92..c92496a1 100644 --- a/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx +++ b/src/pages/common/redirect/components/redirect-section/RedirectSection.tsx @@ -1,5 +1,5 @@ import { useEffect } from 'react'; -import { useLocation, useNavigate } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import { RouterPath } from '@/app/routes/path'; import { useGetKakaoCallback } from '@/pages'; @@ -12,9 +12,6 @@ type Props = { const RedirectSection = ({ code }: Props) => { const navigate = useNavigate(); - const location = useLocation(); - - const origin = new URLSearchParams(location.search).get('origin'); const { setEmail } = useUserEmail(); @@ -34,11 +31,10 @@ const RedirectSection = ({ code }: Props) => { if (accessToken) { const path = data.isSinitto ? RouterPath.SINITTO : RouterPath.GUARD; - // navigate(path); - window.location.href = `${origin}${path}`; + navigate(path); } } - }, [data, navigate, setEmail, origin]); + }, [data, navigate, setEmail]); return ( Date: Wed, 30 Oct 2024 02:54:32 +0900 Subject: [PATCH 28/57] =?UTF-8?q?Feat(sinitto-main):=20=EC=BD=9C=EB=B0=B1?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/call-back-apply/CallBackApply.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pages/sinitto/sinitto-main/components/common/call-back-apply/CallBackApply.tsx b/src/pages/sinitto/sinitto-main/components/common/call-back-apply/CallBackApply.tsx index 2becfe5f..6ff6d02e 100644 --- a/src/pages/sinitto/sinitto-main/components/common/call-back-apply/CallBackApply.tsx +++ b/src/pages/sinitto/sinitto-main/components/common/call-back-apply/CallBackApply.tsx @@ -1,3 +1,6 @@ +import { Link } from 'react-router-dom'; + +import { RouterPath } from '@/app/routes'; import { IconArrow } from '@/pages/assets'; import IconCall from '@/pages/assets/sinitto-main/call.svg'; import { ResponseBox } from '@/pages/sinitto'; @@ -12,12 +15,14 @@ export const CallBackApply = () => { 콜백 요청 - - - 요청 더보기 - - - + + + + 요청 더보기 + + + + call-icon From c2222e1ac00be43d8f7e74dcce2b2e9be6e1dd48 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 02:55:20 +0900 Subject: [PATCH 29/57] =?UTF-8?q?Feat(sinitto-main):=20=EC=95=88=EB=B6=80?= =?UTF-8?q?=EC=A0=84=ED=99=94=20=EB=AA=A9=EB=A1=9D=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=9D=B4=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/hello-call-apply/HelloCallApply.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pages/sinitto/sinitto-main/components/common/hello-call-apply/HelloCallApply.tsx b/src/pages/sinitto/sinitto-main/components/common/hello-call-apply/HelloCallApply.tsx index 506843b3..b3cb5741 100644 --- a/src/pages/sinitto/sinitto-main/components/common/hello-call-apply/HelloCallApply.tsx +++ b/src/pages/sinitto/sinitto-main/components/common/hello-call-apply/HelloCallApply.tsx @@ -1,3 +1,6 @@ +import { Link } from 'react-router-dom'; + +import { RouterPath } from '@/app/routes'; import { IconArrow } from '@/pages/assets'; import HelloCallImg from '@/pages/assets/shared/hello-call.png'; import { ResponseBox } from '@/pages/sinitto'; @@ -12,12 +15,14 @@ export const HelloCallApply = () => { 안부전화 요청 - - - 요청 더보기 - - - + + + + 요청 더보기 + + + + call-icon From 708540ab4d116d1a96d1e292f95a78924115659c Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 03:21:45 +0900 Subject: [PATCH 30/57] =?UTF-8?q?Feat(sinitto-main):=20=EC=8B=9C=EB=8B=88?= =?UTF-8?q?=EB=98=90=20=EC=9D=B4=EB=A6=84=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EB=B6=84=EB=A6=AC=20=EB=B0=8F=20api=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sinitto/sinitto-main/SinittoMainPage.tsx | 17 +++++++---------- .../common/sinitto-name/SinittoName.tsx | 17 +++++++++++++++++ .../components/common/sinitto-name/index.ts | 1 + src/pages/sinitto/sinitto-main/index.ts | 1 + 4 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 src/pages/sinitto/sinitto-main/components/common/sinitto-name/SinittoName.tsx create mode 100644 src/pages/sinitto/sinitto-main/components/common/sinitto-name/index.ts diff --git a/src/pages/sinitto/sinitto-main/SinittoMainPage.tsx b/src/pages/sinitto/sinitto-main/SinittoMainPage.tsx index c867df29..ff174776 100644 --- a/src/pages/sinitto/sinitto-main/SinittoMainPage.tsx +++ b/src/pages/sinitto/sinitto-main/SinittoMainPage.tsx @@ -1,19 +1,16 @@ -import { CallBackApply, Header, HelloCallApply } from './components'; -import { Flex, Text } from '@chakra-ui/react'; +import { + CallBackApply, + Header, + HelloCallApply, + SinittoName, +} from './components'; import styled from '@emotion/styled'; export const SinittoMainPage = () => { return (
- - - 김시니또 - - - 님 안녕하세요! - - + diff --git a/src/pages/sinitto/sinitto-main/components/common/sinitto-name/SinittoName.tsx b/src/pages/sinitto/sinitto-main/components/common/sinitto-name/SinittoName.tsx new file mode 100644 index 00000000..c86dd153 --- /dev/null +++ b/src/pages/sinitto/sinitto-main/components/common/sinitto-name/SinittoName.tsx @@ -0,0 +1,17 @@ +import { useSinittoInfo } from '@/shared'; +import { Flex, Text } from '@chakra-ui/react'; + +export const SinittoName = () => { + const { data } = useSinittoInfo(); + + return ( + + + {data?.name} + + + 님 안녕하세요! + + + ); +}; diff --git a/src/pages/sinitto/sinitto-main/components/common/sinitto-name/index.ts b/src/pages/sinitto/sinitto-main/components/common/sinitto-name/index.ts new file mode 100644 index 00000000..de7680f6 --- /dev/null +++ b/src/pages/sinitto/sinitto-main/components/common/sinitto-name/index.ts @@ -0,0 +1 @@ +export { SinittoName } from './SinittoName'; diff --git a/src/pages/sinitto/sinitto-main/index.ts b/src/pages/sinitto/sinitto-main/index.ts index 6a5c4b34..152917ff 100644 --- a/src/pages/sinitto/sinitto-main/index.ts +++ b/src/pages/sinitto/sinitto-main/index.ts @@ -1,3 +1,4 @@ export { SinittoMainPage } from './SinittoMainPage'; +export * from './api'; export * from './components'; From ac32c7af479b6902bbe7a2197da1fd71f16663f2 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 03:21:59 +0900 Subject: [PATCH 31/57] =?UTF-8?q?Feat(sinitto-main):=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9D=B4=EB=8F=99=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sinitto-main/components/common/header/Header.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/sinitto/sinitto-main/components/common/header/Header.tsx b/src/pages/sinitto/sinitto-main/components/common/header/Header.tsx index 57173bf2..f51fbc51 100644 --- a/src/pages/sinitto/sinitto-main/components/common/header/Header.tsx +++ b/src/pages/sinitto/sinitto-main/components/common/header/Header.tsx @@ -1,3 +1,6 @@ +import { Link } from 'react-router-dom'; + +import { RouterPath } from '@/app/routes'; import IconUser from '@/pages/assets/shared/user.svg'; import { HEADER_HEIGHT } from '@/shared'; import { Image } from '@chakra-ui/react'; @@ -6,7 +9,9 @@ import styled from '@emotion/styled'; export const Header = () => { return ( - icon-user + + icon-user + ); }; From ae23c2b02813db21d9f81de6f03a010dbace2d71 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 03:22:41 +0900 Subject: [PATCH 32/57] =?UTF-8?q?Feat(sinitto-main):=20=EC=8B=9C=EB=8B=88?= =?UTF-8?q?=EB=98=90=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20api=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/sinitto/sinitto-main/api/hooks/index.ts | 1 + src/pages/sinitto/sinitto-main/api/index.ts | 4 ++++ src/pages/sinitto/sinitto-main/api/sinitto-info.api.ts | 10 ++++++++++ src/pages/sinitto/sinitto-main/api/types/index.ts | 1 + .../sinitto-main/api/types/sinitto-info.response.ts | 7 +++++++ 5 files changed, 23 insertions(+) create mode 100644 src/pages/sinitto/sinitto-main/api/hooks/index.ts create mode 100644 src/pages/sinitto/sinitto-main/api/index.ts create mode 100644 src/pages/sinitto/sinitto-main/api/sinitto-info.api.ts create mode 100644 src/pages/sinitto/sinitto-main/api/types/index.ts create mode 100644 src/pages/sinitto/sinitto-main/api/types/sinitto-info.response.ts diff --git a/src/pages/sinitto/sinitto-main/api/hooks/index.ts b/src/pages/sinitto/sinitto-main/api/hooks/index.ts new file mode 100644 index 00000000..819a0cf1 --- /dev/null +++ b/src/pages/sinitto/sinitto-main/api/hooks/index.ts @@ -0,0 +1 @@ +export { useGetSinittoInfo } from './useGetSinittoInfo'; diff --git a/src/pages/sinitto/sinitto-main/api/index.ts b/src/pages/sinitto/sinitto-main/api/index.ts new file mode 100644 index 00000000..36f6f976 --- /dev/null +++ b/src/pages/sinitto/sinitto-main/api/index.ts @@ -0,0 +1,4 @@ +export { getSinittoInfo, sinittoInfoPath } from './sinitto-info.api'; + +export * from './types'; +export * from './hooks'; diff --git a/src/pages/sinitto/sinitto-main/api/sinitto-info.api.ts b/src/pages/sinitto/sinitto-main/api/sinitto-info.api.ts new file mode 100644 index 00000000..dbeaa2e4 --- /dev/null +++ b/src/pages/sinitto/sinitto-main/api/sinitto-info.api.ts @@ -0,0 +1,10 @@ +import { SinittoInfoResponse } from './types'; +import { fetchInstance } from '@/shared'; + +export const sinittoInfoPath = () => `/api/sinitto`; + +export const getSinittoInfo = async (): Promise => { + const response = + await fetchInstance.get(sinittoInfoPath()); + return response.data; +}; diff --git a/src/pages/sinitto/sinitto-main/api/types/index.ts b/src/pages/sinitto/sinitto-main/api/types/index.ts new file mode 100644 index 00000000..9a1d4016 --- /dev/null +++ b/src/pages/sinitto/sinitto-main/api/types/index.ts @@ -0,0 +1 @@ +export type { SinittoInfoResponse } from './sinitto-info.response'; diff --git a/src/pages/sinitto/sinitto-main/api/types/sinitto-info.response.ts b/src/pages/sinitto/sinitto-main/api/types/sinitto-info.response.ts new file mode 100644 index 00000000..4a31330d --- /dev/null +++ b/src/pages/sinitto/sinitto-main/api/types/sinitto-info.response.ts @@ -0,0 +1,7 @@ +export type SinittoInfoResponse = { + name: string; + phoneNumber: string; + email: string; + accountNumber: string; + bankName: string; +}; From 03c46ee6ab845afdeb35c1f44ff98da32e012e42 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 03:22:49 +0900 Subject: [PATCH 33/57] =?UTF-8?q?Feat(sinitto-main):=20=EC=8B=9C=EB=8B=88?= =?UTF-8?q?=EB=98=90=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20api=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20hook=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sinitto-main/api/hooks/useGetSinittoInfo.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/pages/sinitto/sinitto-main/api/hooks/useGetSinittoInfo.ts diff --git a/src/pages/sinitto/sinitto-main/api/hooks/useGetSinittoInfo.ts b/src/pages/sinitto/sinitto-main/api/hooks/useGetSinittoInfo.ts new file mode 100644 index 00000000..0bc9f310 --- /dev/null +++ b/src/pages/sinitto/sinitto-main/api/hooks/useGetSinittoInfo.ts @@ -0,0 +1,12 @@ +import { getSinittoInfo, sinittoInfoPath } from '../sinitto-info.api'; +import { SinittoInfoResponse } from '../types'; +import { useQuery } from '@tanstack/react-query'; + +const SinittoInfoQueryKey = [sinittoInfoPath()]; + +export const useGetSinittoInfo = () => { + return useQuery({ + queryKey: SinittoInfoQueryKey, + queryFn: () => getSinittoInfo(), + }); +}; From f99f84985f877eb0f1a42ea4af405a7ea4f79b7e Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 03:23:10 +0900 Subject: [PATCH 34/57] =?UTF-8?q?Feat(sinitto-main):=20=EC=8B=9C=EB=8B=88?= =?UTF-8?q?=EB=98=90=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20api=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20provider=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sinitto-main/components/common/index.ts | 1 + src/shared/provider/index.ts | 1 + .../provider/sinitto-info/SinittoInfo.tsx | 26 +++++++++++++++++++ src/shared/provider/sinitto-info/index.ts | 1 + 4 files changed, 29 insertions(+) create mode 100644 src/shared/provider/sinitto-info/SinittoInfo.tsx create mode 100644 src/shared/provider/sinitto-info/index.ts diff --git a/src/pages/sinitto/sinitto-main/components/common/index.ts b/src/pages/sinitto/sinitto-main/components/common/index.ts index 49ab53ba..195ad234 100644 --- a/src/pages/sinitto/sinitto-main/components/common/index.ts +++ b/src/pages/sinitto/sinitto-main/components/common/index.ts @@ -1,3 +1,4 @@ export * from './call-back-apply'; export * from './header'; export * from './hello-call-apply'; +export * from './sinitto-name'; diff --git a/src/shared/provider/index.ts b/src/shared/provider/index.ts index e68e6671..ba826f9b 100644 --- a/src/shared/provider/index.ts +++ b/src/shared/provider/index.ts @@ -1,2 +1,3 @@ export * from './user-email'; +export * from './sinitto-info'; export * from './senior-info'; diff --git a/src/shared/provider/sinitto-info/SinittoInfo.tsx b/src/shared/provider/sinitto-info/SinittoInfo.tsx new file mode 100644 index 00000000..ba7dea04 --- /dev/null +++ b/src/shared/provider/sinitto-info/SinittoInfo.tsx @@ -0,0 +1,26 @@ +import { createContext, useContext, ReactNode } from 'react'; + +import { SinittoInfoResponse, useGetSinittoInfo } from '@/pages'; +import { UseQueryResult } from '@tanstack/react-query'; + +type SinittoInfoType = UseQueryResult; + +const SinittoInfo = createContext(undefined); + +export const SinittoInfoProvider = ({ children }: { children: ReactNode }) => { + const sinittoInfo = useGetSinittoInfo(); + + return ( + {children} + ); +}; + +export const useSinittoInfo = (): SinittoInfoType => { + const context = useContext(SinittoInfo); + if (context === undefined) { + throw new Error( + 'useSinittoInfo hook은 SinittoInfoProvider 내부에서 사용되어야 합니다.' + ); + } + return context; +}; diff --git a/src/shared/provider/sinitto-info/index.ts b/src/shared/provider/sinitto-info/index.ts new file mode 100644 index 00000000..89e7a198 --- /dev/null +++ b/src/shared/provider/sinitto-info/index.ts @@ -0,0 +1 @@ +export { SinittoInfoProvider, useSinittoInfo } from './SinittoInfo'; From 12a286c46c14b01caa15be56d976846059cf9986 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 03:23:18 +0900 Subject: [PATCH 35/57] =?UTF-8?q?Feat(sinitto-main):=20=EC=8B=9C=EB=8B=88?= =?UTF-8?q?=EB=98=90=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20api=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20provider=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 47c997ff..076a432a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,6 +4,7 @@ import { queryClient, UserEmailProvider, globalStyle, + SinittoInfoProvider, } from '@/shared'; import { ChakraProvider } from '@chakra-ui/react'; import { Global } from '@emotion/react'; @@ -14,10 +15,12 @@ const App = () => { - - - - + + + + + + From 488ec4b88e3ad6e7cc01555c53f9813f0a7988d9 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 03:42:09 +0900 Subject: [PATCH 36/57] =?UTF-8?q?Refactor(mypage):=20=ED=8F=B4=EB=8D=94=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mypage/{store => api}/hooks/index.ts | 1 - .../{store => api}/hooks/useSinittoInfo.ts | 20 ++------ src/pages/sinitto/mypage/api/index.ts | 7 +++ .../mypage/api/sinitto-information.api.ts | 26 +++++++++++ src/pages/sinitto/mypage/api/types/index.ts | 4 ++ src/pages/sinitto/mypage/store/api/index.ts | 1 - .../store/api/sinitto-information.api.ts | 46 ------------------- .../sinitto/mypage/store/servers/index.ts | 0 8 files changed, 40 insertions(+), 65 deletions(-) rename src/pages/sinitto/mypage/{store => api}/hooks/index.ts (78%) rename src/pages/sinitto/mypage/{store => api}/hooks/useSinittoInfo.ts (62%) create mode 100644 src/pages/sinitto/mypage/api/index.ts create mode 100644 src/pages/sinitto/mypage/api/sinitto-information.api.ts create mode 100644 src/pages/sinitto/mypage/api/types/index.ts delete mode 100644 src/pages/sinitto/mypage/store/api/index.ts delete mode 100644 src/pages/sinitto/mypage/store/api/sinitto-information.api.ts delete mode 100644 src/pages/sinitto/mypage/store/servers/index.ts diff --git a/src/pages/sinitto/mypage/store/hooks/index.ts b/src/pages/sinitto/mypage/api/hooks/index.ts similarity index 78% rename from src/pages/sinitto/mypage/store/hooks/index.ts rename to src/pages/sinitto/mypage/api/hooks/index.ts index ab383c3b..4e7c8152 100644 --- a/src/pages/sinitto/mypage/store/hooks/index.ts +++ b/src/pages/sinitto/mypage/api/hooks/index.ts @@ -1,5 +1,4 @@ export { - useGetSinittoInformation, useModifySinittoBankInfomation, useModifySinittoInformation, } from './useSinittoInfo'; diff --git a/src/pages/sinitto/mypage/store/hooks/useSinittoInfo.ts b/src/pages/sinitto/mypage/api/hooks/useSinittoInfo.ts similarity index 62% rename from src/pages/sinitto/mypage/store/hooks/useSinittoInfo.ts rename to src/pages/sinitto/mypage/api/hooks/useSinittoInfo.ts index 1577ce4e..d5f93021 100644 --- a/src/pages/sinitto/mypage/store/hooks/useSinittoInfo.ts +++ b/src/pages/sinitto/mypage/api/hooks/useSinittoInfo.ts @@ -1,23 +1,9 @@ -import { getSinittoInformation } from '../api'; import { - getSinittoInformationQueryKey, modifySinittoBankInfomation, modifySinittoInfomation, - SinittoBankInfo, - SinittoInformation, -} from '../api/sinitto-information.api'; -import { - useMutation, - UseMutationResult, - useQuery, -} from '@tanstack/react-query'; - -export const useGetSinittoInformation = () => { - return useQuery({ - queryKey: getSinittoInformationQueryKey, - queryFn: () => getSinittoInformation(), - }); -}; +} from '../sinitto-information.api'; +import { SinittoBankInfo, SinittoInformation } from '../types'; +import { useMutation, UseMutationResult } from '@tanstack/react-query'; export const useModifySinittoBankInfomation = (): UseMutationResult< string, diff --git a/src/pages/sinitto/mypage/api/index.ts b/src/pages/sinitto/mypage/api/index.ts new file mode 100644 index 00000000..852dcd03 --- /dev/null +++ b/src/pages/sinitto/mypage/api/index.ts @@ -0,0 +1,7 @@ +export { + modifySinittoBankInfomation, + modifySinittoInfomation, +} from './sinitto-information.api'; + +export * from './types'; +export * from './hooks'; diff --git a/src/pages/sinitto/mypage/api/sinitto-information.api.ts b/src/pages/sinitto/mypage/api/sinitto-information.api.ts new file mode 100644 index 00000000..cb22d693 --- /dev/null +++ b/src/pages/sinitto/mypage/api/sinitto-information.api.ts @@ -0,0 +1,26 @@ +import { SinittoBankInfo, SinittoInformation } from './types'; +import { fetchInstance } from '@/shared'; + +const sinittoInformationPath = () => '/api/sinittos'; + +// 계좌 정보 수정 +export const modifySinittoBankInfomation = async ( + bankInfo: SinittoBankInfo +) => { + const response = await fetchInstance.put( + `${sinittoInformationPath()}/bank`, + bankInfo + ); + return response.data; +}; + +// 본인 정보 수정 +export const modifySinittoInfomation = async ( + sinittoInfo: SinittoInformation +) => { + const response = await fetchInstance.put( + sinittoInformationPath(), + sinittoInfo + ); + return response.data; +}; diff --git a/src/pages/sinitto/mypage/api/types/index.ts b/src/pages/sinitto/mypage/api/types/index.ts new file mode 100644 index 00000000..677e7d8f --- /dev/null +++ b/src/pages/sinitto/mypage/api/types/index.ts @@ -0,0 +1,4 @@ +export type { + SinittoInformation, + SinittoBankInfo, +} from './sinitto-infromation.response'; diff --git a/src/pages/sinitto/mypage/store/api/index.ts b/src/pages/sinitto/mypage/store/api/index.ts deleted file mode 100644 index b86aa3db..00000000 --- a/src/pages/sinitto/mypage/store/api/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { getSinittoInformation } from './sinitto-information.api'; diff --git a/src/pages/sinitto/mypage/store/api/sinitto-information.api.ts b/src/pages/sinitto/mypage/store/api/sinitto-information.api.ts deleted file mode 100644 index 495eda88..00000000 --- a/src/pages/sinitto/mypage/store/api/sinitto-information.api.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { fetchInstance } from '@/shared/api/instance'; - -export type SinittoInformation = { - name: string; - email: string; - phoneNumber: string; - accountNumber: string; - bankName: string; -}; - -export type SinittoBankInfo = { - accountNumber: string; - bankName: string; -}; - -const sinittoInformationPath = () => '/api/sinittos'; - -export const getSinittoInformationQueryKey = ['sinittoInformation']; - -// 본인 정보 조회 -export const getSinittoInformation = async (): Promise => { - const response = await fetchInstance.get(sinittoInformationPath()); - return response.data; -}; - -// 계좌 정보 수정 -export const modifySinittoBankInfomation = async ( - bankInfo: SinittoBankInfo -) => { - const response = await fetchInstance.put( - `${sinittoInformationPath()}/bank`, - bankInfo - ); - return response.data; -}; - -// 본인 정보 수정 -export const modifySinittoInfomation = async ( - sinittoInfo: SinittoInformation -) => { - const response = await fetchInstance.put( - sinittoInformationPath(), - sinittoInfo - ); - return response.data; -}; diff --git a/src/pages/sinitto/mypage/store/servers/index.ts b/src/pages/sinitto/mypage/store/servers/index.ts deleted file mode 100644 index e69de29b..00000000 From d60e550301bdf6776595bad5d4a429b875b19518 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 03:42:37 +0900 Subject: [PATCH 37/57] =?UTF-8?q?Refactor(mypage):=20response=20type=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mypage/api/types/sinitto-infromation.response.ts | 12 ++++++++++++ src/pages/sinitto/mypage/index.ts | 1 + 2 files changed, 13 insertions(+) create mode 100644 src/pages/sinitto/mypage/api/types/sinitto-infromation.response.ts diff --git a/src/pages/sinitto/mypage/api/types/sinitto-infromation.response.ts b/src/pages/sinitto/mypage/api/types/sinitto-infromation.response.ts new file mode 100644 index 00000000..cd17197d --- /dev/null +++ b/src/pages/sinitto/mypage/api/types/sinitto-infromation.response.ts @@ -0,0 +1,12 @@ +export type SinittoInformation = { + name: string; + email: string; + phoneNumber: string; + accountNumber: string; + bankName: string; +}; + +export type SinittoBankInfo = { + accountNumber: string; + bankName: string; +}; diff --git a/src/pages/sinitto/mypage/index.ts b/src/pages/sinitto/mypage/index.ts index 3ec89341..39427722 100644 --- a/src/pages/sinitto/mypage/index.ts +++ b/src/pages/sinitto/mypage/index.ts @@ -1,4 +1,5 @@ export { default as SinittoMypage } from './SinittoMypage'; export * from './components'; +export * from './api'; export * from './data'; From 102e3bca6a4005a870a4f691922a48e4a04949a7 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 03:43:21 +0900 Subject: [PATCH 38/57] =?UTF-8?q?Refactor(mypage):=20=EB=82=B4=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20provider=20=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=20=EB=B0=8F=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/sinitto/mypage/SinittoMypage.tsx | 5 +- .../account-info-box/AccountInfoBox.tsx | 65 ++++++------------- .../profile-box/SinittoProfileBox.tsx | 16 ++--- 3 files changed, 29 insertions(+), 57 deletions(-) diff --git a/src/pages/sinitto/mypage/SinittoMypage.tsx b/src/pages/sinitto/mypage/SinittoMypage.tsx index 25206498..1a04b555 100644 --- a/src/pages/sinitto/mypage/SinittoMypage.tsx +++ b/src/pages/sinitto/mypage/SinittoMypage.tsx @@ -2,7 +2,7 @@ import { useState } from 'react'; import { SinittoProfileBox, AccountInfoBox } from './components'; import { BasicButton, PointBox, PointLogBox } from '@/shared/components'; -import { Box } from '@chakra-ui/react'; +import { Flex } from '@chakra-ui/react'; import styled from '@emotion/styled'; const SinittoMypage = () => { @@ -41,8 +41,7 @@ const SinittoMypage = () => { export default SinittoMypage; -const MyPageLayout = styled(Box)` - display: flex; +const MyPageLayout = styled(Flex)` flex-direction: column; align-items: center; `; diff --git a/src/pages/sinitto/mypage/components/account-info-box/AccountInfoBox.tsx b/src/pages/sinitto/mypage/components/account-info-box/AccountInfoBox.tsx index f39c0b2a..abc076f6 100644 --- a/src/pages/sinitto/mypage/components/account-info-box/AccountInfoBox.tsx +++ b/src/pages/sinitto/mypage/components/account-info-box/AccountInfoBox.tsx @@ -1,10 +1,8 @@ import { useEffect, useState } from 'react'; -import { - useGetSinittoInformation, - useModifySinittoBankInfomation, -} from '../../store/hooks'; -import { Box, Text, Button, Input } from '@chakra-ui/react'; +import { useModifySinittoBankInfomation } from '@/pages'; +import { useSinittoInfo } from '@/shared'; +import { Text, Button, Input, Flex } from '@chakra-ui/react'; import styled from '@emotion/styled'; type Props = { @@ -13,7 +11,7 @@ type Props = { }; const AccountInfoBox = ({ isEditing, setIsEditing }: Props) => { - const { data, isLoading, isError, refetch } = useGetSinittoInformation(); + const { data, refetch } = useSinittoInfo(); const modifyBankInfoMutation = useModifySinittoBankInfomation(); const [accountNumber, setAccountNumber] = useState(''); @@ -38,20 +36,12 @@ const AccountInfoBox = ({ isEditing, setIsEditing }: Props) => { ); }; - if (isLoading) return
로딩 중...
; - if (isError) return
데이터를 가져오는 데 오류가 발생했습니다.
; - return ( - + @@ -72,17 +62,11 @@ const AccountInfoBox = ({ isEditing, setIsEditing }: Props) => { {data?.accountNumber} )} - - + + @@ -99,37 +83,31 @@ const AccountInfoBox = ({ isEditing, setIsEditing }: Props) => { bg='var(--color-white)' /> ) : ( - + {data?.bankName} )} - - + + 계좌 인증 여부 - - 인증 완료 + + {data?.accountNumber ? '인증 완료' : '인증 미완료'} - - + + {isEditing ? ( <> ) : null} - + ); }; export default AccountInfoBox; -const AccountBoxLayout = styled(Box)` - display: flex; +const AccountBoxLayout = styled(Flex)` flex-direction: column; justify-content: center; background-color: #f2f2f2; diff --git a/src/pages/sinitto/mypage/components/profile-box/SinittoProfileBox.tsx b/src/pages/sinitto/mypage/components/profile-box/SinittoProfileBox.tsx index 40488e81..1b62bf70 100644 --- a/src/pages/sinitto/mypage/components/profile-box/SinittoProfileBox.tsx +++ b/src/pages/sinitto/mypage/components/profile-box/SinittoProfileBox.tsx @@ -1,9 +1,7 @@ import { useEffect, useState } from 'react'; -import { - useGetSinittoInformation, - useModifySinittoInformation, -} from '../../store/hooks'; +import { useModifySinittoInformation } from '@/pages'; +import { useSinittoInfo } from '@/shared'; import { Box, Text, Button, Input } from '@chakra-ui/react'; import styled from '@emotion/styled'; @@ -13,12 +11,13 @@ type Props = { }; const SinittoProfileBox = ({ isEditing, setIsEditing }: Props) => { - const { data, isLoading, isError, refetch } = useGetSinittoInformation(); - const modifySinittoInfoMutation = useModifySinittoInformation(); - const [name, setName] = useState(''); const [phoneNumber, setPhoneNumber] = useState(''); + const { data, refetch } = useSinittoInfo(); + + const modifySinittoInfoMutation = useModifySinittoInformation(); + useEffect(() => { if (isEditing) { setName(data?.name || ''); @@ -42,9 +41,6 @@ const SinittoProfileBox = ({ isEditing, setIsEditing }: Props) => { }); }; - if (isLoading) return
로딩 중...
; - if (isError) return
데이터를 가져오는 데 오류가 발생했습니다.
; - return ( From 39060e6c04af554698118ff32b3ce3bc8020928d Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 04:36:41 +0900 Subject: [PATCH 39/57] =?UTF-8?q?Chore:=20dayjs=20=EC=84=A4=EC=B9=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + pnpm-lock.yaml | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 96f60089..b8ac6798 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1e21fb64..3582a4a1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -26,6 +26,9 @@ importers: date-fns: specifier: ^4.1.0 version: 4.1.0 + dayjs: + specifier: ^1.11.13 + version: 1.11.13 msw: specifier: ^2.3.5 version: 2.3.5(typescript@5.5.4) @@ -2584,6 +2587,9 @@ packages: date-fns@4.1.0: resolution: {integrity: sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==} + dayjs@1.11.13: + resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==} + debug@3.2.7: resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} peerDependencies: @@ -7991,6 +7997,8 @@ snapshots: date-fns@4.1.0: {} + dayjs@1.11.13: {} + debug@3.2.7: dependencies: ms: 2.1.3 @@ -8267,7 +8275,7 @@ snapshots: debug: 4.3.6 enhanced-resolve: 5.17.1 eslint: 8.57.0 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) fast-glob: 3.3.2 get-tsconfig: 4.7.6 @@ -8279,7 +8287,7 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.8.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0): + eslint-module-utils@2.8.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0): dependencies: debug: 3.2.7 optionalDependencies: @@ -8307,7 +8315,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.18.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) hasown: 2.0.2 is-core-module: 2.15.1 is-glob: 4.0.3 From db46eb408b8bf9fc465671a18350f07db4e91fab Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 04:37:38 +0900 Subject: [PATCH 40/57] =?UTF-8?q?Feat(call-back):=20=EC=BD=9C=EB=B0=B1=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A0=95=EB=A0=AC=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/sinitto/call-back/list/api/get-call-backs.api.ts | 7 ++++++- src/pages/sinitto/call-back/list/index.ts | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/sinitto/call-back/list/api/get-call-backs.api.ts b/src/pages/sinitto/call-back/list/api/get-call-backs.api.ts index 3bd83f9b..e2715829 100644 --- a/src/pages/sinitto/call-back/list/api/get-call-backs.api.ts +++ b/src/pages/sinitto/call-back/list/api/get-call-backs.api.ts @@ -3,13 +3,18 @@ import { fetchInstance } from '@/shared/api/instance'; const getCallbacksPath = () => `/api/callbacks`; -export const getCallbacks = async (page: number, size: number) => { +export const getCallbacks = async ( + page: number, + size: number, + sort: string = 'DESC' +) => { const response = await fetchInstance.get( getCallbacksPath(), { params: { page, size, + sort, }, } ); diff --git a/src/pages/sinitto/call-back/list/index.ts b/src/pages/sinitto/call-back/list/index.ts index cfab8beb..b3b9f57c 100644 --- a/src/pages/sinitto/call-back/list/index.ts +++ b/src/pages/sinitto/call-back/list/index.ts @@ -2,3 +2,4 @@ export { default as CallBackListPage } from './CallBackListPage'; export * from './components'; export * from './data'; +export * from './api'; From e4a2c7c902371d863685829cf91576a867d00aaa Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 04:38:06 +0900 Subject: [PATCH 41/57] =?UTF-8?q?Feat(hello-call):=20=EC=95=88=EB=B6=80?= =?UTF-8?q?=EC=A0=84=ED=99=94=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/sinitto/call-back/list/api/index.ts | 2 ++ .../hello-call-list/api/service-list.api.ts | 18 +++++++++++++----- src/pages/sinitto/hello-call-list/index.ts | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/pages/sinitto/call-back/list/api/index.ts b/src/pages/sinitto/call-back/list/api/index.ts index a2626325..738b0d55 100644 --- a/src/pages/sinitto/call-back/list/api/index.ts +++ b/src/pages/sinitto/call-back/list/api/index.ts @@ -1 +1,3 @@ export { getCallbacks } from './get-call-backs.api'; + +export * from './hooks'; diff --git a/src/pages/sinitto/hello-call-list/api/service-list.api.ts b/src/pages/sinitto/hello-call-list/api/service-list.api.ts index af579b29..65ac40b2 100644 --- a/src/pages/sinitto/hello-call-list/api/service-list.api.ts +++ b/src/pages/sinitto/hello-call-list/api/service-list.api.ts @@ -1,16 +1,24 @@ import { ServiceListResponse } from './types'; import { fetchInstance } from '@/shared/api/instance'; -const getServiceListPath = (page: number) => - `/api/hellocalls/sinittos/list?page=${page}`; +const getServiceListPath = () => `/api/hellocalls/sinittos/list`; -export const ServiceListQueryKey = ['serviceList']; +export const ServiceListQueryKey = [getServiceListPath]; export const getServiceList = async ( - page: number + page: number, + size: number, + sort: string = 'DESC' ): Promise => { const response = await fetchInstance.get( - getServiceListPath(page) + getServiceListPath(), + { + params: { + page, + size, + sort, + }, + } ); return response.data; }; diff --git a/src/pages/sinitto/hello-call-list/index.ts b/src/pages/sinitto/hello-call-list/index.ts index b5a3635a..5993baba 100644 --- a/src/pages/sinitto/hello-call-list/index.ts +++ b/src/pages/sinitto/hello-call-list/index.ts @@ -1,3 +1,4 @@ export { default as HelloCallListPage } from './HelloCallListPage'; export * from './components'; +export * from './api'; From 988ef96a69ca8b18feb49e2afe4166f5e524e4d1 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 04:39:01 +0900 Subject: [PATCH 42/57] =?UTF-8?q?Fix(hello-call):=20=EB=AC=B4=ED=95=9C=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EA=B8=B0=EB=8A=A5=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=9D=84=20=EC=9C=84=ED=95=9C=20api=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hello-call-list/api/hooks/useGetServiceList.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pages/sinitto/hello-call-list/api/hooks/useGetServiceList.ts b/src/pages/sinitto/hello-call-list/api/hooks/useGetServiceList.ts index 2f0bf308..2692883a 100644 --- a/src/pages/sinitto/hello-call-list/api/hooks/useGetServiceList.ts +++ b/src/pages/sinitto/hello-call-list/api/hooks/useGetServiceList.ts @@ -2,12 +2,16 @@ import { getServiceList, ServiceListQueryKey } from '../service-list.api'; import { ServiceListResponse } from '../types'; import { useInfiniteQuery } from '@tanstack/react-query'; -export const useGetServiceList = () => { +export const useGetServiceList = (size: number) => { return useInfiniteQuery({ - queryKey: ServiceListQueryKey, - queryFn: ({ pageParam = 0 }) => getServiceList(Number(pageParam)), - getNextPageParam: (lastPage, allPages) => - lastPage.content.length > 0 ? allPages.length : undefined, + queryKey: [ServiceListQueryKey, size], + queryFn: ({ pageParam = 0 }) => getServiceList(Number(pageParam), size), + getNextPageParam: (lastPage) => { + if (!lastPage.last) { + return lastPage.number + 1; + } + return undefined; + }, initialPageParam: 0, }); }; From 1390aeccda9a80d67444d4c0be4b41e811935522 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 04:39:38 +0900 Subject: [PATCH 43/57] =?UTF-8?q?Fix(hello-call):=20=EC=95=88=EB=B6=80?= =?UTF-8?q?=EC=A0=84=ED=99=94=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=202=EA=B0=9C?= =?UTF-8?q?=20=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hello-call-apply/HelloCallApply.tsx | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/pages/sinitto/sinitto-main/components/common/hello-call-apply/HelloCallApply.tsx b/src/pages/sinitto/sinitto-main/components/common/hello-call-apply/HelloCallApply.tsx index b3cb5741..b22069c1 100644 --- a/src/pages/sinitto/sinitto-main/components/common/hello-call-apply/HelloCallApply.tsx +++ b/src/pages/sinitto/sinitto-main/components/common/hello-call-apply/HelloCallApply.tsx @@ -3,13 +3,12 @@ import { Link } from 'react-router-dom'; import { RouterPath } from '@/app/routes'; import { IconArrow } from '@/pages/assets'; import HelloCallImg from '@/pages/assets/shared/hello-call.png'; -import { ResponseBox } from '@/pages/sinitto'; -import { Box, Flex, Image, Text } from '@chakra-ui/react'; +import { ResponseBox, useGetServiceList } from '@/pages/sinitto'; +import { Box, Flex, Image, Spinner, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; export const HelloCallApply = () => { - const seniorName = '김순자'; - const seniorId = 1; + const { data: helloCallList, isLoading } = useGetServiceList(2); return ( @@ -33,11 +32,21 @@ export const HelloCallApply = () => { - - {[...Array(2)].map((_, index) => ( - - ))} - + {isLoading ? ( + + + + ) : ( + + {helloCallList?.pages?.[0]?.content.map((helloCall) => ( + + ))} + + )} ); }; From d19a5c50320cd7f209f44faf8336a908a007bf65 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 04:40:04 +0900 Subject: [PATCH 44/57] =?UTF-8?q?Fix(call-back):=20=EC=BD=9C=EB=B0=B1=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=202=EA=B0=9C=20=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A4=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/call-back-apply/CallBackApply.tsx | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/pages/sinitto/sinitto-main/components/common/call-back-apply/CallBackApply.tsx b/src/pages/sinitto/sinitto-main/components/common/call-back-apply/CallBackApply.tsx index 6ff6d02e..f7b30ee9 100644 --- a/src/pages/sinitto/sinitto-main/components/common/call-back-apply/CallBackApply.tsx +++ b/src/pages/sinitto/sinitto-main/components/common/call-back-apply/CallBackApply.tsx @@ -1,15 +1,29 @@ import { Link } from 'react-router-dom'; +import dayjs from 'dayjs'; + import { RouterPath } from '@/app/routes'; import { IconArrow } from '@/pages/assets'; import IconCall from '@/pages/assets/sinitto-main/call.svg'; -import { ResponseBox } from '@/pages/sinitto'; -import { Box, Flex, Image, Text } from '@chakra-ui/react'; +import { ResponseBox, useGetCallbacks } from '@/pages/sinitto'; +import { Box, Flex, Image, Spinner, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; export const CallBackApply = () => { - const seniorName = '김순자'; - const seniorId = 1; + const { data: callBackList, isLoading } = useGetCallbacks(4); + + const timeSince = (postTime: string) => { + const now = dayjs(); + const postDate = dayjs(postTime); + const diffInMinutes = now.diff(postDate, 'minute'); + + if (diffInMinutes < 60) return `${diffInMinutes}분 전`; + const diffInHours = now.diff(postDate, 'hour'); + if (diffInHours < 24) return `${diffInHours}시간 전`; + + const diffInDays = now.diff(postDate, 'day'); + return `${diffInDays}일 전`; + }; return ( @@ -30,11 +44,21 @@ export const CallBackApply = () => { 대기 중인 요청을 잡아 가이드라인을 확인하고 도움을 시작해보세요. - - {[...Array(4)].map((_, index) => ( - - ))} - + {isLoading ? ( + + + + ) : ( + + {callBackList?.pages?.[0]?.content.map((callback) => ( + + ))} + + )} ); }; From 1ba7d691881583e4d974f8e656fa6b88ba1ee560 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 04:40:38 +0900 Subject: [PATCH 45/57] =?UTF-8?q?Fix(main):=20=EC=9A=94=EC=B2=AD=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=ED=91=9C=EC=8B=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/features/response-box/ResponseBox.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/sinitto/sinitto-main/components/features/response-box/ResponseBox.tsx b/src/pages/sinitto/sinitto-main/components/features/response-box/ResponseBox.tsx index 98aafad7..28ea45fa 100644 --- a/src/pages/sinitto/sinitto-main/components/features/response-box/ResponseBox.tsx +++ b/src/pages/sinitto/sinitto-main/components/features/response-box/ResponseBox.tsx @@ -3,14 +3,15 @@ import styled from '@emotion/styled'; type Props = { seniorName: string; + requestTime: string; }; -export const ResponseBox = ({ seniorName }: Props) => { +export const ResponseBox = ({ seniorName, requestTime }: Props) => { return ( {seniorName}님 - 6 분전 + {requestTime} 대기 From 38b3f56c34b74f105727dc0ee757fdff2cf7a21e Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Wed, 30 Oct 2024 04:49:55 +0900 Subject: [PATCH 46/57] =?UTF-8?q?Feat(log-out):=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=95=84=EC=9B=83=20API=20=EC=97=B0=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/guard/mypage/GuardMyPage.tsx | 3 ++- src/pages/sinitto/mypage/SinittoMypage.tsx | 8 +++++++- src/shared/api/hooks/index.ts | 1 + src/shared/api/hooks/useLogout.ts | 19 +++++++++++++++++++ src/shared/api/index.ts | 2 +- src/shared/api/logout.api.ts | 8 ++++++++ .../components/features/mypage/index.ts | 1 + .../features/mypage/logout-button/Logout.tsx | 14 ++++++++++++++ .../features/mypage/logout-button/index.ts | 1 + .../mypage/point-log-box/PointLogBox.tsx | 2 +- 10 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 src/shared/api/hooks/useLogout.ts create mode 100644 src/shared/api/logout.api.ts create mode 100644 src/shared/components/features/mypage/logout-button/Logout.tsx create mode 100644 src/shared/components/features/mypage/logout-button/index.ts diff --git a/src/pages/guard/mypage/GuardMyPage.tsx b/src/pages/guard/mypage/GuardMyPage.tsx index 3ed66222..c4b01a1f 100644 --- a/src/pages/guard/mypage/GuardMyPage.tsx +++ b/src/pages/guard/mypage/GuardMyPage.tsx @@ -1,5 +1,5 @@ import { GuardProfileBox } from './components'; -import { PointBox, PointLogBox } from '@/shared/components'; +import { Logout, PointBox, PointLogBox } from '@/shared/components'; import { Box } from '@chakra-ui/react'; import styled from '@emotion/styled'; @@ -9,6 +9,7 @@ export const GuardMyPage = () => { + ); }; diff --git a/src/pages/sinitto/mypage/SinittoMypage.tsx b/src/pages/sinitto/mypage/SinittoMypage.tsx index 25206498..b436d2fd 100644 --- a/src/pages/sinitto/mypage/SinittoMypage.tsx +++ b/src/pages/sinitto/mypage/SinittoMypage.tsx @@ -1,7 +1,12 @@ import { useState } from 'react'; import { SinittoProfileBox, AccountInfoBox } from './components'; -import { BasicButton, PointBox, PointLogBox } from '@/shared/components'; +import { + BasicButton, + Logout, + PointBox, + PointLogBox, +} from '@/shared/components'; import { Box } from '@chakra-ui/react'; import styled from '@emotion/styled'; @@ -35,6 +40,7 @@ const SinittoMypage = () => { + ); }; diff --git a/src/shared/api/hooks/index.ts b/src/shared/api/hooks/index.ts index 976d77a4..8dc953cb 100644 --- a/src/shared/api/hooks/index.ts +++ b/src/shared/api/hooks/index.ts @@ -1 +1,2 @@ export { useGetCallback } from './useGetCallback'; +export { useLogout } from './useLogout'; diff --git a/src/shared/api/hooks/useLogout.ts b/src/shared/api/hooks/useLogout.ts new file mode 100644 index 00000000..ab03dc89 --- /dev/null +++ b/src/shared/api/hooks/useLogout.ts @@ -0,0 +1,19 @@ +import { useNavigate } from 'react-router-dom'; + +import { RouterPath } from '@/app/routes'; +import { userLogout } from '@/shared'; +import { authStorage } from '@/shared/utils'; +import { useMutation } from '@tanstack/react-query'; + +export const useLogout = () => { + const navigate = useNavigate(); + + return useMutation({ + mutationFn: userLogout, + onSuccess: () => { + authStorage.accessToken.set(undefined); + authStorage.refreshToken.set(undefined); + navigate(RouterPath.ROOT); + }, + }); +}; diff --git a/src/shared/api/index.ts b/src/shared/api/index.ts index 3ff8b375..075b7a60 100644 --- a/src/shared/api/index.ts +++ b/src/shared/api/index.ts @@ -1,5 +1,5 @@ export { getCallback } from './get-call-back.api'; - +export { userLogout } from './logout.api'; export * from './instance'; export * from './hooks'; export * from './point'; diff --git a/src/shared/api/logout.api.ts b/src/shared/api/logout.api.ts new file mode 100644 index 00000000..51cb9c53 --- /dev/null +++ b/src/shared/api/logout.api.ts @@ -0,0 +1,8 @@ +import { fetchInstance } from '@/shared/api/instance'; + +const getLogoutPath = '/api/members/logout'; + +export const userLogout = async () => { + const response = await fetchInstance.delete(getLogoutPath); + return response.data; +}; diff --git a/src/shared/components/features/mypage/index.ts b/src/shared/components/features/mypage/index.ts index 8df36623..bcb65af8 100644 --- a/src/shared/components/features/mypage/index.ts +++ b/src/shared/components/features/mypage/index.ts @@ -1,2 +1,3 @@ export * from './point-box'; export * from './point-log-box'; +export * from './logout-button'; diff --git a/src/shared/components/features/mypage/logout-button/Logout.tsx b/src/shared/components/features/mypage/logout-button/Logout.tsx new file mode 100644 index 00000000..5c02ff79 --- /dev/null +++ b/src/shared/components/features/mypage/logout-button/Logout.tsx @@ -0,0 +1,14 @@ +import { useLogout } from '@/shared/api/hooks/useLogout'; +import { BasicButton } from '@/shared/components/common'; + +const Logout = () => { + const { mutate: logout } = useLogout(); + + return ( + logout()}> + 로그아웃 + + ); +}; + +export default Logout; diff --git a/src/shared/components/features/mypage/logout-button/index.ts b/src/shared/components/features/mypage/logout-button/index.ts new file mode 100644 index 00000000..a32f1378 --- /dev/null +++ b/src/shared/components/features/mypage/logout-button/index.ts @@ -0,0 +1 @@ +export { default as Logout } from './Logout'; diff --git a/src/shared/components/features/mypage/point-log-box/PointLogBox.tsx b/src/shared/components/features/mypage/point-log-box/PointLogBox.tsx index 621702db..564c2436 100644 --- a/src/shared/components/features/mypage/point-log-box/PointLogBox.tsx +++ b/src/shared/components/features/mypage/point-log-box/PointLogBox.tsx @@ -98,7 +98,7 @@ const UseDetailBoxLayout = styled(Box)` background-color: #2e2e2e; border: 1px solid #2e2e2e; border-radius: 10px; - margin-top: 0.5rem; + margin: 0.5rem; `; const TextBox = styled(Box)` From 33f04c5f52649efb14fbe79934abc5747711fa67 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 04:51:57 +0900 Subject: [PATCH 47/57] =?UTF-8?q?Remove:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/shared/components/common/index.ts | 1 - .../visibility-loader/VisibilityLoader.tsx | 30 ------------------- .../common/visibility-loader/index.ts | 1 - 3 files changed, 32 deletions(-) delete mode 100644 src/shared/components/common/visibility-loader/VisibilityLoader.tsx delete mode 100644 src/shared/components/common/visibility-loader/index.ts diff --git a/src/shared/components/common/index.ts b/src/shared/components/common/index.ts index e160f1e8..bd7a6d3c 100644 --- a/src/shared/components/common/index.ts +++ b/src/shared/components/common/index.ts @@ -2,4 +2,3 @@ export * from './button'; export * from './guide-line-button'; export * from './layout'; export * from './view'; -export * from './visibility-loader'; diff --git a/src/shared/components/common/visibility-loader/VisibilityLoader.tsx b/src/shared/components/common/visibility-loader/VisibilityLoader.tsx deleted file mode 100644 index 02fd169a..00000000 --- a/src/shared/components/common/visibility-loader/VisibilityLoader.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { - useIntersectionObserver, - UseIntersectionObserverProps, -} from '@/shared'; -import { Spinner } from '@chakra-ui/react'; -import styled from '@emotion/styled'; - -type Props = { - children?: React.ReactNode; -} & UseIntersectionObserverProps; - -export const VisibilityLoader = ({ - children = , - ...observerProps -}: Props) => { - const { ref } = useIntersectionObserver(observerProps); - - return ( - -
{children}
-
- ); -}; - -const Wrapper = styled.div` - width: 100%; - display: flex; - justify-content: center; - padding: '32px 48px'; -`; diff --git a/src/shared/components/common/visibility-loader/index.ts b/src/shared/components/common/visibility-loader/index.ts deleted file mode 100644 index a6a985c8..00000000 --- a/src/shared/components/common/visibility-loader/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { VisibilityLoader } from './VisibilityLoader'; From ffe09c62bcdc0435a4a92b4f49ed0c1a742acc65 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Wed, 30 Oct 2024 04:52:21 +0900 Subject: [PATCH 48/57] =?UTF-8?q?Fix(hello-call):=20=EB=AC=B4=ED=95=9C?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A1=A4=20=EA=B8=B0=EB=8A=A5=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 --- .../hello-call-list/HelloCallListPage.tsx | 47 +++++++++----- .../components/call-request/CallRequest.tsx | 61 +++++++++++-------- 2 files changed, 67 insertions(+), 41 deletions(-) diff --git a/src/pages/sinitto/hello-call-list/HelloCallListPage.tsx b/src/pages/sinitto/hello-call-list/HelloCallListPage.tsx index 0dadf5cd..12dbfa3e 100644 --- a/src/pages/sinitto/hello-call-list/HelloCallListPage.tsx +++ b/src/pages/sinitto/hello-call-list/HelloCallListPage.tsx @@ -1,18 +1,19 @@ -import { useState, useEffect } from 'react'; +import { useState, useEffect, useRef, useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; import { useGetServiceList } from './api'; import { CallRequest } from './components'; import { RouterPath } from '@/app/routes/path'; -import { LoadingView, VisibilityLoader } from '@/shared/components'; +import { LoadingView } from '@/shared/components'; import { Flex, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; const HelloCallListPage = () => { const [isLastPageReached, setIsLastPageReached] = useState(false); + const observerRef = useRef(null); const { data, isError, isLoading, hasNextPage, fetchNextPage, error } = - useGetServiceList(); + useGetServiceList(10); const navigate = useNavigate(); @@ -22,6 +23,23 @@ const HelloCallListPage = () => { navigate(`${RouterPath.HELLO_CALL_SERVICE}/${helloCallId}`); }; + const lastElementRef = useCallback( + (node: HTMLDivElement | null) => { + if (isLoading) return; + + if (observerRef.current) observerRef.current.disconnect(); + + observerRef.current = new IntersectionObserver((entries) => { + if (entries[0].isIntersecting && hasNextPage) { + fetchNextPage(); + } + }); + + if (node) observerRef.current.observe(node); + }, + [isLoading, fetchNextPage, hasNextPage] + ); + useEffect(() => { if (isError && error instanceof Error && error.message.includes('500')) { setIsLastPageReached(true); @@ -37,17 +55,18 @@ const HelloCallListPage = () => { 새로고침 - {allContent.map((item) => ( - handlerNavigate(item.helloCallId)} - /> - ))} - {hasNextPage && !isLoading && !isLastPageReached && ( - - )} + {allContent.map((item, index) => { + const isLastElement = index === allContent.length - 1; // 마지막 요소인지 확인 + return ( + handlerNavigate(item.helloCallId)} + ref={isLastElement ? lastElementRef : null} // 마지막 요소에 ref 할당 + /> + ); + })} {(!hasNextPage || isLastPageReached) && ( 더 이상 요청이 없어요 🥲 )} diff --git a/src/pages/sinitto/hello-call-list/components/call-request/CallRequest.tsx b/src/pages/sinitto/hello-call-list/components/call-request/CallRequest.tsx index 14da6501..31841927 100644 --- a/src/pages/sinitto/hello-call-list/components/call-request/CallRequest.tsx +++ b/src/pages/sinitto/hello-call-list/components/call-request/CallRequest.tsx @@ -1,3 +1,5 @@ +import { forwardRef } from 'react'; + import ArrowIcon from '../../assets/arrow.svg'; import { Box, Image, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; @@ -8,36 +10,41 @@ type Props = { days?: string[]; }; -const CallRequest = ({ onClick, seniorName, days }: Props) => { - return ( - - - {seniorName}님의 요청 - - - - {days?.map((day, index) => {day})} - +const CallRequest = forwardRef( + ({ onClick, seniorName, days }, ref) => { + return ( + - arrow-icon + {seniorName}님의 요청 + + + + {days?.map((day, index) => {day})} + + + arrow-icon + - - ); -}; + ); + } +); + +CallRequest.displayName = 'CallRequest'; export default CallRequest; From 734459802aa893512fb356e3c8861117830252eb Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Wed, 30 Oct 2024 04:54:38 +0900 Subject: [PATCH 49/57] =?UTF-8?q?Feat(register-redirect):=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EA=B0=80=EC=9E=85=20=ED=9B=84=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=ED=83=80=EC=9E=85=EB=B3=84=EB=A1=9C=20=ED=99=88=20=EB=A6=AC?= =?UTF-8?q?=EB=8B=A4=EC=9D=B4=EB=A0=89=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/register/store/hooks/useRegister.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/common/register/store/hooks/useRegister.ts b/src/pages/common/register/store/hooks/useRegister.ts index aa0c38fe..a6b30629 100644 --- a/src/pages/common/register/store/hooks/useRegister.ts +++ b/src/pages/common/register/store/hooks/useRegister.ts @@ -19,7 +19,9 @@ const useRegister = () => { authStorage.accessToken.set(data.accessToken); authStorage.refreshToken.set(data.refreshToken); alert('회원가입이 완료되었습니다.'); - navigate(data.isSinitto === 'true' ? RouterPath.ROOT : RouterPath.ROOT); + navigate( + data.isSinitto === 'true' ? RouterPath.SINITTO : RouterPath.GUARD + ); } } }; From ff104378f6dbbf54deb37516e5ba5b9174cd1b59 Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Wed, 30 Oct 2024 05:08:36 +0900 Subject: [PATCH 50/57] =?UTF-8?q?Chore:=20eslintrc=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9B=90=EC=83=81=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.json | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 3c659ee0..41f68a8c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,7 +4,6 @@ "es2021": true }, "extends": [ - "@typescript-eslint/parser", "plugin:prettier/recommended", "plugin:@typescript-eslint/recommended", "plugin:react/recommended", From 3ab7156561478468fe865fa6dc079f92abb90ffb Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:13:00 +0900 Subject: [PATCH 51/57] =?UTF-8?q?Fix(register):=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EC=9C=A0=EC=A0=80=20=ED=83=80=EC=9E=85?= =?UTF-8?q?=EB=B3=84=20=EB=A6=AC=EB=8B=A4=EC=9D=B4=EB=A0=89=ED=8A=B8=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/register/store/hooks/useRegister.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/common/register/store/hooks/useRegister.ts b/src/pages/common/register/store/hooks/useRegister.ts index a6b30629..21aff8cf 100644 --- a/src/pages/common/register/store/hooks/useRegister.ts +++ b/src/pages/common/register/store/hooks/useRegister.ts @@ -19,9 +19,7 @@ const useRegister = () => { authStorage.accessToken.set(data.accessToken); authStorage.refreshToken.set(data.refreshToken); alert('회원가입이 완료되었습니다.'); - navigate( - data.isSinitto === 'true' ? RouterPath.SINITTO : RouterPath.GUARD - ); + navigate(data.isSinitto ? RouterPath.SINITTO : RouterPath.GUARD); } } }; From ec8fe5d0766fd313aede1dae4e3d07605e831f7a Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:17:19 +0900 Subject: [PATCH 52/57] =?UTF-8?q?Style:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20UI=20=EB=B6=80=EB=B6=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/guard/mypage/GuardMyPage.tsx | 9 ++++---- .../profile-box/GuardProfileBox.tsx | 21 ++++++++++--------- src/pages/sinitto/mypage/SinittoMypage.tsx | 16 ++++++-------- .../profile-box/SinittoProfileBox.tsx | 16 ++++++++++---- src/shared/api/hooks/useLogout.ts | 1 + .../components/common/button/BasicButton.tsx | 3 ++- .../features/mypage/logout-button/Logout.tsx | 10 ++++++--- 7 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/pages/guard/mypage/GuardMyPage.tsx b/src/pages/guard/mypage/GuardMyPage.tsx index c4b01a1f..70e58200 100644 --- a/src/pages/guard/mypage/GuardMyPage.tsx +++ b/src/pages/guard/mypage/GuardMyPage.tsx @@ -1,6 +1,6 @@ import { GuardProfileBox } from './components'; -import { Logout, PointBox, PointLogBox } from '@/shared/components'; -import { Box } from '@chakra-ui/react'; +import { PointBox, PointLogBox } from '@/shared/components'; +import { Flex } from '@chakra-ui/react'; import styled from '@emotion/styled'; export const GuardMyPage = () => { @@ -9,13 +9,12 @@ export const GuardMyPage = () => { - ); }; -const MyPageLayout = styled(Box)` - display: flex; +const MyPageLayout = styled(Flex)` flex-direction: column; align-items: center; + gap: 0.2rem; `; diff --git a/src/pages/guard/mypage/components/profile-box/GuardProfileBox.tsx b/src/pages/guard/mypage/components/profile-box/GuardProfileBox.tsx index ccfc140b..6ec0072e 100644 --- a/src/pages/guard/mypage/components/profile-box/GuardProfileBox.tsx +++ b/src/pages/guard/mypage/components/profile-box/GuardProfileBox.tsx @@ -2,14 +2,12 @@ import { Link } from 'react-router-dom'; import { useGetGuardInformation } from '../../api'; import { RouterPath } from '@/app/routes/path'; -import { Box } from '@chakra-ui/react'; +import { Logout } from '@/shared'; +import { Box, Text } from '@chakra-ui/react'; import styled from '@emotion/styled'; const GuardProfileBox = () => { - const { data, isLoading, isError } = useGetGuardInformation(); - - if (isLoading) return
로딩 중...
; - if (isError) return
데이터를 가져오는 데 오류가 발생했습니다.
; + const { data } = useGetGuardInformation(); return ( @@ -17,12 +15,14 @@ const GuardProfileBox = () => { - {data?.name} 님 환영합니다. + + {data?.name} 님 환영합니다. + + 서비스 이용 방법 한번에 이해하기! @@ -78,6 +78,7 @@ const TopContainer = styled(Box)` align-items: center; height: 70%; max-height: 120px; + padding: 1rem; `; const BottomContainer = styled(Box)` diff --git a/src/pages/sinitto/mypage/SinittoMypage.tsx b/src/pages/sinitto/mypage/SinittoMypage.tsx index b436d2fd..23bd06f2 100644 --- a/src/pages/sinitto/mypage/SinittoMypage.tsx +++ b/src/pages/sinitto/mypage/SinittoMypage.tsx @@ -1,13 +1,8 @@ import { useState } from 'react'; import { SinittoProfileBox, AccountInfoBox } from './components'; -import { - BasicButton, - Logout, - PointBox, - PointLogBox, -} from '@/shared/components'; -import { Box } from '@chakra-ui/react'; +import { BasicButton, PointBox, PointLogBox } from '@/shared/components'; +import { Flex } from '@chakra-ui/react'; import styled from '@emotion/styled'; const SinittoMypage = () => { @@ -23,6 +18,7 @@ const SinittoMypage = () => { setIsEditingProfile(true)} > 내 정보 수정하기 @@ -34,21 +30,21 @@ const SinittoMypage = () => { setIsEditingAccount(true)} > 계좌번호 수정하기 - ); }; export default SinittoMypage; -const MyPageLayout = styled(Box)` - display: flex; +const MyPageLayout = styled(Flex)` flex-direction: column; align-items: center; + gap: 0.2rem; `; diff --git a/src/pages/sinitto/mypage/components/profile-box/SinittoProfileBox.tsx b/src/pages/sinitto/mypage/components/profile-box/SinittoProfileBox.tsx index 1b62bf70..a8ff41d1 100644 --- a/src/pages/sinitto/mypage/components/profile-box/SinittoProfileBox.tsx +++ b/src/pages/sinitto/mypage/components/profile-box/SinittoProfileBox.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from 'react'; import { useModifySinittoInformation } from '@/pages'; -import { useSinittoInfo } from '@/shared'; +import { Logout, useSinittoInfo } from '@/shared'; import { Box, Text, Button, Input } from '@chakra-ui/react'; import styled from '@emotion/styled'; @@ -43,9 +43,17 @@ const SinittoProfileBox = ({ isEditing, setIsEditing }: Props) => { return ( - - {data?.name} 님 환영합니다. - + + + {data?.name} 님 환영합니다. + + + { onSuccess: () => { authStorage.accessToken.set(undefined); authStorage.refreshToken.set(undefined); + alert('로그아웃 되었습니다.'); navigate(RouterPath.ROOT); }, }); diff --git a/src/shared/components/common/button/BasicButton.tsx b/src/shared/components/common/button/BasicButton.tsx index 464ad729..b0e7c1f6 100644 --- a/src/shared/components/common/button/BasicButton.tsx +++ b/src/shared/components/common/button/BasicButton.tsx @@ -3,11 +3,12 @@ import styled from '@emotion/styled'; type Props = { themeType?: 'default' | 'outline'; width?: string; + height?: string; }; export const BasicButton = styled.button` width: ${(props) => (props.width ? props.width : '100%')}; - height: 50px; + height: ${(props) => (props.height ? props.height : '50px')}; border-radius: 10px; outline: 0; diff --git a/src/shared/components/features/mypage/logout-button/Logout.tsx b/src/shared/components/features/mypage/logout-button/Logout.tsx index 5c02ff79..7eae7303 100644 --- a/src/shared/components/features/mypage/logout-button/Logout.tsx +++ b/src/shared/components/features/mypage/logout-button/Logout.tsx @@ -1,11 +1,15 @@ -import { useLogout } from '@/shared/api/hooks/useLogout'; -import { BasicButton } from '@/shared/components/common'; +import { BasicButton, useLogout } from '@/shared'; const Logout = () => { const { mutate: logout } = useLogout(); return ( - logout()}> + logout()} + > 로그아웃 ); From ccc2437b478d69fb74c193ef2531db20ec28bcbf Mon Sep 17 00:00:00 2001 From: diwoni <70441308+Diwoni@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:25:35 +0900 Subject: [PATCH 53/57] =?UTF-8?q?Style:=20=EC=97=90=EB=9F=AC=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=8B=9C=20UI=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/mypage/point-box/PointBox.tsx | 14 ++------------ .../features/mypage/point-log-box/PointLogBox.tsx | 13 +++++++++---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/shared/components/features/mypage/point-box/PointBox.tsx b/src/shared/components/features/mypage/point-box/PointBox.tsx index 4c915673..2ea4b1ab 100644 --- a/src/shared/components/features/mypage/point-box/PointBox.tsx +++ b/src/shared/components/features/mypage/point-box/PointBox.tsx @@ -5,11 +5,11 @@ import { useGetPointInfo, useWithdrawPoint, } from '@/shared/hooks'; -import { Box, Text, Spinner, Button, Input } from '@chakra-ui/react'; +import { Box, Spinner, Button, Input } from '@chakra-ui/react'; import styled from '@emotion/styled'; const PointBox = () => { - const { data: pointData, isLoading, error, refetch } = useGetPointInfo(); + const { data: pointData, isLoading, refetch } = useGetPointInfo(); const chargePointMutation = useChargePoint(); const withdrawPointMutation = useWithdrawPoint(); const [actionType, setActionType] = useState(''); @@ -42,16 +42,6 @@ const PointBox = () => { ); } - if (error) { - return ( - - - 포인트 조회 중 오류가 발생했습니다. - - - ); - } - return ( { const [currentPage, setCurrentPage] = useState(0); const pageSize = 5; - const { data, isLoading, isError } = useGetPointLogs(currentPage, pageSize); + const { data, isLoading } = useGetPointLogs(currentPage, pageSize); const totalPages = data?.totalPages || 1; - if (isLoading) return
로딩 중...
; - if (isError) return
데이터를 가져오는 데 오류가 발생했습니다.
; + if (isLoading) { + return ( + + + + ); + } return ( From 67ea9f2635a56533ab6297ef1682f9392c2fc057 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Oct 2024 21:11:21 +0900 Subject: [PATCH 54/57] =?UTF-8?q?Fix:=20eslint=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/routes/index.tsx | 185 ------------------ .../guide-line/SinittoGuideLinePage.tsx | 13 +- 2 files changed, 5 insertions(+), 193 deletions(-) delete mode 100644 src/app/routes/index.tsx diff --git a/src/app/routes/index.tsx b/src/app/routes/index.tsx deleted file mode 100644 index 9b69d44c..00000000 --- a/src/app/routes/index.tsx +++ /dev/null @@ -1,185 +0,0 @@ -import { createBrowserRouter, RouterProvider } from 'react-router-dom'; - -import { RouterPath } from './path'; -import { - MainPage, - RegisterPage, - RedirectPage, - SinittoMypage, - GuardMyPage, - GuideLinePage, - ServiceHistoryPage, - HelloCallListPage, - HelloCallServicePage, - HelloCallReportPage, - SeniorRegisterPage, - CallBackListPage, - CallBackDetailPage, - SinittoGuideLinePage, - SinittoReviewPage, - HelloCallApplyPage, - GuardMainPage, - SinittoMainPage, -} from '@/pages'; -import { Layout } from '@/shared/components'; - -export const router = createBrowserRouter([ - { - path: RouterPath.ROOT, - element: , - }, - { - path: RouterPath.SIGNUP, - element: , - children: [ - { - index: true, - element: , - }, - ], - }, - { - path: RouterPath.REDIRECT, - children: [ - { - index: true, - element: , - }, - ], - }, - { - path: RouterPath.GUARD, - children: [ - { - index: true, - element: , - }, - ], - }, - { - path: RouterPath.SINITTO, - children: [ - { - index: true, - element: , - }, - ], - }, - { - path: RouterPath.SINITTO_MYPAGE, - element: , - children: [ - { - index: true, - element: , - }, - ], - }, - { - path: RouterPath.GUARD_MYPAGE, - element: , - children: [ - { - index: true, - element: , - }, - ], - }, - { - path: RouterPath.GUARD_GUIDELINE, - element: , - children: [ - { - index: true, - element: , - }, - ], - }, - { - path: RouterPath.SERVICE_HISTORY, - element: , - children: [ - { - index: true, - element: , - }, - ], - }, - { - path: RouterPath.HELLO_CALL, - element: , - children: [ - { index: true, element: }, - { - path: RouterPath.HELLO_CALL_SERVICE, - element: , - }, - { - path: RouterPath.HELLO_CALL_REPORT, - element: , - }, - { - path: RouterPath.HELLO_CALL_GUARD_APPLY, - element: , - }, - ], - }, - { - path: RouterPath.SENIOR_REGISTER, - element: , - children: [ - { - index: true, - element: , - }, - ], - }, - { - path: RouterPath.CALL_BACK_LIST, - element: , - children: [{ index: true, element: }], - }, - { - path: RouterPath.CALL_BACK_LIST, - element: , - children: [ - { - path: RouterPath.CALL_BACK_DETAIL, - element: , - }, - { - path: RouterPath.CALL_BACK_GUID_LINE, - element: , - }, - ], - }, - { - path: RouterPath.CALL_BACK_LIST, - element: , - children: [ - { - path: RouterPath.CALL_BACK_DETAIL, - children: [ - { - path: RouterPath.CALL_BACK_GUID_LINE, - element: , - }, - ], - }, - ], - }, - { - path: RouterPath.SINITTO_REVIEW, - element: , - children: [ - { - index: true, - element: , - }, - ], - }, -]); - -export const Routes = () => { - return ; -}; diff --git a/src/pages/sinitto/guide-line/SinittoGuideLinePage.tsx b/src/pages/sinitto/guide-line/SinittoGuideLinePage.tsx index fd6e8856..5dd57a92 100644 --- a/src/pages/sinitto/guide-line/SinittoGuideLinePage.tsx +++ b/src/pages/sinitto/guide-line/SinittoGuideLinePage.tsx @@ -1,4 +1,3 @@ -import { useEffect } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import { useGetGuideline } from './api/hooks'; @@ -28,13 +27,11 @@ export const SinittoGuideLinePage = () => { isError: isGuideLineError, } = useGetGuideline(Number(callBackId), guideLineId); - useEffect(() => { - if (isGuideLineError) { - const errorMessage = handleCallbackError(isGuideLineError); - alert(errorMessage); - navigate(RouterPath.CALL_BACK_LIST); - } - }, [isGuideLineError, isGuideLineError, navigate]); + if (isGuideLineError) { + const errorMessage = handleCallbackError(isGuideLineError); + alert(errorMessage); + navigate(RouterPath.CALL_BACK_LIST); + } return ( From c9e601249ffbd98f695b6f7af7d365f87f76df66 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Thu, 31 Oct 2024 19:03:51 +0900 Subject: [PATCH 55/57] =?UTF-8?q?Feat(router):=20dummy=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/routes/path.ts | 2 ++ src/app/routes/router.tsx | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/app/routes/path.ts b/src/app/routes/path.ts index 65754314..260efe46 100644 --- a/src/app/routes/path.ts +++ b/src/app/routes/path.ts @@ -18,4 +18,6 @@ export const RouterPath = { CALL_BACK_GUID_LINE: `:guideLineId`, SENIOR_REGISTER: `/senior-register`, SINITTO_REVIEW: `review`, + + DUMMY_LOGIN: `/dummy`, }; diff --git a/src/app/routes/router.tsx b/src/app/routes/router.tsx index d72aea5f..cd400b8a 100644 --- a/src/app/routes/router.tsx +++ b/src/app/routes/router.tsx @@ -19,6 +19,7 @@ import { HelloCallApplyPage, GuardMainPage, SinittoMainPage, + DummyRedirectPage, } from '@/pages'; import { Layout } from '@/shared/components'; @@ -46,6 +47,16 @@ export const router = createBrowserRouter([ }, ], }, + { + path: RouterPath.DUMMY_LOGIN, + element: , + children: [ + { + index: true, + element: , + }, + ], + }, { path: RouterPath.GUARD, children: [ From 46cbf65644aaf94906d230b78aa3e1745503d91d Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Thu, 31 Oct 2024 19:04:31 +0900 Subject: [PATCH 56/57] =?UTF-8?q?Feat(dummy-redirect):=20dummy=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EB=A6=AC=EB=8B=A4=EC=9D=B4=EB=A0=89?= =?UTF-8?q?=ED=8A=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dummy-redirect/DummyRedirectPage.tsx | 59 +++++++++++++++++++ src/pages/common/dummy-redirect/index.ts | 1 + src/pages/common/index.ts | 1 + 3 files changed, 61 insertions(+) create mode 100644 src/pages/common/dummy-redirect/DummyRedirectPage.tsx create mode 100644 src/pages/common/dummy-redirect/index.ts diff --git a/src/pages/common/dummy-redirect/DummyRedirectPage.tsx b/src/pages/common/dummy-redirect/DummyRedirectPage.tsx new file mode 100644 index 00000000..1dfde032 --- /dev/null +++ b/src/pages/common/dummy-redirect/DummyRedirectPage.tsx @@ -0,0 +1,59 @@ +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) { + console.log('Received tokens:', 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 ( + + + 더미데이터 로그인 + + {statusMessage} + {(isLoading || statusMessage === '유저 정보를 기다리고 있습니다...') && ( + + )} + + ); +}; diff --git a/src/pages/common/dummy-redirect/index.ts b/src/pages/common/dummy-redirect/index.ts new file mode 100644 index 00000000..244e91fc --- /dev/null +++ b/src/pages/common/dummy-redirect/index.ts @@ -0,0 +1 @@ +export { DummyRedirectPage } from './DummyRedirectPage'; diff --git a/src/pages/common/index.ts b/src/pages/common/index.ts index b7ea19a4..85a9c9e7 100644 --- a/src/pages/common/index.ts +++ b/src/pages/common/index.ts @@ -1,3 +1,4 @@ +export * from './dummy-redirect'; export * from './main'; export * from './redirect'; export * from './register'; From df9a6eb08b8f2686e11f698887263e387f6fcd2e Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Thu, 31 Oct 2024 19:14:13 +0900 Subject: [PATCH 57/57] =?UTF-8?q?!Hotfix:=20console=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/dummy-redirect/DummyRedirectPage.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/common/dummy-redirect/DummyRedirectPage.tsx b/src/pages/common/dummy-redirect/DummyRedirectPage.tsx index 1dfde032..2d7f2717 100644 --- a/src/pages/common/dummy-redirect/DummyRedirectPage.tsx +++ b/src/pages/common/dummy-redirect/DummyRedirectPage.tsx @@ -8,7 +8,7 @@ export const DummyRedirectPage = () => { const [statusMessage, setStatusMessage] = useState( '유저 정보를 기다리고 있습니다...' ); - const [isLoading, setIsLoading] = useState(true); // 로딩 상태 추가 + const [isLoading, setIsLoading] = useState(true); const navigate = useNavigate(); useEffect(() => { @@ -19,8 +19,6 @@ export const DummyRedirectPage = () => { const isSinitto = params.get('isSinitto'); if (accessToken && refreshToken && isSinitto) { - console.log('Received tokens:', accessToken, refreshToken, isSinitto); - // 로컬 스토리지에 토큰 저장 localStorage.setItem('accessToken', accessToken); localStorage.setItem('refreshToken', refreshToken);