move card text to PlainText

yhy
FrozenArcher 2024-03-06 15:53:13 +08:00
parent ff880de466
commit 7cd56d7c79
2 changed files with 47 additions and 11 deletions

View File

@ -24,8 +24,6 @@ function mainPageCard(c: CardContent): JSX.Element {
);
}
type DutyState = 'off' | '1' | '2' | '3';
class DutyData {
constructor() {
this.isInDuty = false;
@ -37,9 +35,9 @@ class DutyData {
isInDuty: boolean;
inDutyCnt: number;
currentDuty: DutyState;
offDutyReason: string;
dutyRecoverTime: string;
currentDuty: 'off' | '1' | '2' | '3';
offDutyReason: string; // from backend
dutyRecoverTime: string; // from backend
}
class ExpandItem extends Component {
@ -77,22 +75,24 @@ class DutyInfo extends Component {
offDutyContent(): ReactNode {
const data = this.props.data;
const od = pt.get().mainPage.dutyCard.offDuty;
return (
<View>
<View></View>
<View>{data.offDutyReason}</View>
<View>{data.dutyRecoverTime}</View>
<View>{od.title}</View>
<View>{od.reason(data.offDutyReason)}</View>
<View>{od.recoverTime(data.dutyRecoverTime)}</View>
</View>
);
}
inDutyContent(): ReactNode {
const data = this.props.data;
const id = pt.get().mainPage.dutyCard.inDuty;
return (
<View>
<View></View>
<View> {data.currentDuty}</View>
<View>{data.inDutyCnt}</View>
<View>{id.title}</View>
<View>{id.currentDutyText(data.currentDuty)}</View>
<View>{id.inDutyCnt(data.inDutyCnt)}</View>
</View>
);
}

View File

@ -12,6 +12,19 @@ export interface MainPageText {
};
stepList: Array<{ title: string }>;
tipsList: Array<{ title: string }>;
dutyCard: {
offDuty: {
title: string;
reason: (s: string) => string;
recoverTime: (t: string) => string;
};
inDuty: {
title: string;
currentDutyText: (c: 'off' | '1' | '2' | '3') => string;
inDutyCnt: (n: number) => string;
};
};
}
export const mainPageZhCn: MainPageText = {
@ -38,4 +51,27 @@ export const mainPageZhCn: MainPageText = {
{ title: '204也是实验室请遵守实验室纪律请勿饮食~' },
{ title: '我们是志愿服务,不收任何礼物哦~' },
],
dutyCard: {
offDuty: {
title: '未值班',
reason: s => '值班停止原因:' + s,
recoverTime: t => '恢复值班时间:' + t,
},
inDuty: {
title: '值班中',
currentDutyText: c => {
switch (c) {
case 'off':
return '当前未值班';
case '1':
return '第一班 13:30-16:00';
case '2':
return '第二班 16:00-18:00';
case '3':
return '第三班 18:00-20:30';
}
},
inDutyCnt: n => '当前值班人数:' + n,
},
},
};