Skip to content

Commit

Permalink
[fix] Top 3 order of User Rank component
Browse files Browse the repository at this point in the history
[fix] many i18n detail bugs
[optimize] update Upstream packages
  • Loading branch information
TechQuery committed Oct 17, 2024
1 parent 5754bf4 commit 9461d59
Show file tree
Hide file tree
Showing 81 changed files with 2,381 additions and 2,633 deletions.
4 changes: 1 addition & 3 deletions components/Activity/ActivityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import { Hackathon } from '@kaiyuanshe/openhackathon-service';
import classNames from 'classnames';
import { Card, Col, Row } from 'react-bootstrap';

import { i18n } from '../../models/Base/Translation';
import { t } from '../../models/Base/Translation';
import { convertDatetime } from '../../utils/time';
import { ActivityControl, ActivityControlProps } from './ActivityControl';
import { ActivityEntry } from './ActivityEntry';

const { t } = i18n;

export interface ActivityCardProps extends Hackathon, ActivityControlProps {
className?: string;
controls?: boolean;
Expand Down
4 changes: 1 addition & 3 deletions components/Activity/ActivityControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { observer } from 'mobx-react';
import { FC } from 'react';
import { Button } from 'react-bootstrap';

import { i18n } from '../../models/Base/Translation';
import { t } from '../../models/Base/Translation';
import platformAdmin from '../../models/User/PlatformAdmin';

const { t } = i18n;

export interface ActivityControlProps
extends Pick<Hackathon, 'name' | 'status'> {
onPublish?: (name: string) => any;
Expand Down
9 changes: 4 additions & 5 deletions components/Activity/ActivityEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ import { textJoin } from 'mobx-i18n';
import { observer } from 'mobx-react';
import { BadgeInput, FileUploader } from 'mobx-restful-table';
import dynamic from 'next/dynamic';
import { FormEvent, PureComponent } from 'react';
import { Component, FormEvent } from 'react';
import { Button, Col, Form, Row } from 'react-bootstrap';
import { formToJSON } from 'web-utility';

import activityStore from '../../models/Activity';
import fileStore from '../../models/Base/File';
import { i18n } from '../../models/Base/Translation';
import { t } from '../../models/Base/Translation';
import { DateTimeInput } from '../DateTimeInput';

const { t } = i18n,
HTMLEditor = dynamic(() => import('../HTMLEditor'), { ssr: false });
const HTMLEditor = dynamic(() => import('../HTMLEditor'), { ssr: false });

interface ActivityFormData extends Hackathon {
bannerUrls: string[] | string;
Expand All @@ -26,7 +25,7 @@ export interface ActivityEditorProps {
}

@observer
export class ActivityEditor extends PureComponent<ActivityEditorProps> {
export class ActivityEditor extends Component<ActivityEditorProps> {
@observable
accessor detailHTML = '';

Expand Down
4 changes: 1 addition & 3 deletions components/Activity/ActivityEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { FC } from 'react';
import { Button } from 'react-bootstrap';
import { diffTime } from 'web-utility';

import { i18n } from '../../models/Base/Translation';

const { t } = i18n;
import { t } from '../../models/Base/Translation';

export type ActivityStatusMeta = Pick<
Hackathon,
Expand Down
4 changes: 1 addition & 3 deletions components/Activity/ActivityList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import { FC, PureComponent } from 'react';
import { Col, Row } from 'react-bootstrap';

import { ActivityListType, ActivityModel } from '../../models/Activity';
import { i18n } from '../../models/Base/Translation';
import { i18n, t } from '../../models/Base/Translation';
import platformAdmin from '../../models/User/PlatformAdmin';
import sessionStore from '../../models/User/Session';
import { XScrollListProps } from '../layout/ScrollList';
import { ActivityCard, ActivityCardProps } from './ActivityCard';

const { t } = i18n;

export interface ActivityListLayoutProps
extends XScrollListProps<Hackathon>,
Pick<ActivityCardProps, 'onPublish' | 'onDelete'> {
Expand Down
8 changes: 3 additions & 5 deletions components/Activity/ActivityManageFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { StaffType } from '@kaiyuanshe/openhackathon-service';
import { computed } from 'mobx';
import { observer } from 'mobx-react';
import { Fragment, PureComponent } from 'react';
import { Component, Fragment } from 'react';
import { Container, Nav } from 'react-bootstrap';

import { menus } from '../../configuration/menu';
import activityStore from '../../models/Activity';
import { i18n } from '../../models/Base/Translation';
import { t } from '../../models/Base/Translation';
import { findDeep } from '../../utils/data';
import { MainBreadcrumb } from '../layout/MainBreadcrumb';
import { PageHead } from '../layout/PageHead';
import { PlatformAdminFrameProps } from '../PlatformAdmin/PlatformAdminFrame';

const { t } = i18n;

library.add(
faBullhorn,
faCloud,
Expand All @@ -52,7 +50,7 @@ export interface ActivityManageFrameProps extends PlatformAdminFrameProps {
}

@observer
export class ActivityManageFrame extends PureComponent<ActivityManageFrameProps> {
export class ActivityManageFrame extends Component<ActivityManageFrameProps> {
componentDidMount() {
activityStore.getOne(this.props.name);
}
Expand Down
99 changes: 48 additions & 51 deletions components/Activity/AwardList.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { faTrash } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { observer } from 'mobx-react';
import { ScrollList, ScrollListProps } from 'mobx-restful-table';
import { FC, PureComponent } from 'react';
import { Button, Image, Table } from 'react-bootstrap';

import { Award } from '../../models/Activity/Award';
import { i18n } from '../../models/Base/Translation';
import { i18n, t } from '../../models/Base/Translation';
import styles from '../../styles/Table.module.less';
import { XScrollListProps } from '../layout/ScrollList';

const { t } = i18n;

export interface AwardListLayoutProps extends XScrollListProps<Award> {
onEdit?: (id: number) => any;
onDelete?: (id: number) => any;
Expand All @@ -30,54 +29,52 @@ const AwardTableHead = () => [
t('operation'),
];

export const AwardListLayout: FC<AwardListLayoutProps> = ({
defaultData = [],
onEdit,
onDelete,
}) => (
<Table hover responsive="lg" className={styles.table}>
<thead>
<tr>
{AwardTableHead().map((data, idx) => (
<th key={idx}>{data}</th>
))}
</tr>
</thead>
<tbody>
{defaultData.map(
({ quantity, target, pictures, name, description, id }) => (
<tr key={id}>
<td>{quantity}</td>
<td>{AwardTargetName()[target]}</td>
<td>
{pictures! && (
<Image
src={pictures?.[0].uri}
alt={pictures?.[0].description}
/>
)}
</td>
<td>
<Button variant="link" onClick={() => onEdit?.(id!)}>
{name}
</Button>
</td>
<td>{description}</td>
<td>
<Button
variant="danger"
size="sm"
onClick={() => onDelete?.(id!)}
>
<FontAwesomeIcon icon={faTrash} className="me-2" />
{t('delete')}
</Button>
</td>
</tr>
),
)}
</tbody>
</Table>
export const AwardListLayout: FC<AwardListLayoutProps> = observer(
({ defaultData = [], onEdit, onDelete }) => (
<Table hover responsive="lg" className={styles.table}>
<thead>
<tr>
{AwardTableHead().map((data, idx) => (
<th key={idx}>{data}</th>
))}
</tr>
</thead>
<tbody>
{defaultData.map(
({ quantity, target, pictures, name, description, id }) => (
<tr key={id}>
<td>{quantity}</td>
<td>{AwardTargetName()[target]}</td>
<td>
{pictures! && (
<Image
src={pictures?.[0].uri}
alt={pictures?.[0].description}
/>
)}
</td>
<td>
<Button variant="link" onClick={() => onEdit?.(id!)}>
{name}
</Button>
</td>
<td>{description}</td>
<td>
<Button
variant="danger"
size="sm"
onClick={() => onDelete?.(id!)}
>
<FontAwesomeIcon icon={faTrash} className="me-2" />
{t('delete')}
</Button>
</td>
</tr>
),
)}
</tbody>
</Table>
),
);

export type AwardListProps = Pick<ScrollListProps<Award>, 'store'> &
Expand Down
131 changes: 64 additions & 67 deletions components/Activity/EnrollmentList.tsx
Original file line number Diff line number Diff line change
@@ -1,87 +1,84 @@
import { Enrollment } from '@kaiyuanshe/openhackathon-service';
import { observer } from 'mobx-react';
import { ScrollList } from 'mobx-restful-table';
import { FC, PureComponent } from 'react';
import { Button, Form, Table } from 'react-bootstrap';

import activityStore from '../../models/Activity';
import { statusName } from '../../models/Activity/Enrollment';
import { i18n } from '../../models/Base/Translation';
import { i18n, t } from '../../models/Base/Translation';
import styles from '../../styles/participant.module.less';
import { XScrollListProps } from '../layout/ScrollList';

const { t } = i18n;

export interface EnrollmentListLayoutProps
extends XScrollListProps<Enrollment> {
onPopUp?: (extensions: Enrollment['form']) => any;
onVerify?: (userId: number, status: Enrollment['status']) => any;
}

export const EnrollmentListLayout: FC<EnrollmentListLayoutProps> = ({
defaultData = [],
onPopUp,
onVerify,
}) => (
<Table className={styles['container-table']}>
<thead>
<tr>
<th>#</th>
<th>{t('user_name')}</th>
<th>{t('mail')}</th>
<th>{t('phone_number')}</th>
{/* <th>{t('contact_address')}</th> */}
<th>{t('enrollment')}</th>
<th>{t('status')}</th>
</tr>
</thead>
<tbody>
{defaultData.map(
(
{
createdBy: {
id,
// address,
email,
mobilePhone,
name,
export const EnrollmentListLayout: FC<EnrollmentListLayoutProps> = observer(
({ defaultData = [], onPopUp, onVerify }) => (
<Table className={styles['container-table']}>
<thead>
<tr>
<th>#</th>
<th>{t('user_name')}</th>
<th>{t('mail')}</th>
<th>{t('phone_number')}</th>
{/* <th>{t('contact_address')}</th> */}
<th>{t('enrollment')}</th>
<th>{t('status')}</th>
</tr>
</thead>
<tbody>
{defaultData.map(
(
{
createdBy: {
id,
// address,
email,
mobilePhone,
name,
},
status,
form,
createdAt,
},
status,
form,
createdAt,
},
index,
) => (
<tr key={id}>
<td>{index + 1}</td>
<td>
<Button variant="link" onClick={() => onPopUp?.(form)}>
{name || email || mobilePhone}
</Button>
</td>
<td>{email}</td>
<td>{mobilePhone}</td>
{/* <td>{address}</td> */}
<td>{createdAt.split('T')[0]}</td>
<td>
<Form.Control
as="select"
className={styles.form}
onChange={({ currentTarget: { value } }) =>
onVerify?.(id!, value as Enrollment['status'])
}
>
{Object.entries(statusName).map(([key, value]) => (
<option key={key} value={key} selected={key === status}>
{value}
</option>
))}
</Form.Control>
</td>
</tr>
),
)}
</tbody>
</Table>
index,
) => (
<tr key={id}>
<td>{index + 1}</td>
<td>
<Button variant="link" onClick={() => onPopUp?.(form)}>
{name || email || mobilePhone}
</Button>
</td>
<td>{email}</td>
<td>{mobilePhone}</td>
{/* <td>{address}</td> */}
<td>{createdAt.split('T')[0]}</td>
<td>
<Form.Control
as="select"
className={styles.form}
onChange={({ currentTarget: { value } }) =>
onVerify?.(id!, value as Enrollment['status'])
}
>
{Object.entries(statusName).map(([key, value]) => (
<option key={key} value={key} selected={key === status}>
{value}
</option>
))}
</Form.Control>
</td>
</tr>
),
)}
</tbody>
</Table>
),
);

export interface EnrollmentListProps extends EnrollmentListLayoutProps {
Expand Down
Loading

1 comment on commit 9461d59

@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-fa2yx5das-techquerys-projects.vercel.app

Built with commit 9461d59.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.