Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SETTING] 설정 페이지 추가 및 수정 #106

Merged
merged 32 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0251690
feat: 업데이트 svg 추가
Sep 24, 2023
fd1875f
feat: 비밀번호 변경 확인 모달 추가
Sep 24, 2023
ef78389
feat: 모바일 로그아웃 확인 모달 추가
Sep 24, 2023
3f1d429
feat: 모바일 공통 모달 추가
Sep 24, 2023
ad5296f
feat: PC 설정 페이지 구현
Sep 24, 2023
3170038
feat: 모바일 비밀번호 변경 페이지 구현
Sep 24, 2023
e70c371
refactor: pc, 모바일 설정 페이지 병합
Sep 24, 2023
99ce1a2
feat: 설정페이지 라우팅 추가
Sep 24, 2023
a0d6fc5
refactor: Discriminated Union 추가 및 코드 수정
Sep 24, 2023
aba4034
refactor: 오타 수정 및 ui 수정
Sep 24, 2023
69b5fae
Merge remote-tracking branch 'origin/develop' into feature/#100
Sep 24, 2023
2635577
feat: 회원 탈퇴 api 추가 및 연결
Sep 24, 2023
3e6537b
chore: 폴더 구조 개선
Oct 6, 2023
23b703a
refactor: 디폴트 레이아웃 적용
Oct 6, 2023
2d00785
chore: 폴더구조 개선
Oct 6, 2023
ce31a41
refactor: UI 개선
Oct 6, 2023
8a24750
refactor: useBooleanState 적용
Oct 6, 2023
ac56830
refactor: class 이름 변경
Oct 6, 2023
38935f7
refactor: 인터페이스명 변경
Oct 14, 2023
f793f72
refactor: hook 분리
Oct 14, 2023
d223a63
refactor: 함수명 변경
Oct 14, 2023
601ec76
refactor: 탈퇴하기 UI 변경
Oct 14, 2023
37a9416
refactor: 변수명 변경
Oct 14, 2023
0331c7d
style: 에러메세지 UI 수정
Oct 14, 2023
7430094
refactor: 에러메세지 jsx로 반환
Oct 14, 2023
b94a6fb
refactor: 탈퇴하기 함수명 변경
Oct 14, 2023
0f191a7
refactor: 타입단언 삭제
Oct 22, 2023
4621368
refactor: 도메인 설명 함수 추가
Oct 22, 2023
374eeb9
Merge remote-tracking branch 'origin/develop' into feature/#100
Oct 22, 2023
7b6dff6
Merge branch 'develop' into feature/#100
LUNA-KK Oct 22, 2023
1be8c1a
Merge branch 'feature/#100' of https://github.com/BCSDLab/JJBAKSA_FRO…
Oct 22, 2023
62329ff
refactor: 마이페이지 타입 문제 해결
Oct 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ChangePassword from 'pages/Auth/FindIDPassword/ChangePassword';
import { Suspense } from 'react';
import SearchDetails from 'pages/SearchDetails';
import FollowPage from 'pages/Follow';
import Setting from 'pages/Setting/UserSetting';
import Setting from 'pages/Setting';
import IdChange from 'pages/Setting/UserSetting/IdChange';
import AuthRoute from 'components/common/AuthRoute';
import Withdrawal from 'pages/Setting/Withdrawal';
Expand Down
12 changes: 12 additions & 0 deletions src/api/user/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ export interface User {
};
}

export interface SNSUser {
id: number,
nickname: string,
email: string,
}

export type Users = User | SNSUser;
LUNA-KK marked this conversation as resolved.
Show resolved Hide resolved

export interface SendRegisterEmailParams {
email: string;
}
Expand All @@ -62,3 +70,7 @@ export interface FindPasswordParams {
export interface ChangePasswordParams {
password: string
}

export interface CheckPasswordParams {
password: string
}
8 changes: 7 additions & 1 deletion src/api/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
SendFindEmailParams,
GetAccountParams,
FindPasswordParams,
Users,
CheckPasswordParams,
} from './entity';
import userApi from './userApiClient';

Expand All @@ -22,7 +24,7 @@ export const login = async (param: LoginParams) => {
return { data };
};

export const getMe = () => userApi.get<User>('/me');
export const getMe = () => userApi.get<Users>('/me');

export const withdrawUser = () => userApi.delete<User>('/me');

