Skip to content

Commit e9efee4

Browse files
committed
feat: 모든 수정 심사를 볼 수 있도록 수정
1 parent 9094a77 commit e9efee4

File tree

1 file changed

+50
-8
lines changed
  • apps/pyconkr-participant-portal/src/components/pages

1 file changed

+50
-8
lines changed

apps/pyconkr-participant-portal/src/components/pages/home.tsx

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
import * as Common from "@frontend/common";
2-
import { Button, List, ListItem, ListItemButton, ListItemText, Stack, styled, Typography, useMediaQuery } from "@mui/material";
2+
import {
3+
Button,
4+
FormControlLabel,
5+
FormGroup,
6+
List,
7+
ListItem,
8+
ListItemButton,
9+
ListItemText,
10+
Stack,
11+
styled,
12+
Switch,
13+
Typography,
14+
useMediaQuery,
15+
} from "@mui/material";
316
import { ErrorBoundary, Suspense } from "@suspensive/react";
417
import * as React from "react";
518
import { useNavigate } from "react-router-dom";
19+
import * as R from "remeda";
620

721
import { useAppContext } from "../../contexts/app_context";
822
import { ErrorPage } from "../elements/error_page";
@@ -13,6 +27,15 @@ import { Page } from "../page";
1327

1428
const ProfileImageSize: React.CSSProperties["width" | "height"] = "8rem";
1529

30+
type AuditState = "requested" | "approved" | "rejected" | "cancelled";
31+
32+
const TranslatedAuditState: Record<AuditState, { ko: string; en: string }> = {
33+
requested: { ko: "심사 진행 중", en: "Under review" },
34+
approved: { ko: "승인 후 반영됨", en: "Approved and applied" },
35+
rejected: { ko: "거절됨", en: "Rejected" },
36+
cancelled: { ko: "취소됨", en: "Cancelled" },
37+
};
38+
1639
const FieldsetContainer = styled(Stack)({
1740
width: "100%",
1841
flexWrap: "wrap",
@@ -63,6 +86,10 @@ const ProfileImageFallback: React.FC<{ language: "ko" | "en" }> = ({ language })
6386
);
6487
};
6588

89+
type InnerLandingPageState = {
90+
showAllAudits: boolean;
91+
};
92+
6693
const InnerLandingPage: React.FC = () => {
6794
const navigate = useNavigate();
6895
const { language } = useAppContext();
@@ -72,7 +99,8 @@ const InnerLandingPage: React.FC = () => {
7299
const { data: audits } = Common.Hooks.BackendParticipantPortalAPI.useModificationAuditsQuery(participantPortalAPIClient);
73100
const { data: sessions } = Common.Hooks.BackendParticipantPortalAPI.useListPresentationsQuery(participantPortalAPIClient);
74101

75-
const ongoingAudits = audits?.filter((audit) => audit.status === "requested") || [];
102+
const ongoingAudits = audits.filter((audit) => audit.status === "requested");
103+
const [state, setState] = React.useState<InnerLandingPageState>({ showAllAudits: R.isEmpty(ongoingAudits) });
76104

77105
if (!profile) {
78106
return (
@@ -84,16 +112,21 @@ const InnerLandingPage: React.FC = () => {
84112
);
85113
}
86114

115+
const filteredAudits = state.showAllAudits ? audits : ongoingAudits;
116+
const toggleShowAllAudits = () => setState((ps) => ({ ...ps, showAllAudits: !ps.showAllAudits }));
117+
87118
const greetingStr = language === "ko" ? `안녕하세요, ${profile.nickname}님!` : `Hello, ${profile.nickname}!`;
88119
const myInfoStr = language === "ko" ? "내 정보" : "My Information";
89-
const auditStr = language === "ko" ? "심사 중인 수정 요청" : "Ongoing Audit Requests";
120+
const auditStr = language === "ko" ? "수정 요청" : "Modification Requests";
90121
const sessionsStr = language === "ko" ? "발표 목록" : "Sessions";
91122
// const sponsorsStr = language === "ko" ? "후원사 정보" : "Sponsor informations";
92123
const userNameStr = language === "ko" ? `계정명 : ${profile.username}` : `Username : ${profile.username}`;
93124
const nickNameStr = language === "ko" ? `별칭 : ${profile.nickname}` : `Nickname : ${profile.nickname}`;
94125
const emailStr = language === "ko" ? `이메일 : ${profile.email}` : `Email : ${profile.email}`;
95126
const editProfileStr = language === "ko" ? "프로필 수정" : "Edit Profile";
96-
const auditEmptyStr = language === "ko" ? "진행 중인 수정 요청이 없습니다." : "No ongoing audit requests.";
127+
const showReviewOngoingAuditsStr = language === "ko" ? "현재 심사가 진행 중인 수정 요청만 보기" : "Show only review ongoing modification requests";
128+
const ongoingAuditEmptyStr = language === "ko" ? "진행 중인 수정 요청이 없습니다." : "No ongoing modification requests.";
129+
const auditEmptyStr = language === "ko" ? "수정 요청이 없습니다." : "No modification requests.";
97130

98131
return (
99132
<Page>
@@ -118,19 +151,28 @@ const InnerLandingPage: React.FC = () => {
118151
</Fieldset>
119152
<FieldsetContainer>
120153
<ProperWidthFieldset legend={auditStr}>
154+
{audits.length !== 0 && (
155+
<FormGroup>
156+
<FormControlLabel
157+
control={<Switch value={!state.showAllAudits} onChange={toggleShowAllAudits} size="small" />}
158+
label={showReviewOngoingAuditsStr}
159+
labelPlacement="start"
160+
/>
161+
</FormGroup>
162+
)}
121163
<List>
122-
{ongoingAudits.length > 0 ? (
123-
ongoingAudits.map((audit) => (
164+
{filteredAudits.length > 0 ? (
165+
filteredAudits.map((audit) => (
124166
<ListItem key={audit.id} disablePadding sx={{ cursor: "pointer", border: "1px solid #ccc" }}>
125167
<ListItemButton
126-
children={<ListItemText primary={audit.str_repr} secondary={audit.status} />}
168+
children={<ListItemText primary={audit.str_repr} secondary={TranslatedAuditState[audit.status][language]} />}
127169
onClick={() => navigate(`/session/${audit.instance_id}/`)}
128170
/>
129171
</ListItem>
130172
))
131173
) : (
132174
<ListItem disablePadding sx={{ cursor: "pointer", border: "1px solid #ccc" }}>
133-
<ListItemButton children={<ListItemText primary={auditEmptyStr} />} />
175+
<ListItemButton children={<ListItemText primary={state.showAllAudits ? auditEmptyStr : ongoingAuditEmptyStr} />} />
134176
</ListItem>
135177
)}
136178
</List>

0 commit comments

Comments
 (0)