@hed-hog/operations 0.0.295 → 0.0.296
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/dist/operations.controller.d.ts +415 -0
- package/dist/operations.controller.d.ts.map +1 -0
- package/dist/operations.controller.js +333 -0
- package/dist/operations.controller.js.map +1 -0
- package/dist/operations.module.d.ts.map +1 -1
- package/dist/operations.module.js +4 -3
- package/dist/operations.module.js.map +1 -1
- package/dist/operations.service.d.ts +589 -153
- package/dist/operations.service.d.ts.map +1 -1
- package/dist/operations.service.js +2229 -100
- package/dist/operations.service.js.map +1 -1
- package/hedhog/data/menu.yaml +198 -251
- package/hedhog/data/role.yaml +23 -14
- package/hedhog/data/route.yaml +317 -143
- package/hedhog/frontend/app/_components/collaborator-details-screen.tsx.ejs +310 -0
- package/hedhog/frontend/app/_components/collaborator-form-screen.tsx.ejs +631 -0
- package/hedhog/frontend/app/_components/contract-details-screen.tsx.ejs +132 -0
- package/hedhog/frontend/app/_components/contract-form-screen.tsx.ejs +558 -0
- package/hedhog/frontend/app/_components/project-details-screen.tsx.ejs +291 -0
- package/hedhog/frontend/app/_components/project-form-screen.tsx.ejs +689 -0
- package/hedhog/frontend/app/_lib/api.ts.ejs +32 -0
- package/hedhog/frontend/app/_lib/hooks/use-operations-access.ts.ejs +44 -0
- package/hedhog/frontend/app/_lib/types.ts.ejs +360 -0
- package/hedhog/frontend/app/_lib/utils/format.ts.ejs +129 -25
- package/hedhog/frontend/app/_lib/utils/forms.ts.ejs +14 -0
- package/hedhog/frontend/app/approvals/page.tsx.ejs +386 -147
- package/hedhog/frontend/app/collaborators/[id]/edit/page.tsx.ejs +11 -0
- package/hedhog/frontend/app/collaborators/[id]/page.tsx.ejs +11 -0
- package/hedhog/frontend/app/collaborators/new/page.tsx.ejs +5 -0
- package/hedhog/frontend/app/collaborators/page.tsx.ejs +261 -0
- package/hedhog/frontend/app/contracts/[id]/edit/page.tsx.ejs +11 -0
- package/hedhog/frontend/app/contracts/[id]/page.tsx.ejs +11 -108
- package/hedhog/frontend/app/contracts/new/page.tsx.ejs +17 -0
- package/hedhog/frontend/app/contracts/page.tsx.ejs +262 -181
- package/hedhog/frontend/app/page.tsx.ejs +319 -177
- package/hedhog/frontend/app/projects/[id]/edit/page.tsx.ejs +11 -0
- package/hedhog/frontend/app/projects/[id]/page.tsx.ejs +11 -936
- package/hedhog/frontend/app/projects/new/page.tsx.ejs +5 -0
- package/hedhog/frontend/app/projects/page.tsx.ejs +236 -1074
- package/hedhog/frontend/app/schedule-adjustments/page.tsx.ejs +418 -0
- package/hedhog/frontend/app/team/page.tsx.ejs +339 -0
- package/hedhog/frontend/app/time-off/page.tsx.ejs +328 -0
- package/hedhog/frontend/app/timesheets/page.tsx.ejs +636 -126
- package/hedhog/frontend/messages/en.json +648 -454
- package/hedhog/frontend/messages/pt.json +647 -454
- package/hedhog/table/operations_approval.yaml +49 -0
- package/hedhog/table/operations_approval_history.yaml +29 -0
- package/hedhog/table/{operations_employee.yaml → operations_collaborator.yaml} +67 -64
- package/hedhog/table/operations_collaborator_schedule_day.yaml +34 -0
- package/hedhog/table/operations_contract.yaml +100 -48
- package/hedhog/table/operations_contract_document.yaml +39 -0
- package/hedhog/table/operations_contract_financial_term.yaml +40 -0
- package/hedhog/table/operations_contract_history.yaml +27 -0
- package/hedhog/table/operations_contract_party.yaml +46 -0
- package/hedhog/table/operations_contract_revision.yaml +38 -0
- package/hedhog/table/operations_contract_signature.yaml +38 -0
- package/hedhog/table/operations_project.yaml +54 -50
- package/hedhog/table/{operations_allocation.yaml → operations_project_assignment.yaml} +55 -52
- package/hedhog/table/operations_schedule_adjustment_day.yaml +34 -0
- package/hedhog/table/operations_schedule_adjustment_request.yaml +53 -0
- package/hedhog/table/operations_time_off_request.yaml +57 -0
- package/hedhog/table/operations_timesheet.yaml +41 -36
- package/hedhog/table/operations_timesheet_entry.yaml +40 -50
- package/package.json +8 -7
- package/src/operations.controller.ts +182 -0
- package/src/operations.module.ts +22 -21
- package/src/operations.service.ts +3595 -137
- package/hedhog/data/operations_career_level.yaml +0 -102
- package/hedhog/data/operations_career_track.yaml +0 -8
- package/hedhog/data/operations_certification.yaml +0 -38
- package/hedhog/data/operations_evaluation_cycle.yaml +0 -18
- package/hedhog/data/operations_performance_criterion.yaml +0 -48
- package/hedhog/frontend/app/_components/allocation-calendar.tsx.ejs +0 -56
- package/hedhog/frontend/app/_components/kanban-board.tsx.ejs +0 -626
- package/hedhog/frontend/app/_components/timesheet-entry-dialog.tsx.ejs +0 -142
- package/hedhog/frontend/app/_lib/hooks/use-operations-data.ts.ejs +0 -41
- package/hedhog/frontend/app/_lib/hooks/use-operations-growth-data.ts.ejs +0 -63
- package/hedhog/frontend/app/_lib/mocks/allocations.mock.ts.ejs +0 -74
- package/hedhog/frontend/app/_lib/mocks/contracts.mock.ts.ejs +0 -74
- package/hedhog/frontend/app/_lib/mocks/operations-growth.mock.ts.ejs +0 -824
- package/hedhog/frontend/app/_lib/mocks/projects.mock.ts.ejs +0 -455
- package/hedhog/frontend/app/_lib/mocks/tasks.mock.ts.ejs +0 -117
- package/hedhog/frontend/app/_lib/mocks/timesheets.mock.ts.ejs +0 -84
- package/hedhog/frontend/app/_lib/mocks/users.mock.ts.ejs +0 -67
- package/hedhog/frontend/app/_lib/services/contracts.service.ts.ejs +0 -10
- package/hedhog/frontend/app/_lib/services/operations-growth.service.ts.ejs +0 -31
- package/hedhog/frontend/app/_lib/services/projects.service.ts.ejs +0 -10
- package/hedhog/frontend/app/_lib/services/tasks.service.ts.ejs +0 -10
- package/hedhog/frontend/app/_lib/services/timesheets.service.ts.ejs +0 -10
- package/hedhog/frontend/app/_lib/types/operations-growth.ts.ejs +0 -209
- package/hedhog/frontend/app/_lib/types/operations.ts.ejs +0 -156
- package/hedhog/frontend/app/_lib/utils/growth.ts.ejs +0 -62
- package/hedhog/frontend/app/_lib/utils/metrics.ts.ejs +0 -103
- package/hedhog/frontend/app/_lib/utils/status.ts.ejs +0 -80
- package/hedhog/frontend/app/allocations/page.tsx.ejs +0 -155
- package/hedhog/frontend/app/career/page.tsx.ejs +0 -143
- package/hedhog/frontend/app/certifications/page.tsx.ejs +0 -202
- package/hedhog/frontend/app/evaluations/page.tsx.ejs +0 -278
- package/hedhog/frontend/app/goals/page.tsx.ejs +0 -171
- package/hedhog/frontend/app/growth/page.tsx.ejs +0 -288
- package/hedhog/frontend/app/manager/page.tsx.ejs +0 -175
- package/hedhog/frontend/app/rewards/page.tsx.ejs +0 -196
- package/hedhog/frontend/app/tasks/page.tsx.ejs +0 -999
- package/hedhog/table/operations_calibration_item.yaml +0 -61
- package/hedhog/table/operations_calibration_session.yaml +0 -25
- package/hedhog/table/operations_career_level.yaml +0 -75
- package/hedhog/table/operations_career_track.yaml +0 -21
- package/hedhog/table/operations_certification.yaml +0 -48
- package/hedhog/table/operations_employee_certification.yaml +0 -43
- package/hedhog/table/operations_employee_connect.yaml +0 -61
- package/hedhog/table/operations_employee_evaluation.yaml +0 -113
- package/hedhog/table/operations_employee_evaluation_item.yaml +0 -39
- package/hedhog/table/operations_employee_profile.yaml +0 -80
- package/hedhog/table/operations_employee_skill_matrix.yaml +0 -30
- package/hedhog/table/operations_evaluation_cycle.yaml +0 -31
- package/hedhog/table/operations_goal.yaml +0 -67
- package/hedhog/table/operations_goal_progress.yaml +0 -31
- package/hedhog/table/operations_performance_criterion.yaml +0 -29
- package/hedhog/table/operations_promotion_readiness.yaml +0 -49
- package/hedhog/table/operations_promotion_recommendation.yaml +0 -63
- package/hedhog/table/operations_public_recognition.yaml +0 -46
- package/hedhog/table/operations_reward.yaml +0 -100
- package/hedhog/table/operations_score_event.yaml +0 -81
- package/hedhog/table/operations_task.yaml +0 -60
- package/src/operations-data.controller.ts +0 -54
- package/src/operations-growth.controller.ts +0 -44
|
@@ -1,181 +1,262 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from '
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { EmptyState, Page, SearchBar } from '@/components/entity-list';
|
|
4
|
+
import { Button } from '@/components/ui/button';
|
|
5
|
+
import {
|
|
6
|
+
Table,
|
|
7
|
+
TableBody,
|
|
8
|
+
TableCell,
|
|
9
|
+
TableHead,
|
|
10
|
+
TableHeader,
|
|
11
|
+
TableRow,
|
|
12
|
+
} from '@/components/ui/table';
|
|
13
|
+
import { useApp, useQuery } from '@hed-hog/next-app-provider';
|
|
14
|
+
import { Download, Eye, FileText, Pencil, Upload } from 'lucide-react';
|
|
15
|
+
import Link from 'next/link';
|
|
16
|
+
import { useMemo, useRef, useState } from 'react';
|
|
17
|
+
import { useTranslations } from 'next-intl';
|
|
18
|
+
import { OperationsHeader } from '../_components/operations-header';
|
|
19
|
+
import { StatusBadge } from '../_components/status-badge';
|
|
20
|
+
import { fetchOperations, mutateOperations } from '../_lib/api';
|
|
21
|
+
import { useOperationsAccess } from '../_lib/hooks/use-operations-access';
|
|
22
|
+
import type { OperationsContract, OperationsContractDetails } from '../_lib/types';
|
|
23
|
+
import {
|
|
24
|
+
formatCurrency,
|
|
25
|
+
formatDate,
|
|
26
|
+
formatEnumLabel,
|
|
27
|
+
getStatusBadgeClass,
|
|
28
|
+
} from '../_lib/utils/format';
|
|
29
|
+
|
|
30
|
+
function downloadBase64File(fileName: string, mimeType: string, base64: string) {
|
|
31
|
+
const href = `data:${mimeType};base64,${base64}`;
|
|
32
|
+
const link = document.createElement('a');
|
|
33
|
+
link.href = href;
|
|
34
|
+
link.download = fileName;
|
|
35
|
+
link.click();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function fileToBase64(file: File) {
|
|
39
|
+
return new Promise<string>((resolve, reject) => {
|
|
40
|
+
const reader = new FileReader();
|
|
41
|
+
reader.onload = () => {
|
|
42
|
+
const result = String(reader.result ?? '');
|
|
43
|
+
const [, base64 = ''] = result.split(',');
|
|
44
|
+
resolve(base64);
|
|
45
|
+
};
|
|
46
|
+
reader.onerror = reject;
|
|
47
|
+
reader.readAsDataURL(file);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default function OperationsContractsPage() {
|
|
52
|
+
const t = useTranslations('operations.ContractsPage');
|
|
53
|
+
const commonT = useTranslations('operations.Common');
|
|
54
|
+
const { request, showToastHandler, currentLocaleCode } = useApp();
|
|
55
|
+
const access = useOperationsAccess();
|
|
56
|
+
const [search, setSearch] = useState('');
|
|
57
|
+
const [statusFilter, setStatusFilter] = useState('all');
|
|
58
|
+
const [categoryFilter, setCategoryFilter] = useState('all');
|
|
59
|
+
const [originFilter, setOriginFilter] = useState('all');
|
|
60
|
+
const uploadTargetRef = useRef<number | null>(null);
|
|
61
|
+
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
62
|
+
|
|
63
|
+
const { data: contracts = [], refetch } = useQuery<OperationsContract[]>({
|
|
64
|
+
queryKey: ['operations-contracts-list', currentLocaleCode],
|
|
65
|
+
queryFn: () => fetchOperations<OperationsContract[]>(request, '/operations/contracts'),
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const filteredRows = useMemo(
|
|
69
|
+
() =>
|
|
70
|
+
contracts.filter((item) => {
|
|
71
|
+
const matchesSearch = !search.trim()
|
|
72
|
+
? true
|
|
73
|
+
: [
|
|
74
|
+
item.name,
|
|
75
|
+
item.code,
|
|
76
|
+
item.mainRelatedPartyName,
|
|
77
|
+
item.clientName,
|
|
78
|
+
item.contractType,
|
|
79
|
+
]
|
|
80
|
+
.filter(Boolean)
|
|
81
|
+
.some((value) =>
|
|
82
|
+
String(value).toLowerCase().includes(search.trim().toLowerCase())
|
|
83
|
+
);
|
|
84
|
+
const matchesStatus = statusFilter === 'all' ? true : item.status === statusFilter;
|
|
85
|
+
const matchesCategory =
|
|
86
|
+
categoryFilter === 'all' ? true : item.contractCategory === categoryFilter;
|
|
87
|
+
const matchesOrigin =
|
|
88
|
+
originFilter === 'all' ? true : item.originType === originFilter;
|
|
89
|
+
return matchesSearch && matchesStatus && matchesCategory && matchesOrigin;
|
|
90
|
+
}),
|
|
91
|
+
[contracts, search, statusFilter, categoryFilter, originFilter]
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const downloadPdf = async (contractId: number) => {
|
|
95
|
+
const detail = await fetchOperations<OperationsContractDetails>(
|
|
96
|
+
request,
|
|
97
|
+
`/operations/contracts/${contractId}`
|
|
98
|
+
);
|
|
99
|
+
const document = detail.documents.find((item) => item.isCurrent && item.fileContentBase64);
|
|
100
|
+
if (!document?.fileContentBase64) {
|
|
101
|
+
showToastHandler?.('error', t('messages.noPdf'));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
downloadBase64File(document.fileName, document.mimeType, document.fileContentBase64);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const duplicateContract = async (contractId: number) => {
|
|
108
|
+
window.location.href = `/operations/contracts/new?duplicate=${contractId}`;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const toggleArchived = async (contract: OperationsContract) => {
|
|
112
|
+
try {
|
|
113
|
+
await mutateOperations(request, `/operations/contracts/${contract.id}`, 'PATCH', {
|
|
114
|
+
status: contract.status === 'archived' ? 'active' : 'archived',
|
|
115
|
+
isActive: contract.status === 'archived',
|
|
116
|
+
});
|
|
117
|
+
showToastHandler?.('success', t('messages.statusSuccess'));
|
|
118
|
+
await refetch();
|
|
119
|
+
} catch {
|
|
120
|
+
showToastHandler?.('error', t('messages.statusError'));
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<Page>
|
|
126
|
+
<OperationsHeader
|
|
127
|
+
title={t('title')}
|
|
128
|
+
description={t('description')}
|
|
129
|
+
current={t('breadcrumb')}
|
|
130
|
+
actions={
|
|
131
|
+
access.isDirector ? (
|
|
132
|
+
<Button size="sm" asChild>
|
|
133
|
+
<Link href="/operations/contracts/new">{commonT('actions.create')}</Link>
|
|
134
|
+
</Button>
|
|
135
|
+
) : undefined
|
|
136
|
+
}
|
|
137
|
+
/>
|
|
138
|
+
|
|
139
|
+
<SearchBar
|
|
140
|
+
searchQuery={search}
|
|
141
|
+
onSearchChange={setSearch}
|
|
142
|
+
onSearch={() => undefined}
|
|
143
|
+
placeholder={t('searchPlaceholder')}
|
|
144
|
+
controls={[
|
|
145
|
+
{
|
|
146
|
+
id: 'category',
|
|
147
|
+
type: 'select',
|
|
148
|
+
value: categoryFilter,
|
|
149
|
+
onChange: setCategoryFilter,
|
|
150
|
+
placeholder: commonT('labels.contractCategory'),
|
|
151
|
+
options: [{ value: 'all', label: commonT('filters.allTypes') }, ...['employee','contractor','client','supplier','vendor','partner','internal','other'].map((value) => ({ value, label: formatEnumLabel(value) }))],
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: 'origin',
|
|
155
|
+
type: 'select',
|
|
156
|
+
value: originFilter,
|
|
157
|
+
onChange: setOriginFilter,
|
|
158
|
+
placeholder: t('filters.originType'),
|
|
159
|
+
options: [{ value: 'all', label: commonT('filters.allTypes') }, ...['manual','employee_hiring','client_project'].map((value) => ({ value, label: formatEnumLabel(value) }))],
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: 'status',
|
|
163
|
+
type: 'select',
|
|
164
|
+
value: statusFilter,
|
|
165
|
+
onChange: setStatusFilter,
|
|
166
|
+
placeholder: commonT('labels.status'),
|
|
167
|
+
options: [{ value: 'all', label: commonT('filters.allStatuses') }, ...['draft','under_review','active','renewal','expired','closed','archived'].map((value) => ({ value, label: formatEnumLabel(value) }))],
|
|
168
|
+
},
|
|
169
|
+
]}
|
|
170
|
+
/>
|
|
171
|
+
|
|
172
|
+
<input
|
|
173
|
+
ref={fileInputRef}
|
|
174
|
+
type="file"
|
|
175
|
+
accept="application/pdf"
|
|
176
|
+
className="hidden"
|
|
177
|
+
onChange={async (event) => {
|
|
178
|
+
const file = event.target.files?.[0];
|
|
179
|
+
const contractId = uploadTargetRef.current;
|
|
180
|
+
if (!file || !contractId) return;
|
|
181
|
+
try {
|
|
182
|
+
const fileContentBase64 = await fileToBase64(file);
|
|
183
|
+
await mutateOperations(request, `/operations/contracts/${contractId}`, 'PATCH', {
|
|
184
|
+
replaceUploadedPdfDocument: {
|
|
185
|
+
fileName: file.name,
|
|
186
|
+
mimeType: file.type || 'application/pdf',
|
|
187
|
+
fileContentBase64,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
showToastHandler?.('success', t('messages.uploadSuccess'));
|
|
191
|
+
await refetch();
|
|
192
|
+
} catch {
|
|
193
|
+
showToastHandler?.('error', t('messages.uploadError'));
|
|
194
|
+
} finally {
|
|
195
|
+
uploadTargetRef.current = null;
|
|
196
|
+
event.target.value = '';
|
|
197
|
+
}
|
|
198
|
+
}}
|
|
199
|
+
/>
|
|
200
|
+
|
|
201
|
+
{filteredRows.length ? (
|
|
202
|
+
<div className="overflow-x-auto rounded-md border">
|
|
203
|
+
<Table>
|
|
204
|
+
<TableHeader>
|
|
205
|
+
<TableRow>
|
|
206
|
+
<TableHead>{t('columns.title')}</TableHead>
|
|
207
|
+
<TableHead>{t('columns.code')}</TableHead>
|
|
208
|
+
<TableHead>{commonT('labels.contractCategory')}</TableHead>
|
|
209
|
+
<TableHead>{t('columns.type')}</TableHead>
|
|
210
|
+
<TableHead>{t('columns.origin')}</TableHead>
|
|
211
|
+
<TableHead>{t('columns.party')}</TableHead>
|
|
212
|
+
<TableHead>{commonT('labels.startDate')}</TableHead>
|
|
213
|
+
<TableHead>{commonT('labels.endDate')}</TableHead>
|
|
214
|
+
<TableHead>{t('columns.signatureStatus')}</TableHead>
|
|
215
|
+
<TableHead>{t('columns.active')}</TableHead>
|
|
216
|
+
<TableHead>{t('columns.financials')}</TableHead>
|
|
217
|
+
<TableHead>{commonT('labels.status')}</TableHead>
|
|
218
|
+
<TableHead className="w-[320px] text-right">{commonT('labels.actions')}</TableHead>
|
|
219
|
+
</TableRow>
|
|
220
|
+
</TableHeader>
|
|
221
|
+
<TableBody>
|
|
222
|
+
{filteredRows.map((contract) => (
|
|
223
|
+
<TableRow key={contract.id}>
|
|
224
|
+
<TableCell>{contract.name}</TableCell>
|
|
225
|
+
<TableCell>{contract.code}</TableCell>
|
|
226
|
+
<TableCell>{formatEnumLabel(contract.contractCategory)}</TableCell>
|
|
227
|
+
<TableCell>{formatEnumLabel(contract.contractType)}</TableCell>
|
|
228
|
+
<TableCell>{formatEnumLabel(contract.originType)}</TableCell>
|
|
229
|
+
<TableCell>{contract.mainRelatedPartyName || commonT('labels.notAvailable')}</TableCell>
|
|
230
|
+
<TableCell>{formatDate(contract.startDate)}</TableCell>
|
|
231
|
+
<TableCell>{formatDate(contract.endDate)}</TableCell>
|
|
232
|
+
<TableCell><StatusBadge label={formatEnumLabel(contract.signatureStatus)} className={getStatusBadgeClass(contract.signatureStatus)} /></TableCell>
|
|
233
|
+
<TableCell>{contract.isActive ? t('labels.active') : t('labels.inactive')}</TableCell>
|
|
234
|
+
<TableCell>{formatCurrency((contract.valueAmount ?? 0) + (contract.revenueAmount ?? 0))}</TableCell>
|
|
235
|
+
<TableCell><StatusBadge label={formatEnumLabel(contract.status)} className={getStatusBadgeClass(contract.status)} /></TableCell>
|
|
236
|
+
<TableCell>
|
|
237
|
+
<div className="flex justify-end gap-2">
|
|
238
|
+
<Button variant="outline" size="icon" asChild><Link href={`/operations/contracts/${contract.id}`}><Eye className="size-4" /></Link></Button>
|
|
239
|
+
{access.isDirector ? <Button variant="outline" size="icon" asChild><Link href={`/operations/contracts/${contract.id}/edit`}><Pencil className="size-4" /></Link></Button> : null}
|
|
240
|
+
<Button variant="outline" size="icon" onClick={() => void downloadPdf(contract.id)}><Download className="size-4" /></Button>
|
|
241
|
+
{access.isDirector ? <Button variant="outline" size="icon" onClick={() => { uploadTargetRef.current = contract.id; fileInputRef.current?.click(); }}><Upload className="size-4" /></Button> : null}
|
|
242
|
+
{access.isDirector ? <Button variant="outline" size="sm" onClick={() => void duplicateContract(contract.id)}>{t('actions.duplicate')}</Button> : null}
|
|
243
|
+
{access.isDirector ? <Button variant="outline" size="sm" onClick={() => void toggleArchived(contract)}>{contract.status === 'archived' ? commonT('actions.activate') : t('actions.archive')}</Button> : null}
|
|
244
|
+
</div>
|
|
245
|
+
</TableCell>
|
|
246
|
+
</TableRow>
|
|
247
|
+
))}
|
|
248
|
+
</TableBody>
|
|
249
|
+
</Table>
|
|
250
|
+
</div>
|
|
251
|
+
) : (
|
|
252
|
+
<EmptyState
|
|
253
|
+
icon={<FileText className="size-12" />}
|
|
254
|
+
title={commonT('states.emptyTitle')}
|
|
255
|
+
description={t('emptyDescription')}
|
|
256
|
+
actionLabel={access.isDirector ? commonT('actions.create') : commonT('actions.refresh')}
|
|
257
|
+
onAction={access.isDirector ? () => { window.location.href = '/operations/contracts/new'; } : () => void refetch()}
|
|
258
|
+
/>
|
|
259
|
+
)}
|
|
260
|
+
</Page>
|
|
261
|
+
);
|
|
262
|
+
}
|