@hed-hog/operations 0.0.297 → 0.0.298
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hedhog/frontend/app/_components/collaborator-details-screen.tsx.ejs +310 -310
- package/hedhog/frontend/app/_components/collaborator-form-screen.tsx.ejs +631 -631
- package/hedhog/frontend/app/_components/contract-details-screen.tsx.ejs +132 -132
- package/hedhog/frontend/app/_components/contract-form-screen.tsx.ejs +558 -558
- package/hedhog/frontend/app/_components/project-details-screen.tsx.ejs +291 -291
- package/hedhog/frontend/app/_components/project-form-screen.tsx.ejs +689 -689
- package/hedhog/frontend/app/_lib/api.ts.ejs +32 -32
- package/hedhog/frontend/app/_lib/hooks/use-operations-access.ts.ejs +44 -44
- package/hedhog/frontend/app/_lib/types.ts.ejs +360 -360
- package/hedhog/frontend/app/_lib/utils/format.ts.ejs +129 -129
- package/hedhog/frontend/app/_lib/utils/forms.ts.ejs +14 -14
- package/hedhog/frontend/app/approvals/page.tsx.ejs +386 -386
- package/hedhog/frontend/app/collaborators/[id]/edit/page.tsx.ejs +11 -11
- package/hedhog/frontend/app/collaborators/[id]/page.tsx.ejs +11 -11
- package/hedhog/frontend/app/collaborators/new/page.tsx.ejs +5 -5
- package/hedhog/frontend/app/collaborators/page.tsx.ejs +261 -261
- package/hedhog/frontend/app/contracts/[id]/edit/page.tsx.ejs +11 -11
- package/hedhog/frontend/app/contracts/[id]/page.tsx.ejs +11 -11
- package/hedhog/frontend/app/contracts/new/page.tsx.ejs +17 -17
- package/hedhog/frontend/app/contracts/page.tsx.ejs +262 -262
- package/hedhog/frontend/app/page.tsx.ejs +319 -319
- package/hedhog/frontend/app/projects/[id]/edit/page.tsx.ejs +11 -11
- package/hedhog/frontend/app/projects/[id]/page.tsx.ejs +11 -11
- package/hedhog/frontend/app/projects/new/page.tsx.ejs +5 -5
- package/hedhog/frontend/app/projects/page.tsx.ejs +236 -236
- package/hedhog/frontend/app/schedule-adjustments/page.tsx.ejs +418 -418
- package/hedhog/frontend/app/team/page.tsx.ejs +339 -339
- package/hedhog/frontend/app/time-off/page.tsx.ejs +328 -328
- package/hedhog/frontend/app/timesheets/page.tsx.ejs +636 -636
- package/hedhog/frontend/messages/en.json +648 -648
- package/hedhog/frontend/messages/pt.json +647 -647
- package/package.json +4 -4
|
@@ -1,319 +1,319 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { EmptyState, Page } from '@/components/entity-list';
|
|
4
|
-
import { Button } from '@/components/ui/button';
|
|
5
|
-
import { KpiCardsGrid } from '@/components/ui/kpi-cards-grid';
|
|
6
|
-
import { Skeleton } from '@/components/ui/skeleton';
|
|
7
|
-
import {
|
|
8
|
-
Table,
|
|
9
|
-
TableBody,
|
|
10
|
-
TableCell,
|
|
11
|
-
TableHead,
|
|
12
|
-
TableHeader,
|
|
13
|
-
TableRow,
|
|
14
|
-
} from '@/components/ui/table';
|
|
15
|
-
import { useApp, useQuery } from '@hed-hog/next-app-provider';
|
|
16
|
-
import {
|
|
17
|
-
CheckCircle2,
|
|
18
|
-
ClipboardList,
|
|
19
|
-
FolderKanban,
|
|
20
|
-
Hourglass,
|
|
21
|
-
PlaneTakeoff,
|
|
22
|
-
RefreshCcw,
|
|
23
|
-
Users,
|
|
24
|
-
} from 'lucide-react';
|
|
25
|
-
import Link from 'next/link';
|
|
26
|
-
import { useTranslations } from 'next-intl';
|
|
27
|
-
import { OperationsHeader } from './_components/operations-header';
|
|
28
|
-
import { SectionCard } from './_components/section-card';
|
|
29
|
-
import { StatusBadge } from './_components/status-badge';
|
|
30
|
-
import { fetchOperations } from './_lib/api';
|
|
31
|
-
import { useOperationsAccess } from './_lib/hooks/use-operations-access';
|
|
32
|
-
import type { OperationsDashboard, OperationsTeamOverview } from './_lib/types';
|
|
33
|
-
import {
|
|
34
|
-
formatDate,
|
|
35
|
-
formatDateRange,
|
|
36
|
-
formatEnumLabel,
|
|
37
|
-
formatHours,
|
|
38
|
-
getStatusBadgeClass,
|
|
39
|
-
} from './_lib/utils/format';
|
|
40
|
-
|
|
41
|
-
export default function OperationsDashboardPage() {
|
|
42
|
-
const t = useTranslations('operations.DashboardPage');
|
|
43
|
-
const commonT = useTranslations('operations.Common');
|
|
44
|
-
const { request, currentLocaleCode } = useApp();
|
|
45
|
-
const access = useOperationsAccess();
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
data: dashboard,
|
|
49
|
-
isLoading,
|
|
50
|
-
refetch,
|
|
51
|
-
} = useQuery<OperationsDashboard>({
|
|
52
|
-
queryKey: ['operations-dashboard', currentLocaleCode],
|
|
53
|
-
queryFn: () => fetchOperations<OperationsDashboard>(request, '/operations/dashboard'),
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const { data: team } = useQuery<OperationsTeamOverview>({
|
|
57
|
-
queryKey: ['operations-team-overview', currentLocaleCode],
|
|
58
|
-
enabled: access.isSupervisor,
|
|
59
|
-
queryFn: () => fetchOperations<OperationsTeamOverview>(request, '/operations/team'),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const cards = dashboard
|
|
63
|
-
? [
|
|
64
|
-
{
|
|
65
|
-
key: 'projects',
|
|
66
|
-
title: t('cards.projects'),
|
|
67
|
-
value: dashboard.cards.projectsTotal,
|
|
68
|
-
description: t('cards.projectsDescription', {
|
|
69
|
-
active: dashboard.cards.activeProjects,
|
|
70
|
-
}),
|
|
71
|
-
icon: FolderKanban,
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
key: 'timesheets',
|
|
75
|
-
title: t('cards.timesheets'),
|
|
76
|
-
value: dashboard.cards.visibleTimesheets,
|
|
77
|
-
description: t('cards.timesheetsDescription', {
|
|
78
|
-
pending: dashboard.cards.pendingTimesheets,
|
|
79
|
-
}),
|
|
80
|
-
icon: ClipboardList,
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
key: 'timeOff',
|
|
84
|
-
title: t('cards.timeOff'),
|
|
85
|
-
value: dashboard.cards.timeOffRequests,
|
|
86
|
-
description: t('cards.timeOffDescription'),
|
|
87
|
-
icon: PlaneTakeoff,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
key: 'approvals',
|
|
91
|
-
title: t('cards.approvals'),
|
|
92
|
-
value: dashboard.cards.pendingApprovals,
|
|
93
|
-
description: t('cards.approvalsDescription'),
|
|
94
|
-
icon: Hourglass,
|
|
95
|
-
},
|
|
96
|
-
]
|
|
97
|
-
: [];
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<Page>
|
|
101
|
-
<OperationsHeader
|
|
102
|
-
title={t('title')}
|
|
103
|
-
description={t('description')}
|
|
104
|
-
current={t('breadcrumb')}
|
|
105
|
-
actions={
|
|
106
|
-
<div className="flex gap-2">
|
|
107
|
-
<Button variant="outline" size="sm" onClick={() => void refetch()}>
|
|
108
|
-
<RefreshCcw className="size-4" />
|
|
109
|
-
{commonT('actions.refresh')}
|
|
110
|
-
</Button>
|
|
111
|
-
<Button asChild size="sm">
|
|
112
|
-
<Link href="/operations/timesheets">{t('actions.openTimesheets')}</Link>
|
|
113
|
-
</Button>
|
|
114
|
-
</div>
|
|
115
|
-
}
|
|
116
|
-
/>
|
|
117
|
-
|
|
118
|
-
{isLoading || access.isLoading ? (
|
|
119
|
-
<div className="space-y-4">
|
|
120
|
-
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
|
121
|
-
{Array.from({ length: 4 }).map((_, index) => (
|
|
122
|
-
<Skeleton key={index} className="h-32 w-full" />
|
|
123
|
-
))}
|
|
124
|
-
</div>
|
|
125
|
-
<div className="grid gap-4 xl:grid-cols-3">
|
|
126
|
-
<Skeleton className="h-64 w-full xl:col-span-2" />
|
|
127
|
-
<Skeleton className="h-64 w-full" />
|
|
128
|
-
</div>
|
|
129
|
-
</div>
|
|
130
|
-
) : dashboard ? (
|
|
131
|
-
<>
|
|
132
|
-
<KpiCardsGrid items={cards} />
|
|
133
|
-
|
|
134
|
-
<div className="grid gap-4 xl:grid-cols-3">
|
|
135
|
-
<SectionCard
|
|
136
|
-
title={t('scope.title')}
|
|
137
|
-
description={t('scope.description')}
|
|
138
|
-
className="xl:col-span-1"
|
|
139
|
-
>
|
|
140
|
-
<dl className="space-y-3 text-sm">
|
|
141
|
-
<div className="flex items-center justify-between gap-4">
|
|
142
|
-
<dt className="text-muted-foreground">{t('scope.roleScope')}</dt>
|
|
143
|
-
<dd className="font-medium">
|
|
144
|
-
{formatEnumLabel(dashboard.actor.roleScope)}
|
|
145
|
-
</dd>
|
|
146
|
-
</div>
|
|
147
|
-
<div className="flex items-center justify-between gap-4">
|
|
148
|
-
<dt className="text-muted-foreground">{t('scope.collaborator')}</dt>
|
|
149
|
-
<dd className="font-medium">
|
|
150
|
-
{dashboard.actor.collaboratorName ?? commonT('labels.notAvailable')}
|
|
151
|
-
</dd>
|
|
152
|
-
</div>
|
|
153
|
-
<div className="flex items-center justify-between gap-4">
|
|
154
|
-
<dt className="text-muted-foreground">{t('scope.teamSize')}</dt>
|
|
155
|
-
<dd className="font-medium">{dashboard.actor.teamSize}</dd>
|
|
156
|
-
</div>
|
|
157
|
-
</dl>
|
|
158
|
-
</SectionCard>
|
|
159
|
-
|
|
160
|
-
<SectionCard
|
|
161
|
-
title={t('recentTimesheets.title')}
|
|
162
|
-
description={t('recentTimesheets.description')}
|
|
163
|
-
className="xl:col-span-2"
|
|
164
|
-
>
|
|
165
|
-
{dashboard.recentTimesheets.length === 0 ? (
|
|
166
|
-
<EmptyState
|
|
167
|
-
icon={<ClipboardList className="size-12" />}
|
|
168
|
-
title={commonT('states.emptyTitle')}
|
|
169
|
-
description={t('recentTimesheets.empty')}
|
|
170
|
-
actionLabel={t('actions.openTimesheets')}
|
|
171
|
-
onAction={() => {
|
|
172
|
-
window.location.href = '/operations/timesheets';
|
|
173
|
-
}}
|
|
174
|
-
/>
|
|
175
|
-
) : (
|
|
176
|
-
<div className="overflow-x-auto rounded-md border">
|
|
177
|
-
<Table>
|
|
178
|
-
<TableHeader>
|
|
179
|
-
<TableRow>
|
|
180
|
-
<TableHead>{commonT('labels.collaborator')}</TableHead>
|
|
181
|
-
<TableHead>{commonT('labels.week')}</TableHead>
|
|
182
|
-
<TableHead>{commonT('labels.totalHours')}</TableHead>
|
|
183
|
-
<TableHead>{commonT('labels.status')}</TableHead>
|
|
184
|
-
</TableRow>
|
|
185
|
-
</TableHeader>
|
|
186
|
-
<TableBody>
|
|
187
|
-
{dashboard.recentTimesheets.map((item) => (
|
|
188
|
-
<TableRow key={item.id}>
|
|
189
|
-
<TableCell className="font-medium">
|
|
190
|
-
{item.collaboratorName}
|
|
191
|
-
</TableCell>
|
|
192
|
-
<TableCell>
|
|
193
|
-
{formatDateRange(item.weekStartDate, item.weekEndDate)}
|
|
194
|
-
</TableCell>
|
|
195
|
-
<TableCell>{formatHours(item.totalHours)}</TableCell>
|
|
196
|
-
<TableCell>
|
|
197
|
-
<StatusBadge
|
|
198
|
-
label={formatEnumLabel(item.status)}
|
|
199
|
-
className={getStatusBadgeClass(item.status)}
|
|
200
|
-
/>
|
|
201
|
-
</TableCell>
|
|
202
|
-
</TableRow>
|
|
203
|
-
))}
|
|
204
|
-
</TableBody>
|
|
205
|
-
</Table>
|
|
206
|
-
</div>
|
|
207
|
-
)}
|
|
208
|
-
</SectionCard>
|
|
209
|
-
</div>
|
|
210
|
-
|
|
211
|
-
<div className="grid gap-4 xl:grid-cols-2">
|
|
212
|
-
<SectionCard
|
|
213
|
-
title={t('nextSteps.title')}
|
|
214
|
-
description={t('nextSteps.description')}
|
|
215
|
-
>
|
|
216
|
-
<div className="space-y-3 text-sm">
|
|
217
|
-
<div className="flex items-start gap-3">
|
|
218
|
-
<CheckCircle2 className="mt-0.5 size-4 text-emerald-600" />
|
|
219
|
-
<p>{t('nextSteps.submitTimesheet')}</p>
|
|
220
|
-
</div>
|
|
221
|
-
<div className="flex items-start gap-3">
|
|
222
|
-
<CheckCircle2 className="mt-0.5 size-4 text-emerald-600" />
|
|
223
|
-
<p>{t('nextSteps.requestTimeOff')}</p>
|
|
224
|
-
</div>
|
|
225
|
-
<div className="flex items-start gap-3">
|
|
226
|
-
<CheckCircle2 className="mt-0.5 size-4 text-emerald-600" />
|
|
227
|
-
<p>{t('nextSteps.adjustSchedule')}</p>
|
|
228
|
-
</div>
|
|
229
|
-
</div>
|
|
230
|
-
</SectionCard>
|
|
231
|
-
|
|
232
|
-
<SectionCard
|
|
233
|
-
title={t('team.title')}
|
|
234
|
-
description={t('team.description')}
|
|
235
|
-
>
|
|
236
|
-
{access.isSupervisor && team ? (
|
|
237
|
-
<>
|
|
238
|
-
<div className="mb-4 grid gap-3 md:grid-cols-3">
|
|
239
|
-
<div className="rounded-lg border p-4">
|
|
240
|
-
<div className="text-xs uppercase tracking-[0.2em] text-muted-foreground">
|
|
241
|
-
{t('team.members')}
|
|
242
|
-
</div>
|
|
243
|
-
<div className="mt-2 text-2xl font-semibold">
|
|
244
|
-
{team.teamMembers.length}
|
|
245
|
-
</div>
|
|
246
|
-
</div>
|
|
247
|
-
<div className="rounded-lg border p-4">
|
|
248
|
-
<div className="text-xs uppercase tracking-[0.2em] text-muted-foreground">
|
|
249
|
-
{t('team.projects')}
|
|
250
|
-
</div>
|
|
251
|
-
<div className="mt-2 text-2xl font-semibold">
|
|
252
|
-
{team.projectCount}
|
|
253
|
-
</div>
|
|
254
|
-
</div>
|
|
255
|
-
<div className="rounded-lg border p-4">
|
|
256
|
-
<div className="text-xs uppercase tracking-[0.2em] text-muted-foreground">
|
|
257
|
-
{t('team.pendingApprovals')}
|
|
258
|
-
</div>
|
|
259
|
-
<div className="mt-2 text-2xl font-semibold">
|
|
260
|
-
{team.pendingApprovals}
|
|
261
|
-
</div>
|
|
262
|
-
</div>
|
|
263
|
-
</div>
|
|
264
|
-
|
|
265
|
-
{team.teamMembers.length > 0 ? (
|
|
266
|
-
<div className="space-y-3">
|
|
267
|
-
{team.teamMembers.slice(0, 4).map((member) => (
|
|
268
|
-
<div
|
|
269
|
-
key={member.id}
|
|
270
|
-
className="flex items-center justify-between rounded-lg border px-4 py-3 text-sm"
|
|
271
|
-
>
|
|
272
|
-
<div>
|
|
273
|
-
<div className="font-medium">{member.displayName}</div>
|
|
274
|
-
<div className="text-muted-foreground">
|
|
275
|
-
{[member.department, member.title]
|
|
276
|
-
.filter(Boolean)
|
|
277
|
-
.join(' • ') || commonT('labels.notAvailable')}
|
|
278
|
-
</div>
|
|
279
|
-
</div>
|
|
280
|
-
<div className="text-right">
|
|
281
|
-
<div className="font-medium">
|
|
282
|
-
{member.activeAssignments ?? 0}{' '}
|
|
283
|
-
{t('team.assignments')}
|
|
284
|
-
</div>
|
|
285
|
-
<div className="text-muted-foreground">
|
|
286
|
-
{member.pendingApprovals ?? 0}{' '}
|
|
287
|
-
{t('team.awaitingReview')}
|
|
288
|
-
</div>
|
|
289
|
-
</div>
|
|
290
|
-
</div>
|
|
291
|
-
))}
|
|
292
|
-
</div>
|
|
293
|
-
) : (
|
|
294
|
-
<p className="text-sm text-muted-foreground">
|
|
295
|
-
{t('team.empty')}
|
|
296
|
-
</p>
|
|
297
|
-
)}
|
|
298
|
-
</>
|
|
299
|
-
) : (
|
|
300
|
-
<div className="flex items-start gap-3 rounded-lg border border-dashed p-4 text-sm text-muted-foreground">
|
|
301
|
-
<Users className="mt-0.5 size-4" />
|
|
302
|
-
<p>{t('team.collaboratorMessage')}</p>
|
|
303
|
-
</div>
|
|
304
|
-
)}
|
|
305
|
-
</SectionCard>
|
|
306
|
-
</div>
|
|
307
|
-
</>
|
|
308
|
-
) : (
|
|
309
|
-
<EmptyState
|
|
310
|
-
icon={<FolderKanban className="size-12" />}
|
|
311
|
-
title={commonT('states.emptyTitle')}
|
|
312
|
-
description={commonT('states.emptyDescription')}
|
|
313
|
-
actionLabel={commonT('actions.refresh')}
|
|
314
|
-
onAction={() => void refetch()}
|
|
315
|
-
/>
|
|
316
|
-
)}
|
|
317
|
-
</Page>
|
|
318
|
-
);
|
|
319
|
-
}
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { EmptyState, Page } from '@/components/entity-list';
|
|
4
|
+
import { Button } from '@/components/ui/button';
|
|
5
|
+
import { KpiCardsGrid } from '@/components/ui/kpi-cards-grid';
|
|
6
|
+
import { Skeleton } from '@/components/ui/skeleton';
|
|
7
|
+
import {
|
|
8
|
+
Table,
|
|
9
|
+
TableBody,
|
|
10
|
+
TableCell,
|
|
11
|
+
TableHead,
|
|
12
|
+
TableHeader,
|
|
13
|
+
TableRow,
|
|
14
|
+
} from '@/components/ui/table';
|
|
15
|
+
import { useApp, useQuery } from '@hed-hog/next-app-provider';
|
|
16
|
+
import {
|
|
17
|
+
CheckCircle2,
|
|
18
|
+
ClipboardList,
|
|
19
|
+
FolderKanban,
|
|
20
|
+
Hourglass,
|
|
21
|
+
PlaneTakeoff,
|
|
22
|
+
RefreshCcw,
|
|
23
|
+
Users,
|
|
24
|
+
} from 'lucide-react';
|
|
25
|
+
import Link from 'next/link';
|
|
26
|
+
import { useTranslations } from 'next-intl';
|
|
27
|
+
import { OperationsHeader } from './_components/operations-header';
|
|
28
|
+
import { SectionCard } from './_components/section-card';
|
|
29
|
+
import { StatusBadge } from './_components/status-badge';
|
|
30
|
+
import { fetchOperations } from './_lib/api';
|
|
31
|
+
import { useOperationsAccess } from './_lib/hooks/use-operations-access';
|
|
32
|
+
import type { OperationsDashboard, OperationsTeamOverview } from './_lib/types';
|
|
33
|
+
import {
|
|
34
|
+
formatDate,
|
|
35
|
+
formatDateRange,
|
|
36
|
+
formatEnumLabel,
|
|
37
|
+
formatHours,
|
|
38
|
+
getStatusBadgeClass,
|
|
39
|
+
} from './_lib/utils/format';
|
|
40
|
+
|
|
41
|
+
export default function OperationsDashboardPage() {
|
|
42
|
+
const t = useTranslations('operations.DashboardPage');
|
|
43
|
+
const commonT = useTranslations('operations.Common');
|
|
44
|
+
const { request, currentLocaleCode } = useApp();
|
|
45
|
+
const access = useOperationsAccess();
|
|
46
|
+
|
|
47
|
+
const {
|
|
48
|
+
data: dashboard,
|
|
49
|
+
isLoading,
|
|
50
|
+
refetch,
|
|
51
|
+
} = useQuery<OperationsDashboard>({
|
|
52
|
+
queryKey: ['operations-dashboard', currentLocaleCode],
|
|
53
|
+
queryFn: () => fetchOperations<OperationsDashboard>(request, '/operations/dashboard'),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const { data: team } = useQuery<OperationsTeamOverview>({
|
|
57
|
+
queryKey: ['operations-team-overview', currentLocaleCode],
|
|
58
|
+
enabled: access.isSupervisor,
|
|
59
|
+
queryFn: () => fetchOperations<OperationsTeamOverview>(request, '/operations/team'),
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const cards = dashboard
|
|
63
|
+
? [
|
|
64
|
+
{
|
|
65
|
+
key: 'projects',
|
|
66
|
+
title: t('cards.projects'),
|
|
67
|
+
value: dashboard.cards.projectsTotal,
|
|
68
|
+
description: t('cards.projectsDescription', {
|
|
69
|
+
active: dashboard.cards.activeProjects,
|
|
70
|
+
}),
|
|
71
|
+
icon: FolderKanban,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
key: 'timesheets',
|
|
75
|
+
title: t('cards.timesheets'),
|
|
76
|
+
value: dashboard.cards.visibleTimesheets,
|
|
77
|
+
description: t('cards.timesheetsDescription', {
|
|
78
|
+
pending: dashboard.cards.pendingTimesheets,
|
|
79
|
+
}),
|
|
80
|
+
icon: ClipboardList,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
key: 'timeOff',
|
|
84
|
+
title: t('cards.timeOff'),
|
|
85
|
+
value: dashboard.cards.timeOffRequests,
|
|
86
|
+
description: t('cards.timeOffDescription'),
|
|
87
|
+
icon: PlaneTakeoff,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
key: 'approvals',
|
|
91
|
+
title: t('cards.approvals'),
|
|
92
|
+
value: dashboard.cards.pendingApprovals,
|
|
93
|
+
description: t('cards.approvalsDescription'),
|
|
94
|
+
icon: Hourglass,
|
|
95
|
+
},
|
|
96
|
+
]
|
|
97
|
+
: [];
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<Page>
|
|
101
|
+
<OperationsHeader
|
|
102
|
+
title={t('title')}
|
|
103
|
+
description={t('description')}
|
|
104
|
+
current={t('breadcrumb')}
|
|
105
|
+
actions={
|
|
106
|
+
<div className="flex gap-2">
|
|
107
|
+
<Button variant="outline" size="sm" onClick={() => void refetch()}>
|
|
108
|
+
<RefreshCcw className="size-4" />
|
|
109
|
+
{commonT('actions.refresh')}
|
|
110
|
+
</Button>
|
|
111
|
+
<Button asChild size="sm">
|
|
112
|
+
<Link href="/operations/timesheets">{t('actions.openTimesheets')}</Link>
|
|
113
|
+
</Button>
|
|
114
|
+
</div>
|
|
115
|
+
}
|
|
116
|
+
/>
|
|
117
|
+
|
|
118
|
+
{isLoading || access.isLoading ? (
|
|
119
|
+
<div className="space-y-4">
|
|
120
|
+
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
|
121
|
+
{Array.from({ length: 4 }).map((_, index) => (
|
|
122
|
+
<Skeleton key={index} className="h-32 w-full" />
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
<div className="grid gap-4 xl:grid-cols-3">
|
|
126
|
+
<Skeleton className="h-64 w-full xl:col-span-2" />
|
|
127
|
+
<Skeleton className="h-64 w-full" />
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
) : dashboard ? (
|
|
131
|
+
<>
|
|
132
|
+
<KpiCardsGrid items={cards} />
|
|
133
|
+
|
|
134
|
+
<div className="grid gap-4 xl:grid-cols-3">
|
|
135
|
+
<SectionCard
|
|
136
|
+
title={t('scope.title')}
|
|
137
|
+
description={t('scope.description')}
|
|
138
|
+
className="xl:col-span-1"
|
|
139
|
+
>
|
|
140
|
+
<dl className="space-y-3 text-sm">
|
|
141
|
+
<div className="flex items-center justify-between gap-4">
|
|
142
|
+
<dt className="text-muted-foreground">{t('scope.roleScope')}</dt>
|
|
143
|
+
<dd className="font-medium">
|
|
144
|
+
{formatEnumLabel(dashboard.actor.roleScope)}
|
|
145
|
+
</dd>
|
|
146
|
+
</div>
|
|
147
|
+
<div className="flex items-center justify-between gap-4">
|
|
148
|
+
<dt className="text-muted-foreground">{t('scope.collaborator')}</dt>
|
|
149
|
+
<dd className="font-medium">
|
|
150
|
+
{dashboard.actor.collaboratorName ?? commonT('labels.notAvailable')}
|
|
151
|
+
</dd>
|
|
152
|
+
</div>
|
|
153
|
+
<div className="flex items-center justify-between gap-4">
|
|
154
|
+
<dt className="text-muted-foreground">{t('scope.teamSize')}</dt>
|
|
155
|
+
<dd className="font-medium">{dashboard.actor.teamSize}</dd>
|
|
156
|
+
</div>
|
|
157
|
+
</dl>
|
|
158
|
+
</SectionCard>
|
|
159
|
+
|
|
160
|
+
<SectionCard
|
|
161
|
+
title={t('recentTimesheets.title')}
|
|
162
|
+
description={t('recentTimesheets.description')}
|
|
163
|
+
className="xl:col-span-2"
|
|
164
|
+
>
|
|
165
|
+
{dashboard.recentTimesheets.length === 0 ? (
|
|
166
|
+
<EmptyState
|
|
167
|
+
icon={<ClipboardList className="size-12" />}
|
|
168
|
+
title={commonT('states.emptyTitle')}
|
|
169
|
+
description={t('recentTimesheets.empty')}
|
|
170
|
+
actionLabel={t('actions.openTimesheets')}
|
|
171
|
+
onAction={() => {
|
|
172
|
+
window.location.href = '/operations/timesheets';
|
|
173
|
+
}}
|
|
174
|
+
/>
|
|
175
|
+
) : (
|
|
176
|
+
<div className="overflow-x-auto rounded-md border">
|
|
177
|
+
<Table>
|
|
178
|
+
<TableHeader>
|
|
179
|
+
<TableRow>
|
|
180
|
+
<TableHead>{commonT('labels.collaborator')}</TableHead>
|
|
181
|
+
<TableHead>{commonT('labels.week')}</TableHead>
|
|
182
|
+
<TableHead>{commonT('labels.totalHours')}</TableHead>
|
|
183
|
+
<TableHead>{commonT('labels.status')}</TableHead>
|
|
184
|
+
</TableRow>
|
|
185
|
+
</TableHeader>
|
|
186
|
+
<TableBody>
|
|
187
|
+
{dashboard.recentTimesheets.map((item) => (
|
|
188
|
+
<TableRow key={item.id}>
|
|
189
|
+
<TableCell className="font-medium">
|
|
190
|
+
{item.collaboratorName}
|
|
191
|
+
</TableCell>
|
|
192
|
+
<TableCell>
|
|
193
|
+
{formatDateRange(item.weekStartDate, item.weekEndDate)}
|
|
194
|
+
</TableCell>
|
|
195
|
+
<TableCell>{formatHours(item.totalHours)}</TableCell>
|
|
196
|
+
<TableCell>
|
|
197
|
+
<StatusBadge
|
|
198
|
+
label={formatEnumLabel(item.status)}
|
|
199
|
+
className={getStatusBadgeClass(item.status)}
|
|
200
|
+
/>
|
|
201
|
+
</TableCell>
|
|
202
|
+
</TableRow>
|
|
203
|
+
))}
|
|
204
|
+
</TableBody>
|
|
205
|
+
</Table>
|
|
206
|
+
</div>
|
|
207
|
+
)}
|
|
208
|
+
</SectionCard>
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<div className="grid gap-4 xl:grid-cols-2">
|
|
212
|
+
<SectionCard
|
|
213
|
+
title={t('nextSteps.title')}
|
|
214
|
+
description={t('nextSteps.description')}
|
|
215
|
+
>
|
|
216
|
+
<div className="space-y-3 text-sm">
|
|
217
|
+
<div className="flex items-start gap-3">
|
|
218
|
+
<CheckCircle2 className="mt-0.5 size-4 text-emerald-600" />
|
|
219
|
+
<p>{t('nextSteps.submitTimesheet')}</p>
|
|
220
|
+
</div>
|
|
221
|
+
<div className="flex items-start gap-3">
|
|
222
|
+
<CheckCircle2 className="mt-0.5 size-4 text-emerald-600" />
|
|
223
|
+
<p>{t('nextSteps.requestTimeOff')}</p>
|
|
224
|
+
</div>
|
|
225
|
+
<div className="flex items-start gap-3">
|
|
226
|
+
<CheckCircle2 className="mt-0.5 size-4 text-emerald-600" />
|
|
227
|
+
<p>{t('nextSteps.adjustSchedule')}</p>
|
|
228
|
+
</div>
|
|
229
|
+
</div>
|
|
230
|
+
</SectionCard>
|
|
231
|
+
|
|
232
|
+
<SectionCard
|
|
233
|
+
title={t('team.title')}
|
|
234
|
+
description={t('team.description')}
|
|
235
|
+
>
|
|
236
|
+
{access.isSupervisor && team ? (
|
|
237
|
+
<>
|
|
238
|
+
<div className="mb-4 grid gap-3 md:grid-cols-3">
|
|
239
|
+
<div className="rounded-lg border p-4">
|
|
240
|
+
<div className="text-xs uppercase tracking-[0.2em] text-muted-foreground">
|
|
241
|
+
{t('team.members')}
|
|
242
|
+
</div>
|
|
243
|
+
<div className="mt-2 text-2xl font-semibold">
|
|
244
|
+
{team.teamMembers.length}
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
<div className="rounded-lg border p-4">
|
|
248
|
+
<div className="text-xs uppercase tracking-[0.2em] text-muted-foreground">
|
|
249
|
+
{t('team.projects')}
|
|
250
|
+
</div>
|
|
251
|
+
<div className="mt-2 text-2xl font-semibold">
|
|
252
|
+
{team.projectCount}
|
|
253
|
+
</div>
|
|
254
|
+
</div>
|
|
255
|
+
<div className="rounded-lg border p-4">
|
|
256
|
+
<div className="text-xs uppercase tracking-[0.2em] text-muted-foreground">
|
|
257
|
+
{t('team.pendingApprovals')}
|
|
258
|
+
</div>
|
|
259
|
+
<div className="mt-2 text-2xl font-semibold">
|
|
260
|
+
{team.pendingApprovals}
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
</div>
|
|
264
|
+
|
|
265
|
+
{team.teamMembers.length > 0 ? (
|
|
266
|
+
<div className="space-y-3">
|
|
267
|
+
{team.teamMembers.slice(0, 4).map((member) => (
|
|
268
|
+
<div
|
|
269
|
+
key={member.id}
|
|
270
|
+
className="flex items-center justify-between rounded-lg border px-4 py-3 text-sm"
|
|
271
|
+
>
|
|
272
|
+
<div>
|
|
273
|
+
<div className="font-medium">{member.displayName}</div>
|
|
274
|
+
<div className="text-muted-foreground">
|
|
275
|
+
{[member.department, member.title]
|
|
276
|
+
.filter(Boolean)
|
|
277
|
+
.join(' • ') || commonT('labels.notAvailable')}
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
<div className="text-right">
|
|
281
|
+
<div className="font-medium">
|
|
282
|
+
{member.activeAssignments ?? 0}{' '}
|
|
283
|
+
{t('team.assignments')}
|
|
284
|
+
</div>
|
|
285
|
+
<div className="text-muted-foreground">
|
|
286
|
+
{member.pendingApprovals ?? 0}{' '}
|
|
287
|
+
{t('team.awaitingReview')}
|
|
288
|
+
</div>
|
|
289
|
+
</div>
|
|
290
|
+
</div>
|
|
291
|
+
))}
|
|
292
|
+
</div>
|
|
293
|
+
) : (
|
|
294
|
+
<p className="text-sm text-muted-foreground">
|
|
295
|
+
{t('team.empty')}
|
|
296
|
+
</p>
|
|
297
|
+
)}
|
|
298
|
+
</>
|
|
299
|
+
) : (
|
|
300
|
+
<div className="flex items-start gap-3 rounded-lg border border-dashed p-4 text-sm text-muted-foreground">
|
|
301
|
+
<Users className="mt-0.5 size-4" />
|
|
302
|
+
<p>{t('team.collaboratorMessage')}</p>
|
|
303
|
+
</div>
|
|
304
|
+
)}
|
|
305
|
+
</SectionCard>
|
|
306
|
+
</div>
|
|
307
|
+
</>
|
|
308
|
+
) : (
|
|
309
|
+
<EmptyState
|
|
310
|
+
icon={<FolderKanban className="size-12" />}
|
|
311
|
+
title={commonT('states.emptyTitle')}
|
|
312
|
+
description={commonT('states.emptyDescription')}
|
|
313
|
+
actionLabel={commonT('actions.refresh')}
|
|
314
|
+
onAction={() => void refetch()}
|
|
315
|
+
/>
|
|
316
|
+
)}
|
|
317
|
+
</Page>
|
|
318
|
+
);
|
|
319
|
+
}
|