Expand All @@ -39,3 +41,7 @@ export const findPassowrd = (param: FindPasswordParams) => userApi.post('/passwo
code: param.code,
email: param.email,
});

export const checkPassword = (param: CheckPasswordParams) => userApi.post(`/check-password?password=${param.password}`);

export const secession = () => userApi.delete('/me');
3 changes: 3 additions & 0 deletions src/assets/svg/setting/version-check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/pages/Follow/components/SearchPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useAuth } from 'store/auth';
import { User } from 'api/user/entity';
import { FollowerInfo, SearchPageInfo } from '../static/entity';
import FollowList from './FollowList';

export default function SearchPage({ data }: SearchPageInfo) {
const auth = useAuth();
const auth = useAuth() as User;
LUNA-KK marked this conversation as resolved.
Show resolved Hide resolved
const myFriends: FollowerInfo[] = data.filter((follower) => follower.followedType === 'FOLLOWED');
const newFriends: FollowerInfo[] = data.filter((follower) => follower.followedType === 'NONE').filter((follower) => follower.account !== auth?.account);

Expand Down
28 changes: 28 additions & 0 deletions src/pages/Setting/PC/LogoutModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createPortal } from 'react-dom';
import { Link } from 'react-router-dom';
import { useClearAuth } from 'store/auth';
import { ReactComponent as Favicon } from 'assets/svg/common/favicon.svg';
import style from './PasswordSuccessModal.module.scss';

interface Props {
children: React.ReactNode;
}
export default function LogoutModal({ children }: Props) {
const root = document.body;
const clearAuth = useClearAuth();
return createPortal(
LUNA-KK marked this conversation as resolved.
Show resolved Hide resolved
<div className={style.container}>
<div className={style.overay} />
<div className={style.modal}>
<Favicon />
<button className={style.modal__close} type="button" onClick={clearAuth}>X</button>
<div className={style.modal__title}>
로그아웃을 진행하실건가요?
</div>
<div className={style.modal__content}>{children}</div>
<Link to="/login" onClick={clearAuth}><button type="button" className={style.modal__button}>확인</button></Link>
</div>
</div>,
root,
);
}
140 changes: 140 additions & 0 deletions src/pages/Setting/PC/ManageAccount.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { ReactComponent as ShowIcon } from 'assets/svg/auth/pw-show.svg';
import { ReactComponent as BlindIcon } from 'assets/svg/auth/pw-blind.svg';
import { useAuth } from 'store/auth';
import { ReactComponent as ErrorIcon } from 'assets/svg/auth/error.svg';
import cn from 'utils/ts/classNames';
import useTripleBlindCheck from './hook/useTripleBlindCheck';
import style from './index.module.scss';
import useModifyPassword, { ERROR_MESSAGE } from './hook/useModifyPassword';
import PasswordSuccessModal from './PasswordSuccessModal';

