@hed-hog/operations 0.0.306 → 0.0.310

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 (123) hide show
  1. package/dist/controllers/operations-approvals.controller.d.ts +114 -1
  2. package/dist/controllers/operations-approvals.controller.d.ts.map +1 -1
  3. package/dist/controllers/operations-approvals.controller.js +16 -3
  4. package/dist/controllers/operations-approvals.controller.js.map +1 -1
  5. package/dist/controllers/operations-collaborators.controller.d.ts +16 -1
  6. package/dist/controllers/operations-collaborators.controller.d.ts.map +1 -1
  7. package/dist/controllers/operations-collaborators.controller.js +16 -3
  8. package/dist/controllers/operations-collaborators.controller.js.map +1 -1
  9. package/dist/controllers/operations-contracts.controller.d.ts +14 -453
  10. package/dist/controllers/operations-contracts.controller.d.ts.map +1 -1
  11. package/dist/controllers/operations-contracts.controller.js +11 -112
  12. package/dist/controllers/operations-contracts.controller.js.map +1 -1
  13. package/dist/controllers/operations-org-structure.controller.d.ts +65 -2
  14. package/dist/controllers/operations-org-structure.controller.d.ts.map +1 -1
  15. package/dist/controllers/operations-org-structure.controller.js +18 -5
  16. package/dist/controllers/operations-org-structure.controller.js.map +1 -1
  17. package/dist/controllers/operations-projects.controller.d.ts +28 -4
  18. package/dist/controllers/operations-projects.controller.d.ts.map +1 -1
  19. package/dist/controllers/operations-projects.controller.js +17 -5
  20. package/dist/controllers/operations-projects.controller.js.map +1 -1
  21. package/dist/controllers/operations-timesheets.controller.d.ts +31 -4
  22. package/dist/controllers/operations-timesheets.controller.d.ts.map +1 -1
  23. package/dist/controllers/operations-timesheets.controller.js +16 -11
  24. package/dist/controllers/operations-timesheets.controller.js.map +1 -1
  25. package/dist/dto/list-approvals.dto.d.ts +6 -0
  26. package/dist/dto/list-approvals.dto.d.ts.map +1 -0
  27. package/dist/dto/list-approvals.dto.js +28 -0
  28. package/dist/dto/list-approvals.dto.js.map +1 -0
  29. package/dist/dto/list-collaborator-types.dto.d.ts +3 -1
  30. package/dist/dto/list-collaborator-types.dto.d.ts.map +1 -1
  31. package/dist/dto/list-collaborator-types.dto.js +7 -1
  32. package/dist/dto/list-collaborator-types.dto.js.map +1 -1
  33. package/dist/dto/list-collaborators.dto.d.ts +1 -0
  34. package/dist/dto/list-collaborators.dto.d.ts.map +1 -1
  35. package/dist/dto/list-collaborators.dto.js +5 -0
  36. package/dist/dto/list-collaborators.dto.js.map +1 -1
  37. package/dist/dto/list-contracts.dto.d.ts +8 -0
  38. package/dist/dto/list-contracts.dto.d.ts.map +1 -0
  39. package/dist/dto/list-contracts.dto.js +38 -0
  40. package/dist/dto/list-contracts.dto.js.map +1 -0
  41. package/dist/dto/list-departments.dto.d.ts +5 -0
  42. package/dist/dto/list-departments.dto.d.ts.map +1 -0
  43. package/dist/dto/list-departments.dto.js +23 -0
  44. package/dist/dto/list-departments.dto.js.map +1 -0
  45. package/dist/dto/list-projects.dto.d.ts +5 -0
  46. package/dist/dto/list-projects.dto.d.ts.map +1 -0
  47. package/dist/dto/list-projects.dto.js +23 -0
  48. package/dist/dto/list-projects.dto.js.map +1 -0
  49. package/dist/dto/list-schedule-adjustments.dto.d.ts +5 -0
  50. package/dist/dto/list-schedule-adjustments.dto.d.ts.map +1 -0
  51. package/dist/dto/list-schedule-adjustments.dto.js +23 -0
  52. package/dist/dto/list-schedule-adjustments.dto.js.map +1 -0
  53. package/dist/dto/list-time-off-requests.dto.d.ts +5 -0
  54. package/dist/dto/list-time-off-requests.dto.d.ts.map +1 -0
  55. package/dist/dto/list-time-off-requests.dto.js +23 -0
  56. package/dist/dto/list-time-off-requests.dto.js.map +1 -0
  57. package/dist/dto/list-timesheets.dto.d.ts +5 -0
  58. package/dist/dto/list-timesheets.dto.d.ts.map +1 -0
  59. package/dist/dto/list-timesheets.dto.js +23 -0
  60. package/dist/dto/list-timesheets.dto.js.map +1 -0
  61. package/dist/dto/reorder-collaborator-types.dto.d.ts +4 -0
  62. package/dist/dto/reorder-collaborator-types.dto.d.ts.map +1 -0
  63. package/dist/dto/reorder-collaborator-types.dto.js +25 -0
  64. package/dist/dto/reorder-collaborator-types.dto.js.map +1 -0
  65. package/dist/operations.service.d.ts +340 -271
  66. package/dist/operations.service.d.ts.map +1 -1
  67. package/dist/operations.service.js +1007 -1043
  68. package/dist/operations.service.js.map +1 -1
  69. package/dist/operations.service.spec.js +0 -22
  70. package/dist/operations.service.spec.js.map +1 -1
  71. package/hedhog/data/menu.yaml +0 -36
  72. package/hedhog/data/route.yaml +42 -73
  73. package/hedhog/frontend/app/_components/collaborator-form-screen.tsx.ejs +8 -1
  74. package/hedhog/frontend/app/_components/collaborator-select-with-create.tsx.ejs +15 -10
  75. package/hedhog/frontend/app/_components/contract-details-screen.tsx.ejs +108 -213
  76. package/hedhog/frontend/app/_components/contract-form-screen.tsx.ejs +251 -2039
  77. package/hedhog/frontend/app/_components/project-details-screen.tsx.ejs +167 -60
  78. package/hedhog/frontend/app/_components/project-form-screen.tsx.ejs +70 -301
  79. package/hedhog/frontend/app/_components/system-user-select-with-create.tsx.ejs +102 -51
  80. package/hedhog/frontend/app/_lib/types.ts.ejs +19 -24
  81. package/hedhog/frontend/app/_lib/utils/format.ts.ejs +14 -9
  82. package/hedhog/frontend/app/approvals/page.tsx.ejs +842 -150
  83. package/hedhog/frontend/app/collaborator-types/page.tsx.ejs +445 -153
  84. package/hedhog/frontend/app/collaborators/page.tsx.ejs +118 -49
  85. package/hedhog/frontend/app/contracts/[id]/page.tsx.ejs +2 -2
  86. package/hedhog/frontend/app/contracts/page.tsx.ejs +215 -617
  87. package/hedhog/frontend/app/departments/page.tsx.ejs +257 -113
  88. package/hedhog/frontend/app/projects/page.tsx.ejs +90 -51
  89. package/hedhog/frontend/app/schedule-adjustments/page.tsx.ejs +412 -147
  90. package/hedhog/frontend/app/time-off/page.tsx.ejs +400 -123
  91. package/hedhog/frontend/app/timesheets/page.tsx.ejs +460 -365
  92. package/hedhog/frontend/messages/en.json +143 -14
  93. package/hedhog/frontend/messages/pt.json +192 -54
  94. package/hedhog/table/operations_contract.yaml +0 -9
  95. package/package.json +4 -4
  96. package/src/controllers/operations-approvals.controller.ts +9 -3
  97. package/src/controllers/operations-collaborators.controller.ts +15 -2
  98. package/src/controllers/operations-contracts.controller.ts +8 -92
  99. package/src/controllers/operations-org-structure.controller.ts +17 -4
  100. package/src/controllers/operations-projects.controller.ts +10 -4
  101. package/src/controllers/operations-timesheets.controller.ts +17 -8
  102. package/src/dto/list-approvals.dto.ts +12 -0
  103. package/src/dto/list-collaborator-types.dto.ts +7 -2
  104. package/src/dto/list-collaborators.dto.ts +4 -0
  105. package/src/dto/list-contracts.dto.ts +20 -0
  106. package/src/dto/list-departments.dto.ts +8 -0
  107. package/src/dto/list-projects.dto.ts +8 -0
  108. package/src/dto/list-schedule-adjustments.dto.ts +8 -0
  109. package/src/dto/list-time-off-requests.dto.ts +8 -0
  110. package/src/dto/list-timesheets.dto.ts +8 -0
  111. package/src/dto/reorder-collaborator-types.dto.ts +10 -0
  112. package/src/operations.service.spec.ts +0 -30
  113. package/src/operations.service.ts +1557 -1806
  114. package/hedhog/frontend/app/_components/contract-creation-wizard.tsx.ejs +0 -631
  115. package/hedhog/frontend/app/_components/contract-template-form-screen.tsx.ejs +0 -526
  116. package/hedhog/frontend/app/_components/contract-template-select-with-create.tsx.ejs +0 -247
  117. package/hedhog/frontend/app/_components/contract-wizard-sheet.tsx.ejs +0 -3520
  118. package/hedhog/frontend/app/contracts/templates/page.tsx.ejs +0 -380
  119. package/hedhog/frontend/app/team/page.tsx.ejs +0 -352
  120. package/hedhog/table/operations_contract_financial_term.yaml +0 -40
  121. package/hedhog/table/operations_contract_revision.yaml +0 -38
  122. package/hedhog/table/operations_contract_signature.yaml +0 -38
  123. package/hedhog/table/operations_contract_template.yaml +0 -58
