Skip to content

Commit

Permalink
feat: fix idealPartner types and add convertPartnerToDto
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooorobo committed Aug 18, 2024
1 parent ddaf77a commit 13d8011
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/entities/ideal_partner/api/__mock__/idealPartner.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { IdealPartner } from 'src/entities/ideal_partner/model/idealPartnerStore

export const MockIdealPartner: IdealPartner = {
ageRange: { max: 25, min: 20 },
drinking: { drinkingAmount: '주 1-2회 가볍게는 괜찮아요', drinkingCategory: '' },
drinking: { drinkingAmount: '주 1-2회 가볍게는 괜찮아요', drinkingCategory: 'ONE_TWO_TIMES_A_WEEK' },
heightRange: { max: 180, min: 175 },
hobbies: [{ name: '맛집탐방' }, { name: '뜨개질' }],
images: [],
locations: [
{ city: { cityName: '서울시', city: 'SEOUL' }, town: [{ town: 'GANGNAM', townName: '강남구' }] },
{ city: { cityName: '경기도', city: 'GYEONGGI' }, town: [{ town: 'SUWON', townName: '수원시' }] },
],
religion: { religionCategory: 'NONE', religionName: '' },
religion: { religionCategory: 'ETC', religionName: '' },
requiredOptions: [],
smoking: { smokingAmount: '', smokingCategory: 'NON_SMOKER' },
style: '눈이 크신 분',
Expand Down
21 changes: 21 additions & 0 deletions src/entities/ideal_partner/model/convertIdealPartnerToDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { IdealPartner } from 'src/entities/ideal_partner/model/idealPartnerStore';
import { IdealPartnerRequest, ImageDto } from 'src/types';

export const convertIdealPartnerToDto = (idealPartner: IdealPartner, images: ImageDto[]): IdealPartnerRequest => {
return {
ageRange: idealPartner.ageRange,
heightRange: idealPartner.heightRange,
style: idealPartner.style,
images,
location: {
cities: idealPartner.locations.map((l) => l.city.city),
towns: idealPartner.locations.flatMap((l) => l.town.map((t) => t.town)),
},
hobbies: idealPartner.hobbies.map((h) => h.name),
drinking: idealPartner.drinking,
religion: idealPartner.religion,
smoking: idealPartner.smoking,
requiredOptions: idealPartner.requiredOptions,
toMatchMaker: idealPartner.toMatchMaker,
};
};
20 changes: 10 additions & 10 deletions src/entities/ideal_partner/model/idealPartnerStore.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Location } from 'src/entities/location/types/location';
import { ReligionType } from 'src/entities/profile/types/profileSummary';
import { create } from 'zustand';
import { Hobby } from 'src/entities/hobby/types/hobby';
import { createStoreContext } from 'src/shared/functions/createStoreContext';
import { MAX_IDEAL_HEIGHT, MIN_IDEAL_HEIGHT } from 'src/processes/ideal_partner/HeightStyleForm/HeightStyleForm';
import { DrinkingDrinkingCategory, ReligionReligionCategory, SmokingSmokingCategory } from 'src/types';

