Skip to content

Commit

Permalink
feat: 질문 선택 및 답변 aria-label 이 질문 내용 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ooherin committed Oct 22, 2024
1 parent 472f7c9 commit 49c65f8
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 38 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/ChecklistList/CustomBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const CustomBanner = ({ onClick }: Props) => {
<S.Banner onClick={onClick}>
<S.Wrapper>
<PencilIcon width={30} height={30} aria-hidden="true" />
<S.Title>체크리스트 질문</S.Title>
<S.Title>체크리스트 질문 선택하기</S.Title>
</S.Wrapper>
<S.Button>편집하기</S.Button>
<S.Button aria-label="체크리스트 질문을 편집하려면 이 버튼을 누르세요.">편집하기</S.Button>
</S.Banner>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,32 @@ import { ChecklistQuestionWithIsSelected } from '@/types/checklist';

const QuestionSelectCard = ({ question }: { question: ChecklistQuestionWithIsSelected }) => {
const { title, subtitle, isSelected, questionId } = question;
const { toggleQuestionSelect } = useChecklistQuestionSelect();
const { toggleQuestionSelect, statusMessage } = useChecklistQuestionSelect();
const { currentTabId: categoryId } = useTabContext();

const handleCheckQuestion = () => {
toggleQuestionSelect({ questionId, isSelected: !isSelected, categoryId });
};

return (
<S.Container isChecked={isSelected} onClick={handleCheckQuestion}>
<S.FlexColumn>
<FlexBox.Vertical>
<S.Title>{title}</S.Title>
{subtitle && <S.Subtitle>{subtitle}</S.Subtitle>}
</FlexBox.Vertical>
</S.FlexColumn>
<S.CheckBoxContainer>
<Checkbox iconType="plus" isChecked={isSelected} onClick={handleCheckQuestion} />
</S.CheckBoxContainer>
</S.Container>
<>
<S.Container isChecked={isSelected} onClick={handleCheckQuestion}>
<S.FlexColumn>
<FlexBox.Vertical>
<S.Title>{title}</S.Title>
{subtitle && <S.Subtitle>{subtitle}</S.Subtitle>}
</FlexBox.Vertical>
</S.FlexColumn>
<S.CheckBoxContainer>
<Checkbox iconType="plus" isChecked={isSelected} onClick={handleCheckQuestion} />
</S.CheckBoxContainer>
</S.Container>
{statusMessage && (
<div className="visually-hidden" role="alert">
{title + statusMessage}
</div>
)}
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ChecklistQuestionItem = ({ question, answer }: Props) => {
<HighlightText title={title} highlights={highlights} />
</S.Question>
<S.Options>
<ChecklistQuestionAnswers answer={answer} questionId={questionId} />
<ChecklistQuestionAnswers title={title} answer={answer} questionId={questionId} />
</S.Options>
</S.Container>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@ import { ANSWER_OPTIONS } from '@/constants/answer';
import useChecklistQuestionAnswer from '@/hooks/useChecklistQuestionAnswer';
import { Answer, AnswerType } from '@/types/answer';

<<<<<<< HEAD
const ChecklistQuestionAnswers = ({ answer, questionId }: { answer: AnswerType; questionId: number }) => {
const { toggleAnswer, statusMessage } = useChecklistQuestionAnswer();
=======
interface Props {
questionId: number;
answer: AnswerType;
title: string;
}

const ChecklistQuestionAnswers = ({ questionId, answer }: Props) => {
>>>>>>> 6e976eb2c3447b7835fac11bb79d8b2ac88424f8
const ChecklistQuestionAnswers = ({ questionId, answer, title }: Props) => {
const { currentTabId } = useTabContext();
const { toggleAnswer } = useChecklistQuestionAnswer();
const { toggleAnswer, statusMessage } = useChecklistQuestionAnswer();

const handleClick = useCallback(
(newAnswer: AnswerType) => {
Expand All @@ -45,7 +41,7 @@ const ChecklistQuestionAnswers = ({ questionId, answer }: Props) => {
})}
{statusMessage && (
<div className="visually-hidden" role="alert">
{statusMessage}
{title + statusMessage}
</div>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const AlertModal = ({
<Modal.body>
<S.Container>
<S.IconBox>{hasIcon && <BangBangCryIcon width={70} height={70} />}</S.IconBox>
<S.Title>{title}</S.Title>
{subtitle && <S.subtitle>{subtitle}</S.subtitle>}
<S.Title tabIndex={0}>{title}</S.Title>
{subtitle && <S.subtitle tabIndex={0}>{subtitle}</S.subtitle>}
</S.Container>
</Modal.body>
<Modal.footer>
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/hooks/useChecklistQuestionSelect.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useState } from 'react';

import useChecklistQuestionSelectStore from '@/store/useChecklistQuestionSelectStore';
import { CategoryAndQuestion } from '@/types/checklist';

Expand All @@ -7,6 +9,7 @@ export interface UpdateCheckProps extends CategoryAndQuestion {

const useChecklistQuestionSelect = () => {
const { setChecklistAllQuestionList, checklistAllQuestionList } = useChecklistQuestionSelectStore();
const [statusMessage, setStatusMessage] = useState('');

const toggleQuestionSelect = ({ categoryId, questionId, isSelected }: UpdateCheckProps) => {
const targetCategory = checklistAllQuestionList.find(category => category.categoryId === categoryId);
Expand All @@ -23,11 +26,13 @@ const useChecklistQuestionSelect = () => {
category.categoryId === categoryId ? updatedCategory : category,
);

setStatusMessage(isSelected ? '질문이 선택되었습니다' : '질문 선택이 취소되었습니다.');

setChecklistAllQuestionList(newCategories);
}
};

return { toggleQuestionSelect };
return { toggleQuestionSelect, statusMessage };
};

export default useChecklistQuestionSelect;
2 changes: 1 addition & 1 deletion frontend/src/pages/ChecklistQuestionSelectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ChecklistQuestionSelectPage = () => {
<>
<Header
left={<Header.Backward />}
center={<Header.Text>{'체크리스트 질문 편집'}</Header.Text>}
center={<Header.Text>{'체크리스트 질문 선택'}</Header.Text>}
right={<Button label={'저장'} size="small" color="dark" onClick={handleSubmitChecklist} />}
/>
<TabProvider defaultTab={1}>
Expand Down
11 changes: 0 additions & 11 deletions frontend/src/pages/NewChecklistPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,7 @@ const NewChecklistPage = () => {
roomInfoNonValidatedActions.resetAll();
checklistActions.reset();
selectedOptionActions.reset();
<<<<<<< HEAD
resetShowTip();
};

const handleChecklistPage = () => {
=======
resetShowTip(); // 옵션의 팁박스 다시표시
>>>>>>> 6e976eb2c3447b7835fac11bb79d8b2ac88424f8
navigate(ROUTE_PATH.checklistList);
};

Expand Down Expand Up @@ -95,13 +88,9 @@ const NewChecklistPage = () => {
}
isOpen={isAlertModalOpen}
onClose={closeAlertModal}
<<<<<<< HEAD
handleApprove={handleChecklistPage}
=======
handleApprove={() => {
resetChecklist();
}}
>>>>>>> 6e976eb2c3447b7835fac11bb79d8b2ac88424f8
approveButtonName="나가기"
/>
<LoginModal isModalOpen={isLoginModalOpen} modalClose={closeLoginModal} />
Expand Down

0 comments on commit 49c65f8

Please sign in to comment.