Skip to content

Commit

Permalink
[add] Time Range component
Browse files Browse the repository at this point in the history
[fix] some SSR detail errors
[fix] Sentry SSL error in Docker
  • Loading branch information
TechQuery committed Dec 28, 2023
1 parent 861eff9 commit bfc822d
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:18-slim AS base
RUN apt-get update && \
apt-get install curl -y --no-install-recommends
apt-get install ca-certificates curl -y --no-install-recommends
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
Expand Down
5 changes: 2 additions & 3 deletions components/Activity/Agenda/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { observer } from 'mobx-react';
import dynamic from 'next/dynamic';
import { Component } from 'react';
import { Badge, Carousel, Col, Container, Row } from 'react-bootstrap';
import { formatDate } from 'web-utility';

import { blobURLOf } from '../../../models/Base';
import { LarkImage } from '../../Base/LarkImage';
import { ScoreBar } from '../../Base/ScoreBar';
import { TextScrollableBox } from '../../Base/TextScrollableBox';
import { TimeRange } from '../../Base/TimeRange';
import { ActivityPeople } from '../People';
import { AgendaToolbarProps } from './Toolbar';

Expand Down Expand Up @@ -98,8 +98,7 @@ export class AgendaCard extends Component<AgendaToolbarProps> {
</h3>
<ul className="list-unstyled flex-fill d-flex flex-column justify-content-between gap-2">
<li>
🕒 {formatDate(+startTime!, 'YYYY-MM-DD')} ~{' '}
{formatDate(+endTime!, 'YYYY-MM-DD')}
<TimeRange {...{ startTime, endTime }} />
</li>
<li>{(mentorOrganizations as string[])?.join(' ')}</li>

Expand Down
15 changes: 15 additions & 0 deletions components/Base/TimeRange.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TableCellValue } from 'mobx-lark';
import { FC } from 'react';
import { formatDate } from 'web-utility';

export const TimeRange: FC<Record<'startTime' | 'endTime', TableCellValue>> = ({
startTime,
endTime,
}) =>
startTime &&
endTime && (
<>
🕒 {formatDate(+startTime!, 'YYYY-MM-DD')} ~{' '}
{formatDate(+endTime!, 'YYYY-MM-DD')}
</>
);
11 changes: 10 additions & 1 deletion models/Activity/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HTTPError } from 'koajax';
import { action, computed, makeObservable, observable } from 'mobx';
import {
BiDataTable,
Expand Down Expand Up @@ -185,13 +186,21 @@ export class ActivityModel extends BiDataTable<Activity>() {
return database ? `/activity/${alias || id}` : link + '';
}

@toggle('downloading')
async getOneByAlias(alias: string) {
const { body } = await this.client.get<LarkPageData<TableRecord<Activity>>>(
`${this.baseURI}?${buildURLData({
filter: makeSimpleFilter({ alias }, '='),
})}`,
);
const [item] = body!.data!.items;
const [item] = body!.data!.items || [];

if (!item)
throw new HTTPError(`Activity "${alias}" is not found`, {
status: 404,
statusText: 'Not found',
headers: {},
});
return (this.currentOne = this.normalize(item));
}

Expand Down
11 changes: 10 additions & 1 deletion models/Product/Article.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HTTPError } from 'koajax';
import {
BiDataTable,
LarkPageData,
Expand Down Expand Up @@ -67,7 +68,15 @@ export class ArticleModel extends BiDataTable<Article>() {
filter: makeSimpleFilter({ alias }, '='),
})}`,
);
const item = this.normalize(body!.data!.items[0]);
const [rawItem] = body!.data!.items || [];

if (!rawItem)
throw new HTTPError(`Article "${alias}" is not found`, {
status: 404,
statusText: 'Not found',
headers: {},
});
const item = this.normalize(rawItem);

const path = `article/${
(item.link as string).split('/').slice(-1)[0]
Expand Down
6 changes: 3 additions & 3 deletions pages/activity/[id]/agenda/[agendaId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
DropdownButton,
Row,
} from 'react-bootstrap';
import { buildURLData, formatDate } from 'web-utility';
import { buildURLData } from 'web-utility';

import {
ActivityPeople,
Expand All @@ -33,6 +33,7 @@ import {
import { CommentBox } from '../../../../../components/Base/CommentBox';
import { QRCodeButton } from '../../../../../components/Base/QRCodeButton';
import { ScoreBar } from '../../../../../components/Base/ScoreBar';
import { TimeRange } from '../../../../../components/Base/TimeRange';
import PageHead from '../../../../../components/Layout/PageHead';
import { Activity, ActivityModel } from '../../../../../models/Activity';
import { Agenda } from '../../../../../models/Activity/Agenda';
Expand Down Expand Up @@ -128,8 +129,7 @@ export default class AgendaDetailPage extends PureComponent<AgendaDetailPageProp

<div className="text-success">{forum as string}</div>
<div>
🕒 {formatDate(+startTime!, 'YYYY-MM-DD')} ~{' '}
{formatDate(+endTime!, 'YYYY-MM-DD')}
<TimeRange {...{ startTime, endTime }} />
</div>
</div>

Expand Down
3 changes: 2 additions & 1 deletion pages/community/pioneer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { observer } from 'mobx-react';
import { InferGetServerSidePropsType } from 'next';
import { compose, errorLogger, translator } from 'next-ssr-middleware';
import { cache, compose, errorLogger, translator } from 'next-ssr-middleware';
import { FC } from 'react';
import { Breadcrumb, Container } from 'react-bootstrap';

Expand All @@ -11,6 +11,7 @@ import { i18n } from '../../models/Base/Translation';
import { PersonnelModel } from '../../models/Personnel';

export const getServerSideProps = compose<{}, Pick<PersonnelModel, 'group'>>(
cache(),
errorLogger,
translator(i18n),
async () => {
Expand Down
4 changes: 2 additions & 2 deletions pages/user/[uuid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TimeDistance } from 'idea-react';
import { observer } from 'mobx-react';
import { ScrollList } from 'mobx-restful-table';
import { InferGetServerSidePropsType } from 'next';
import { cache, compose } from 'next-ssr-middleware';
import { cache, compose, errorLogger } from 'next-ssr-middleware';
import { PureComponent } from 'react';
import { Breadcrumb, Button, Col, Container, Row } from 'react-bootstrap';

Expand All @@ -15,7 +15,7 @@ import userStore, { UserModel } from '../../models/Base/User';
export const getServerSideProps = compose<
{ uuid: string },
{ user: User; checkEvents: CheckEvent[] }
>(cache(), async ({ params: { uuid } = {} }) => {
>(cache(), errorLogger, async ({ params: { uuid } = {} }) => {
const user = await new UserModel().getOne(uuid!);

const checkEvents = await new CheckEventModel().getList({ user: user.id });
Expand Down

1 comment on commit bfc822d

@github-actions
Copy link

@github-actions github-actions bot commented on bfc822d Dec 28, 2023

Choose a reason for hiding this comment

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

Deploy preview for kaiyuanshe ready!

✅ Preview
https://kaiyuanshe-5f0snsvwe-techquery.vercel.app

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

Please sign in to comment.