export type IdealPartner = {
ageRange: {
Expand All @@ -19,15 +19,15 @@ export type IdealPartner = {
locations: Location[];
hobbies: Hobby[];
religion: {
religionCategory: ReligionType;
religionCategory: ReligionReligionCategory;
religionName: string;
};
drinking: {
drinkingCategory: string;
drinkingCategory: DrinkingDrinkingCategory;
drinkingAmount: string;
};
smoking: {
smokingCategory: string;
smokingCategory: SmokingSmokingCategory;
smokingAmount: string;
};
requiredOptions: string[];
Expand All @@ -43,11 +43,11 @@ type Action = {
setImages: (getState: (prevFiles: File[]) => File[]) => void;
setLocation: (value: Location[]) => void;
setHobbies: (hobbies: Hobby[]) => void;
setReligionCategory: (category: ReligionType) => void;
setReligionCategory: (category: ReligionReligionCategory) => void;
setReligionName: (name: string) => void;
setDrinkingCategory: (category: string) => void;
setDrinkingCategory: (category: DrinkingDrinkingCategory) => void;
setDrinkingAmount: (name: string) => void;
setSmokingCategory: (category: string) => void;
setSmokingCategory: (category: SmokingSmokingCategory) => void;
setSmokingAmount: (name: string) => void;
setRequiredOptions: (options: string[]) => void;
setToMatchMaker: (value: string) => void;
Expand Down Expand Up @@ -76,19 +76,19 @@ const createStoreHook = () =>
hobbies: [],
setHobbies: (hobbies) => set({ hobbies }),
religion: {
religionCategory: 'NONE',
religionCategory: 'ETC',
religionName: '',
},
setReligionCategory: (religion) => set({ religion: { ...get().religion, religionCategory: religion } }),
setReligionName: (desc) => set({ religion: { ...get().religion, religionName: desc } }),
drinking: {
drinkingCategory: '',
drinkingCategory: 'ETC',
drinkingAmount: '',
},
setDrinkingCategory: (drinking) => set({ drinking: { ...get().drinking, drinkingCategory: drinking } }),
setDrinkingAmount: (amount) => set({ drinking: { ...get().drinking, drinkingAmount: amount } }),
smoking: {
smokingCategory: '',
smokingCategory: 'ETC',
smokingAmount: '',
},
setSmokingCategory: (smoking) => set({ smoking: { ...get().smoking, smokingCategory: smoking } }),
Expand Down
11 changes: 6 additions & 5 deletions src/processes/ideal_partner/DrinkingForm/DrinkingForm.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import styles from './DrinkingForm.module.css';
import { RadioList, RadioMeta } from 'src/shared/ui/RadioList/RadioList';
import { useIdealPartnerStore } from 'src/entities/ideal_partner/model/idealPartnerStore';
import { DrinkingDrinkingCategory } from 'src/types';

const drinkingRadioMeta: RadioMeta<string>[] = [
{ key: 'A', name: '상관 없어요', allowInput: false },
{ key: 'B', name: '주 1-2회 가볍게는 괜찮아요', allowInput: false },
{ key: 'C', name: '달 1-2회 정도 괜찮아요', allowInput: false },
{ key: 'D', name: '되도록 안하면 좋겠어요', allowInput: false },
const drinkingRadioMeta: RadioMeta<DrinkingDrinkingCategory>[] = [
{ key: 'NO_PROBLEM', name: '상관 없어요', allowInput: false },
{ key: 'ONE_TWO_TIMES_A_WEEK', name: '주 1-2회 가볍게는 괜찮아요', allowInput: false },
{ key: 'ONE_TWO_TIMES_A_MONTH', name: '달 1-2회 정도 괜찮아요', allowInput: false },
{ key: 'NEVER', name: '되도록 안하면 좋겠어요', allowInput: false },
{ key: 'ETC', name: '기타', allowInput: true, placeholder: '기타 의견을 입력해주세요.' },
];

Expand Down
11 changes: 6 additions & 5 deletions src/processes/ideal_partner/ReligionForm/ReligionForm.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import styles from './ReligionForm.module.css';
import { RadioList, RadioMeta } from 'src/shared/ui/RadioList/RadioList';
import { useIdealPartnerStore } from 'src/entities/ideal_partner/model/idealPartnerStore';
import { ReligionReligionCategory } from 'src/types';

const religionRadioMeta: RadioMeta<string>[] = [
{ key: 'A', name: '무교', allowInput: false },
{ key: 'B', name: '기독교', allowInput: false },
{ key: 'C', name: '불교', allowInput: false },
{ key: 'D', name: '천주교', allowInput: false },
const religionRadioMeta: RadioMeta<ReligionReligionCategory>[] = [
// { key: '', name: '무교', allowInput: false },
{ key: 'CHRISTIANITY', name: '기독교', allowInput: false },
{ key: 'BUDDHISM', name: '불교', allowInput: false },
{ key: 'CATHOLICISM', name: '천주교', allowInput: false },
{ key: 'ETC', name: '기타(기타 선택 시 직접 입력)', allowInput: true, placeholder: '종교를 입력해주세요.' },
];

Expand Down
7 changes: 4 additions & 3 deletions src/processes/ideal_partner/SmokingForm/SmokingForm.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import styles from './SmokingForm.module.css';
import { RadioList, RadioMeta } from 'src/shared/ui/RadioList/RadioList';
import { useIdealPartnerStore } from 'src/entities/ideal_partner/model/idealPartnerStore';
import { SmokingSmokingCategory } from 'src/types';

const smokingRadioMeta: RadioMeta<string>[] = [
{ key: 'A', name: '상관 없어요', allowInput: false },
{ key: 'B', name: '절대 안돼!', allowInput: false },
const smokingRadioMeta: RadioMeta<SmokingSmokingCategory>[] = [
{ key: 'SMOKER', name: '상관 없어요', allowInput: false },
{ key: 'NON_SMOKER', name: '절대 안돼!', allowInput: false },
{ key: 'ETC', name: '기타', allowInput: true, placeholder: '기타 의견을 입력해주세요.' },
];

Expand Down

0 comments on commit 13d8011

Please sign in to comment.