@hed-hog/operations 0.0.2 → 0.0.285

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.
Files changed (108) hide show
  1. package/README.md +122 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/operations-data.controller.d.ts +139 -0
  7. package/dist/operations-data.controller.d.ts.map +1 -0
  8. package/dist/operations-data.controller.js +113 -0
  9. package/dist/operations-data.controller.js.map +1 -0
  10. package/dist/operations-growth.controller.d.ts +48 -0
  11. package/dist/operations-growth.controller.d.ts.map +1 -0
  12. package/dist/operations-growth.controller.js +90 -0
  13. package/dist/operations-growth.controller.js.map +1 -0
  14. package/dist/operations.module.d.ts.map +1 -1
  15. package/dist/operations.module.js +10 -4
  16. package/dist/operations.module.js.map +1 -1
  17. package/dist/operations.service.d.ts +178 -0
  18. package/dist/operations.service.d.ts.map +1 -0
  19. package/dist/operations.service.js +134 -0
  20. package/dist/operations.service.js.map +1 -0
  21. package/hedhog/data/menu.yaml +251 -132
  22. package/hedhog/data/operations_career_level.yaml +102 -0
  23. package/hedhog/data/operations_career_track.yaml +8 -0
  24. package/hedhog/data/operations_certification.yaml +38 -0
  25. package/hedhog/data/operations_evaluation_cycle.yaml +18 -0
  26. package/hedhog/data/operations_performance_criterion.yaml +48 -0
  27. package/hedhog/data/role.yaml +14 -7
  28. package/hedhog/data/route.yaml +143 -80
  29. package/hedhog/frontend/app/_components/allocation-calendar.tsx.ejs +56 -56
  30. package/hedhog/frontend/app/_components/kanban-board.tsx.ejs +83 -83
  31. package/hedhog/frontend/app/_components/operations-header.tsx.ejs +29 -29
  32. package/hedhog/frontend/app/_components/section-card.tsx.ejs +32 -32
  33. package/hedhog/frontend/app/_components/status-badge.tsx.ejs +15 -15
  34. package/hedhog/frontend/app/_components/timesheet-entry-dialog.tsx.ejs +142 -142
  35. package/hedhog/frontend/app/_lib/hooks/use-operations-data.ts.ejs +41 -41
  36. package/hedhog/frontend/app/_lib/hooks/use-operations-growth-data.ts.ejs +63 -0
  37. package/hedhog/frontend/app/_lib/mocks/allocations.mock.ts.ejs +74 -74
  38. package/hedhog/frontend/app/_lib/mocks/contracts.mock.ts.ejs +74 -74
  39. package/hedhog/frontend/app/_lib/mocks/operations-growth.mock.ts.ejs +824 -0
  40. package/hedhog/frontend/app/_lib/mocks/projects.mock.ts.ejs +60 -60
  41. package/hedhog/frontend/app/_lib/mocks/tasks.mock.ts.ejs +88 -88
  42. package/hedhog/frontend/app/_lib/mocks/timesheets.mock.ts.ejs +84 -84
  43. package/hedhog/frontend/app/_lib/mocks/users.mock.ts.ejs +67 -67
  44. package/hedhog/frontend/app/_lib/services/contracts.service.ts.ejs +10 -10
  45. package/hedhog/frontend/app/_lib/services/operations-growth.service.ts.ejs +31 -0
  46. package/hedhog/frontend/app/_lib/services/projects.service.ts.ejs +10 -10
  47. package/hedhog/frontend/app/_lib/services/tasks.service.ts.ejs +10 -10
  48. package/hedhog/frontend/app/_lib/services/timesheets.service.ts.ejs +10 -10
  49. package/hedhog/frontend/app/_lib/types/operations-growth.ts.ejs +209 -0
  50. package/hedhog/frontend/app/_lib/types/operations.ts.ejs +95 -95
  51. package/hedhog/frontend/app/_lib/utils/format.ts.ejs +25 -25
  52. package/hedhog/frontend/app/_lib/utils/growth.ts.ejs +62 -0
  53. package/hedhog/frontend/app/_lib/utils/metrics.ts.ejs +103 -103
  54. package/hedhog/frontend/app/_lib/utils/status.ts.ejs +80 -80
  55. package/hedhog/frontend/app/allocations/page.tsx.ejs +154 -99
  56. package/hedhog/frontend/app/approvals/page.tsx.ejs +147 -147
  57. package/hedhog/frontend/app/career/page.tsx.ejs +143 -0
  58. package/hedhog/frontend/app/certifications/page.tsx.ejs +201 -0
  59. package/hedhog/frontend/app/contracts/[id]/page.tsx.ejs +108 -108
  60. package/hedhog/frontend/app/contracts/page.tsx.ejs +180 -124
  61. package/hedhog/frontend/app/evaluations/page.tsx.ejs +277 -0
  62. package/hedhog/frontend/app/goals/page.tsx.ejs +170 -0
  63. package/hedhog/frontend/app/growth/page.tsx.ejs +288 -0
  64. package/hedhog/frontend/app/layout.tsx.ejs +9 -9
  65. package/hedhog/frontend/app/manager/page.tsx.ejs +175 -0
  66. package/hedhog/frontend/app/page.tsx.ejs +177 -177
  67. package/hedhog/frontend/app/projects/[id]/page.tsx.ejs +186 -186
  68. package/hedhog/frontend/app/projects/page.tsx.ejs +111 -111
  69. package/hedhog/frontend/app/rewards/page.tsx.ejs +195 -0
  70. package/hedhog/frontend/app/tasks/page.tsx.ejs +47 -47
  71. package/hedhog/frontend/app/timesheets/page.tsx.ejs +126 -126
  72. package/hedhog/frontend/messages/en.json +152 -142
  73. package/hedhog/frontend/messages/pt.json +152 -142
  74. package/hedhog/table/operations_allocation.yaml +52 -0
  75. package/hedhog/table/operations_calibration_item.yaml +61 -0
  76. package/hedhog/table/operations_calibration_session.yaml +25 -0
  77. package/hedhog/table/operations_career_level.yaml +75 -0
  78. package/hedhog/table/operations_career_track.yaml +21 -0
  79. package/hedhog/table/operations_certification.yaml +48 -0
  80. package/hedhog/table/operations_contract.yaml +57 -0
  81. package/hedhog/table/operations_employee.yaml +64 -0
  82. package/hedhog/table/operations_employee_certification.yaml +43 -0
  83. package/hedhog/table/operations_employee_connect.yaml +61 -0
  84. package/hedhog/table/operations_employee_evaluation.yaml +113 -0
  85. package/hedhog/table/operations_employee_evaluation_item.yaml +39 -0
  86. package/hedhog/table/operations_employee_profile.yaml +80 -0
  87. package/hedhog/table/operations_employee_skill_matrix.yaml +30 -0
  88. package/hedhog/table/operations_evaluation_cycle.yaml +31 -0
  89. package/hedhog/table/operations_goal.yaml +67 -0
  90. package/hedhog/table/operations_goal_progress.yaml +31 -0
  91. package/hedhog/table/operations_performance_criterion.yaml +29 -0
  92. package/hedhog/table/operations_project.yaml +66 -0
  93. package/hedhog/table/operations_promotion_readiness.yaml +49 -0
  94. package/hedhog/table/operations_promotion_recommendation.yaml +63 -0
  95. package/hedhog/table/operations_public_recognition.yaml +46 -0
  96. package/hedhog/table/operations_reward.yaml +100 -0
  97. package/hedhog/table/operations_score_event.yaml +81 -0
  98. package/hedhog/table/operations_task.yaml +60 -0
  99. package/hedhog/table/operations_timesheet.yaml +49 -0
  100. package/hedhog/table/operations_timesheet_entry.yaml +51 -0
  101. package/package.json +3 -3
  102. package/src/index.ts +2 -1
  103. package/src/language/en.json +8 -8
  104. package/src/language/pt.json +8 -8
  105. package/src/operations-data.controller.ts +54 -0
  106. package/src/operations-growth.controller.ts +44 -0
  107. package/src/operations.module.ts +21 -15
  108. package/src/operations.service.ts +137 -0
