144 lines
4.1 KiB
TypeScript
144 lines
4.1 KiB
TypeScript
import { apiRequest } from './api';
|
|
|
|
export type InspectionReportStatus = 'WORKING' | 'OFFICIALIZED' | 'FROZEN' | 'CANCELLED';
|
|
export type InspectionReportFollowUpType =
|
|
| 'COMPANY_NOTE'
|
|
| 'COMPANY_DOCUMENT'
|
|
| 'INTERNAL_NOTE'
|
|
| 'VERIFICATION'
|
|
| 'OTHER';
|
|
|
|
export interface InspectionReportDetailF4 {
|
|
id: string;
|
|
visitId: string;
|
|
actId: string;
|
|
reportYear: number;
|
|
reportNumber: number;
|
|
code: string;
|
|
status: InspectionReportStatus;
|
|
executiveSummary: string | null;
|
|
reportDescription: string | null;
|
|
gedoIfIdentifier: string | null;
|
|
gedoOfficializedAt: string | null;
|
|
gedoPdfOriginalName: string | null;
|
|
gedoPdfSha256: string | null;
|
|
pdfStatus: 'PENDING' | 'READY' | 'FAILED';
|
|
wordStatus: 'PENDING' | 'READY' | 'FAILED';
|
|
wordGeneratedAt: string | null;
|
|
title: string;
|
|
actVersion: number;
|
|
actClosureSha256: string;
|
|
frozenSha256: string;
|
|
generatedAt: string;
|
|
generatedBy: { id: string; username: string; firstName: string; lastName: string };
|
|
act: {
|
|
id: string;
|
|
code: string;
|
|
title: string;
|
|
status: string;
|
|
occurredAt: string;
|
|
sealedAt: string | null;
|
|
urgency: string;
|
|
deadlineAt: string | null;
|
|
};
|
|
visit: { id: string; code: string; title: string; status: string };
|
|
companies: Array<{ id: string; code: string; name: string }>;
|
|
areas: Array<{ id: string; code: string; name: string }>;
|
|
findingCount: number;
|
|
}
|
|
|
|
export interface InspectionReportFollowUp {
|
|
id: string;
|
|
reportId: string;
|
|
type: InspectionReportFollowUpType;
|
|
externalReference: string | null;
|
|
occurredAt: string;
|
|
description: string | null;
|
|
originalName: string | null;
|
|
mimeType: string | null;
|
|
sizeBytes: number | null;
|
|
sha256: string | null;
|
|
createdBy: string | null;
|
|
createdAt: string;
|
|
}
|
|
|
|
export interface InspectionReportWorkflowView {
|
|
id: string;
|
|
actId: string;
|
|
visitId: string;
|
|
code: string;
|
|
status: InspectionReportStatus;
|
|
executiveSummary: string | null;
|
|
reportDescription: string | null;
|
|
gedoIfIdentifier: string | null;
|
|
gedoOfficializedAt: string | null;
|
|
act: {
|
|
code: string;
|
|
urgency: string;
|
|
deadlineDays: number | null;
|
|
deadlineDayType: 'BUSINESS' | 'CALENDAR' | null;
|
|
deadlineBasis: string | null;
|
|
deadlineBaseAt: string | null;
|
|
deadlineAt: string | null;
|
|
} | null;
|
|
followUps: InspectionReportFollowUp[];
|
|
}
|
|
|
|
export function getInspectionReportF4(id: string) {
|
|
return apiRequest<InspectionReportDetailF4>(`/inspection-reports/${id}`);
|
|
}
|
|
|
|
export function listInspectionReportFollowUps(id: string) {
|
|
return apiRequest<InspectionReportFollowUp[]>(`/inspection-reports/${id}/follow-ups`);
|
|
}
|
|
|
|
export function updateInspectionReportNarrative(
|
|
id: string,
|
|
input: { executiveSummary?: string | null; description?: string | null },
|
|
) {
|
|
return apiRequest<InspectionReportWorkflowView>(`/inspection-reports/${id}`, {
|
|
method: 'PATCH',
|
|
body: JSON.stringify(input),
|
|
});
|
|
}
|
|
|
|
export function officializeInspectionReport(
|
|
id: string,
|
|
input: { gedoIfIdentifier: string; gedoOfficializedAt: string; file: File },
|
|
) {
|
|
const body = new FormData();
|
|
body.set('gedoIfIdentifier', input.gedoIfIdentifier);
|
|
body.set('gedoOfficializedAt', input.gedoOfficializedAt);
|
|
body.set('file', input.file);
|
|
return apiRequest<InspectionReportWorkflowView>(`/inspection-reports/${id}/officialize`, {
|
|
method: 'POST',
|
|
body,
|
|
});
|
|
}
|
|
|
|
export function addInspectionReportFollowUp(
|
|
id: string,
|
|
input: {
|
|
type: InspectionReportFollowUpType;
|
|
occurredAt: string;
|
|
externalReference?: string | null;
|
|
description?: string | null;
|
|
file?: File | null;
|
|
},
|
|
) {
|
|
const body = new FormData();
|
|
body.set('type', input.type);
|
|
body.set('occurredAt', input.occurredAt);
|
|
if (input.externalReference?.trim()) body.set('externalReference', input.externalReference.trim());
|
|
if (input.description?.trim()) body.set('description', input.description.trim());
|
|
if (input.file) body.set('file', input.file);
|
|
return apiRequest<InspectionReportFollowUp[]>(`/inspection-reports/${id}/follow-ups`, {
|
|
method: 'POST',
|
|
body,
|
|
});
|
|
}
|
|
|
|
export function inspectionReportWordDownloadUrl(id: string) {
|
|
return `/api/v3/inspection-reports/${id}/word`;
|
|
}
|