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
4 changes: 2 additions & 2 deletions src/entities/user/ui/my-profile-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { useState } from 'react';
import { usePatchAutoMatchingMutation } from '@/entities/user/model/use-user-profile-query';
import { useReviewReminder } from '@/features/study/lib/use-reminder-review';
import StudyReviewModal from '@/features/study/ui/study-review-modal';
import { getSincerityPresetByLevelId } from '@/shared/config/sincerity-temp-presets';
import { getSincerityPresetByLevelName } from '@/shared/config/sincerity-temp-presets';
import { cn } from '@/shared/shadcn/lib/utils';
import UserAvatar from '@/shared/ui/avatar';
import { ToggleSwitch } from '@/shared/ui/toggle';
Expand Down Expand Up @@ -41,7 +41,7 @@ export default function MyProfileCard({
const { showReviewReminder, setShowReviewReminder } = useReviewReminder();

const [enabled, setEnabled] = useState(matching);
const temperPreset = getSincerityPresetByLevelId(sincerityTemp.levelId);
const temperPreset = getSincerityPresetByLevelName(sincerityTemp.levelName);

const { mutate: patchAutoMatching, isPending } =
usePatchAutoMatchingMutation();
Expand Down
6 changes: 3 additions & 3 deletions src/entities/user/ui/user-profile-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import GithubIcon from '@/features/my-page/ui/icon/github-logo.svg';
import GlobeIcon from '@/features/my-page/ui/icon/globe-simple.svg';
import PhoneIcon from '@/features/my-page/ui/icon/phone.svg';
import { useUserPositiveKeywordsQuery } from '@/features/study/model/use-review-query';
import { getSincerityPresetByLevelId } from '@/shared/config/sincerity-temp-presets';
import { getSincerityPresetByLevelName } from '@/shared/config/sincerity-temp-presets';
import UserAvatar from '@/shared/ui/avatar';
import Badge from '@/shared/ui/badge';
import { Modal } from '@/shared/ui/modal';
Expand All @@ -31,8 +31,8 @@ export default function UserProfileModal({
if (isLoading || isError || !profile || !positiveKeywordsData) return null;

const positiveKeywords = positiveKeywordsData?.keywords || [];
const temperPreset = getSincerityPresetByLevelId(
profile.sincerityTemp.levelId,
const temperPreset = getSincerityPresetByLevelName(
profile.sincerityTemp.levelName,
);

return (
Expand Down
4 changes: 2 additions & 2 deletions src/features/my-page/ui/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GithubIcon from '@/features/my-page/ui/icon/github-logo.svg';
import GlobeIcon from '@/features/my-page/ui/icon/globe-simple.svg';
import PhoneIcon from '@/features/my-page/ui/icon/phone.svg';
import ProfileEditModal from '@/features/my-page/ui/profile-edit-modal';
import { getSincerityPresetByLevelId } from '@/shared/config/sincerity-temp-presets';
import { getSincerityPresetByLevelName } from '@/shared/config/sincerity-temp-presets';
import { cn } from '@/shared/shadcn/lib/utils';
import UserAvatar from '@/shared/ui/avatar';
import Badge from '@/shared/ui/badge';
Expand All @@ -22,7 +22,7 @@ export default function Profile({
memberProfile,
sincerityTemp,
}: ProfileProps) {
const temperPreset = getSincerityPresetByLevelId(sincerityTemp.levelId);
const temperPreset = getSincerityPresetByLevelName(sincerityTemp.levelName);

return (
<div className="flex w-full max-w-[80%] gap-300 px-200">
Expand Down
34 changes: 16 additions & 18 deletions src/shared/config/sincerity-temp-presets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TempType2 from '@/shared/icons/temp_2.svg';
import TempType3 from '@/shared/icons/temp_3.svg';
import TempType4 from '@/shared/icons/temp_4.svg';

export type SincerityType = 'type1' | 'type2' | 'type3' | 'type4';
export type SincerityLabel = '1단계' | '2단계' | '3단계' | '4단계';

export interface SincerityPreset {
indicatorClass: string;
Expand All @@ -13,8 +13,8 @@ export interface SincerityPreset {
label?: string;
}

export const SINCERITY_TEMP_PRESETS: Record<SincerityType, SincerityPreset> = {
type1: {
export const SINCERITY_TEMP_PRESETS: Record<SincerityLabel, SincerityPreset> = {
'1단계': {
// todo: Figma에 헥스코드로만 존재. 디자인 시스템 X. 현재 코드에서는 헥스값 인식을 하지 못하기 때문에 임의 컬러로 설정
// 현재 기획 여쭤본 상태, 컬러값에 따라 global에 추가후 변경 가능성 O.
// indicatorClass: '#F5C400',
Expand All @@ -25,21 +25,21 @@ export const SINCERITY_TEMP_PRESETS: Record<SincerityType, SincerityPreset> = {
Icon: TempType1,
label: '노란불씨',
},
type2: {
'2단계': {
indicatorClass: 'bg-orange-400',
textClass: 'text-orange-400',
bgClass: 'bg-orange-50',
Icon: TempType2,
label: '주황불꽃',
},
type3: {
'3단계': {
indicatorClass: 'bg-rose-500',
textClass: 'text-rose-500',
bgClass: 'bg-rose-50',
Icon: TempType3,
label: '불꽃',
},
type4: {
'4단계': {
indicatorClass: 'bg-indigo-500',
textClass: 'text-indigo-500',
bgClass: 'bg-indigo-50',
Expand All @@ -48,18 +48,16 @@ export const SINCERITY_TEMP_PRESETS: Record<SincerityType, SincerityPreset> = {
},
} as const;

const LEVEL_ID_TO_TYPE: Record<number, SincerityType> = {
5: 'type1', // 1단계
6: 'type2', // 2단계
7: 'type3', // 3단계
8: 'type4', // 4단계
};
export function toLevelLabel(levelName?: string): SincerityLabel {
const n = Number((levelName ?? '').match(/\d+/)?.[0] ?? 1);
const clamped = Math.min(4, Math.max(1, n || 1));

// 매핑 안되는 값이 들어왔을 경우 FALLBACK
const FALLBACK_TYPE: SincerityType = 'type1';

export function getSincerityPresetByLevelId(levelId: number): SincerityPreset {
const type = LEVEL_ID_TO_TYPE[levelId] ?? FALLBACK_TYPE;
return `${clamped}단계` as SincerityLabel;
}

return SINCERITY_TEMP_PRESETS[type];
// 매핑 안되는 값이 들어왔을 경우 FALLBACK
export function getSincerityPresetByLevelName(
levelName?: string,
): SincerityPreset {
return SINCERITY_TEMP_PRESETS[toLevelLabel(levelName)];
}