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] refactor: 사용자 테스트에서 피드백 받은 사소한 버그 수정 #345

Merged
merged 10 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 9 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
5 changes: 4 additions & 1 deletion frontend/src/components/AnswerListRecheckModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Fragment } from 'react';

import { MultilineTextViewer } from '@/components';
import { ReviewWritingAnswer, ReviewWritingCardSection } from '@/types';

import CheckboxItem from '../common/CheckboxItem';
Expand Down Expand Up @@ -54,7 +55,9 @@ const AnswerListRecheckModal = ({ questionSectionList, answerMap, closeModal }:
))}
</div>
)}
<div>{question.questionType === 'TEXT' && <div>{findTextAnswer(question.questionId)}</div>}</div>
{question.questionType === 'TEXT' && (
<MultilineTextViewer text={findTextAnswer(question.questionId) || ''} />
)}
</S.ContentContainer>
</Fragment>
))}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/common/LongReviewItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ interface LongReviewItemProps extends TextareaHTMLAttributes<HTMLTextAreaElement
minLength: number;
maxLength: number;
initialValue?: string;
required: boolean;
handleTextareaChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
}

const LongReviewItem = ({
minLength,
maxLength,
initialValue = '',
required,
handleTextareaChange,
style,
...rest
Expand All @@ -23,6 +25,7 @@ const LongReviewItem = ({
minLength,
maxLength,
initialValue,
required,
});

const handleWriteTextarea = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
Expand All @@ -38,6 +41,7 @@ const LongReviewItem = ({
$style={style}
onChange={handleWriteTextarea}
onBlur={handleBlur}
placeholder={`최대 ${maxLength}자까지 입력 가능해요.`}
{...rest}
/>
<S.TextareaInfoContainer>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/common/MultilineTextViewer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as S from './styles';

interface MultilineTextViewerProps {
text: string;
Expand All @@ -8,10 +8,10 @@ const MultilineTextViewer = ({ text }: MultilineTextViewerProps) => {
return (
<>
{text.split('\n').map((line, index) => (
<React.Fragment key={index}>
<S.MultilineText key={index}>
{line}
<br />
</React.Fragment>
</S.MultilineText>
))}
</>
);
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/components/common/MultilineTextViewer/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styled from '@emotion/styled';

export const MultilineText = styled.div`
word-wrap: break-word;
`;
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
// import LogoIcon from '../../../../../assets/logo.svg';

import { useNavigate } from 'react-router';

import * as S from './styles';

const Logo = () => {
const navigate = useNavigate();

const handleLogoClick = () => {
navigate('/');
};

return (
<S.Logo>
{/* <img src={LogoIcon} alt="로고 아이콘" /> */}
<S.LogoText>
<S.LogoText onClick={handleLogoClick}>
<span>REVIEW</span>
<span>ME</span>
</S.LogoText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const Logo = styled.div`
`;

export const LogoText = styled.div`
cursor: pointer;
line-height: 8rem;
text-align: center;

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/layouts/Topbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Topbar = ({ openSidebar }: TopbarProps) => {
return (
<S.Layout>
<S.Container>
<SidebarOpenButton openSidebar={openSidebar} />
{/* <SidebarOpenButton openSidebar={openSidebar} /> */}
<Logo />
</S.Container>
<S.Container>
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/hooks/useLongReviewItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ interface UseLongReviewItemProps {
minLength: number;
maxLength: number;
initialValue?: string;
required: boolean;
}

const useLongReviewItem = ({ minLength, maxLength, initialValue }: UseLongReviewItemProps) => {
const useLongReviewItem = ({ minLength, maxLength, initialValue, required }: UseLongReviewItemProps) => {
const [value, setValue] = useState(initialValue);
const [isError, setIsError] = useState(false);
const [errorMessage, setErrorMessage] = useState('');
Expand All @@ -19,7 +20,10 @@ const useLongReviewItem = ({ minLength, maxLength, initialValue }: UseLongReview

const handleBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {
const value = e.target.value;
if (value.length < minLength) {
const errorOnRequired = required && value.length < minLength;
const errorOnNotRequired = !required && value.length > 0 && value.length < minLength;

if (errorOnRequired || errorOnNotRequired) {
setIsError(true);
setErrorMessage(`최소 ${minLength}자 이상 작성해 주세요.`);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const QnABox = ({ question, updateAnswerMap, updateAnswerValidationMap }: QnABox
if (!optionGroup) return;

const { minCount, maxCount } = optionGroup;
if (!maxCount) return `(최소 ${minCount}개 이상)`;

const isAllSelectAvailable = maxCount === optionGroup.options.length;
if (!maxCount || isAllSelectAvailable) return `(최소 ${minCount}개 이상)`;

return `(${minCount}개 ~ ${maxCount}개)`;
})();
Expand All @@ -38,6 +40,7 @@ const QnABox = ({ question, updateAnswerMap, updateAnswerValidationMap }: QnABox
<S.QuestionTitle>
{question.content}
{question.required && <S.QuestionRequiredMark>*</S.QuestionRequiredMark>}
{question.questionType === 'TEXT' && ` (최소 ${TEXT_ANSWER_LENGTH.min}자 이상)`}
<S.MultipleGuideline>{multipleGuideline ?? ''}</S.MultipleGuideline>
</S.QuestionTitle>
{question.guideline && <S.QuestionGuideline>{question.guideline}</S.QuestionGuideline>}
Expand Down Expand Up @@ -67,6 +70,7 @@ const QnABox = ({ question, updateAnswerMap, updateAnswerValidationMap }: QnABox
minLength={TEXT_ANSWER_LENGTH.min}
maxLength={TEXT_ANSWER_LENGTH.max}
handleTextareaChange={handleTextAnswerChange}
required={question.required}
/>
)}
</S.QnASection>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/styles/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const reset = () => css`

button {
cursor: pointer;
user-select: none;

box-sizing: border-box;
margin: 0;
Expand Down