Skip to content

Commit

Permalink
[fix] Data Type of i18n text joining
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Jul 12, 2023
1 parent 9ebee3f commit 63de96a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
14 changes: 8 additions & 6 deletions components/Activity/ActivityEntry.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { FC } from 'react';
import { Button } from 'react-bootstrap';
import { diffTime } from 'web-utility';

Expand All @@ -7,7 +8,7 @@ import { TimeUnit } from '../../utils/time';

const { t } = i18n;

export type ActivityStatusTextProps = Pick<
export type ActivityStatusMeta = Pick<
Activity,
| 'status'
| 'enrollmentStartedAt'
Expand All @@ -26,7 +27,7 @@ export const getActivityStatusText = ({
eventEndedAt,
judgeStartedAt,
judgeEndedAt,
}: ActivityStatusTextProps) => {
}: ActivityStatusMeta) => {
const now = Date.now(),
isOnline = status === 'online',
enrollmentStart = new Date(enrollmentStartedAt),
Expand All @@ -53,11 +54,12 @@ export const getActivityStatusText = ({
? t('judges_review')
: t('activity_ended');
};
export interface ActivityEntryProps extends ActivityStatusTextProps {

export interface ActivityEntryProps extends ActivityStatusMeta {
href: string;
}

export function ActivityEntry({
export const ActivityEntry: FC<ActivityEntryProps> = ({
status,
enrollmentStartedAt,
enrollmentEndedAt,
Expand All @@ -66,7 +68,7 @@ export function ActivityEntry({
judgeStartedAt,
judgeEndedAt,
href,
}: ActivityEntryProps) {
}) => {
const now = Date.now(),
isOnline = status === 'online',
enrollmentStart = new Date(enrollmentStartedAt),
Expand All @@ -91,4 +93,4 @@ export function ActivityEntry({
})}
</Button>
);
}
};
5 changes: 3 additions & 2 deletions translation/en-US.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { textJoin } from 'mobx-i18n';
import { diffTime } from 'web-utility';

export default {
home_page: 'Home page',
Expand All @@ -12,8 +13,8 @@ export default {
idea2app_scaffolding: 'idea2app Scaffolding',
registration_period: 'Registration Period',
activity_period: 'Activity Period',
register_after: ({ distance, unit }: Record<'distance' | 'unit', string>) =>
textJoin('Registration after', distance, unit),
register_after: ({ distance, unit }: ReturnType<typeof diffTime>) =>
textJoin('Registration after', distance + '', unit),
accepting_applications: 'Accepting Applications',
activity_ended: 'Activity ended',
my_team: 'My Team',
Expand Down
5 changes: 3 additions & 2 deletions translation/zh-CN.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { textJoin } from 'mobx-i18n';
import { diffTime } from 'web-utility';

export default {
home_page: '主页',
Expand All @@ -12,8 +13,8 @@ export default {
idea2app_scaffolding: 'idea2app 脚手架强力驱动',
registration_period: '报名时段',
activity_period: '活动时段',
register_after: ({ distance, unit }: Record<'distance' | 'unit', string>) =>
textJoin(distance, unit, '后开始报名'),
register_after: ({ distance, unit }: ReturnType<typeof diffTime>) =>
textJoin(distance + '', unit, '后开始报名'),
accepting_applications: '正在报名',
activity_ended: '比赛结束',
my_team: '我的团队',
Expand Down
5 changes: 3 additions & 2 deletions translation/zh-TW.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { textJoin } from 'mobx-i18n';
import { diffTime } from 'web-utility';

export default {
home_page: '主頁',
Expand All @@ -12,8 +13,8 @@ export default {
idea2app_scaffolding: 'idea2app 腳手架強力驅動',
registration_period: '報名時段',
activity_period: '活動時段',
register_after: ({ distance, unit }: Record<'distance' | 'unit', string>) =>
textJoin(distance, unit, '後開始報名'),
register_after: ({ distance, unit }: ReturnType<typeof diffTime>) =>
textJoin(distance + '', unit, '後開始報名'),
accepting_applications: '正在報名',
activity_ended: '比賽結束',
my_team: '我的團隊',
Expand Down

1 comment on commit 63de96a

@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-21nd3jad5-techquery.vercel.app

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

Please sign in to comment.