Skip to content

Commit

Permalink
SKRF-452 refactor: submitted forms page exception (#214)
Browse files Browse the repository at this point in the history
* feat: 공연에 제출된 폼일 때 인당 예매수 보여주기

* refactor: 상태변경버튼 모달 메시지 '확인'->'승인'으로 변경

* refactor: 취소요청된 폼에 대해서는 상태변경 불가능

* refactor: ticketCount type 변경
  • Loading branch information
colorkite10 authored Dec 1, 2023
1 parent a14f4e9 commit 95117ff
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 18 deletions.
32 changes: 19 additions & 13 deletions src/components/ChangeFormStatusButton/ChangeFormStatusButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { EventStatus } from '@/types/event';
import { FaCheckCircle } from 'react-icons/fa';
import { FaRegCheckCircle } from 'react-icons/fa';

import AlertModal from '../Modals/AlertModal';
import ConfirmModal from '../Modals/ConfirmModal';
import { ButtonValueStyled, StatusButtonContainer } from './ChangeFormStatusButton.style';

Expand All @@ -20,19 +21,24 @@ const ChangeFormStatusButton = ({ eventId, formId, status }: ChangeFormStatusBut

return (
<>
{showModal && (
<ConfirmModal
message={`상태를 ${status === 'CONFIRMED' ? '"대기"로' : '"확인"으로'} 변경하시겠습니까?`}
onConfirm={() =>
changeSubmittedFormStatus({
eventId,
formUserId: formId,
participationStatus: status === 'CONFIRMED' ? 'PENDING' : 'CONFIRMED',
})
}
onClose={modalClose}
/>
)}
{showModal &&
(status === 'CANCEL_REQUESTED' ? (
<AlertModal message="취소요청한 폼은 상태를 변경할 수 없습니다." onClose={modalClose} />
) : (
<ConfirmModal
message={`상태를 ${
status === 'CONFIRMED' ? '"대기"로' : '"승인"으로'
} 변경하시겠습니까?`}
onConfirm={() =>
changeSubmittedFormStatus({
eventId,
formUserId: formId,
participationStatus: status === 'CONFIRMED' ? 'PENDING' : 'CONFIRMED',
})
}
onClose={modalClose}
/>
))}
<StatusButtonContainer
status={status}
onClick={() => modalOpen()}
Expand Down
9 changes: 8 additions & 1 deletion src/components/Modals/FormDetailModal/FormDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ interface FormDetailModalProps {
onClose: () => void;
options: { title: string; content: string }[];
nthForm: number;
ticketCount?: string;
}

const FormDetailModal = ({ onClose, options, nthForm }: FormDetailModalProps) => {
const FormDetailModal = ({ onClose, options, nthForm, ticketCount }: FormDetailModalProps) => {
return (
<Portal>
<BackgroundOverlay onClick={onClose}>
<FormDetailModalContainer>
<SubmittedFormDetailTitleStyled>{`${nthForm}번째 폼`}</SubmittedFormDetailTitleStyled>
{ticketCount && (
<FormItemContainer>
<QuestionStyled>인원수</QuestionStyled>
<div>{ticketCount}</div>
</FormItemContainer>
)}
{options.map((option, index) => {
return (
<FormItemContainer key={index}>
Expand Down
4 changes: 3 additions & 1 deletion src/components/SubmittedForms/Category/Category.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import {
interface CategoryProps {
optionTitles: string[];
managed: boolean;
isPerform: boolean;
}

const Category = ({ optionTitles, managed }: CategoryProps) => {
const Category = ({ optionTitles, managed, isPerform }: CategoryProps) => {
const manageTitles = ['요청', '상태', '취소'];

return (
<CategoryStyled>
<CategoryNthStyled>순서</CategoryNthStyled>
<CategoryRowStyled>제출시간</CategoryRowStyled>
{isPerform && <CategoryNthStyled>인원</CategoryNthStyled>}
{optionTitles.map((title, index) => {
return <CategoryItemStyled key={index}>{title}</CategoryItemStyled>;
})}
Expand Down
12 changes: 11 additions & 1 deletion src/components/SubmittedForms/SubmittedForm/SubmittedForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface SubmittedFormProps {
status: EventStatus;
dateTime: string;
};
ticketCount?: string;
managed: boolean;
}

Expand All @@ -26,6 +27,7 @@ const SubmittedForm = ({
userId,
options,
participation,
ticketCount,
managed,
}: SubmittedFormProps) => {
const { showModal, modalOpen, modalClose } = useModal();
Expand All @@ -34,10 +36,18 @@ const SubmittedForm = ({

return (
<>
{showModal && <FormDetailModal onClose={modalClose} options={options} nthForm={nthForm} />}
{showModal && (
<FormDetailModal
onClose={modalClose}
options={options}
nthForm={nthForm}
ticketCount={ticketCount}
/>
)}
<FormStyled key={index}>
<FormNthStyled>{nthForm}</FormNthStyled>
<FormRowStyled>{dateTime}</FormRowStyled>
{ticketCount && <FormNthStyled>{ticketCount}</FormNthStyled>}
{options.map((option, index) => (
<FormItemStyled onClick={modalOpen} key={index}>
{option.content}
Expand Down
9 changes: 8 additions & 1 deletion src/components/SubmittedForms/SubmittedForms.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ import {
} from './SubmittedForms.style';

const SubmittedForms = ({ formInfo, userForms }: { formInfo: FormInfo; userForms: UserForm[] }) => {
const isPerform = Boolean(userForms[0].ticketCount);

return (
<SubmittedFormsContainer>
<SubmittedFormsWrapper>
<FormsWrapper>
<FormLengthStyled>{`제출된 폼: ${formInfo.count}`}</FormLengthStyled>
<Category optionTitles={formInfo.optionTitles} managed={formInfo.managed} />
<Category
optionTitles={formInfo.optionTitles}
managed={formInfo.managed}
isPerform={isPerform}
/>
{userForms?.map((form, index) => {
return (
<SubmittedForm
Expand All @@ -25,6 +31,7 @@ const SubmittedForms = ({ formInfo, userForms }: { formInfo: FormInfo; userForms
userId={form.userId}
options={form.options}
participation={form.participation}
ticketCount={form.ticketCount}
managed={formInfo.managed}
/>
);
Expand Down
1 change: 1 addition & 0 deletions src/styles/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const CommonEmptyEventsWrapper = styled.div`
justify-content: center;
align-items: center;
width: 100%;
padding: 2rem 0;
color: ${Theme.color.gray};
`;

Expand Down
3 changes: 2 additions & 1 deletion src/types/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EventStatus } from './event';

interface Form {
title: string;
content: string; //#TODO: boolean일 수도 있음 (체크박스?)
content: string;
}

interface UserForm {
Expand All @@ -12,6 +12,7 @@ interface UserForm {
status: EventStatus;
dateTime: string;
};
ticketCount: string;
}

interface FormInfo {
Expand Down

0 comments on commit 95117ff

Please sign in to comment.