Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions src/apis/auth/dto.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { BaseSuccessResponse } from '../core/dto';
import type { BaseSuccessResponse } from '@apis/core/dto';

// jwt를 이용한 사용자 정보 조회 응답
export type getUserInfoByJwtResponse = BaseSuccessResponse<getUserInfoByJwtData>;
// jwt를 이용한 사용자 정보 조회 응답 데이터
export interface getUserInfoByJwtData {
userId: number;
id: number;
name: string;
phoneNumber: string;
email: string;
nickname: string;
profilePictureUrl: string;
bio: string;
birthDate: string;
}
4 changes: 2 additions & 2 deletions src/apis/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getUserInfoByJwtResponse } from './dto';
import { newRequest } from '../core';
import { newRequest } from '@apis/core';
import type { getUserInfoByJwtResponse } from './dto';

// jwt로 사용자 정보 조회 api /auth/me
export const getUserInfoByJwtApi = () => newRequest.get<getUserInfoByJwtResponse>('/auth/me');
2 changes: 1 addition & 1 deletion src/apis/user-block/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EmptySuccessResponse } from '@apis/core/dto';
import { newRequest } from '@apis/core';
import type { EmptySuccessResponse } from '@apis/core/dto';
import type { PostUserBlockRequest } from './dto';

// 유저 차단 api
Expand Down
2 changes: 1 addition & 1 deletion src/apis/user-report/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EmptySuccessResponse } from '@apis/core/dto';
import { newRequest } from '@apis/core';
import type { EmptySuccessResponse } from '@apis/core/dto';
import type { PostUserReportRequest } from './dto';

// 유저 신고 api
Expand Down
8 changes: 4 additions & 4 deletions src/apis/user/dto.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { BaseSuccessResponse } from '../core/dto';
import type { BaseSuccessResponse } from '@apis/core/dto';

// 사용자 정보 공통 인터페이스
export interface UserInfoData {
userId: number;
id: number;
name: string;
phoneNumber: string;
email: string;
nickname: string;
profilePictureUrl: string;
bio: string;
birthDate: string; // user 공통 인터페이스에 이 두 개는 안 나와있어서 일단 이것들만 optional 처리했습니다...
birthDate: string;
isFriend: boolean;
}

Expand Down Expand Up @@ -37,5 +37,5 @@ export type PatchUserWithDrawResponse = BaseSuccessResponse<PatchUserWithdrawDat
export interface PatchUserWithdrawData {
isSuccess: boolean;
code: string;
data: Record<string, never>; // 탈퇴 성공 시 항상 빈 객체가 응답으로 온다면 Record<string, never>으로 타입 안정성 높일 수 있답니다
data: Record<string, never>; // 탈퇴 성공 시 항상 빈 객체가 응답으로 온다면 Record<string, never>으로 타입 안정성 높일 수 있음
}
11 changes: 8 additions & 3 deletions src/apis/user/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { GetUserInfoResponse, PatchUserInfoRequest, PatchUserInfoResponse, PatchUserWithDrawResponse } from './dto';
import { newRequest } from '../core';
import { EmptySuccessResponse } from '../core/dto';
import { newRequest } from '@apis/core';
import type { EmptySuccessResponse } from '@apis/core/dto';
import type {
GetUserInfoResponse,
PatchUserInfoRequest,
PatchUserInfoResponse,
PatchUserWithDrawResponse,
} from './dto';

// 유저 정보 수정 api
export const patchUserInfoApi = (data: Partial<PatchUserInfoRequest>, userId: number) =>
Expand Down
8 changes: 4 additions & 4 deletions src/pages/Login/LoginComplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ const LoginComplete: React.FC = () => {
const response = await getUserInfoByJwtApi();
console.log(response);

const { nickname, name, userId } = response.data;
localStorage.setItem('current_user_id', `${userId}`);
const { nickname, name, id } = response.data;
localStorage.setItem('current_user_id', `${id}`);

if (nickname && name) {
if (nickname && name) {
const isAgreed = await hasAgreedToTerms(userId);
navigate(isAgreed ? '/' : '/terms-agreement'); // 이용 약관이 필요하면 (false) 해당 페이지로 이동
const isAgreed = await hasAgreedToTerms(id);
navigate(isAgreed ? '/' : '/signup/terms-agreement'); // 이용 약관이 필요하면 (false) 해당 페이지로 이동
}
} else {
navigate('/signup');
Expand Down
4 changes: 2 additions & 2 deletions src/recoil/ProfileViewer/userDetailsAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { atom } from 'recoil';
import type { UserInfoData } from '@apis/user/dto';
import imageBasic from '@assets/default/defaultProfile.svg';

type BasicUserInfo = Pick<UserInfoData, 'userId' | 'nickname' | 'bio' | 'isFriend' | 'profilePictureUrl'>;
type BasicUserInfo = Pick<UserInfoData, 'id' | 'nickname' | 'bio' | 'isFriend' | 'profilePictureUrl'>;

export const UserInfoAtom = atom<BasicUserInfo | null>({
key: 'UserInfoAtom',
default: {
userId: -1,
id: -1,
nickname: '알 수 없음',
bio: '',
isFriend: false,
Expand Down
Loading