Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] 지하철 포맷을 일시 수정한다. #866

Merged
merged 3 commits into from
Oct 23, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ const ChecklistDetailSection = () => {
return (
<>
<RoomInfoSection
checklist={checklist}
room={checklist?.room}
options={checklist?.options}
isLiked={checklist?.isLiked}
checklistId={Number(checklistId)}
nearSubways={[]}
nearSubways={checklist.stations.stations}
/>
<ChecklistAnswerSection categories={checklist?.categories} />
<MemoSection memo={checklist?.room?.memo} />
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/components/ChecklistDetail/RoomInfoSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import AddressMap from '@/components/_common/Map/AddressMap';
import SubwayStations from '@/components/_common/Subway/SubwayStations';
import { IncludedMaintenancesData } from '@/constants/roomInfo';
import { flexColumn, flexRow, flexSpaceBetween, title2 } from '@/styles/common';
import { ChecklistInfo } from '@/types/checklist';
import { Option } from '@/types/option';
import { RoomInfo } from '@/types/room';
import { SubwayStation } from '@/types/subway';
Expand All @@ -29,9 +30,10 @@ interface Props {
checklistId: number;
isLiked: boolean;
nearSubways: SubwayStation[];
checklist: ChecklistInfo;
}

const RoomInfoSection = ({ nearSubways, room, options, checklistId, isLiked }: Props) => {
const RoomInfoSection = ({ checklist, nearSubways, room, options, checklistId, isLiked }: Props) => {
const {
roomName,
deposit,
Expand Down Expand Up @@ -95,7 +97,7 @@ const RoomInfoSection = ({ nearSubways, room, options, checklistId, isLiked }: P
</S.Row>
<S.Row>
<Subway aria-label="가까운 지하철" />
<SubwayStations stations={nearSubways} />
<SubwayStations stations={nearSubways} checklist={checklist} />
</S.Row>
<S.GapBox>
<S.Row>
Expand Down
30 changes: 22 additions & 8 deletions frontend/src/components/_common/Subway/SubwayStations.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
import FlexBox from '@/components/_common/FlexBox/FlexBox';
import FormField from '@/components/_common/FormField/FormField';
import styled from '@emotion/styled';

import SubwayStationItem from '@/components/_common/Subway/SubwayStationItem';
import { flexColumn } from '@/styles/common';
import { ChecklistInfo } from '@/types/checklist';
import { SubwayStation } from '@/types/subway';

const SubwayStations = ({ stations }: { stations: SubwayStation[] }) => {
interface Props {
checklist?: ChecklistInfo;
stations: SubwayStation[];
}

const SubwayStations = ({ stations }: Props) => {
return (
<FlexBox.Vertical>
{stations?.length ? (
stations?.map(station => <SubwayStationItem key={station.stationName} station={station} />)
<>
{stations.length ? (
<S.Box>{stations?.map(station => <SubwayStationItem station={station} key={station.stationName} />)}</S.Box>
) : (
<FormField.TextBox text={'보신 방과 가까운 지하철역을 찾아드릴게요.'} />
<span>{'보신 방과 가까운 지하철역을 찾아드릴게요.'}</span>
)}
</FlexBox.Vertical>
</>
);
};

export default SubwayStations;

const S = {
Box: styled.div`
${flexColumn};
gap: 1rem;
`,
};
4 changes: 3 additions & 1 deletion frontend/src/mocks/fixtures/checklistDetail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@ export const checklistDetail: ChecklistInfo = {
],
},
],
stations: nearSubway,
stations: {
stations: nearSubway,
},
};
5 changes: 4 additions & 1 deletion frontend/src/types/checklist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export interface ChecklistInfo {
room: Partial<RoomInfo>;
options: Option[];
categories: ChecklistCategoryWithAnswer[];
stations: SubwayStation[];
//TODO: 나중에 백엔드 api 수정되면 수정
stations: {
stations: SubwayStation[];
};
}

export interface ChecklistSelectedQuestions {
Expand Down
Loading