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

[#134] 등록 페이지 QA 수정사항 반영 #141

Merged
merged 8 commits into from
Jan 29, 2024
7 changes: 3 additions & 4 deletions src/components/Register/Steps/FirstStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,11 @@ const FirstStep = () => {
/>
</InputWrapper>
</LimitWrapper>
{!isValid.isDiscountTypeValid && (
{(!isValid.isDiscountTypeValid ||
!isValid.isDiscountFlatValid ||
!isValid.isDiscountFlatRateValid) && (
<ErrorMessage>쿠폰 할인 설정은 필수입니다.</ErrorMessage>
)}
{(!isValid.isDiscountFlatValid || !isValid.isDiscountFlatRateValid) && (
<ErrorMessage>숫자로 입력해주세요.</ErrorMessage>
)}
{!isValid.isThousands && (
<ErrorMessage>1,000 원 단위로 입력 가능합니다.</ErrorMessage>
)}
Expand Down
65 changes: 34 additions & 31 deletions src/components/Register/Steps/SecondStep/RoomSelectModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { useRecoilState } from 'recoil';
import styled from '@emotion/styled';

import { Backdrop } from '@components/common';
import {
RoomType,
RoomSelectModalProps,
RoomSelectModalStyleProps
} from '@/types/register';
import { RoomType, RoomSelectModalProps } from '@/types/register';
import close from '@assets/icons/ic-register-close.svg';
import sort from '@assets/icons/ic-register-sort.svg';
import filterChecked from '@assets/icons/ic-register-filter-checked.svg';
Expand Down Expand Up @@ -96,10 +92,12 @@ const RoomSelectModal = ({ setIsOpen }: RoomSelectModalProps) => {
<Container>
<Header>
적용 객실 설정
<CloseButton
$src={close}
onClick={handleClose}
/>
<CloseButton onClick={handleClose}>
<CloseIcon
src={close}
alt="닫기 아이콘"
/>
</CloseButton>
</Header>
<Filter>
<FilterCell>
Expand All @@ -109,10 +107,16 @@ const RoomSelectModal = ({ setIsOpen }: RoomSelectModalProps) => {
checked={
selectedRooms.length === sortedRooms.length ? true : false
}
$src={filterChecked}
onChange={handleSelectAll}
/>
<FilterCheckIcon $src={filterUnchecked} />
<FilterCheckIcon
src={
selectedRooms.length === sortedRooms.length
? filterChecked
: filterUnchecked
}
alt="체크박스 아이콘"
/>
</label>
</FilterCell>
<FilterCell>
Expand All @@ -137,10 +141,16 @@ const RoomSelectModal = ({ setIsOpen }: RoomSelectModalProps) => {
<SelectOne
type="checkbox"
checked={selectedRooms.includes(room) ? true : false}
$src={listChecked}
onChange={e => handleSelectOne(e, room)}
/>
<ListCheckIcon $src={listUnchecked} />
<ListCheckIcon
src={
selectedRooms.includes(room)
? listChecked
: listUnchecked
}
alt="체크박스 아이콘"
/>
</label>
</ListCell>
<ListCell>{sliceName(room.roomNumber)}</ListCell>
Expand Down Expand Up @@ -190,18 +200,23 @@ const Header = styled.div`
font-size: 18px;
`;

const CloseButton = styled.button<RoomSelectModalStyleProps>`
const CloseButton = styled.button`
width: 35px;
height: 35px;

padding: 0px;
border: none;

background: url(${props => props.$src}) center / contain;
background: #fff;

cursor: pointer;
`;

const CloseIcon = styled.img`
width: 35px;
height: 35px;
`;

const Filter = styled.div`
height: 63px;

Expand All @@ -224,19 +239,13 @@ const FilterCell = styled.div`
align-items: center;
`;

const SelectAll = styled.input<RoomSelectModalStyleProps>`
const SelectAll = styled.input`
display: none;

&:checked + div {
background: url(${props => props.$src}) no-repeat;
}
`;

const FilterCheckIcon = styled.div<RoomSelectModalStyleProps>`
const FilterCheckIcon = styled.img`
width: 21px;
height: 21px;

background: url(${props => props.$src}) no-repeat;
`;

const SortButton = styled.button`
Expand Down Expand Up @@ -289,19 +298,13 @@ const ListCell = styled.div`
align-items: center;
`;

const SelectOne = styled.input<RoomSelectModalStyleProps>`
const SelectOne = styled.input`
display: none;

&:checked + div {
background: url(${props => props.$src}) no-repeat;
}
`;

const ListCheckIcon = styled.div<RoomSelectModalStyleProps>`
const ListCheckIcon = styled.img`
width: 21px;
height: 21px;

background: url(${props => props.$src}) no-repeat;
`;

const Footer = styled.div`
Expand Down
5 changes: 4 additions & 1 deletion src/components/Register/Steps/SecondStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ const SecondStep = () => {

const handleToAllRoomsChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setInput({ ...input, toAllRooms: e.target.value });
setPreview({ ...preview, toAllRooms: e.target.value });
setPreview({
...preview,
toAllRooms: e.target.value === 'true' ? '모든 객실' : '일부 객실'
Copy link
Collaborator

Choose a reason for hiding this comment

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

toAllRooms: !!e.target.value ? '모든 객실' : '일부 객실'

부정 연산자(!)를 사용하면 === true를 작성하지 않고도 boolean 값에 따라 판별할 수 있을 것같습니다!

});
setIsValid(prev => ({
...prev,
isToAllRoomsValid: true
Expand Down
10 changes: 7 additions & 3 deletions src/components/Register/common/InputAccordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ const InputAccordion = ({ title, value, children }: InputAccordionProps) => {
<Description>{title}</Description>
<Button
$isOpen={isOpen}
src={toggle}
onClick={handleToggle}
/>
>
<img
src={toggle}
alt="아코디언 토글 아이콘"
/>
</Button>
</Header>
<ContentWrapper ref={contentWrapperRef}>
<Content ref={contentRef}>{children}</Content>
Expand Down Expand Up @@ -77,7 +81,7 @@ const Button = styled.button<ButtonStyleProps>`
padding: 0px;
border: none;

background: url(${props => props.src});
background: #fff;

transform: rotate(
${props => {
Expand Down
9 changes: 0 additions & 9 deletions src/types/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export type InputAccordionProps = {

export type ButtonStyleProps = {
$isOpen: boolean;
src: string;
};

// InputField
Expand All @@ -65,10 +64,6 @@ export type LabelStyleProps = {
$isChecked: boolean;
};

export type CheckIconStyleProps = {
$src: string;
};

// InputRadio
export type InputRadioProps = {
id: string;
Expand Down Expand Up @@ -159,10 +154,6 @@ export type RoomSelectModalProps = {
setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
};

export type RoomSelectModalStyleProps = {
$src: string;
};

// RoomSelectButton
export type RoomSelectButtonProps = {
type: string;
Expand Down
17 changes: 0 additions & 17 deletions src/utils/lib/showValidationMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,3 @@ export const showFourthStepValidationMessage = (
setIsValid(prev => ({ ...prev, endDateAfterStartDate: false }));
}
};

// export const handleStepLessThan3 = (
// currentStep,
// input,
// isFilled,
// onButtonClick
// ) => {
// if (
// currentStep === 0 &&
// input.discountType === '정액 할인' &&
// Number(input.discountFlat) % 1000
// ) {
// return;
// } else if (currentStep === 2 || isFilled) {
// onButtonClick(prev => prev + 1);
// }
// };