From 5f7c816f6d3733ad1b815f5e6013fe258d9526d7 Mon Sep 17 00:00:00 2001 From: "using6843@gmail.com" Date: Tue, 3 Dec 2024 15:51:02 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[refactor]=20return=20data=20=EC=8A=A4?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=ED=81=AC=20=EC=BC=80=EC=9D=B4=EC=8A=A4=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 --- apps/backend/src/websocket/websocket.gateway.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/websocket/websocket.gateway.ts b/apps/backend/src/websocket/websocket.gateway.ts index 54ab26d..2d8c730 100644 --- a/apps/backend/src/websocket/websocket.gateway.ts +++ b/apps/backend/src/websocket/websocket.gateway.ts @@ -82,7 +82,14 @@ export class WebsocketGateway implements OnGatewayInit, OnGatewayConnection, OnG WHERE member_id = $1 `; const crops = await this.databaseService.query(query, [memberId]); - this.cropDataTransfer(memberId, crops.rows); + const data = crops.rows.map(crop => ({ + cropId: crop.crop_id, + availableQuantity: crop.available_quantity, + pendingQuantity: crop.pending_quantity, + totalQuantity: crop.total_quantity + })); + + this.cropDataTransfer(memberId, data); }); await subscriber.pSubscribe('__keyspace@0__:orderBook:*', async (_, message) => { From cd7f6909d5b1688497b4f58fca6e919cf949f63d Mon Sep 17 00:00:00 2001 From: "using6843@gmail.com" Date: Tue, 3 Dec 2024 15:52:06 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[fix]=20api=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C,=20url=20=EC=9D=B4=EB=8F=99=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 --- apps/frontend/src/services/Api.tsx | 2 ++ apps/frontend/src/services/AuthApi.tsx | 23 ++++++++++++----------- apps/frontend/src/services/OrderApi.tsx | 8 ++++++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/apps/frontend/src/services/Api.tsx b/apps/frontend/src/services/Api.tsx index 6aa462a..fb891bf 100644 --- a/apps/frontend/src/services/Api.tsx +++ b/apps/frontend/src/services/Api.tsx @@ -46,8 +46,10 @@ api.interceptors.response.use( pendingRequests.delete(requestKey); if (error.response && error.response.status === 401) { + console.log(error); localStorage.clear(); alert('액세스 토큰이 만료되었습니다. 로그아웃되었습니다.'); + window.location.href = '/'; } return Promise.reject(error); diff --git a/apps/frontend/src/services/AuthApi.tsx b/apps/frontend/src/services/AuthApi.tsx index 4b1caeb..d70a950 100644 --- a/apps/frontend/src/services/AuthApi.tsx +++ b/apps/frontend/src/services/AuthApi.tsx @@ -10,6 +10,7 @@ export const login = async (data: Login) => { const { accessToken, refreshToken, nickname } = response.data.data; localStorage.setItem('accessToken', accessToken); localStorage.setItem('refreshToken', refreshToken); + localStorage.setItem('nickname', nickname); return { success: true, @@ -58,21 +59,21 @@ export const logout = async () => { export const getIntroduce = async () => { try { - const response = await api.get('auth/introduce'); + const response = await api.get('auth/introduce'); - if (response.data.code === 200) { - const { introduce } = response.data.data; + if (response.data.code === 200) { + const { introduce } = response.data.data; - return { - success: true, - message: response.data.message, - introduce - }; - } + return { + success: true, + message: response.data.message, + introduce + }; + } - return { success: false, message: '알 수 없는 오류가 발생했습니다.' }; + return { success: false, message: '알 수 없는 오류가 발생했습니다.' }; } catch (error) { - return handleError(error, '데이터 로딩 중 오류가 발생했습니다.'); + return handleError(error, '데이터 로딩 중 오류가 발생했습니다.'); } }; diff --git a/apps/frontend/src/services/OrderApi.tsx b/apps/frontend/src/services/OrderApi.tsx index 52d0f92..54f758f 100644 --- a/apps/frontend/src/services/OrderApi.tsx +++ b/apps/frontend/src/services/OrderApi.tsx @@ -6,7 +6,7 @@ export const getOrderHistory = async () => { try { const response = await api.get('order'); - if (response.data.code === 201) { + if (response.data.code === 200) { const history: HistoryData[] = response.data.data; return { @@ -72,6 +72,8 @@ export const postMarketBuyOrder = async (data: Order) => { if (response.data.code === 201) { return { success: true, message: response.data.message }; + } else if(response.data.code === 400) { + return { success: true, message: response.data.message }; } return { success: false, message: '알 수 없는 오류가 발생했습니다.' }; @@ -84,7 +86,9 @@ export const postMarketSellOrder = async (data: Order) => { try { const response = await api.post('order/sell/market', data); - if (response.data.code === 200) { + if (response.data.code === 201) { + return { success: true, message: response.data.message }; + } else if(response.data.code === 400) { return { success: true, message: response.data.message }; } From 34ff63baf98115b153b3e7ad10a63ea64f5b8af7 Mon Sep 17 00:00:00 2001 From: "using6843@gmail.com" Date: Tue, 3 Dec 2024 15:53:34 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[feat]=20=EB=AA=A8=EB=8B=AC=20=EB=B0=94?= =?UTF-8?q?=EA=B9=A5=20=ED=81=B4=EB=A6=AD=EC=8B=9C=20=EB=81=84=EA=B8=B0=20?= =?UTF-8?q?=EB=B0=8F=20=EC=97=94=ED=84=B0=EC=8B=9C=20=EC=A0=9C=EC=B6=9C=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 --- .../src/components/Intro/LoginModal.tsx | 19 ++++++++++++++---- .../src/components/Intro/OauthLogin.tsx | 5 +---- .../src/components/Intro/SignUpModal.tsx | 20 +++++++++++++++---- apps/frontend/src/pages/Intro.tsx | 9 +++++++-- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/apps/frontend/src/components/Intro/LoginModal.tsx b/apps/frontend/src/components/Intro/LoginModal.tsx index 3036fcd..0c8e777 100644 --- a/apps/frontend/src/components/Intro/LoginModal.tsx +++ b/apps/frontend/src/components/Intro/LoginModal.tsx @@ -1,8 +1,7 @@ -import { useState, useContext } from 'react'; +import { useState, useContext, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { ModalStep } from '@/constants/ModalConstants'; import { login } from '@/services/AuthApi'; -import { useUser } from '@/components/public/UserContext'; import { AlertContext } from '@/components/public/AlertContext'; interface LoginProps { @@ -14,7 +13,6 @@ const LoginModal: React.FC = ({ setModalStep }) => { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(null); - const { setNickname } = useUser(); const { alert } = useContext(AlertContext); const handleLogin = async () => { @@ -33,7 +31,6 @@ const LoginModal: React.FC = ({ setModalStep }) => { try { const response = await login({ email, password }); if (response.success) { - setNickname(response.nickname); navigate('/main'); } else { await alert(response.message || '로그인 중 오류가 발생했습니다. 다시 시도해주세요.'); @@ -51,6 +48,20 @@ const LoginModal: React.FC = ({ setModalStep }) => { window.location.href = `${import.meta.env.VITE_BASE_URL}/api/auth/kakao`; }; + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === 'Enter') { + handleLogin(); + } + }; + + window.addEventListener('keydown', handleKeyDown); + + return () => { + window.removeEventListener('keydown', handleKeyDown); + }; + }, [handleLogin]); + return ( <> diff --git a/apps/frontend/src/components/Intro/OauthLogin.tsx b/apps/frontend/src/components/Intro/OauthLogin.tsx index 37b7695..cb8f8e2 100644 --- a/apps/frontend/src/components/Intro/OauthLogin.tsx +++ b/apps/frontend/src/components/Intro/OauthLogin.tsx @@ -1,9 +1,6 @@ import { useEffect } from 'react'; -import { useUser } from '@/components/public/UserContext'; const OauthLogin: React.FC = () => { - const { setNickname } = useUser(); - useEffect(() => { const handleCallback = () => { const urlParams = new URLSearchParams(window.location.search); @@ -14,7 +11,7 @@ const OauthLogin: React.FC = () => { if (accessToken && refreshToken && nickname) { localStorage.setItem('accessToken', accessToken); localStorage.setItem('refreshToken', refreshToken); - setNickname(nickname); + localStorage.setItem('nickname', nickname); setTimeout(() => { window.location.href = '/main'; diff --git a/apps/frontend/src/components/Intro/SignUpModal.tsx b/apps/frontend/src/components/Intro/SignUpModal.tsx index d6903be..ac85f31 100644 --- a/apps/frontend/src/components/Intro/SignUpModal.tsx +++ b/apps/frontend/src/components/Intro/SignUpModal.tsx @@ -1,8 +1,7 @@ -import { useState, useRef, useContext } from 'react'; +import { useState, useRef, useContext, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { ModalStep } from '@/constants/ModalConstants'; import { signUp, login } from '@/services/AuthApi'; -import { useUser } from '@/components/public/UserContext'; import { AlertContext } from '@/components/public/AlertContext'; interface SignUpModalProps { @@ -17,7 +16,6 @@ const SignUpModal: React.FC = ({ step, setModalStep }) => { const [pwCheck, setPwCheck] = useState(''); const [id, setId] = useState(''); const [error, setError] = useState(null); - const { setNickname } = useUser(); const { alert } = useContext(AlertContext); const emailInputRef = useRef(null); @@ -65,7 +63,6 @@ const SignUpModal: React.FC = ({ step, setModalStep }) => { try { const loginResponse = await login({ email, password }); if (loginResponse.success) { - setNickname(loginResponse.nickname); navigate('/main'); } else { await alert(loginResponse.message || '로그인 중 오류가 발생했습니다. 다시 시도해주세요.'); @@ -80,6 +77,21 @@ const SignUpModal: React.FC = ({ step, setModalStep }) => { } }; + useEffect(() => { + const handleKeyDown = (event: KeyboardEvent) => { + if (event.key === 'Enter') { + if(step === 1) handleSign1(); + else handleSign2(); + } + }; + + window.addEventListener('keydown', handleKeyDown); + + return () => { + window.removeEventListener('keydown', handleKeyDown); + }; + }, [handleSign1, handleSign2]); + return (
diff --git a/apps/frontend/src/pages/Intro.tsx b/apps/frontend/src/pages/Intro.tsx index c1bbd34..518db75 100644 --- a/apps/frontend/src/pages/Intro.tsx +++ b/apps/frontend/src/pages/Intro.tsx @@ -52,8 +52,13 @@ const Intro: React.FC = () => { > {modalStep !== ModalStep.None && ( -
-
+
+
e.stopPropagation()} + >
From 46840f2ab0d7ebae325769a0e6284b9a84dd1169 Mon Sep 17 00:00:00 2001 From: "using6843@gmail.com" Date: Tue, 3 Dec 2024 15:54:46 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[design]=20tailwind=20=EC=BB=A4=EC=8A=A4?= =?UTF-8?q?=ED=85=80=20=EC=83=89=EC=83=81=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/frontend/src/components/MyPage/Pagination.tsx | 6 +++--- .../src/components/MyPage/TransactionTable.tsx | 12 ++++++------ apps/frontend/tailwind.config.js | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/apps/frontend/src/components/MyPage/Pagination.tsx b/apps/frontend/src/components/MyPage/Pagination.tsx index 047a9ac..3e7b271 100644 --- a/apps/frontend/src/components/MyPage/Pagination.tsx +++ b/apps/frontend/src/components/MyPage/Pagination.tsx @@ -9,7 +9,7 @@ const Pagination: React.FC = ({ currentPage, totalPages, onPage
))}