Skip to content

Commit

Permalink
feat: add translation values
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooorobo committed Dec 22, 2024
1 parent 741b7a6 commit e4f0bed
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
6 changes: 6 additions & 0 deletions public/locales/ko/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@
"DRINKING_ONE_TWO_TIMES_A_WEEK":"주 1-2회 가볍게는 괜찮아요",
"DRINKING_ONE_TWO_TIMES_A_MONTH": "달 1-2회 정도 괜찮아요",
"DRINKING_NEVER":"되도록 안하면 좋겠어요",
"DRINKING_DRINKER": "O",
"DRINKING_NON_DRINKER": "X",
"DRINKING_ETC": "기타",
"JOB_STUDENT": "학생(대학원생)",
"JOB_EMPLOYEE": "직장인",
"JOB_FREELANCER": "자영업자, 프리랜서",
"JOB_ETC": "기타",
"LOCATION_IMPORTANT": "중요해요",
"LOCATION_NOT_IMPORTANT": "상관 없어요",
"HOBBY_IMPORTANT": "중요해요",
"HOBBY_NOT_IMPORTANT": "상관 없어요",
"CITY_SEOUL": "서울",
"CITY_GYEONGGI": "경기",
"CITY_INCHEON": "인천",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import { getSmokingText } from '../../../profile/lib/getSmokingText';
import { getDrinkingText } from '../../../profile/lib/getDrinkingText';
import { getReligionText } from '../../../profile/lib/getReligionText';
import { useProfileEditContext } from 'src/features/EditInfo/ProfileEditContext';
import { useTranslation } from 'react-i18next';

export const IdealPartnerProfile = ({ profile }: { profile: IdealPartner }) => {
const { t } = useTranslation();

const value = useProfileEditContext();
const onClickEdit = value.canEdit ? value.onEdit : undefined;

Expand All @@ -17,19 +20,19 @@ export const IdealPartnerProfile = ({ profile }: { profile: IdealPartner }) => {

return (
<section className={styles.Grid}>
{(showBlankValue || profile.ageRange) && (
{
<div className={styles.Cell}>
<ProfileCellHeader title={'선호하는 연령대'} onClickEdit={() => onClickEdit?.('IDEAL_AGE')} />
<span>
{profile.ageRange?.min}-{profile.ageRange?.max}
{profile.ageRange ? `${profile.ageRange?.min}-${profile.ageRange?.max}` : '나이는 딱히 상관 없어요'}
</span>
</div>
)}
}
{(showBlankValue || profile.heightRange) && (
<div className={styles.Cell}>
<ProfileCellHeader title={'선호하는 키'} onClickEdit={() => onClickEdit?.('IDEAL_HEIGHT_STYLE')} />
<span>
{profile.heightRange?.min}cm-{profile.heightRange?.max}cm
{profile.heightRange?.min}cm - {profile.heightRange?.max}cm
</span>
</div>
)}
Expand All @@ -49,11 +52,11 @@ export const IdealPartnerProfile = ({ profile }: { profile: IdealPartner }) => {
)}
<div className={styles.Cell}>
<ProfileCellHeader title={'희망 지역'} onClickEdit={() => onClickEdit?.('IDEAL_LOCATION')} />
<span>{profile.locations}</span>
<span>{t(`LOCATION_${profile.locations}`)}</span>
</div>
<div className={styles.Cell}>
<ProfileCellHeader title={'취미'} onClickEdit={() => onClickEdit?.('IDEAL_HOBBY')} />
<div className={styles.ChipList}>{profile.hobbies}</div>
<div className={styles.ChipList}>{t(`HOBBY_${profile.hobbies}`)}</div>
</div>
{(showBlankValue || profile.religion) && (
<div className={styles.Cell}>
Expand Down
4 changes: 3 additions & 1 deletion src/entities/profile/lib/getDrinkingText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import { t } from 'i18next';
import { IdealPartnerDrinking, UserInfoDrinking } from 'src/types';

export const getDrinkingText = (drinking: UserInfoDrinking | IdealPartnerDrinking) => {
return t(`DRINKING_${drinking.drinkingCategory}`);
return drinking.drinkingCategory === 'DRINKER'
? drinking.drinkingAmount || 'O'
: t(`DRINKING_${drinking.drinkingCategory}`);
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ export const TasteInfoGrid = ({ profile, onClickEdit }: { profile: MyProfile; on
<div className={styles.GridRow}>
{(showBlankValue || profile.smoking) && (
<div className={styles.Cell}>
<ProfileCellHeader title={'흡연여부'} onClickEdit={() => onClickEdit?.('PROFILE_SMOKE_ALCOHOL')} />
<ProfileCellHeader title={'흡연 여부'} onClickEdit={() => onClickEdit?.('PROFILE_SMOKE_ALCOHOL')} />
<span>{getSmokingText(profile.smoking, 'INFO')}</span>
</div>
)}
{(showBlankValue || profile.drinking) && (
<div className={styles.Cell}>
<ProfileCellHeader title={'음주 빈도'} onClickEdit={() => onClickEdit?.('PROFILE_SMOKE_ALCOHOL')} />
<ProfileCellHeader title={'음주 여부'} onClickEdit={() => onClickEdit?.('PROFILE_SMOKE_ALCOHOL')} />
<span>{getDrinkingText(profile.drinking)}</span>
</div>
)}
Expand Down
3 changes: 1 addition & 2 deletions src/entities/profile/ui/ProfileCard/ProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { getReligionText } from 'src/entities/profile/lib/getReligionText';
import { Chip } from 'src/shared/ui/Chip/Chip';
import { getJobText } from 'src/entities/profile/lib/getJobText';
import { Avatar } from 'src/shared/ui/Avatar/Avatar';
import { getLocationText } from 'src/entities/profile/lib/getLocationText';
import { convertDtoToLocation } from 'src/entities/profile/model/convertProfileToDto';
import { getDrinkingText } from 'src/entities/profile/lib/getDrinkingText';

Expand Down Expand Up @@ -40,7 +39,7 @@ export const ProfileCard = ({ profile, headerRightSlot }: Props) => {
<div className={styles.Info}>
<span>{calculateAge(new Date(profile.birthDate))}</span>
<span>{t(profile.gender)}</span>
<span>{location ? getLocationText(location) : ''}</span>
{location && <span>getLocationText(location)</span>}
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/shared/ui/Profile/Profile.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
display: grid;
gap: 8px;
width: 100%;

& > span {
line-height: 24px;
}
}

.CellHeader {
Expand Down

0 comments on commit e4f0bed

Please sign in to comment.