@@ -0,0 +1,195 @@
1
+ 'use client';
2
+
3
+ import { Page, PaginationFooter, SearchBar } from '@/components/entity-list';
4
+ import { Badge } from '@/components/ui/badge';
5
+ import {
6
+ Table,
7
+ TableBody,
8
+ TableCell,
9
+ TableHead,
10
+ TableHeader,
11
+ TableRow,
12
+ } from '@/components/ui/table';
13
+ import { Gift } from 'lucide-react';
14
+ import { useTranslations } from 'next-intl';
15
+ import { useMemo, useState } from 'react';
16
+ import { OperationsHeader } from '../_components/operations-header';
17
+ import { SectionCard } from '../_components/section-card';
18
+ import { StatusBadge } from '../_components/status-badge';
19
+ import { useOperationsGrowthData } from '../_lib/hooks/use-operations-growth-data';
20
+ import { formatCurrency, formatDate } from '../_lib/utils/format';
21
+ import { getGrowthRewardBadgeClasses, humanizeGrowthStatus } from '../_lib/utils/growth';
22
+
23
+ const PAGE_SIZE_OPTIONS = [4, 8, 12];
24
+
25
+ export default function OperationsRewardsPage() {
26
+ const t = useTranslations('operations.RewardsPage');
27
+ const { rewards, recognitions, users, projects } = useOperationsGrowthData();
28
+ const [searchInput, setSearchInput] = useState('');
29
+ const [search, setSearch] = useState('');
30
+ const [employeeFilter, setEmployeeFilter] = useState('all');
31
+ const [currentPage, setCurrentPage] = useState(1);
32
+ const [pageSize, setPageSize] = useState(PAGE_SIZE_OPTIONS[0]);
33
+
34
+ const filteredRewards = useMemo(
35
+ () =>
36
+ rewards.filter((reward) => {
37
+ const employee = users.find((item) => item.id === reward.employeeId);
38
+ const haystack = `${employee?.name ?? ''} ${reward.description} ${reward.type} ${reward.origin}`;
39
+ const matchesSearch = haystack.toLowerCase().includes(search.toLowerCase());
40
+ const matchesEmployee =
41
+ employeeFilter === 'all' || reward.employeeId === employeeFilter;
42
+
43
+ return matchesSearch && matchesEmployee;
44
+ }),
45
+ [employeeFilter, rewards, search, users]
46
+ );
47
+
48
+ const totalPages = Math.max(1, Math.ceil(filteredRewards.length / pageSize));
49
+ const safePage = Math.min(Math.max(currentPage, 1), totalPages);
50
+ const paginatedRewards = filteredRewards.slice(
51
+ (safePage - 1) * pageSize,
52
+ safePage * pageSize
53
+ );
54
+
55
+ return (
56
+ <Page>
57
+ <OperationsHeader
58
+ title={t('title')}
59
+ description={t('description')}
60
+ current={t('breadcrumb')}
61
+ />
62
+
63
+ <SearchBar
64
+ className="mb-6"
65
+ searchQuery={searchInput}
66
+ onSearchChange={setSearchInput}
67
+ onSearch={() => {
68
+ setSearch(searchInput);
69
+ setCurrentPage(1);
70
+ }}
71
+ placeholder={t('searchPlaceholder')}
72
+ controls={[
73
+ {
74
+ id: 'employee-filter',
75
+ type: 'select',
76
+ value: employeeFilter,
77
+ onChange: (value) => {
78
+ setEmployeeFilter(value);
79
+ setCurrentPage(1);
80
+ },
81
+ placeholder: t('filters.allEmployees'),
82
+ options: [
83
+ { value: 'all', label: t('filters.allEmployees') },
84
+ ...users.map((item) => ({ value: item.id, label: item.name })),
85
+ ],
86
+ },
87
+ ]}
88
+ />
89
+
90
+ <SectionCard title={t('rewardsTitle')} description={t('rewardsDescription')}>
91
+ <div className="space-y-4">
92
+ <Table>
93
+ <TableHeader>
94
+ <TableRow>
95
+ <TableHead>{t('columns.employee')}</TableHead>
96
+ <TableHead>{t('columns.type')}</TableHead>
97
+ <TableHead>{t('columns.origin')}</TableHead>
98
+ <TableHead>{t('columns.amount')}</TableHead>
99
+ <TableHead>{t('columns.score')}</TableHead>
100
+ <TableHead>{t('columns.status')}</TableHead>
101
+ </TableRow>
102
+ </TableHeader>
103
+ <TableBody>
104
+ {paginatedRewards.map((reward) => {
105
+ const employee = users.find((item) => item.id === reward.employeeId);
106
+
107
+ return (
108
+ <TableRow key={reward.id}>
109
+ <TableCell className="font-medium">{employee?.name}</TableCell>
110
+ <TableCell>{humanizeGrowthStatus(reward.type)}</TableCell>
111
+ <TableCell>{humanizeGrowthStatus(reward.origin)}</TableCell>
112
+ <TableCell>
113
+ {reward.amount && reward.currency
114
+ ? formatCurrency(reward.amount)
115
+ : t('notApplicable')}
116
+ </TableCell>
117
+ <TableCell>{reward.relatedScore ?? '-'}</TableCell>
118
+ <TableCell>
119
+ <StatusBadge
120
+ label={humanizeGrowthStatus(reward.status)}
121
+ className={getGrowthRewardBadgeClasses(reward.status)}
122
+ />
123
+ </TableCell>
124
+ </TableRow>
125
+ );
126
+ })}
127
+ </TableBody>
128
+ </Table>
129
+ <PaginationFooter
130
+ currentPage={safePage}
131
+ pageSize={pageSize}
132
+ totalItems={filteredRewards.length}
133
+ onPageChange={setCurrentPage}
134
+ onPageSizeChange={(value) => {
135
+ setPageSize(value);
136
+ setCurrentPage(1);
137
+ }}
138
+ pageSizeOptions={PAGE_SIZE_OPTIONS}
139
+ />
140
+ </div>
141
+ </SectionCard>
142
+
143
+ <SectionCard title={t('recognitionTitle')} description={t('recognitionDescription')}>
144
+ <div className="grid gap-4 lg:grid-cols-2">
145
+ {recognitions.map((recognition) => {
146
+ const employee = users.find((item) => item.id === recognition.employeeId);
147
+ const author = users.find((item) => item.id === recognition.authorId);
148
+ const project = projects.find((item) => item.id === recognition.projectId);
149
+
150
+ return (
151
+ <div key={recognition.id} className="rounded-lg border p-4">
152
+ <div className="mb-3 flex items-center justify-between gap-3">
153
+ <div>
154
+ <p className="font-medium">{employee?.name}</p>
155
+ <p className="text-muted-foreground text-sm">{author?.name}</p>
156
+ </div>
157
+ <Badge variant="secondary">+{recognition.relatedScore ?? 0}</Badge>
158
+ </div>
159
+ <p className="text-sm">{recognition.message}</p>
160
+ <div className="text-muted-foreground mt-3 flex items-center justify-between text-xs">
161
+ <span>{project?.name ?? t('withoutProject')}</span>
162
+ <span>{formatDate(recognition.date)}</span>
163
+ </div>
164
+ </div>
165
+ );
166
+ })}
167
+ </div>
168
+ </SectionCard>
169
+
170
+ <SectionCard title={t('highlightsTitle')} description={t('highlightsDescription')}>
171
+ <div className="grid gap-4 md:grid-cols-3">
172
+ <div className="rounded-lg border border-dashed border-slate-300 p-4">
173
+ <Gift className="mb-3 h-5 w-5 text-emerald-700" />
174
+ <p className="font-medium">{t('highlights.granted')}</p>
175
+ <p className="mt-2 text-2xl font-bold">
176
+ {rewards.filter((item) => item.status === 'granted').length}
177
+ </p>
178
+ </div>
179
+ <div className="rounded-lg border border-dashed border-slate-300 p-4">
180
+ <Gift className="mb-3 h-5 w-5 text-blue-700" />
181
+ <p className="font-medium">{t('highlights.publicRecognition')}</p>
182
+ <p className="mt-2 text-2xl font-bold">{recognitions.length}</p>
183
+ </div>
184
+ <div className="rounded-lg border border-dashed border-slate-300 p-4">
185
+ <Gift className="mb-3 h-5 w-5 text-orange-700" />
186
+ <p className="font-medium">{t('highlights.financial')}</p>
187
+ <p className="mt-2 text-2xl font-bold">
188
+ {rewards.filter((item) => item.type === 'financial' || item.type === 'bonus').length}
189
+ </p>
190
+ </div>
191
+ </div>
192
+ </SectionCard>
193
+ </Page>
194
+ );
195
+ }
@@ -1,47 +1,47 @@
1
- 'use client';
2
-
3
- import { Page } from '@/components/entity-list';
4
- import { Input } from '@/components/ui/input';
5
- import { useTranslations } from 'next-intl';
6
- import { useMemo, useState } from 'react';
7
- import { KanbanBoard } from '../_components/kanban-board';
8
- import { OperationsHeader } from '../_components/operations-header';
9
- import { SectionCard } from '../_components/section-card';
10
- import { useOperationsData } from '../_lib/hooks/use-operations-data';
11
-
12
- export default function TasksPage() {
13
- const t = useTranslations('operations.TasksPage');
14
- const { tasks, users } = useOperationsData();
15
- const [search, setSearch] = useState('');
16
-
17
- const filteredTasks = useMemo(
18
- () =>
19
- tasks.filter((task) =>
20
- `${task.title} ${task.projectName} ${task.labels.join(' ')}`
21
- .toLowerCase()
22
- .includes(search.toLowerCase())
23
- ),
24
- [tasks, search]
25
- );
26
-
27
- return (
28
- <Page>
29
- <OperationsHeader
30
- title={t('title')}
31
- description={t('description')}
32
- current={t('breadcrumb')}
33
- />
34
-
35
- <SectionCard title={t('boardTitle')} description={t('boardDescription')}>
36
- <div className="mb-4">
37
- <Input
38
- value={search}
39
- onChange={(event) => setSearch(event.target.value)}
40
- placeholder={t('searchPlaceholder')}
41
- />
42
- </div>
43
- <KanbanBoard tasks={filteredTasks} users={users} />
44
- </SectionCard>
45
- </Page>
46
- );
47
- }
1
+ 'use client';
2
+
3
+ import { Page } from '@/components/entity-list';
4
+ import { Input } from '@/components/ui/input';
5
+ import { useTranslations } from 'next-intl';
6
+ import { useMemo, useState } from 'react';
7
+ import { KanbanBoard } from '../_components/kanban-board';
8
+ import { OperationsHeader } from '../_components/operations-header';
9
+ import { SectionCard } from '../_components/section-card';
10
+ import { useOperationsData } from '../_lib/hooks/use-operations-data';
11
+
12
+ export default function TasksPage() {
13
+ const t = useTranslations('operations.TasksPage');
14
+ const { tasks, users } = useOperationsData();
15
+ const [search, setSearch] = useState('');
16
+
17
+ const filteredTasks = useMemo(
18
+ () =>
19
+ tasks.filter((task) =>
20
+ `${task.title} ${task.projectName} ${task.labels.join(' ')}`
21
+ .toLowerCase()
22
+ .includes(search.toLowerCase())
23
+ ),
24
+ [tasks, search]
25
+ );
26
+
27
+ return (
28
+ <Page>
29
+ <OperationsHeader
30
+ title={t('title')}
31
+ description={t('description')}
32
+ current={t('breadcrumb')}
33
+ />
34
+
35
+ <SectionCard title={t('boardTitle')} description={t('boardDescription')}>
36
+ <div className="mb-4">
37
+ <Input
38
+ value={search}
39
+ onChange={(event) => setSearch(event.target.value)}
40
+ placeholder={t('searchPlaceholder')}
41
+ />
42
+ </div>
43
+ <KanbanBoard tasks={filteredTasks} users={users} />
44
+ </SectionCard>
45
+ </Page>
46
+ );
47
+ }
@@ -1,126 +1,126 @@
1
- 'use client';
2
-
3
- import { Page } from '@/components/entity-list';
4
- import { Input } from '@/components/ui/input';
5
- import {
6
- Table,
7
- TableBody,
8
- TableCell,
9
- TableHead,
10
- TableHeader,
11
- TableRow,
12
- } from '@/components/ui/table';
13
- import { useTranslations } from 'next-intl';
14
- import { useMemo, useState } from 'react';
15
- import { OperationsHeader } from '../_components/operations-header';
16
- import { SectionCard } from '../_components/section-card';
17
- import { StatusBadge } from '../_components/status-badge';
18
- import { TimesheetEntryDialog } from '../_components/timesheet-entry-dialog';
19
- import { useOperationsData } from '../_lib/hooks/use-operations-data';
20
- import { formatDate, formatHours } from '../_lib/utils/format';
21
- import { getApprovalBadgeClasses, getApprovalLabel } from '../_lib/utils/status';
22
-
23
- export default function TimesheetsPage() {
24
- const t = useTranslations('operations.TimesheetsPage');
25
- const { timesheets, users, projects, tasks, dailyTotals } =
26
- useOperationsData();
27
- const [search, setSearch] = useState('');
28
-
29
- const filteredTimesheets = useMemo(
30
- () =>
31
- timesheets.filter((entry) => {
32
- const user = users.find((item) => item.id === entry.userId);
33
- const project = projects.find((item) => item.id === entry.projectId);
34
- const task = tasks.find((item) => item.id === entry.taskId);
35
-
36
- return `${user?.name} ${project?.name} ${task?.title} ${entry.description}`
37
- .toLowerCase()
38
- .includes(search.toLowerCase());
39
- }),
40
- [timesheets, users, projects, tasks, search]
41
- );
42
-
43
- const weeklyTotal = filteredTimesheets.reduce(
44
- (sum, entry) => sum + entry.hours,
45
- 0
46
- );
47
-
48
- return (
49
- <Page>
50
- <OperationsHeader
51
- title={t('title')}
52
- description={t('description')}
53
- current={t('breadcrumb')}
54
- actions={
55
- <TimesheetEntryDialog users={users} projects={projects} tasks={tasks} />
56
- }
57
- />
58
-
59
- <div className="grid gap-4 md:grid-cols-3">
60
- <SectionCard title={t('summary.totalHours')}>
61
- <p className="text-3xl font-semibold">{formatHours(weeklyTotal)}</p>
62
- </SectionCard>
63
- <SectionCard title={t('summary.dailyTotals')}>
64
- <div className="space-y-2 text-sm">
65
- {Object.entries(dailyTotals).map(([date, total]) => (
66
- <div key={date} className="flex items-center justify-between">
67
- <span>{formatDate(date)}</span>
68
- <span>{formatHours(total)}</span>
69
- </div>
70
- ))}
71
- </div>
72
- </SectionCard>
73
- <SectionCard title={t('summary.weeklyTotal')}>
74
- <p className="text-3xl font-semibold">{formatHours(weeklyTotal)}</p>
75
- </SectionCard>
76
- </div>
77
-
78
- <SectionCard title={t('gridTitle')} description={t('gridDescription')}>
79
- <div className="mb-4">
80
- <Input
81
- value={search}
82
- onChange={(event) => setSearch(event.target.value)}
83
- placeholder={t('searchPlaceholder')}
84
- />
85
- </div>
86
- <Table>
87
- <TableHeader>
88
- <TableRow>
89
- <TableHead>{t('columns.date')}</TableHead>
90
- <TableHead>{t('columns.user')}</TableHead>
91
- <TableHead>{t('columns.project')}</TableHead>
92
- <TableHead>{t('columns.task')}</TableHead>
93
- <TableHead>{t('columns.hours')}</TableHead>
94
- <TableHead>{t('columns.description')}</TableHead>
95
- <TableHead>{t('columns.status')}</TableHead>
96
- </TableRow>
97
- </TableHeader>
98
- <TableBody>
99
- {filteredTimesheets.map((entry) => {
100
- const user = users.find((item) => item.id === entry.userId);
101
- const project = projects.find((item) => item.id === entry.projectId);
102
- const task = tasks.find((item) => item.id === entry.taskId);
103
-
104
- return (
105
- <TableRow key={entry.id}>
106
- <TableCell>{formatDate(entry.date)}</TableCell>
107
- <TableCell>{user?.name}</TableCell>
108
- <TableCell>{project?.name}</TableCell>
109
- <TableCell>{task?.title}</TableCell>
110
- <TableCell>{formatHours(entry.hours)}</TableCell>
111
- <TableCell>{entry.description}</TableCell>
112
- <TableCell>
113
- <StatusBadge
114
- label={getApprovalLabel(entry.status)}
115
- className={getApprovalBadgeClasses(entry.status)}
116
- />
117
- </TableCell>
118
- </TableRow>
119
- );
120
- })}
121
- </TableBody>
122
- </Table>
123
- </SectionCard>
124
- </Page>
125
- );
126
- }
1
+ 'use client';
2
+
3
+ import { Page } from '@/components/entity-list';
4
+ import { Input } from '@/components/ui/input';
5
+ import {
6
+ Table,
7
+ TableBody,
8
+ TableCell,
9
+ TableHead,
10
+ TableHeader,
11
+ TableRow,
12
+ } from '@/components/ui/table';
13
+ import { useTranslations } from 'next-intl';
14
+ import { useMemo, useState } from 'react';
15
+ import { OperationsHeader } from '../_components/operations-header';
16
+ import { SectionCard } from '../_components/section-card';
17
+ import { StatusBadge } from '../_components/status-badge';
18
+ import { TimesheetEntryDialog } from '../_components/timesheet-entry-dialog';
19
+ import { useOperationsData } from '../_lib/hooks/use-operations-data';
20
+ import { formatDate, formatHours } from '../_lib/utils/format';
21
+ import { getApprovalBadgeClasses, getApprovalLabel } from '../_lib/utils/status';
22
+
23
+ export default function TimesheetsPage() {
24
+ const t = useTranslations('operations.TimesheetsPage');
25
+ const { timesheets, users, projects, tasks, dailyTotals } =
26
+ useOperationsData();
27
+ const [search, setSearch] = useState('');
28
+
29
+ const filteredTimesheets = useMemo(
30
+ () =>
31
+ timesheets.filter((entry) => {
32
+ const user = users.find((item) => item.id === entry.userId);
33
+ const project = projects.find((item) => item.id === entry.projectId);
34
+ const task = tasks.find((item) => item.id === entry.taskId);
35
+
36
+ return `${user?.name} ${project?.name} ${task?.title} ${entry.description}`
37
+ .toLowerCase()
38
+ .includes(search.toLowerCase());
39
+ }),
40
+ [timesheets, users, projects, tasks, search]
41
+ );
42
+
43
+ const weeklyTotal = filteredTimesheets.reduce(
44
+ (sum, entry) => sum + entry.hours,
45
+ 0
46
+ );
47
+
48
+ return (
49
+ <Page>
50
+ <OperationsHeader
51
+ title={t('title')}
52
+ description={t('description')}
53
+ current={t('breadcrumb')}
54
+ actions={
55
+ <TimesheetEntryDialog users={users} projects={projects} tasks={tasks} />
56
+ }
57
+ />
58
+
59
+ <div className="grid gap-4 md:grid-cols-3">
60
+ <SectionCard title={t('summary.totalHours')}>
61
+ <p className="text-3xl font-semibold">{formatHours(weeklyTotal)}</p>
62
+ </SectionCard>
63
+ <SectionCard title={t('summary.dailyTotals')}>
64
+ <div className="space-y-2 text-sm">
65
+ {Object.entries(dailyTotals).map(([date, total]) => (
66
+ <div key={date} className="flex items-center justify-between">
67
+ <span>{formatDate(date)}</span>
68
+ <span>{formatHours(total)}</span>
69
+ </div>
70
+ ))}
71
+ </div>
72
+ </SectionCard>
73
+ <SectionCard title={t('summary.weeklyTotal')}>
74
+ <p className="text-3xl font-semibold">{formatHours(weeklyTotal)}</p>
75
+ </SectionCard>
76
+ </div>
77
+
78
+ <SectionCard title={t('gridTitle')} description={t('gridDescription')}>
79
+ <div className="mb-4">
80
+ <Input
81
+ value={search}
82
+ onChange={(event) => setSearch(event.target.value)}
83
+ placeholder={t('searchPlaceholder')}
84
+ />
85
+ </div>
86
+ <Table>
87
+ <TableHeader>
88
+ <TableRow>
89
+ <TableHead>{t('columns.date')}</TableHead>
90
+ <TableHead>{t('columns.user')}</TableHead>
91
+ <TableHead>{t('columns.project')}</TableHead>
92
+ <TableHead>{t('columns.task')}</TableHead>
93
+ <TableHead>{t('columns.hours')}</TableHead>
94
+ <TableHead>{t('columns.description')}</TableHead>
95
+ <TableHead>{t('columns.status')}</TableHead>
96
+ </TableRow>
97
+ </TableHeader>
98
+ <TableBody>
99
+ {filteredTimesheets.map((entry) => {
100
+ const user = users.find((item) => item.id === entry.userId);
101
+ const project = projects.find((item) => item.id === entry.projectId);
102
+ const task = tasks.find((item) => item.id === entry.taskId);
103
+
104
+ return (
105
+ <TableRow key={entry.id}>
106
+ <TableCell>{formatDate(entry.date)}</TableCell>
107
+ <TableCell>{user?.name}</TableCell>
108
+ <TableCell>{project?.name}</TableCell>
109
+ <TableCell>{task?.title}</TableCell>
110
+ <TableCell>{formatHours(entry.hours)}</TableCell>
111
+ <TableCell>{entry.description}</TableCell>
112
+ <TableCell>
113
+ <StatusBadge
114
+ label={getApprovalLabel(entry.status)}
115
+ className={getApprovalBadgeClasses(entry.status)}
116
+ />
117
+ </TableCell>
118
+ </TableRow>
119
+ );
120
+ })}
121
+ </TableBody>
122
+ </Table>
123
+ </SectionCard>
124
+ </Page>
125
+ );
126
+ }