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

SKRF-452 refactor: submitted forms page exception #214

Merged
merged 4 commits into from
Dec 1, 2023
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
Loading