@@ -1,6 +1,11 @@
1
1
  'use client';
2
2
 
3
- import { EmptyState, Page, SearchBar } from '@/components/entity-list';
3
+ import {
4
+ EmptyState,
5
+ Page,
6
+ PaginationFooter,
7
+ SearchBar,
8
+ } from '@/components/entity-list';
4
9
  import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
5
10
  import { Button } from '@/components/ui/button';
6
11
  import { Card, CardContent } from '@/components/ui/card';
@@ -44,7 +49,9 @@ import { fetchOperations, mutateOperations } from '../_lib/api';
44
49
  import { useOperationsAccess } from '../_lib/hooks/use-operations-access';
45
50
  import type {
46
51
  OperationsCollaborator,
52
+ OperationsCollaboratorStats,
47
53
  OperationsCollaboratorType,
54
+ PaginatedResponse,
48
55
  } from '../_lib/types';
49
56
  import {
50
57
  formatCurrency,
@@ -91,6 +98,8 @@ export default function OperationsCollaboratorsPage() {
91
98
  const [search, setSearch] = useState('');
92
99
  const [statusFilter, setStatusFilter] = useState('all');
93
100
  const [typeFilter, setTypeFilter] = useState('all');
101
+ const [page, setPage] = useState(1);
102
+ const [pageSize, setPageSize] = useState(12);
94
103
  const [viewMode, setViewMode] = useState<CollaboratorViewMode>(() => {
95
104
  if (typeof window === 'undefined') {
96
105
  return 'table';
@@ -154,16 +163,43 @@ export default function OperationsCollaboratorsPage() {
154
163
  }
155
164
  };
156
165
 
157
- const { data: collaborators = [], refetch } = useQuery<
158
- OperationsCollaborator[]
166
+ const { data: collaboratorsResponse, refetch } = useQuery<
167
+ PaginatedResponse<OperationsCollaborator>
159
168
  >({
160
- queryKey: ['operations-collaborators-list', currentLocaleCode],
169
+ queryKey: [
170
+ 'operations-collaborators-list',
171
+ currentLocaleCode,
172
+ search,
173
+ statusFilter,
174
+ typeFilter,
175
+ page,
176
+ pageSize,
177
+ ],
161
178
  enabled: access.isCollaborator,
162
- queryFn: () =>
163
- fetchOperations<OperationsCollaborator[]>(
179
+ queryFn: () => {
180
+ const params = new URLSearchParams({
181
+ page: String(page),
182
+ pageSize: String(pageSize),
183
+ });
184
+
185
+ if (search.trim()) {
186
+ params.set('search', search.trim());
187
+ }
188
+
189
+ if (statusFilter !== 'all') {
190
+ params.set('status', statusFilter);
191
+ }
192
+
193
+ if (typeFilter !== 'all') {
194
+ params.set('collaboratorType', typeFilter);
195
+ }
196
+
197
+ return fetchOperations<PaginatedResponse<OperationsCollaborator>>(
164
198
  request,
165
- '/operations/collaborators'
166
- ),
199
+ `/operations/collaborators?${params.toString()}`
200
+ );
201
+ },
202
+ placeholderData: (previous) => previous,
167
203
  });
168
204
 
169
205
  const { data: collaboratorTypes = [] } = useQuery<
@@ -178,6 +214,41 @@ export default function OperationsCollaboratorsPage() {
178
214
  ),
179
215
  });
180
216
 
217
+ const { data: collaboratorStats } = useQuery<OperationsCollaboratorStats>({
218
+ queryKey: [
219
+ 'operations-collaborators-stats',
220
+ currentLocaleCode,
221
+ search,
222
+ statusFilter,
223
+ typeFilter,
224
+ ],
225
+ enabled: access.isCollaborator,
226
+ queryFn: () => {
227
+ const params = new URLSearchParams();
228
+
229
+ if (search.trim()) {
230
+ params.set('search', search.trim());
231
+ }
232
+
233
+ if (statusFilter !== 'all') {
234
+ params.set('status', statusFilter);
235
+ }
236
+
237
+ if (typeFilter !== 'all') {
238
+ params.set('collaboratorType', typeFilter);
239
+ }
240
+
241
+ const query = params.toString();
242
+
243
+ return fetchOperations<OperationsCollaboratorStats>(
244
+ request,
245
+ query
246
+ ? `/operations/collaborators/stats?${query}`
247
+ : '/operations/collaborators/stats'
248
+ );
249
+ },
250
+ });
251
+
181
252
  const getCollaboratorTypeLabel = (
182
253
  slug?: string | null,
183
254
  fallbackName?: string | null
@@ -190,35 +261,8 @@ export default function OperationsCollaboratorsPage() {
190
261
  return matchedType?.name ?? formatEnumLabel(slug);
191
262
  };
192
263
 
193
- const filteredRows = useMemo(
194
- () =>
195
- collaborators.filter((item) => {
196
- const matchesSearch = !search.trim()
197
- ? true
198
- : [
199
- item.displayName,
200
- item.code,
201
- item.department,
202
- item.title,
203
- item.supervisorName,
204
- ]
205
- .filter(Boolean)
206
- .some((value) =>
207
- String(value)
208
- .toLowerCase()
209
- .includes(search.trim().toLowerCase())
210
- );
211
- const matchesStatus =
212
- statusFilter === 'all' ? true : item.status === statusFilter;
213
- const matchesType =
214
- typeFilter === 'all'
215
- ? true
216
- : item.collaboratorTypeSlug === typeFilter ||
217
- item.collaboratorType === typeFilter;
218
- return matchesSearch && matchesStatus && matchesType;
219
- }),
220
- [collaborators, search, statusFilter, typeFilter]
221
- );
264
+ const collaborators = collaboratorsResponse?.data ?? [];
265
+ const filteredRows = collaborators;
222
266
 
223
267
  const statsCards = useMemo(
224
268
  () => [
@@ -226,33 +270,32 @@ export default function OperationsCollaboratorsPage() {
226
270
  key: 'total',
227
271
  title: t('cards.total'),
228
272
  description: t('cards.totalDescription'),
229
- value: collaborators.length,
273
+ value: collaboratorStats?.total ?? 0,
230
274
  icon: Users,
231
275
  },
232
276
  {
233
277
  key: 'active',
234
278
  title: t('cards.active'),
235
279
  description: t('cards.activeDescription'),
236
- value: collaborators.filter((item) => item.status === 'active').length,
280
+ value: collaboratorStats?.active ?? 0,
237
281
  icon: UserCheck,
238
282
  },
239
283
  {
240
284
  key: 'onLeave',
241
285
  title: t('cards.onLeave'),
242
286
  description: t('cards.onLeaveDescription'),
243
- value: collaborators.filter((item) => item.status === 'on_leave')
244
- .length,
287
+ value: collaboratorStats?.onLeave ?? 0,
245
288
  icon: CalendarDays,
246
289
  },
247
290
  {
248
291
  key: 'withContracts',
249
292
  title: t('cards.withContracts'),
250
293
  description: t('cards.withContractsDescription'),
251
- value: collaborators.filter((item) => Boolean(item.contractId)).length,
294
+ value: collaboratorStats?.withContracts ?? 0,
252
295
  icon: FileText,
253
296
  },
254
297
  ],
255
- [collaborators, t]
298
+ [collaboratorStats, t]
256
299
  );
257
300
 
258
301
  const handleViewModeChange = (value: string) => {
@@ -308,15 +351,22 @@ export default function OperationsCollaboratorsPage() {
308
351
  <div className="flex-1">
309
352
  <SearchBar
310
353
  searchQuery={search}
311
- onSearchChange={setSearch}
312
- onSearch={() => undefined}
354
+ onSearchChange={(value) => {
355
+ setSearch(value);
356
+ setPage(1);
357
+ }}
358
+ showSearchButton={false}
359
+ debounceMs={500}
313
360
  placeholder={t('searchPlaceholder')}
314
361
  controls={[
315
362
  {
316
363
  id: 'type',
317
364
  type: 'select',
318
365
  value: typeFilter,
319
- onChange: setTypeFilter,
366
+ onChange: (value) => {
367
+ setTypeFilter(value);
368
+ setPage(1);
369
+ },
320
370
  placeholder: commonT('labels.collaboratorType'),
321
371
  options: [
322
372
  { value: 'all', label: commonT('filters.allTypes') },
@@ -330,7 +380,10 @@ export default function OperationsCollaboratorsPage() {
330
380
  id: 'status',
331
381
  type: 'select',
332
382
  value: statusFilter,
333
- onChange: setStatusFilter,
383
+ onChange: (value) => {
384
+ setStatusFilter(value);
385
+ setPage(1);
386
+ },
334
387
  placeholder: commonT('labels.status'),
335
388
  options: [
336
389
  { value: 'all', label: commonT('filters.allStatuses') },
@@ -448,7 +501,9 @@ export default function OperationsCollaboratorsPage() {
448
501
  </span>{' '}
449
502
  {collaborator.compensationAmount != null
450
503
  ? formatCurrency(
451
- Number(collaborator.compensationAmount)
504
+ Number(collaborator.compensationAmount),
505
+ getSettingValue,
506
+ currentLocaleCode
452
507
  )
453
508
  : commonT('labels.notAvailable')}
454
509
  </div>
@@ -649,7 +704,9 @@ export default function OperationsCollaboratorsPage() {
649
704
  <TableCell className="hidden 2xl:table-cell">
650
705
  {collaborator.compensationAmount != null
651
706
  ? formatCurrency(
652
- Number(collaborator.compensationAmount)
707
+ Number(collaborator.compensationAmount),
708
+ getSettingValue,
709
+ currentLocaleCode
653
710
  )
654
711
  : commonT('labels.notAvailable')}
655
712
  </TableCell>
@@ -726,6 +783,18 @@ export default function OperationsCollaboratorsPage() {
726
783
  />
727
784
  )}
728
785
 
786
+ <PaginationFooter
787
+ currentPage={collaboratorsResponse?.page ?? page}
788
+ pageSize={collaboratorsResponse?.pageSize ?? pageSize}
789
+ totalItems={collaboratorsResponse?.total ?? 0}
790
+ onPageChange={setPage}
791
+ onPageSizeChange={(value) => {
792
+ setPageSize(value);
793
+ setPage(1);
794
+ }}
795
+ pageSizeOptions={[12, 24, 48]}
796
+ />
797
+
729
798
  <Sheet
730
799
  open={isCreateSheetOpen || editingCollaboratorId !== null}
731
800
  onOpenChange={(open) => {
@@ -1,4 +1,4 @@
1
- import { redirect } from 'next/navigation';
1
+ import { ContractDetailsScreen } from '../../_components/contract-details-screen';
2
2
 
3
3
  export default async function OperationsContractDetailsPage({
4
4
  params,
@@ -7,5 +7,5 @@ export default async function OperationsContractDetailsPage({
7
7
  }) {
8
8
  const { id } = await params;
9
9
 
10
- redirect(`/operations/contracts?edit=${id}`);
10
+ return <ContractDetailsScreen contractId={Number(id)} />;
11
11
  }