Skip to content

Commit 19b1a0b

Browse files
committed
[fix] several GitHub copilot bugs
1 parent dd9a343 commit 19b1a0b

File tree

7 files changed

+174
-225
lines changed

7 files changed

+174
-225
lines changed
Lines changed: 105 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,112 @@
1-
import { RequirementEvaluation } from '@idea2app/data-server';
1+
import { RequirementEvaluation, UserRole } from '@idea2app/data-server';
22
import { Box, Typography } from '@mui/material';
3+
import { observer } from 'mobx-react';
34
import { FC, useContext } from 'react';
45

56
import { I18nContext } from '../../models/Translation';
7+
import userStore from '../../models/User';
68

7-
export const EvaluationDisplay: FC<RequirementEvaluation> = ({
8-
title,
9-
description,
10-
scopes = [],
11-
developerCount,
12-
designerCount,
13-
workload,
14-
monthPeriod,
15-
budget,
16-
factor,
17-
}) => {
18-
const { t } = useContext(I18nContext);
9+
export const EvaluationDisplay: FC<RequirementEvaluation> = observer(
10+
({
11+
title,
12+
scopes = [],
13+
developerCount,
14+
designerCount,
15+
workload,
16+
monthPeriod,
17+
budget,
18+
factor,
19+
}) => {
20+
const { t } = useContext(I18nContext),
21+
{ roles } = userStore.session || {};
1922

20-
return (
21-
<Box sx={{
22-
'& .evaluation-item': {
23-
marginBottom: 1,
24-
fontSize: '0.875rem',
25-
padding: '4px 0',
26-
borderLeft: '3px solid',
27-
borderColor: 'primary.light',
28-
paddingLeft: 1,
29-
},
30-
'& strong': {
31-
fontWeight: 600,
32-
color: 'primary.dark',
33-
},
34-
'& ul': {
35-
margin: '8px 0',
36-
paddingLeft: '20px',
37-
},
38-
'& li': {
39-
marginBottom: '4px',
40-
},
41-
}}>
42-
{title && (
43-
<Box className="evaluation-item">
44-
<Typography component="h3" sx={{ fontWeight: 600, mb: 1 }}>
45-
{title}
46-
</Typography>
47-
</Box>
48-
)}
49-
50-
{description && (
51-
<Box className="evaluation-item">
52-
<Typography component="span" sx={{ fontWeight: 600 }}>
53-
{t('description')}
54-
</Typography>
55-
{' '}
56-
{description}
57-
</Box>
58-
)}
59-
60-
{scopes && scopes.length > 0 && (
61-
<Box className="evaluation-item">
62-
<Typography component="span" sx={{ fontWeight: 600 }}>
63-
{t('development_scopes')}
64-
</Typography>
65-
<Box component="ul" sx={{ mt: 0.5 }}>
66-
{scopes.map((scope, index) => (
67-
<Box key={index} component="li" sx={{ ml: 1 }}>
68-
{scope}
69-
</Box>
70-
))}
23+
return (
24+
<Box
25+
sx={{
26+
'& .evaluation-item': {
27+
marginBottom: 1,
28+
fontSize: '0.875rem',
29+
padding: '4px 0',
30+
borderLeft: '3px solid',
31+
borderColor: 'primary.light',
32+
paddingLeft: 1,
33+
},
34+
'& ul': {
35+
margin: '8px 0',
36+
paddingLeft: '20px',
37+
},
38+
'& li': {
39+
marginBottom: '4px',
40+
},
41+
}}
42+
>
43+
{title && (
44+
<Box className="evaluation-item">
45+
<Typography component="h3" sx={{ fontWeight: 600, mb: 1 }}>
46+
{title}
47+
</Typography>
7148
</Box>
72-
</Box>
73-
)}
74-
75-
{workload && (
76-
<Box className="evaluation-item">
77-
<Typography component="span" sx={{ fontWeight: 600 }}>
78-
{t('workload')}
79-
</Typography>
80-
{' '}
81-
{workload} {t('hours')}
82-
</Box>
83-
)}
84-
85-
{monthPeriod && (
86-
<Box className="evaluation-item">
87-
<Typography component="span" sx={{ fontWeight: 600 }}>
88-
{t('timeline')}
89-
</Typography>
90-
{' '}
91-
{monthPeriod} {t('months')}
92-
</Box>
93-
)}
94-
95-
{budget && (
96-
<Box className="evaluation-item">
97-
<Typography component="span" sx={{ fontWeight: 600 }}>
98-
{t('budget')}
99-
</Typography>
100-
{' '}
101-
${budget.toLocaleString()}
102-
</Box>
103-
)}
104-
105-
{(developerCount || designerCount) && (
106-
<Box className="evaluation-item">
107-
<Typography component="span" sx={{ fontWeight: 600 }}>
108-
{t('team_size')}
109-
</Typography>
110-
{' '}
111-
{[
112-
developerCount && `${developerCount} ${t('developers')}`,
113-
designerCount && `${designerCount} ${t('designers')}`
114-
].filter(Boolean).join(', ')}
115-
</Box>
116-
)}
117-
118-
{factor && (
119-
<Box className="evaluation-item">
120-
<Typography component="span" sx={{ fontWeight: 600 }}>
121-
{t('complexity_factor')}
122-
</Typography>
123-
{' '}
124-
{factor}
125-
</Box>
126-
)}
127-
</Box>
128-
);
129-
};
49+
)}
50+
{scopes[0] && (
51+
<Box className="evaluation-item">
52+
<Typography component="h4" sx={{ fontWeight: 600 }}>
53+
{t('development_scopes')}
54+
</Typography>
55+
<Box component="ul" sx={{ mt: 0.5 }}>
56+
{scopes.map(scope => (
57+
<Box key={scope} component="li" sx={{ ml: 1 }}>
58+
{scope}
59+
</Box>
60+
))}
61+
</Box>
62+
</Box>
63+
)}
64+
{workload && (
65+
<Box className="evaluation-item">
66+
<Typography component="h4" sx={{ fontWeight: 600 }}>
67+
{t('workload')}
68+
</Typography>{' '}
69+
{workload} {t('hours')}
70+
</Box>
71+
)}
72+
{monthPeriod && (
73+
<Box className="evaluation-item">
74+
<Typography component="h4" sx={{ fontWeight: 600 }}>
75+
{t('timeline')}
76+
</Typography>{' '}
77+
{monthPeriod} {t('months')}
78+
</Box>
79+
)}
80+
{budget && (
81+
<Box className="evaluation-item">
82+
<Typography component="h4" sx={{ fontWeight: 600 }}>
83+
{t('budget')}
84+
</Typography>{' '}
85+
{budget.toLocaleString()}
86+
</Box>
87+
)}
88+
{(developerCount || designerCount) && (
89+
<Box className="evaluation-item">
90+
<Typography component="h4" sx={{ fontWeight: 600 }}>
91+
{t('team_size')}
92+
</Typography>{' '}
93+
{[
94+
developerCount && `${developerCount} ${t('developers')}`,
95+
designerCount && `${designerCount} ${t('designers')}`,
96+
]
97+
.filter(Boolean)
98+
.join(', ')}
99+
</Box>
100+
)}
101+
{roles && roles.includes(2 as UserRole.Client) && (
102+
<Box className="evaluation-item">
103+
<Typography component="h4" sx={{ fontWeight: 600 }}>
104+
{t('complexity_factor')}
105+
</Typography>{' '}
106+
{factor}
107+
</Box>
108+
)}
109+
</Box>
110+
);
111+
},
112+
);

