Skip to content

Commit 9ed840a

Browse files
CopilotTechQuery
andcommitted
Address user feedback: Fix translations, EvaluationDisplay component, role-based filtering, and class field declarations
Co-authored-by: TechQuery <19969570+TechQuery@users.noreply.github.com>
1 parent 44cb859 commit 9ed840a

File tree

10 files changed

+89
-78
lines changed

10 files changed

+89
-78
lines changed

components/Project/EvaluationDisplay.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Box, Typography } from '@mui/material';
2-
import { TranslationModel } from 'mobx-i18n';
3-
import { FC } from 'react';
2+
import { FC, useContext } from 'react';
3+
4+
import { I18nContext } from '../../models/Translation';
45

56
// Based on typical requirement evaluation structure
67
export interface RequirementEvaluation {
@@ -13,21 +14,16 @@ export interface RequirementEvaluation {
1314
riskAssessment?: string;
1415
}
1516

16-
export interface EvaluationDisplayProps extends RequirementEvaluation {
17-
translator: TranslationModel<any, any>;
18-
}
19-
20-
export const EvaluationDisplay: FC<RequirementEvaluation & { translator: TranslationModel<any, any> }> = ({
17+
export const EvaluationDisplay: FC<RequirementEvaluation> = ({
2118
techStack = [],
2219
difficulty = '',
2320
timeline = '',
2421
cost = '',
2522
architecture = '',
2623
keyFeatures = '',
2724
riskAssessment = '',
28-
translator,
2925
}) => {
30-
const { t } = translator;
26+
const { t } = useContext(I18nContext);
3127

3228
return (
3329
<Box sx={{

components/Project/NewCard.tsx

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,53 @@
11
import { Button, Card, CardActions, CardContent, Typography } from '@mui/material';
22
import Link from 'next/link';
3-
import { FC } from 'react';
3+
import { FC, useContext } from 'react';
4+
5+
import { I18nContext } from '../../models/Translation';
46

57
export interface ProjectCardProps {
68
id: string;
79
name: string;
8-
description: string;
9-
status: string;
10+
description?: string;
11+
status?: string;
1012
}
1113

12-
export const ProjectCard: FC<ProjectCardProps> = ({ id, name, description, status }) => (
13-
<Card>
14-
<CardContent>
15-
<Typography variant="h6" component="h3" gutterBottom>
16-
{name}
17-
</Typography>
18-
<Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
19-
{description}
20-
</Typography>
21-
<Typography
22-
variant="caption"
23-
sx={{
24-
px: 1,
25-
py: 0.5,
26-
borderRadius: 1,
27-
bgcolor: status === '评估完成' ? 'success.light' :
28-
status === '评估中' ? 'warning.light' : 'grey.200',
29-
color: status === '评估完成' ? 'success.contrastText' :
30-
status === '评估中' ? 'warning.contrastText' : 'text.primary'
31-
}}
32-
>
33-
{status}
34-
</Typography>
35-
</CardContent>
36-
<CardActions>
37-
<Button
38-
component={Link}
39-
href={`/dashboard/project/${id}`}
40-
size="small"
41-
variant="contained"
42-
>
43-
查看评估
44-
</Button>
45-
</CardActions>
46-
</Card>
47-
);
14+
export const ProjectCard: FC<ProjectCardProps> = ({ id, name, description = '', status = '' }) => {
15+
const { t } = useContext(I18nContext);
16+
17+
return (
18+
<Card>
19+
<CardContent>
20+
<Typography variant="h6" component="h3" gutterBottom>
21+
{name}
22+
</Typography>
23+
<Typography variant="body2" color="text.secondary" sx={{ mb: 2 }}>
24+
{description}
25+
</Typography>
26+
<Typography
27+
variant="caption"
28+
sx={{
29+
px: 1,
30+
py: 0.5,
31+
borderRadius: 1,
32+
bgcolor: status === '评估完成' ? 'success.light' :
33+
status === '评估中' ? 'warning.light' : 'grey.200',
34+
color: status === '评估完成' ? 'success.contrastText' :
35+
status === '评估中' ? 'warning.contrastText' : 'text.primary'
36+
}}
37+
>
38+
{status}
39+
</Typography>
40+
</CardContent>
41+
<CardActions>
42+
<Button
43+
component={Link}
44+
href={`/dashboard/project/${id}`}
45+
size="small"
46+
variant="contained"
47+
>
48+
{t('view_evaluation')}
49+
</Button>
50+
</CardActions>
51+
</Card>
52+
);
53+
};

models/ProjectEvaluation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import userStore from './User';
77
export interface ProjectFilter extends Filter<Project> {
88
owner?: string;
99
status?: string;
10+
createdBy?: string;
1011
}
1112

1213
export interface ConsultMessageFilter extends Filter<ConsultMessage> {
@@ -21,6 +22,7 @@ export class ProjectModel extends TableModel<Project, ProjectFilter> {
2122

2223
export class ConsultMessageModel extends TableModel<ConsultMessage, ConsultMessageFilter> {
2324
client = userStore.client;
25+
baseURI: string;
2426

2527
constructor(public projectId: number) {
2628
super();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"@cspell/eslint-plugin": "^9.2.0",
5151
"@eslint/compat": "^1.3.2",
5252
"@eslint/js": "^9.34.0",
53-
"@idea2app/data-server": "^1.0.0-rc.1",
53+
"@idea2app/data-server": "1.0.0-rc.1",
5454
"@next/eslint-plugin-next": "^15.5.2",
5555
"@stylistic/eslint-plugin": "^5.2.3",
5656
"@tailwindcss/postcss": "^4.1.12",

pages/dashboard/index.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Container, Grid, Typography } from '@mui/material';
33
import { observer } from 'mobx-react';
44
import { useRouter } from 'next/router';
55
import { compose, JWTProps, jwtVerifier } from 'next-ssr-middleware';
6-
import { FC, useContext, useMemo } from 'react';
6+
import { FC, useContext } from 'react';
77

88
import { ProjectCard } from '../../components/Project/NewCard';
99
import { ScrollList } from '../../components/ScrollList';
@@ -25,15 +25,6 @@ const DashboardPage: FC<DashboardPageProps> = observer(({ jwtPayload }) => {
2525

2626
const menu = [{ href: '/dashboard', title: t('overview') }];
2727

28-
// Role-based filtering: pass createdBy for client users, empty for others
29-
const filter = useMemo(() => {
30-
const userRole = jwtPayload?.role;
31-
if (userRole === 'client' && jwtPayload?.id) {
32-
return { createdBy: jwtPayload.id };
33-
}
34-
return {};
35-
}, [jwtPayload]);
36-
3728
return (
3829
<SessionBox title={t('backend_management')} path={asPath} {...{ menu, jwtPayload }}>
3930
<Container maxWidth="lg" className="py-8">
@@ -42,19 +33,19 @@ const DashboardPage: FC<DashboardPageProps> = observer(({ jwtPayload }) => {
4233
</Typography>
4334

4435
<Typography variant="h5" component="h2" sx={{ mt: 4, mb: 3 }}>
45-
最近项目
36+
{t('recent_projects')}
4637
</Typography>
4738

4839
<ScrollList
4940
translator={i18n}
5041
store={projectStore}
51-
filter={filter}
42+
filter={jwtPayload?.role === 'client' && jwtPayload?.id ? { createdBy: jwtPayload.id } : {}}
5243
renderList={(allItems: Project[]) => (
5344
<Grid container spacing={3}>
5445
{allItems.length === 0 ? (
5546
<Grid size={{ xs: 12 }}>
5647
<Typography color="textSecondary" sx={{ textAlign: 'center', mt: 4 }}>
57-
暂无项目数据
48+
{t('no_project_data')}
5849
</Typography>
5950
</Grid>
6051
) : (

pages/dashboard/project/[id].tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ export const getServerSideProps = compose<{}, ProjectEvaluationPageProps>(
2323
export default class ProjectEvaluationPage extends ObservedComponent<ProjectEvaluationPageProps, typeof i18n> {
2424
static contextType = I18nContext;
2525

26-
get evaluationStore() {
27-
const projectId = Number(this.props.route!.params!.id);
28-
return new ConsultMessageModel(projectId);
29-
}
30-
31-
get projectId() {
32-
return this.props.route!.params!.id;
33-
}
26+
projectId = +this.props.route!.params!.id;
27+
28+
evaluationStore = new ConsultMessageModel(this.projectId);
3429

3530
get menu() {
3631
const { t } = this.observedContext;
32+
3733
return [
3834
{ href: '/dashboard', title: t('overview') },
3935
{ href: `/dashboard/project/${this.projectId}`, title: t('project_evaluation') },
@@ -90,7 +86,7 @@ export default class ProjectEvaluationPage extends ObservedComponent<ProjectEval
9086
)}
9187

9288
{evaluation && (
93-
<EvaluationDisplay {...(evaluation as RequirementEvaluation)} translator={this.observedContext} />
89+
<EvaluationDisplay {...(evaluation as RequirementEvaluation)} />
9490
)}
9591

9692
{createdAt && (
@@ -126,7 +122,7 @@ export default class ProjectEvaluationPage extends ObservedComponent<ProjectEval
126122
<ScrollList
127123
translator={this.observedContext}
128124
store={this.evaluationStore}
129-
filter={{ project: this.projectId }}
125+
filter={{ project: String(this.projectId) }}
130126
renderList={(allItems: ConsultMessage[]) => (
131127
<Box sx={{ height: '100%', overflowY: 'auto', p: 1 }}>
132128
{allItems.length === 0 ? (

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

translation/en-US.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,15 @@ export default {
8282
tech_stack: 'Tech Stack',
8383
difficulty: 'Difficulty',
8484
timeline: 'Timeline',
85-
cost: 'Cost',
85+
cost: 'Cost Estimate',
8686
key_features: 'Key Features',
8787
risk_assessment: 'Risk Assessment',
8888
architecture: 'Architecture',
8989
ai_assistant: 'AI Assistant',
9090
loading_project_evaluation: 'Loading project evaluation data',
91+
view_evaluation: 'View Evaluation',
92+
recent_projects: 'Recent Projects',
93+
no_project_data: 'No project data',
9194

9295
// User authentication
9396
phone_number: 'Phone Number',

translation/zh-CN.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ export default {
8686
architecture: '架构设计',
8787
ai_assistant: 'AI助手',
8888
loading_project_evaluation: '正在加载项目评估数据',
89+
view_evaluation: '查看评估',
90+
recent_projects: '最近项目',
91+
no_project_data: '暂无项目数据',
8992

9093
// User authentication
9194
phone_number: '手机号码',

translation/zh-TW.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,18 @@ export default {
9090
settings: '設定',
9191
phone_required_for_webauthn: '手機號是 WebAuthn 註冊的必填項',
9292
registration_success_please_login: '註冊成功,請登入',
93+
94+
// Project evaluation translations
95+
tech_stack: '技術棧',
96+
difficulty: '難度',
97+
timeline: '開發週期',
98+
cost: '成本預估',
99+
architecture: '架構設計',
100+
key_features: '核心功能',
101+
risk_assessment: '風險評估',
102+
ai_assistant: 'AI助手',
103+
loading_project_evaluation: '正在載入專案評估資料',
104+
view_evaluation: '查看評估',
105+
recent_projects: '最近專案',
106+
no_project_data: '暫無專案資料',
93107
} as const;

0 commit comments

Comments
 (0)