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] 새 방 비교 페이지를 완성하고 방 선택 페이지를 만들어 연결한다. #973

Merged
merged 24 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f501172
fix: 복구
ooherin Oct 25, 2024
aee63d6
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin Oct 25, 2024
e660e67
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin Nov 9, 2024
800f221
fix: 충돌 해결
ooherin Nov 16, 2024
cf910ac
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin Nov 18, 2024
eef7c37
feat: 체크리스트 작성 페이지 퍼블리싱
ooherin Nov 18, 2024
a60e94a
feat: 방 비교 선택 페이지 데이터 로직 완성
ooherin Nov 18, 2024
6091a54
feat: 옵션 디테일 모달 완성
ooherin Nov 19, 2024
0cb6a29
feat: 체크리스트 카테고리 디테일 쿼리 생성
ooherin Nov 19, 2024
29b99e9
feat: 카테고리 디테일 질문 모달 완성
ooherin Nov 19, 2024
4411edb
fix: 불필요한 페이지 코드 삭제 및 Badge 컴포넌트 리팩토링
ooherin Nov 19, 2024
7b288ff
feat: 불필요한 컴포넌트 Marker 공용 컴포넌트로 만들어서 통합
ooherin Nov 19, 2024
9b495e4
fix: HightLight 컴포넌트 폰트 크기 확장 및 적용
ooherin Nov 19, 2024
2981338
feat: 작업 중 불필요한 변경사항 삭제
ooherin Nov 19, 2024
7421ae8
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin Nov 19, 2024
08731cd
fix: 디테일 아코디언 컴포넌트 리팩토링 및 적용
ooherin Nov 19, 2024
fe893f2
feat: 방 비교 선택 페이지 스켈레톤 생성
ooherin Nov 21, 2024
7aef9a4
fix: 불필요한 커밋 수정
ooherin Nov 21, 2024
293e07b
fix: 변경된 api url 로 수정
ooherin Nov 21, 2024
4e0c44b
fix: 비교 백엔드 api 연결 및 라우팅 수정
ooherin Nov 24, 2024
8282257
Merge branch 'dev-fe' of https://github.com/woowacourse-teams/2024-ba…
ooherin Nov 24, 2024
d54d68f
refactor: roomComparePage의 접근성을 높이기 위해 리팩토링
ooherin Nov 25, 2024
a726810
fix: attribute 타입의 범위를 작게 수정
ooherin Nov 25, 2024
5cbcaaf
fix: 지하철 섹션 비교 ui 수정
ooherin Nov 29, 2024
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
14 changes: 14 additions & 0 deletions frontend/src/apis/room.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import fetcher from '@/apis/fetcher';
import { BASE_URL, ENDPOINT } from '@/apis/url';

export const getRoomCompare = async (roomId1: number, roomId2: number) => {
const response = await fetcher.get({ url: BASE_URL + ENDPOINT.ROOM_COMPARE(roomId1, roomId2) });
const data = await response.json();
return data.checklists;
};