components/Project/NewCard.tsx

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
11
import { Project } from '@idea2app/data-server';
22
import { Button, Card, CardActions, CardContent, Typography } from '@mui/material';
3+
import { observer } from 'mobx-react';
34
import Link from 'next/link';
45
import { FC, useContext } from 'react';
56

67
import { I18nContext } from '../../models/Translation';
78

8-
export const ProjectCard: FC<Project> = ({ id, name, requirementText, projectStatus }) => {
9+
export const ProjectCard: FC<Project> = observer(({ id, name, projectStatus }) => {
910
const { t } = useContext(I18nContext);
10-
11+
1112
return (
1213
<Card>
1314
<CardContent>
1415
<Typography variant="h6" component="h3" gutterBottom>
1516
{name}
1617
</Typography>
17-
<Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
18-
{requirementText || ''}
19-
</Typography>
20-
<Typography
21-
variant="caption"
22-
sx={{
23-
px: 1,
18+
<Typography
19+
variant="caption"
20+
sx={{
21+
px: 1,
2422
py: 0.5,
25-
borderRadius: 1,
26-
bgcolor: projectStatus === '1' ? 'success.light' :
27-
projectStatus === '0' ? 'grey.200' : 'warning.light',
28-
color: projectStatus === '1' ? 'success.contrastText' :
29-
projectStatus === '0' ? 'text.primary' : 'warning.contrastText'
23+
borderRadius: 1,
24+
bgcolor:
25+
projectStatus === '1'
26+
? 'success.light'
27+
: projectStatus === '0'
28+
? 'grey.200'
29+
: 'warning.light',
30+
color:
31+
projectStatus === '1'
32+
? 'success.contrastText'
33+
: projectStatus === '0'
34+
? 'text.primary'
35+
: 'warning.contrastText',
3036
}}
3137
>
32-
{projectStatus === '1' ? t('project_open') :
33-
projectStatus === '0' ? t('project_closed') : t('project_pending')}
38+
{projectStatus === '1'
39+
? t('project_open')
40+
: projectStatus === '0'
41+
? t('project_closed')
42+
: t('project_pending')}
3443
</Typography>
3544
</CardContent>
3645
<CardActions>
37-
<Button
38-
component={Link}
39-
href={`/dashboard/project/${id}`}
40-
size="small"
41-
variant="contained"
42-
>
46+
<Button component={Link} href={`/dashboard/project/${id}`} size="small" variant="contained">
4347
{t('view_evaluation')}
4448
</Button>
4549
</CardActions>
4650
</Card>
4751
);
48-
};
52+
});

models/ProjectEvaluation.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
11
import { Project, ConsultMessage, ProjectFilter, UserBaseFilter } from '@idea2app/data-server';
2-
import { Filter } from 'mobx-restful';
32

43
import { TableModel } from './Base';
54
import userStore from './User';
65

7-
// Combine ProjectFilter with UserBaseFilter to support role-based filtering
8-
export interface ExtendedProjectFilter extends ProjectFilter {
9-
createdBy?: number;
10-
}
11-
12-
export interface ConsultMessageFilter extends Filter<ConsultMessage> {
13-
project?: string;
14-
user?: string;
15-
}
6+
export type ExtendedProjectFilter = ProjectFilter & UserBaseFilter;
167

178
export class ProjectModel extends TableModel<Project, ExtendedProjectFilter> {
18-
client = userStore.client;
199
baseURI = 'project';
10+
client = userStore.client;
2011
}
2112

22-
export class ConsultMessageModel extends TableModel<ConsultMessage, ConsultMessageFilter> {
13+
export class ConsultMessageModel extends TableModel<ConsultMessage> {
14+
baseURI = '';
2315
client = userStore.client;
24-
baseURI: string;
2516

2617
constructor(public projectId: number) {
2718
super();
2819
this.baseURI = `project/${projectId}/consult-message`;
2920
}
30-
}
21+
}

next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const nextConfig = withPWA({
4545
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
4646
return config;
4747
},
48-
rewrites: rewrites as any,
48+
rewrites,
4949
});
5050

5151
export default isDev || !SENTRY_AUTH_TOKEN

0 commit comments

Comments
 (0)