Skip to content

Commit

Permalink
fix: 닉네임 중복 로직 추가 및 약관 동의 여부 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Songhyejeong committed Dec 7, 2024
1 parent b403de8 commit 8b174a8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/components/login/Consent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Grey, DarkGreen, DarkGrey, Orange } from '../../color';
import { Button } from '../common';
import { useState } from 'react';

const Consent = ({ setIsConsent }) => {
const Consent = ({ setIsAllConsent }) => {
const [checkedItems, setCheckedItems] = useState({
terms: false,
privacyConsent: false,
Expand All @@ -19,7 +19,7 @@ const Consent = ({ setIsConsent }) => {

const handleClickNextStep = (e) => {
if (isAllChecked) {
setIsConsent(true);
setIsAllConsent(true);
}
};

Expand Down
25 changes: 19 additions & 6 deletions src/components/login/SignUp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import { signUp } from '../../apis/api/postSignupForm';
import { Button } from '../common';
import Swal from 'sweetalert2';

const Signup = () => {
const Signup = ({ isAllConsent }) => {
const navigate = useNavigate();
const [signupForms, setSignupForms] = useState({
email: '',
password: '',
nickname: '',
serviceAgreement: isAllConsent,
privacyAgreement: isAllConsent,
ageConfirmation: isAllConsent,
});

const [errors, setErrors] = useState({
Expand Down Expand Up @@ -53,12 +56,22 @@ const Signup = () => {

if (response.status !== 201) {
const errorMessage = response.error.message;
Swal.fire({
icon: 'warning',
title: '회원 가입 실패',
text: errorMessage,
});
if (response.status === 409) {
setErrors((prev) => ({
...prev,
nickname: '중복된 닉네임 입니다.',
}));
} else {
Swal.fire({
icon: 'warning',
title: '회원가입 실패',
text: errorMessage,
});
}

console.log(errorMessage);
}

if (response.status === 201) {
Swal.fire({
icon: 'success',
Expand Down
8 changes: 4 additions & 4 deletions src/pages/SignUpPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Signup } from '../components/login';
import { Consent } from '../components/login';

const SignUpPage = () => {
const [isConsent, setIsConsent] = useState(false);
const [isAllConsent, setIsAllConsent] = useState(false);

if (isConsent) {
return <Signup />;
if (isAllConsent) {
return <Signup isAllConsent={isAllConsent} />;
} else {
return <Consent setIsConsent={setIsConsent} />;
return <Consent setIsAllConsent={setIsAllConsent} />;
}
};

Expand Down

0 comments on commit 8b174a8

Please sign in to comment.