Skip to content

Commit

Permalink
feat: show locations in profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooorobo committed Dec 8, 2024
1 parent 7b1c07d commit d613ba2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/entities/ideal_partner/model/convertIdealPartnerToDto.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/entities/profile/lib/getLocationText.ts
Original file line number Diff line number Diff line change
@@ -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)}`);
};
15 changes: 14 additions & 1 deletion src/entities/profile/model/convertProfileToDto.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d613ba2

Please sign in to comment.