export const getRoomCategoryDetail = async ({ roomId, categoryId }: { roomId: number; categoryId: number }) => {
const response = await fetcher.get({ url: BASE_URL + ENDPOINT.ROOM_CATEGORY_DETAIL(roomId, categoryId) });
const data = await response.json();
return data;
};
4 changes: 3 additions & 1 deletion frontend/src/apis/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export const ENDPOINT = {
CHECKLIST_ID: (id: number) => `/checklists/${id}`,
CHECKLIST_ID_V1: (id: number) => `/v1/checklists/${id}`,
//compare
CHECKLIST_COMPARE: (roomId1: number, roomId2: number) => `/v1/checklists/compare?id=${roomId1}&id=${roomId2}`,
ROOM_COMPARE: (roomId1: number, roomId2: number) => `/v1/checklists/comparison?id=${roomId1}&id=${roomId2}`,
ROOM_CATEGORY_DETAIL: (roomId: number, categoryId: number) =>
`/v1/comparison/checklists/${roomId}/categories/${categoryId}/questions`,

// like
LIKE: (id: number | ':id') => `/checklists/${id}/like`,
Expand Down
22 changes: 0 additions & 22 deletions frontend/src/components/ChecklistDetail/CategoryAccordion.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Accordion from '@/components/_common/Accordion/Accordion';
import CategoryAccordion from '@/components/ChecklistDetail/CategoryAccordion';
import Divider from '@/components/_common/Divider/Divider';
import ChecklistAnswer from '@/components/ChecklistDetail/CheckListAnswer';
import { CATEGORY_COUNT } from '@/constants/category';
import { ChecklistCategoryWithAnswer } from '@/types/checklist';

Expand All @@ -17,7 +18,12 @@ const ChecklistAnswerSection = ({ categories }: Props) => {
<div key={`accordion-${category.categoryId}`}>
<Accordion.header text={category.categoryName} id={category.categoryId} isMarked={true} />
<Accordion.body id={category.categoryId}>
<CategoryAccordion key={category.categoryId} category={category} />
{category.questions.map((question, index) => (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

불필요한 depth 를 줄였습니다.

<>
<ChecklistAnswer key={`answer-${question.questionId}`} QuestionAndAnswer={question} />
{index !== category.questions.length - 1 && <Divider />}
</>
))}
</Accordion.body>
</div>
);
Expand Down
18 changes: 11 additions & 7 deletions frontend/src/components/ChecklistList/CustomBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import styled from '@emotion/styled';

import { PencilIcon } from '@/assets/assets';
import Button from '@/components/_common/Button/Button';
import { boxShadow, flexCenter, flexRow } from '@/styles/common';

interface Props {
onClick?: () => void;
title: string;
buttonColor: string;
buttonText: string;
Icon: React.ReactElement;
buttonDetailText: string;
}

const CustomBanner = ({ onClick }: Props) => {
const CustomBanner = ({ onClick, Icon, title, buttonColor, buttonText, buttonDetailText }: Props) => {
return (
<S.Banner onClick={onClick}>
<S.Wrapper>
<PencilIcon width={30} height={30} aria-hidden="true" />
<S.Title>체크리스트 질문 템플릿</S.Title>
{Icon}
<S.Title>{title}</S.Title>
</S.Wrapper>
<S.Button aria-label="체크리스트 질문 템플릿을 편집하려면 이 버튼을 누르세요." label={'수정하기'} />
<S.Button aria-label={buttonDetailText} label={buttonText} buttonColor={buttonColor} />
</S.Banner>
);
};
Expand Down Expand Up @@ -47,10 +51,10 @@ const S = {
Title: styled.span`
${flexCenter}
`,
Button: styled(Button)`
Button: styled(Button)<{ buttonColor: string }>`
padding: 0.6rem 1rem;

background-color: ${({ theme }) => theme.palette.green500};
background-color: ${({ buttonColor }) => buttonColor};

color: ${({ theme }) => theme.palette.white};
border-radius: 0.8rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import Divider from '@/components/_common/Divider/Divider';
import Layout from '@/components/_common/layout/Layout';
import { useTabContext } from '@/components/_common/Tabs/TabContext';
import ChecklistQuestionItem from '@/components/NewChecklist/ChecklistQuestion/ChecklistQuestion';
import ChecklistQuestionAnswers from '@/components/NewChecklist/ChecklistQuestion/ChecklistQuestionAnswers';
import MoveNextButton from '@/components/NewChecklist/MoveNextButton';
import useChecklistStore from '@/store/useChecklistStore';
import { flexColumn } from '@/styles/common';
import { flexColumn, flexRow, flexSpaceBetween } from '@/styles/common';
import theme from '@/styles/theme';
import { ChecklistQuestion } from '@/types/checklist';

Expand All @@ -28,11 +29,15 @@ const EditChecklistQuestionTemplate = () => {
const isLastQuestion = questions?.questions.length - 1 === index;
return (
<>
<ChecklistQuestionItem
key={`${currentTabId}-${question.questionId}`}
question={question}
answer={answer}
/>
<S.QuestionBox key={question.questionId}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChecklistQuestionItem을 제사용하기 위해 해당 컴포넌트의 Wrapper 를 제거하여 리팩토링하였습니다.

<ChecklistQuestionItem
key={`${currentTabId}-${question.questionId}`}
question={question}
width={'80%'}
/>
<ChecklistQuestionAnswers title={question.title} answer={answer} questionId={question.questionId} />
</S.QuestionBox>

{!isLastQuestion && <Divider />}
</>
);
Expand All @@ -56,6 +61,15 @@ const S = {
gap: 0.2rem;
`,
QuestionBox: styled.div`
position: relative;
width: 100%;
${flexRow}
${flexSpaceBetween}
padding: 1.6rem;
border-radius: 0.8rem;

box-sizing: border-box;

background-color: ${({ theme }) => theme.palette.white};
`,
};
2 changes: 1 addition & 1 deletion frontend/src/components/Main/ChecklistPreviewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface Props {

const ChecklistPreviewCard = ({ index, checklist }: Props) => {
const navigate = useNavigate();
const colorList = ['green', 'blue', 'red'];
const colorList = ['green', 'blue', 'yellow'];
const { color200, color500 } = getSeqColor(index, colorList);

const { checklistId, station, roomName, deposit, rent, address } = checklist;
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/MyPage/UserFeature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const UserFeature = () => {
useUserQuery();

const queryClient = useQueryClient();

const checklist = queryClient.getQueryData([QUERY_KEYS.CHECKLIST_LIST]);

const { isModalOpen: isLogoutModalOpen, openModal: openLogoutModal, closeModal: closeLogoutModal } = useModal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,79 +2,31 @@ import styled from '@emotion/styled';
import React from 'react';

import HighlightText from '@/components/_common/Highlight/HighlightText';
import ChecklistQuestionAnswers from '@/components/NewChecklist/ChecklistQuestion/ChecklistQuestionAnswers';
import { flexCenter, flexRow, flexSpaceBetween } from '@/styles/common';
import { AnswerType } from '@/types/answer';
import { ChecklistQuestion } from '@/types/checklist';

type FontSize = 'medium' | 'small';
interface Props {
question: ChecklistQuestion;
answer: AnswerType;
width?: string;
fontSize?: FontSize;
}

const ChecklistQuestionItem = ({ question, answer }: Props) => {
const { questionId, title, highlights } = question;
const ChecklistQuestionItem = ({ question, width = '100%', fontSize = 'medium' }: Props) => {
const { title, highlights } = question;

return (
<S.Container>
<S.Question className="question">
<HighlightText title={title} highlights={highlights} />
</S.Question>
<S.Options>
<ChecklistQuestionAnswers title={title} answer={answer} questionId={questionId} />
</S.Options>
</S.Container>
<S.Question className="question" width={width}>
<HighlightText fontSize={fontSize} title={title} highlights={highlights} />
</S.Question>
);
};

export default React.memo(ChecklistQuestionItem);

const S = {
Container: styled.div`
position: relative;
width: 100%;
${flexRow}
${flexSpaceBetween}
padding: 1.6rem;
border-radius: 0.8rem;

box-sizing: border-box;

background-color: ${({ theme }) => theme.palette.white};
`,
Question: styled.div`
Question: styled.div<{ width: string }>`
display: flex;
width: 80%;
width: ${({ width }) => width};
flex-flow: column wrap;
`,
Subtitle: styled.div`
width: 100%;

color: ${({ theme }) => theme.palette.grey500};
font-size: ${({ theme }) => theme.text.size.small};
word-break: keep-all;
`,
Options: styled.div`
width: 8rem;

${flexRow}
gap: 1.5rem;

${flexSpaceBetween}
align-items: center;
cursor: pointer;
`,
ButtonBox: styled.div`
position: absolute;
top: 1rem;
right: 1rem;
border-radius: 50%;
width: 4rem;
height: 4rem;
${flexCenter}

:hover {
background-color: ${({ theme }) => theme.palette.background};
}
`,
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import styled from '@emotion/styled';
import React, { useCallback } from 'react';

import { useTabContext } from '@/components/_common/Tabs/TabContext';
import AnswerIcon from '@/components/Answer/AnswerIcon';
import { ANSWER_OPTIONS } from '@/constants/answer';
import useChecklistQuestionAnswer from '@/hooks/useChecklistQuestionAnswer';
import { trackChecklistQuestion } from '@/service/amplitude/trackEvent';
import { flexRow, flexSpaceBetween } from '@/styles/common';
import { Answer, AnswerType } from '@/types/answer';

interface Props {
Expand All @@ -26,7 +28,7 @@ const ChecklistQuestionAnswers = ({ questionId, answer, title }: Props) => {
);

return (
<>
<S.Options>
{ANSWER_OPTIONS.map((option: Answer) => {
const isSelected = answer === option.name;

Expand All @@ -46,8 +48,21 @@ const ChecklistQuestionAnswers = ({ questionId, answer, title }: Props) => {
{title + statusMessage}
</div>
)}
</>
</S.Options>
);
};

const S = {
Options: styled.div`
width: 8rem;

${flexRow}
gap: 1.5rem;

${flexSpaceBetween}
align-items: center;
cursor: pointer;
`,
};

export default React.memo(ChecklistQuestionAnswers);
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import Divider from '@/components/_common/Divider/Divider';
import Layout from '@/components/_common/layout/Layout';
import { useTabContext } from '@/components/_common/Tabs/TabContext';
import ChecklistQuestionItem from '@/components/NewChecklist/ChecklistQuestion/ChecklistQuestion';
import ChecklistQuestionAnswers from '@/components/NewChecklist/ChecklistQuestion/ChecklistQuestionAnswers';
import MoveNextButton from '@/components/NewChecklist/MoveNextButton';
import useInitialChecklist from '@/hooks/useInitialChecklist';
import useChecklistStore from '@/store/useChecklistStore';
import { flexCenter, flexColumn } from '@/styles/common';
import { flexCenter, flexColumn, flexRow, flexSpaceBetween } from '@/styles/common';
import theme from '@/styles/theme';
import { ChecklistQuestion } from '@/types/checklist';

Expand All @@ -29,17 +30,20 @@ const ChecklistQuestionTemplate = () => {
const isLastQuestion = questions?.questions.length - 1 === index;
return (
<>
<ChecklistQuestionItem
key={`${currentTabId}-${question.questionId}`}
question={question}
answer={answer}
/>
<S.QuestionBox key={question.questionId}>
<ChecklistQuestionItem
key={`${currentTabId}-${question.questionId}`}
question={question}
width={'80%'}
/>
<ChecklistQuestionAnswers title={question.title} answer={answer} questionId={question.questionId} />
</S.QuestionBox>

{!isLastQuestion && <Divider />}
</>
);
})}
</S.ContentBox>

<MoveNextButton marginTop="2rem" marginBottom="4rem" />
</Layout>
);
Expand All @@ -57,6 +61,15 @@ const S = {
gap: 0.2rem;
`,
QuestionBox: styled.div`
position: relative;
width: 100%;
${flexRow}
${flexSpaceBetween}
padding: 1.6rem;
border-radius: 0.8rem;

box-sizing: border-box;

background-color: ${({ theme }) => theme.palette.white};
`,
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from '@emotion/styled';
import { Memo } from '@/assets/assets';
import { boxShadow, title3 } from '@/styles/common';

interface Props extends React.HTMLAttributes<HTMLButtonElement> {
interface Props extends React.ButtonHTMLAttributes<HTMLButtonElement> {
onClick?: () => void;
}

Expand Down
Loading