Skip to content

Commit

Permalink
feat: support team sign up in competition
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed Dec 8, 2024
1 parent 50179e9 commit f74442d
Show file tree
Hide file tree
Showing 15 changed files with 346 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/common
2 changes: 1 addition & 1 deletion src/components/AchievementToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AchievementToast extends React.Component<IAchievementToastProps> {
componentDidMount() {
const sound = new Howl({
src: [`${process.env.PUBLIC_PATH}assets/audio/achievement-toast.mp3`],
volume: 0.8,
volume: 0.5,
});
setTimeout(() => sound.play(), 200);
}
Expand Down
40 changes: 32 additions & 8 deletions src/components/GeneralForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class GeneralForm extends React.Component<IGeneralFormProps, State> {
);
}
switch (item.component) {
case 'input':
case 'input': {
return (
<Form.Item key={item.field} label={item.name}>
{getFieldDecorator(item.field, {
Expand All @@ -109,7 +109,8 @@ class GeneralForm extends React.Component<IGeneralFormProps, State> {
)}
</Form.Item>
);
case 'textarea':
}
case 'textarea': {
return (
<Form.Item key={item.field} label={item.name}>
{getFieldDecorator(item.field, {
Expand All @@ -124,7 +125,8 @@ class GeneralForm extends React.Component<IGeneralFormProps, State> {
)}
</Form.Item>
);
case 'select':
}
case 'select': {
const useCustomMode = item.options.some((i) => !!i.icon);
return (
<Form.Item key={item.field} label={item.name}>
Expand All @@ -140,7 +142,14 @@ class GeneralForm extends React.Component<IGeneralFormProps, State> {
>
{item.options.map((opt) =>
useCustomMode ? (
<Select.Option key={`${opt.value}`} value={`${opt.value}`} label={`${opt.name}`}>{opt.icon}{opt.name}</Select.Option>
<Select.Option
key={`${opt.value}`}
value={`${opt.value}`}
label={`${opt.name}`}
>
{opt.icon}
{opt.name}
</Select.Option>
) : (
<Select.Option key={`${opt.value}`}>{opt.name}</Select.Option>
),
Expand All @@ -149,7 +158,8 @@ class GeneralForm extends React.Component<IGeneralFormProps, State> {
)}
</Form.Item>
);
case 'checkbox':
}
case 'checkbox': {
return (
<Form.Item key={item.field}>
{getFieldDecorator(item.field, {
Expand All @@ -158,7 +168,8 @@ class GeneralForm extends React.Component<IGeneralFormProps, State> {
})(<Checkbox>{item.name}</Checkbox>)}
</Form.Item>
);
case 'datetime':
}
case 'datetime': {
return (
<Form.Item key={item.field} label={item.name}>
{getFieldDecorator(item.field, {
Expand All @@ -177,7 +188,8 @@ class GeneralForm extends React.Component<IGeneralFormProps, State> {
)}
</Form.Item>
);
case 'richtext':
}
case 'richtext': {
const rules = [...(item.rules || [])];
// @ts-ignore
let requiredRuleIndex = rules.findIndex((r) => r.required === true);
Expand Down Expand Up @@ -211,8 +223,20 @@ class GeneralForm extends React.Component<IGeneralFormProps, State> {
)}
</Form.Item>
);
}
default: {
return item.field ? (
<Form.Item key={item.field} label={item.name}>
{getFieldDecorator(item.field, {
rules: item.rules,
initialValue: initialValues[item.field] || item.initialValue,
})(item.component)}
</Form.Item>
) : (
item.component
);
}
}
return null;
})}
</Form>
);
Expand Down
9 changes: 8 additions & 1 deletion src/components/UserBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Props {
showAsText?: boolean;
showRating?: boolean;
useTooltip?: boolean;
tabindex?: number;
nameFormat?: (user: IUser) => string;
}

Expand All @@ -29,6 +30,7 @@ const UserBar: React.FC<Props> = ({
showAsText = false,
showRating = false,
useTooltip = false,
tabindex,
nameFormat,
className,
}) => {
Expand Down Expand Up @@ -59,13 +61,18 @@ const UserBar: React.FC<Props> = ({
if (isContestUser || showAsText) {
return inner;
}
const extraAttrs: any = {};
if (tabindex) {
extraAttrs.tabIndex = tabindex;
}
if (disableJump) {
return <a>{inner}</a>;
return <a {...extraAttrs}>{inner}</a>;
}
return (
<Link
to={urlf(pages.users.detail, { param: { id: user.userId } })}
onClick={(e) => e.stopPropagation()}
{...extraAttrs}
>
{useTooltip ? <Tooltip title={nameFormat?.(user) ?? user.nickname}>{inner}</Tooltip> : inner}
</Link>
Expand Down
1 change: 1 addition & 0 deletions src/global.less
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,7 @@ a {
font-family: 'Marcellus', serif;
font-size: 25px;
text-transform: uppercase;
user-select: none;
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/models/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ export default {
yield put({
type: 'users/getSelfAchievedAchievements',
});
yield put({
type: 'users/getSelfOfficialMembers',
});
yield put({
type: 'users/getSelfJoinedTeams',
});
Expand Down Expand Up @@ -131,6 +134,9 @@ export default {
yield put({
type: 'users/getSelfAchievedAchievements',
});
yield put({
type: 'users/getSelfOfficialMembers',
});
yield put({
type: 'users/getSelfJoinedTeams',
});
Expand Down Expand Up @@ -178,6 +184,9 @@ export default {
yield put({
type: 'users/clearSelfAchievedAchievements',
});
yield put({
type: 'users/clearSelfOfficialMembers',
});
yield put({
type: 'users/clearSelfJoinedTeams',
});
Expand Down
Loading

0 comments on commit f74442d

Please sign in to comment.