From d613ba23141ada36bbe33ff33fcd487bfc623c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=98=88=EC=A7=84?= Date: Sun, 8 Dec 2024 21:14:45 +0900 Subject: [PATCH] feat: show locations in profile page --- .../model/convertIdealPartnerToDto.ts | 15 ++++++++++++++- src/entities/profile/lib/getLocationText.ts | 3 ++- src/entities/profile/model/convertProfileToDto.ts | 15 ++++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/entities/ideal_partner/model/convertIdealPartnerToDto.ts b/src/entities/ideal_partner/model/convertIdealPartnerToDto.ts index 2df814a..b451ca5 100644 --- a/src/entities/ideal_partner/model/convertIdealPartnerToDto.ts +++ b/src/entities/ideal_partner/model/convertIdealPartnerToDto.ts @@ -1,5 +1,6 @@ import { IdealPartner } from 'src/entities/ideal_partner/model/idealPartnerStore'; import { DetailedInfoIdealPartner, IdealPartnerRequest, ImageDto } from 'src/types'; +import { Location } from 'src/entities/location/types/location'; export const convertIdealPartnerToDto = (idealPartner: IdealPartner, images: ImageDto[]): IdealPartnerRequest => { return { @@ -28,7 +29,19 @@ export const convertDtoToIdealPartner = (dto: DetailedInfoIdealPartner): IdealPa hobbies: dto.hobbies?.map((h) => ({ name: h })) ?? [], images: [], imageDtoList: dto.images ?? [], - locations: [], + locations: + (dto.location?.towns + .map((town, idx) => { + const city = dto.location?.cities[idx]; + if (!city) return null; + return dto.location?.cities[idx] + ? ({ + town: [{ town, townName: `TOWN_${town}` }], + city: { city, cityName: `CITY_${city}` }, + } satisfies Location) + : null; + }) + .filter(Boolean) as Location[]) || [], religion: dto.religion, requiredOptions: dto.requiredOptions ?? [], smoking: dto.smoking, diff --git a/src/entities/profile/lib/getLocationText.ts b/src/entities/profile/lib/getLocationText.ts index b750a63..50f056f 100644 --- a/src/entities/profile/lib/getLocationText.ts +++ b/src/entities/profile/lib/getLocationText.ts @@ -1,5 +1,6 @@ import { Location } from '../../location/types/location'; +import { t } from 'i18next'; export const getLocationText = (location: Location) => { - return location.town.map((t) => `${location.city.cityName} ${t.townName}`); + return location.town.map((town) => `${t(location.city.cityName)} ${t(town.townName)}`); }; diff --git a/src/entities/profile/model/convertProfileToDto.ts b/src/entities/profile/model/convertProfileToDto.ts index 6bba786..ea5c832 100644 --- a/src/entities/profile/model/convertProfileToDto.ts +++ b/src/entities/profile/model/convertProfileToDto.ts @@ -1,6 +1,7 @@ import { MyProfile } from 'src/entities/profile/model/myProfileStore'; import { DetailedInfoUserInfo, ImageDto, UserInfoRequest, UserInfoRequestMbti } from 'src/types'; import { convertDateObjectToDate, convertDateToDateObject } from 'src/shared/vo/date'; +import { Location } from 'src/entities/location/types/location'; export const convertProfileToDto = (profile: MyProfile, images: ImageDto[]): UserInfoRequest => { return { @@ -40,7 +41,19 @@ export const convertDtoToProfile = (dto: DetailedInfoUserInfo): MyProfile => { imageDtoList: dto.images, introduction: '', job: dto.job, - location: [], + location: + (dto.location?.towns + .map((town, idx) => { + const city = dto.location?.cities[idx]; + if (!city) return null; + return dto.location?.cities[idx] + ? ({ + town: [{ town, townName: `TOWN_${town}` }], + city: { city, cityName: `CITY_${city}` }, + } satisfies Location) + : null; + }) + .filter(Boolean) as Location[]) || [], mbti: dto.mbti ?? null, name: dto.name, religion: dto.religion,