Skip to content

Commit

Permalink
Feat: #211 DB 명세서에 따라 프로필 사진 저장 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoonyesol committed Oct 13, 2024
1 parent 6427a01 commit c948b9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/mocks/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,17 +842,17 @@ export const FILE_DUMMY: FileInfo[] = [
export const PROFILE_IMAGE_DUMMY = [
{
userId: 1,
file: new Blob([''], { type: 'image/jpeg' }),
file: new Blob(['프로필_이미지_1'], { type: 'image/jpeg' }),
uploadName: 'PROFILE_IMAGE_UUID_1.jpg',
},
{
userId: 2,
file: new Blob([''], { type: 'image/jpeg' }),
file: new Blob(['프로필_이미지_2'], { type: 'image/jpeg' }),
uploadName: 'PROFILE_IMAGE_UUID_2.jpg',
},
{
userId: 3,
file: new Blob([''], { type: 'image/png' }),
file: new Blob(['프로필_이미지_3'], { type: 'image/png' }),
uploadName: 'PROFILE_IMAGE_UUID_3.jpg',
},
];
15 changes: 7 additions & 8 deletions src/mocks/services/userServiceHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@mocks/mockData';
import { NICKNAME_REGEX } from '@constants/regex';
import { convertTokenToUserId } from '@utils/converter';
import { fileNameParser } from '@utils/fileNameParser';
import type { Team } from '@/types/TeamType';
import type { Role } from '@/types/RoleType';
import type { EditUserInfoForm, User } from '@/types/UserType';
Expand Down Expand Up @@ -88,8 +89,10 @@ const userServiceHandler = [
);
}

const uploadName = `PROFILE_IMAGE_UUID_${PROFILE_IMAGE_DUMMY.length + 1}.jpg`;
const { fileName, extension } = fileNameParser(file.name);
const uploadName = extension ? `${fileName}_${Date.now()}.${extension}` : `${fileName}_${Date.now()}`;

// 프로필 이미지 더미 데이터 추가
const profileImageIndex = PROFILE_IMAGE_DUMMY.findIndex((user) => user.userId === userId);
if (profileImageIndex !== -1) {
PROFILE_IMAGE_DUMMY[profileImageIndex].uploadName = uploadName;
Expand All @@ -101,14 +104,10 @@ const userServiceHandler = [
});
}

console.log(PROFILE_IMAGE_DUMMY);
// 유저 정보에 이미지 링크 추가 (UUID.extension)
USER_DUMMY[userIndex].profileImageName = uploadName;

// URL 경로 설정
const imageUrl = `${BASE_URL}/images/${uploadName}`;

USER_DUMMY[userIndex].profileImageName = imageUrl;

return HttpResponse.json({ imageUrl }, { status: 200 });
return HttpResponse.json(null, { status: 200 });
}),
// 가입한 팀 목록 조회 API
http.get(`${BASE_URL}/user/team`, ({ request }) => {
Expand Down

0 comments on commit c948b9e

Please sign in to comment.