@@ -5,8 +5,36 @@ import Link from 'next/link';
55import { FC , useContext } from 'react' ;
66
77import { I18nContext } from '../../models/Translation' ;
8+ import type zhCN from '../../translation/zh-CN' ;
89
9- export const ProjectCard : FC < Project > = observer ( ( { id, name, status } ) => {
10+ const statusTextKeys : ( keyof typeof zhCN ) [ ] = [
11+ 'project_open' , // Open
12+ 'project_evaluated' , // Evaluated
13+ 'project_contract_generated' , // ContractGenerated
14+ 'project_in_development' , // InDevelopment
15+ 'project_in_testing' , // InTesting
16+ 'project_maintenance' , // Maintenance
17+ ] ;
18+
19+ const bgColors : string [ ] = [
20+ 'grey.200' , // Open
21+ 'success.light' , // Evaluated
22+ 'warning.light' , // ContractGenerated
23+ 'info.light' , // InDevelopment
24+ 'secondary.light' , // InTesting
25+ 'primary.light' , // Maintenance
26+ ] ;
27+
28+ const textColors : string [ ] = [
29+ 'text.primary' , // Open
30+ 'success.contrastText' , // Evaluated
31+ 'warning.contrastText' , // ContractGenerated
32+ 'info.contrastText' , // InDevelopment
33+ 'secondary.contrastText' , // InTesting
34+ 'primary.contrastText' , // Maintenance
35+ ] ;
36+
37+ export const ProjectCard : FC < Project > = observer ( ( { id, name, status = 0 } ) => {
1038 const { t } = useContext ( I18nContext ) ;
1139
1240 return (
@@ -21,20 +49,11 @@ export const ProjectCard: FC<Project> = observer(({ id, name, status }) => {
2149 px : 1 ,
2250 py : 0.5 ,
2351 borderRadius : 1 ,
24- bgcolor : status === 1 ? 'success.light' : status === 0 ? 'grey.200' : 'warning.light' ,
25- color :
26- status === 1
27- ? 'success.contrastText'
28- : status === 0
29- ? 'text.primary'
30- : 'warning.contrastText' ,
52+ bgcolor : bgColors [ status ] ?? 'grey.200' ,
53+ color : textColors [ status ] ?? 'text.primary' ,
3154 } }
3255 >
33- { status === 1
34- ? t ( 'project_open' )
35- : status === 0
36- ? t ( 'project_closed' )
37- : t ( 'project_pending' ) }
56+ { t ( ( statusTextKeys [ status ] ?? 'project_open' ) as keyof typeof zhCN ) }
3857 </ Typography >
3958 </ CardContent >
4059 < CardActions >
0 commit comments