From 285f611371dd9240157922279653261ac36eacd8 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 2 Dec 2024 22:07:34 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20signup=20api=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/loginApi.ts | 16 ++++++ src/components/pages/login/SignUpPage.tsx | 68 ++++++++++++++++++++--- 2 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 src/api/loginApi.ts diff --git a/src/api/loginApi.ts b/src/api/loginApi.ts new file mode 100644 index 0000000..f855e66 --- /dev/null +++ b/src/api/loginApi.ts @@ -0,0 +1,16 @@ +import axiosInstance from './axiosInstance'; + +export const postSignUp = async (body: { + email: string; + password: string; + password_confirm: string; + nickname: string; + name: string; + phone: string; + profile: File; + address: string; +}) => { + const response = await axiosInstance.post(`/users`, body); + + return response.data; +}; diff --git a/src/components/pages/login/SignUpPage.tsx b/src/components/pages/login/SignUpPage.tsx index 3ca4e88..19a9490 100644 --- a/src/components/pages/login/SignUpPage.tsx +++ b/src/components/pages/login/SignUpPage.tsx @@ -1,9 +1,16 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { styled } from 'styled-components'; +import { postSignUp } from '../../../api/loginApi'; function SignUpPage() { const navigate = useNavigate(); + const [name, setName] = useState(''); + const [phone, setPhone] = useState(''); + const [email, setEmail] = useState(''); + const [pw, setPw] = useState(''); + const [cpw, setCpw] = useState(''); + return ( @@ -20,17 +27,64 @@ function SignUpPage() { 회원가입 Name - + ) => { + setName(e.target.value); + }} + /> Phone Number - + ) => { + setPhone(e.target.value); + }} + /> Email Address - + ) => { + setEmail(e.target.value); + }} + /> Password - + ) => { + setPw(e.target.value); + }} + /> Confirm Password - + ) => { + setCpw(e.target.value); + }} + /> { + onClick={async () => { + const staticFile = new File( + ['This is a static file content'], + 'profile.txt', + { + type: 'text/plain', + } + ); + await postSignUp({ + email: email, + password: pw, + password_confirm: cpw, + nickname: name, + name: name, + phone: phone, + profile: staticFile, + address: '', + }); navigate('/termsandservice'); }} > From fdf58833c0ed8e6e4f888c5ae2b962ee9127e258 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 2 Dec 2024 22:17:37 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20login=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/loginApi.ts | 6 ++++ src/components/pages/login/SignInPage.tsx | 34 ++++++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/api/loginApi.ts b/src/api/loginApi.ts index f855e66..96d106d 100644 --- a/src/api/loginApi.ts +++ b/src/api/loginApi.ts @@ -14,3 +14,9 @@ export const postSignUp = async (body: { return response.data; }; + +export const postSignIn = async (body: { email: string; password: string }) => { + const response = await axiosInstance.post(`/users/login`, body); + + return response.data; +}; diff --git a/src/components/pages/login/SignInPage.tsx b/src/components/pages/login/SignInPage.tsx index 2ef050f..c0be81d 100644 --- a/src/components/pages/login/SignInPage.tsx +++ b/src/components/pages/login/SignInPage.tsx @@ -1,9 +1,13 @@ -import React from 'react'; +import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { styled } from 'styled-components'; +import { postSignIn } from '../../../api/loginApi'; const SignInPage = () => { const navigate = useNavigate(); + const [email, setEmail] = useState(''); + const [pw, setPw] = useState(''); + return ( @@ -20,10 +24,32 @@ const SignInPage = () => { Welcome 👋🏼 email address - + ) => { + setEmail(e.target.value); + }} + /> password - - Login + ) => { + setPw(e.target.value); + }} + /> + { + await postSignIn({ + email: email, + password: pw, + }); + }} + > + Login + Date: Mon, 2 Dec 2024 22:22:06 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=EC=B2=B4=ED=81=AC=20=EC=9D=B4?= =?UTF-8?q?=EB=A9=94=EC=9D=BC=20api=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/loginApi.ts | 5 +---- src/components/pages/login/SignUpPage.tsx | 10 ---------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/api/loginApi.ts b/src/api/loginApi.ts index 96d106d..9fc1e12 100644 --- a/src/api/loginApi.ts +++ b/src/api/loginApi.ts @@ -4,13 +4,10 @@ export const postSignUp = async (body: { email: string; password: string; password_confirm: string; - nickname: string; name: string; phone: string; - profile: File; - address: string; }) => { - const response = await axiosInstance.post(`/users`, body); + const response = await axiosInstance.post(`/users/checkemail`, body); return response.data; }; diff --git a/src/components/pages/login/SignUpPage.tsx b/src/components/pages/login/SignUpPage.tsx index 19a9490..1058be0 100644 --- a/src/components/pages/login/SignUpPage.tsx +++ b/src/components/pages/login/SignUpPage.tsx @@ -68,22 +68,12 @@ function SignUpPage() { /> { - const staticFile = new File( - ['This is a static file content'], - 'profile.txt', - { - type: 'text/plain', - } - ); await postSignUp({ email: email, password: pw, password_confirm: cpw, - nickname: name, name: name, phone: phone, - profile: staticFile, - address: '', }); navigate('/termsandservice'); }} From 326537b609bd0f30589e41a5a2bcab2b02a1aba6 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 2 Dec 2024 22:59:30 +0900 Subject: [PATCH 4/8] =?UTF-8?q?feat:=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=EC=B0=BE=EA=B8=B0=20api=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/login/FindPasswordPage.tsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/components/pages/login/FindPasswordPage.tsx b/src/components/pages/login/FindPasswordPage.tsx index e472df9..b772097 100644 --- a/src/components/pages/login/FindPasswordPage.tsx +++ b/src/components/pages/login/FindPasswordPage.tsx @@ -1,10 +1,13 @@ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { styled } from 'styled-components'; +import { postFindPassword } from '../../../api/loginApi'; const FindPasswordPage = () => { const navigate = useNavigate(); const [showModal, setShowModal] = useState(false); + const [email, setEmail] = useState(''); + return ( <> @@ -37,9 +40,21 @@ const FindPasswordPage = () => { 등록된 이메일 주소를 입력하고 확인 버튼을 클릭해주세요 email address - - - setShowModal(true)}>확인 + ) => { + setEmail(e.target.value); + }} + /> + { + setShowModal(true); + await postFindPassword({ email: email }); + }} + > + 확인 + {showModal && ( From f0cdecc3f379c069f1a2a70cb2a42c6828c5020f Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 2 Dec 2024 22:59:55 +0900 Subject: [PATCH 5/8] =?UTF-8?q?feat:=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EB=A6=AC=EC=85=8B=20api=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20(#7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/loginApi.ts | 18 +++++ .../pages/login/ResetPasswordPage.tsx | 77 +++++++++---------- 2 files changed, 56 insertions(+), 39 deletions(-) diff --git a/src/api/loginApi.ts b/src/api/loginApi.ts index 9fc1e12..0da9b9f 100644 --- a/src/api/loginApi.ts +++ b/src/api/loginApi.ts @@ -17,3 +17,21 @@ export const postSignIn = async (body: { email: string; password: string }) => { return response.data; }; + +export const postFindPassword = async (body: { email: string }) => { + const response = await axiosInstance.post(`/users/find`, body); + + return response.data; +}; + +export const postResetPassword = async ( + body: { newPassword: string }, + token: string +) => { + const response = await axiosInstance.post( + `/users/reset?token=${token}`, + body + ); + + return response.data; +}; diff --git a/src/components/pages/login/ResetPasswordPage.tsx b/src/components/pages/login/ResetPasswordPage.tsx index 00f5648..bb256ea 100644 --- a/src/components/pages/login/ResetPasswordPage.tsx +++ b/src/components/pages/login/ResetPasswordPage.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { styled } from 'styled-components'; +import { postResetPassword } from '../../../api/loginApi'; const ResetPasswordPage = () => { const navigate = useNavigate(); @@ -8,8 +9,9 @@ const ResetPasswordPage = () => { const [confirmPassword, setConfirmPassword] = useState(''); const [showModal, setShowModal] = useState(false); - const handleConfirm = () => { + const handleConfirm = async () => { if (password === confirmPassword && password.length >= 8) { + await postResetPassword({ newPassword: password }, '1'); setShowModal(true); } else { alert('비밀번호가 일치하지 않거나 유효하지 않습니다.'); @@ -17,43 +19,40 @@ const ResetPasswordPage = () => { }; return ( - <> - - - Login background - - - 비밀번호 재설정 - password - ) => - setPassword(e.target.value) - } - /> - confirm password - ) => - setConfirmPassword(e.target.value) - } - /> - Confirm - - - + + + Login background + + + 비밀번호 재설정 + password + ) => + setPassword(e.target.value) + } + /> + confirm password + ) => + setConfirmPassword(e.target.value) + } + /> + Confirm + {showModal && ( @@ -68,7 +67,7 @@ const ResetPasswordPage = () => { )} - + ); }; From 74ac57b0f182bb450622fcfc1217e313aadcb799 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 2 Dec 2024 23:07:20 +0900 Subject: [PATCH 6/8] =?UTF-8?q?feat:=20=ED=98=84=EC=9E=AC=20=EB=B9=84?= =?UTF-8?q?=EB=B0=80=EB=B2=88=ED=98=B8=20=ED=99=95=EC=9D=B8=20api=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mypageApi.ts | 7 +++++++ src/components/pages/myPage/Modal/PasswordModal.tsx | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/api/mypageApi.ts diff --git a/src/api/mypageApi.ts b/src/api/mypageApi.ts new file mode 100644 index 0000000..598522c --- /dev/null +++ b/src/api/mypageApi.ts @@ -0,0 +1,7 @@ +import axiosInstance from './axiosInstance'; + +export const postPasswordVerify = async (body: { currentPassword: string }) => { + const response = await axiosInstance.post(`/mypage/verfiy`, body); + + return response.data; +}; diff --git a/src/components/pages/myPage/Modal/PasswordModal.tsx b/src/components/pages/myPage/Modal/PasswordModal.tsx index 741ce14..79d8203 100644 --- a/src/components/pages/myPage/Modal/PasswordModal.tsx +++ b/src/components/pages/myPage/Modal/PasswordModal.tsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; import { styled } from 'styled-components'; +import { postPasswordVerify } from '../../../../api/mypageApi'; const PasswordModal = ({ onClose }: { onClose: () => void }) => { const [step, setStep] = useState(1); @@ -7,8 +8,9 @@ const PasswordModal = ({ onClose }: { onClose: () => void }) => { const [newPassword, setNewPassword] = useState(''); const [confirmPassword, setConfirmPassword] = useState(''); - const handleNextStep = () => { + const handleNextStep = async () => { if (step === 1) { + await postPasswordVerify({ currentPassword: currentPassword }); setStep(2); } else if (step === 2) { if (newPassword === confirmPassword) { From 2d6eb8508fd8a7156511645ed6ac677c50e5e410 Mon Sep 17 00:00:00 2001 From: jiyoung Date: Mon, 2 Dec 2024 23:09:32 +0900 Subject: [PATCH 7/8] =?UTF-8?q?feat:=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EB=B3=80=EA=B2=BD=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mypageApi.ts | 6 ++++++ src/components/pages/myPage/Modal/PasswordModal.tsx | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/api/mypageApi.ts b/src/api/mypageApi.ts index 598522c..442a579 100644 --- a/src/api/mypageApi.ts +++ b/src/api/mypageApi.ts @@ -5,3 +5,9 @@ export const postPasswordVerify = async (body: { currentPassword: string }) => { return response.data; }; + +export const postPasswordChange = async (body: { newPassword: string }) => { + const response = await axiosInstance.post(`/mypage/change`, body); + + return response.data; +}; diff --git a/src/components/pages/myPage/Modal/PasswordModal.tsx b/src/components/pages/myPage/Modal/PasswordModal.tsx index 79d8203..421a31a 100644 --- a/src/components/pages/myPage/Modal/PasswordModal.tsx +++ b/src/components/pages/myPage/Modal/PasswordModal.tsx @@ -1,6 +1,9 @@ import React, { useState } from 'react'; import { styled } from 'styled-components'; -import { postPasswordVerify } from '../../../../api/mypageApi'; +import { + postPasswordChange, + postPasswordVerify, +} from '../../../../api/mypageApi'; const PasswordModal = ({ onClose }: { onClose: () => void }) => { const [step, setStep] = useState(1); @@ -14,6 +17,7 @@ const PasswordModal = ({ onClose }: { onClose: () => void }) => { setStep(2); } else if (step === 2) { if (newPassword === confirmPassword) { + await postPasswordChange({ newPassword: newPassword }); onClose(); } else { alert('비밀번호가 일치하지 않습니다.'); From 0f176e764a2a8f61522b2fdac9c662220da186cb Mon Sep 17 00:00:00 2001 From: jiyoung Date: Tue, 3 Dec 2024 11:33:58 +0900 Subject: [PATCH 8/8] =?UTF-8?q?feat:=20=EB=8F=99=EB=84=A4=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20api=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=20(?= =?UTF-8?q?=20#13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mypageApi.ts | 6 ++++++ src/components/pages/myPage/LocationPage.tsx | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/api/mypageApi.ts b/src/api/mypageApi.ts index 442a579..b898a63 100644 --- a/src/api/mypageApi.ts +++ b/src/api/mypageApi.ts @@ -11,3 +11,9 @@ export const postPasswordChange = async (body: { newPassword: string }) => { return response.data; }; + +export const postLocationChange = async (body: { newAddress: string }) => { + const response = await axiosInstance.post(`/mypage/changeneighbor`, body); + + return response.data; +}; diff --git a/src/components/pages/myPage/LocationPage.tsx b/src/components/pages/myPage/LocationPage.tsx index dfac4b6..7863b53 100644 --- a/src/components/pages/myPage/LocationPage.tsx +++ b/src/components/pages/myPage/LocationPage.tsx @@ -3,6 +3,7 @@ import Sidemenu from './SideMenu'; import GS from './GS'; import KakaoMap from '../../common/KakaoMap'; import styled from 'styled-components'; +import { postLocationChange } from '../../../api/mypageApi'; function LocationPage() { const [location, setLocation] = useState<{ @@ -64,7 +65,15 @@ function LocationPage() { 현재 위치가 내 동네로 설정한 {region || '00동'}에 있습니다. - 동네인증 완료하기 + { + if (region) { + await postLocationChange({ newAddress: region }); + } + }} + > + 동네인증 완료하기 +