Skip to content

Commit

Permalink
[fix] several detail bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Jul 12, 2023
1 parent 35149be commit 4f897f2
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 21 deletions.
18 changes: 10 additions & 8 deletions components/Activity/ActivityEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class ActivityEditor extends PureComponent<ActivityEditorProps> {
this.detailHTML = detail || '';
}

componentWillUnmount() {
activityStore.clearCurrent();
}

submitHandler = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
event.stopPropagation();
Expand All @@ -56,7 +60,7 @@ export class ActivityEditor extends PureComponent<ActivityEditorProps> {
const { name } = this.props,
data = formToJSON<ActivityFormData>(form);

data.detail = data.detail + '';
data.detail = (data.detail || '') + '';

data.banners = [data.bannerUrls ?? []].flat().map(bannerUrl => {
const name = bannerUrl.split('/').slice(-1)[0];
Expand Down Expand Up @@ -271,13 +275,11 @@ export class ActivityEditor extends PureComponent<ActivityEditorProps> {
<span className="text-danger"> *</span>
</Form.Label>
<Col sm={10}>
{detail && (
<HTMLEditor
name="detail"
defaultValue={detail}
onChange={code => (this.detailHTML = code)}
/>
)}
<HTMLEditor
name="detail"
defaultValue={detail}
onChange={code => (this.detailHTML = code)}
/>
<Form.Control
className="d-none"
isInvalid={!this.detailHTML.trim() && this.validated}
Expand Down
8 changes: 4 additions & 4 deletions components/User/UserBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { observer } from 'mobx-react';
import Link from 'next/link';
import { Button, Dropdown } from 'react-bootstrap';

import sessionStore from '../../models/Session';
Expand All @@ -21,9 +20,10 @@ const UserBar = observer(() => {
</SessionBox>
) : (
<>
<Link href="/activity/create" passHref>
<Button variant="success">{t('create_hackathons')}</Button>
</Link>
<Button variant="success" href="/activity/create">
{t('create_hackathons')}
</Button>

<Dropdown>
<Dropdown.Toggle>{showName}</Dropdown.Toggle>
<Dropdown.Menu>
Expand Down
1 change: 1 addition & 0 deletions pages/activity/[name]/manage/administrator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class AdministratorPage extends PureComponent<
> {
store = activityStore.staffOf(this.props.route.params!.name + '');

@observable
selectedIds: string[] = [];

@observable
Expand Down
6 changes: 2 additions & 4 deletions pages/activity/[name]/manage/award.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const getServerSideProps = withRoute<{ name: string }>();
const { t } = i18n;

@observer
class AwardPage extends PureComponent<
export default class AwardPage extends PureComponent<
InferGetServerSidePropsType<typeof getServerSideProps>
> {
store = activityStore.awardOf(this.props.route.params!.name);
Expand Down Expand Up @@ -106,7 +106,7 @@ class AwardPage extends PureComponent<
</Form.Label>
<Col sm="9">
<Form.Select name="target">
{Object.entries(AwardTargetName).map(([value, name]) => (
{Object.entries(AwardTargetName()).map(([value, name]) => (
<option
key={name}
value={value}
Expand Down Expand Up @@ -161,5 +161,3 @@ class AwardPage extends PureComponent<
);
}
}

export default AwardPage;
7 changes: 4 additions & 3 deletions pages/activity/[name]/manage/git.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ export const getServerSideProps = withRoute<{ name: string }>();
export default class ActivityManageGitPage extends PureComponent<
InferGetServerSidePropsType<typeof getServerSideProps>
> {
@observable
show = false;

store = activityStore.templateOf(this.props.route.params!.name + '');

@observable
selectedIds: string[] = [];

@observable
show = false;

handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
event.stopPropagation();
Expand Down
5 changes: 3 additions & 2 deletions pages/activity/[name]/manage/message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ export default class MessageListPage extends PureComponent<
form = createRef<HTMLFormElement>();

@observable
show = false;

selectedIds: string[] = [];

@observable
show = false;

handleReset = () => this.form.current?.reset();

handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
Expand Down
1 change: 1 addition & 0 deletions pages/activity/[name]/manage/organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class OrganizationPage extends PureComponent<
> {
store = activityStore.organizationOf(this.props.route.params!.name);

@observable
selectedIds: string[] = [];

@observable
Expand Down
1 change: 1 addition & 0 deletions pages/admin/platform-admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function PlatformAdminPage() {
class PlatformAdmin extends PureComponent {
store = new PlatformAdminModel();

@observable
selectedIds: string[] = [];

@observable
Expand Down

1 comment on commit 4f897f2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for open-hackathon ready!

✅ Preview
https://open-hackathon-q7bj31uo8-techquery.vercel.app

Built with commit 4f897f2.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.