Skip to content

Commit

Permalink
feat: optimize legacy contest user registration
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Dec 1, 2023
1 parent 807628c commit 15427f8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onlinejudge3-fe",
"version": "3.5.5",
"version": "3.5.6",
"description": "",
"scripts": {
"dev": "gulp dev",
Expand Down
2 changes: 1 addition & 1 deletion src/common
Submodule common updated 1 files
+102 −102 contracts/contest.ts
11 changes: 6 additions & 5 deletions src/components/ContestUserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,13 @@ class ContestUserList extends React.Component<Props, State> {
field: 'class1',
component: 'input',
initialValue: safeGet(contestUser[uid], 'members[0].class', ''),
rules: [{ required: true, message: 'Please input class' }],
},
{
name: 'Tel',
field: 'tel1',
component: 'input',
initialValue: safeGet(contestUser[uid], 'members[0].tel', ''),
rules: [{ required: true, message: 'Please input phone number' }],
},
{
name: 'Email',
Expand Down Expand Up @@ -293,7 +293,7 @@ class ContestUserList extends React.Component<Props, State> {
value: item.id,
})),
initialValue: `${contestUser[uid]?.status ?? ContestUserStatus.accepted}`,
rules: [{ required: true, message: 'Please ' }],
rules: [{ required: true, message: 'Please select status' }],
});
}
return items;
Expand Down Expand Up @@ -364,13 +364,13 @@ class ContestUserList extends React.Component<Props, State> {
field: 'class1',
component: 'input',
initialValue: safeGet(contestUser[uid], 'members[0].class', ''),
rules: [{ required: true, message: 'Please input class' }],
},
{
name: 'Tel of Member 1',
field: 'tel1',
component: 'input',
initialValue: safeGet(contestUser[uid], 'members[0].tel', ''),
rules: [{ required: true, message: 'Please input phone number' }],
},
{
name: 'Email of Member 1',
Expand Down Expand Up @@ -426,7 +426,6 @@ class ContestUserList extends React.Component<Props, State> {
field: 'class2',
component: 'input',
initialValue: safeGet(contestUser[uid], 'members[1].class', ''),
rules: [{ required: true, message: 'Please input class' }],
},
{
name: 'Tel of Member 2',
Expand Down Expand Up @@ -487,7 +486,6 @@ class ContestUserList extends React.Component<Props, State> {
field: 'class3',
component: 'input',
initialValue: safeGet(contestUser[uid], 'members[2].class', ''),
rules: [{ required: true, message: 'Please input class' }],
},
{
name: 'Tel of Member 3',
Expand Down Expand Up @@ -705,6 +703,7 @@ class ContestUserList extends React.Component<Props, State> {
<GeneralFormModal
loadingEffect="contests/updateContestUser"
title="Edit Register Info"
maskClosable={false}
autoMsg
items={
contestUser[text.contestUserId]
Expand Down Expand Up @@ -777,6 +776,7 @@ class ContestUserList extends React.Component<Props, State> {
<GeneralFormModal
loadingEffect="admin/auditContestUser"
title="Audit Registration"
maskClosable={false}
autoMsg
items={this.auditFormItems}
submit={(dispatch: ReduxProps['dispatch'], values) => {
Expand Down Expand Up @@ -839,6 +839,7 @@ class ContestUserList extends React.Component<Props, State> {
<GeneralFormModal
loadingEffect="contests/addContestUser"
title="Add Contest User"
maskClosable={false}
autoMsg
items={contestDetail?.team ? this.addTeamUserFormItems() : this.addUserFormItems()}
submit={(dispatch: ReduxProps['dispatch'], values) => {
Expand Down
3 changes: 3 additions & 0 deletions src/components/GeneralFormModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface IGeneralFormModalProps extends ReduxProps, FormProps {
autoMsg?: boolean;
className?: string;
disabled?: boolean;
maskClosable?: boolean;
submit(dispatch: ReduxProps['dispatch'], values): Promise<IApiResponse<any>>;
onSuccess?(dispatch: ReduxProps['dispatch'], ret: IApiResponse<any>): void;
onSuccessModalClosed?(dispatch: ReduxProps['dispatch'], ret: IApiResponse<any>): void;
Expand Down Expand Up @@ -94,6 +95,7 @@ class GeneralFormModal extends React.Component<IGeneralFormModalProps, State> {
okText,
cancelText,
className,
maskClosable,
} = this.props;

return (
Expand All @@ -109,6 +111,7 @@ class GeneralFormModal extends React.Component<IGeneralFormModalProps, State> {
confirmLoading={loadings[loadingEffect] || false}
onOk={this.handleOk}
onCancel={this.handleHideModel}
maskClosable={maskClosable}
>
<GeneralForm form={form} items={items} initialValues={initialValues} />
</Modal>
Expand Down
3 changes: 3 additions & 0 deletions src/pages/contests/$id/users/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class ContestUserListPage extends React.Component<Props, State> {
} = this.props;
return (
<PageAnimation>
<h4 className="mb-md-lg">
Participants of {id} - {contestDetail?.title || '-'}
</h4>
<ContestUserList
id={id}
data={data}
Expand Down
11 changes: 7 additions & 4 deletions src/pages/contests/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ class ContestList extends React.Component<Props, State> {
name: 'Class',
field: 'class1',
component: 'input',
rules: [{ required: true, message: 'Please input class' }],
},
{
name: 'Tel',
field: 'tel1',
component: 'input',
rules: [{ required: true, message: 'Please input phone number' }],
},
{
name: 'Email',
Expand Down Expand Up @@ -253,12 +253,12 @@ class ContestList extends React.Component<Props, State> {
name: 'Class of Member 1',
field: 'class1',
component: 'input',
rules: [{ required: true, message: 'Please input class' }],
},
{
name: 'Tel of Member 1',
field: 'tel1',
component: 'input',
rules: [{ required: true, message: 'Please input phone number' }],
},
{
name: 'Email of Member 1',
Expand Down Expand Up @@ -306,7 +306,6 @@ class ContestList extends React.Component<Props, State> {
name: 'Class of Member 2',
field: 'class2',
component: 'input',
rules: [{ required: true, message: 'Please input class' }],
},
{
name: 'Tel of Member 2',
Expand Down Expand Up @@ -358,7 +357,6 @@ class ContestList extends React.Component<Props, State> {
name: 'Class of Member 3',
field: 'class3',
component: 'input',
rules: [{ required: true, message: 'Please input class' }],
},
{
name: 'Tel of Member 3',
Expand Down Expand Up @@ -477,6 +475,7 @@ class ContestList extends React.Component<Props, State> {
<GeneralFormModal
loadingEffect="contests/addContestUser"
title="Register Contest"
maskClosable={false}
autoMsg
items={record.team ? addTeamUserFormItems : addUserFormItems}
submit={(dispatch: ReduxProps['dispatch'], values) => {
Expand Down Expand Up @@ -519,6 +518,10 @@ class ContestList extends React.Component<Props, State> {
category: 'contests',
action: 'registerContest',
});
setTimeout(
() => router.push(urlf(pages.contests.users, { param: { id: record.contestId } })),
constants.modalAnimationDurationFade,
);
}}
>
<a title="Register Contest">
Expand Down
4 changes: 2 additions & 2 deletions src/pages/contests/models/contests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ export default {
return ret;
},
*getUserList({ payload: prams }, { call, put, select }) {
const formattedQuery = {
const formattedQuery: any = {
...formatListQuery(prams.query),
// order: [['contestUserId', 'DESC']],
order: [['contestUserId', 'DESC']],
};
formattedQuery.contestUserId &&
(formattedQuery.contestUserId = +formattedQuery.contestUserId);
Expand Down

0 comments on commit 15427f8

Please sign in to comment.