export default function ManageAccount() {
const {
isCurrentBlind,
changeCurrentBlind,
isNewBlind,
changeNewBlind,
isNewCheckBlind,
changeNewCheckBlind,
} = useTripleBlindCheck();
const {
current,
newPassword,
check,
handleCheck,
handleCurrent,
handleNewPassword,
modifyPassword,
isShowError,
message,
isShowModal,
} = useModifyPassword();
LUNA-KK marked this conversation as resolved.
Show resolved Hide resolved
const auth = useAuth();
return (
<form className={style.formContainer}>

LUNA-KK marked this conversation as resolved.
Show resolved Hide resolved
<div className={style.title}>계정</div>
<div className={style.account}>
<span>이메일</span>
<input className={style.account__input} value={auth ? auth.email : ''} disabled />
</div>
<div>
<span>아이디</span>
<input className={style.account__input} value={auth && 'account' in auth ? auth.account : 'SNSLogin'} disabled />
LUNA-KK marked this conversation as resolved.
Show resolved Hide resolved
</div>

<div className={style.title}>비밀번호 변경</div>
<div>
<span>현재 비밀번호</span>
<span className={style.blindBox}>
<input
className={cn({
[style.password]: true,
[style.password__error]:
message === ERROR_MESSAGE.Current_Error || message === ERROR_MESSAGE.Type_Error,
LUNA-KK marked this conversation as resolved.
Show resolved Hide resolved
})}
type={isCurrentBlind ? 'text' : 'password'}
disabled={!(auth && 'account' in auth)}
value={current}
onChange={handleCurrent}
/>
<button
type="button"
onClick={() => (auth && 'account' in auth) && changeCurrentBlind()}
className={style.blindBox__button}
>
{isCurrentBlind ? (
<ShowIcon aria-hidden />
) : (
<BlindIcon aria-hidden />
)}
</button>
</span>
</div>
<div>
<span>새 비밀번호</span>
<span className={style.blindBox}>
<input
className={cn({
[style.password]: true,
[style.password__error]:
message === ERROR_MESSAGE.Correct_Error,
})}
type={isNewBlind ? 'text' : 'password'}
disabled={!(auth && 'account' in auth)}
value={newPassword}
onChange={handleNewPassword}
/>
<button
type="button"
onClick={() => (auth && 'account' in auth) && changeNewBlind()}
className={style.blindBox__button}
>
{isNewBlind ? (
<ShowIcon aria-hidden />
) : (
<BlindIcon aria-hidden />
)}
</button>
</span>
</div>
<div>
<span>새 비밀번호 확인</span>
<span className={style.blindBox}>
<input
className={cn({
[style.password]: true,
[style.password__error]:
message === ERROR_MESSAGE.Correct_Error,
})}
type={isNewCheckBlind ? 'text' : 'password'}
disabled={!(auth && 'account' in auth)}
value={check}
onChange={handleCheck}
/>
<button
type="button"
onClick={() => (auth && 'account' in auth) && changeNewCheckBlind()}
className={style.blindBox__button}
>
{isNewCheckBlind ? (
<ShowIcon aria-hidden />
) : (
<BlindIcon aria-hidden />
)}
</button>
</span>
</div>
{isShowError && (
<div>
<ErrorIcon />
<span className={style.errorMessage}>
{message}
</span>
</div>
)}
<button className={style.button} type="button" onClick={modifyPassword}>비밀번호 변경</button>
{isShowModal && <PasswordSuccessModal>변경된 비밀번호로 로그인 해주세요.</PasswordSuccessModal>}
LUNA-KK marked this conversation as resolved.
Show resolved Hide resolved
</form>
);
}
90 changes: 90 additions & 0 deletions src/pages/Setting/PC/PasswordSuccessModal.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
.container {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
width: 100vw;
}

.overay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: rgb(0 0 0 / 35%);
height: 100vh;
width: 100vw;
}

.modal {
position: absolute;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
background-color: white;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 320px;
height: 200px;
border-radius: 20px;
padding: 15px;
padding-bottom: 0.5px;

&__container {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}

&__title {
font-size: 18px;
font-weight: 700;
color: #ff7f23;
}

&__content {
text-align: center;
font-size: 12px;
padding-bottom: 10px;
}

&__button {
border: none;
border-radius: 20px;
background-color: #ff7f23;
text-align: center;
width: 146px;
height: 44px;
color: white;
cursor: pointer;
margin-bottom: 15px;

&--cancel {
background-color: #c4c4c4;
color: white;
border: none;
border-radius: 20px;
width: 146px;
height: 44px;
margin-bottom: 15px;
}
}

&__close {
position: absolute;
top: 16px;
right: 22px;
font-size: 15px;
color: #c4c4c4;
background-color: transparent;
border: none;

&:hover {
cursor: pointer;
}
}
}
28 changes: 28 additions & 0 deletions src/pages/Setting/PC/PasswordSuccessModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createPortal } from 'react-dom';
import { Link } from 'react-router-dom';
import { useClearAuth } from 'store/auth';
import { ReactComponent as Favicon } from 'assets/svg/common/favicon.svg';
import style from './PasswordSuccessModal.module.scss';

interface Props {
children: React.ReactNode;
}
export default function PasswordSuccessModal({ children }: Props) {
const root = document.body;
const clearAuth = useClearAuth();
return createPortal(
<div className={style.container}>
<div className={style.overay} />
<div className={style.modal}>
<Favicon />
<button className={style.modal__close} type="button" onClick={clearAuth}>X</button>
<div className={style.modal__title}>
비밀번호 변경을 완료했습니다.
</div>
<div className={style.modal__content}>{children}</div>
<Link to="/login" onClick={clearAuth}><button type="button" className={style.modal__button}>로그인</button></Link>
</div>
</div>,
root,
);
}
Loading
Loading