diff --git a/package.json b/package.json index 8f131640..8c2736d5 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "type": "module", "dependencies": { "@headlessui/react": "^1.7.17", - "@pzh-ui/components": "^0.0.463", + "@pzh-ui/components": "^0.0.465", "@pzh-ui/config": "^0.0.56", - "@pzh-ui/css": "^0.0.79", + "@pzh-ui/css": "^0.0.80", "@pzh-ui/icons": "^0.0.50", "@react-hookz/web": "^24.0.2", "@tanstack/react-query": "^5.14.2", diff --git a/src/api/fetchers.msw.ts b/src/api/fetchers.msw.ts index 03436946..29e913d3 100644 --- a/src/api/fetchers.msw.ts +++ b/src/api/fetchers.msw.ts @@ -10,7 +10,13 @@ */ import { faker } from '@faker-js/faker' import { HttpResponse, delay, http } from 'msw' -import { GraphEdgeType } from './fetchers.schemas' +import { + AppExtensionsPublicationsEnumsDocumentType, + GraphEdgeType, + PackageEventType, + ProcedureStepType, + ProcedureType, +} from './fetchers.schemas' export const getAmbitiesValidGetMock = () => ({ limit: faker.helpers.arrayElement([ @@ -11848,6 +11854,849 @@ export const getObjectsValidGetMock = () => ({ total: faker.number.int({ min: undefined, max: undefined }), }) +export const getPublicationsGetMock = () => ({ + limit: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + offset: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + results: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Document_Type: faker.helpers.arrayElement( + Object.values(AppExtensionsPublicationsEnumsDocumentType) + ), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Module_ID: faker.number.int({ min: undefined, max: undefined }), + Official_Title: faker.word.sample(), + Regulation_Title: faker.word.sample(), + Template_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + UUID: faker.string.uuid(), + Work_ID: faker.number.int({ min: undefined, max: undefined }), + })), + total: faker.number.int({ min: undefined, max: undefined }), +}) + +export const getPublicationsPostMock = () => ({ + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Document_Type: faker.helpers.arrayElement( + Object.values(AppExtensionsPublicationsEnumsDocumentType) + ), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Module_ID: faker.number.int({ min: undefined, max: undefined }), + Official_Title: faker.word.sample(), + Regulation_Title: faker.word.sample(), + Template_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + UUID: faker.string.uuid(), + Work_ID: faker.number.int({ min: undefined, max: undefined }), +}) + +export const getPublicationsPublicationUuidGetMock = () => ({ + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Document_Type: faker.helpers.arrayElement( + Object.values(AppExtensionsPublicationsEnumsDocumentType) + ), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Module_ID: faker.number.int({ min: undefined, max: undefined }), + Official_Title: faker.word.sample(), + Regulation_Title: faker.word.sample(), + Template_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + UUID: faker.string.uuid(), + Work_ID: faker.number.int({ min: undefined, max: undefined }), +}) + +export const getPublicationsPublicationUuidPatchMock = () => ({ + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Document_Type: faker.helpers.arrayElement( + Object.values(AppExtensionsPublicationsEnumsDocumentType) + ), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Module_ID: faker.number.int({ min: undefined, max: undefined }), + Official_Title: faker.word.sample(), + Regulation_Title: faker.word.sample(), + Template_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + UUID: faker.string.uuid(), + Work_ID: faker.number.int({ min: undefined, max: undefined }), +}) + +export const getPublicationsPublicationUuidBillsGetMock = () => ({ + limit: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + offset: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + results: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Is_Official: faker.datatype.boolean(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Module_Status_ID: faker.number.int({ min: undefined, max: undefined }), + Procedure_Type: faker.helpers.arrayElement( + Object.values(ProcedureType) + ), + Publication_UUID: faker.string.uuid(), + UUID: faker.string.uuid(), + Version_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + })), + total: faker.number.int({ min: undefined, max: undefined }), +}) + +export const getPublicationsPublicationUuidBillsPostMock = () => ({ + Announcement_Date: faker.date.past().toISOString().split('T')[0], + Bill_Data: faker.helpers.arrayElement([ + { + Amendment_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + Articles: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + })), + undefined, + ]), + Bill_Title: faker.word.sample(), + Closing: faker.word.sample(), + Preamble: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Regulation_Title: faker.word.sample(), + Signature: faker.word.sample(), + Time_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Effective_Date: faker.date.past().toISOString().split('T')[0], + Is_Official: faker.datatype.boolean(), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Module_Status_ID: faker.number.int({ min: undefined, max: undefined }), + Procedure_Data: faker.helpers.arrayElement([ + { + Announcement_Date: faker.date.past().toISOString().split('T')[0], + Steps: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Conclusion_Date: faker.date.past().toISOString().split('T')[0], + Step_Type: faker.helpers.arrayElement( + Object.values(ProcedureStepType) + ), + })), + }, + undefined, + ]), + Procedure_Type: faker.helpers.arrayElement(Object.values(ProcedureType)), + Publication_UUID: faker.string.uuid(), + PZH_Bill_Identifier: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + UUID: faker.string.uuid(), + Version_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), +}) + +export const getPublicationsPublicationUuidBillsBillUuidGetMock = () => ({ + Announcement_Date: faker.date.past().toISOString().split('T')[0], + Bill_Data: faker.helpers.arrayElement([ + { + Amendment_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + Articles: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + })), + undefined, + ]), + Bill_Title: faker.word.sample(), + Closing: faker.word.sample(), + Preamble: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Regulation_Title: faker.word.sample(), + Signature: faker.word.sample(), + Time_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Effective_Date: faker.date.past().toISOString().split('T')[0], + Is_Official: faker.datatype.boolean(), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Module_Status_ID: faker.number.int({ min: undefined, max: undefined }), + Procedure_Data: faker.helpers.arrayElement([ + { + Announcement_Date: faker.date.past().toISOString().split('T')[0], + Steps: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Conclusion_Date: faker.date.past().toISOString().split('T')[0], + Step_Type: faker.helpers.arrayElement( + Object.values(ProcedureStepType) + ), + })), + }, + undefined, + ]), + Procedure_Type: faker.helpers.arrayElement(Object.values(ProcedureType)), + Publication_UUID: faker.string.uuid(), + PZH_Bill_Identifier: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + UUID: faker.string.uuid(), + Version_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), +}) + +export const getPublicationsPublicationUuidBillsBillUuidPatchMock = () => ({ + Announcement_Date: faker.date.past().toISOString().split('T')[0], + Bill_Data: faker.helpers.arrayElement([ + { + Amendment_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + Articles: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + })), + undefined, + ]), + Bill_Title: faker.word.sample(), + Closing: faker.word.sample(), + Preamble: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Regulation_Title: faker.word.sample(), + Signature: faker.word.sample(), + Time_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Effective_Date: faker.date.past().toISOString().split('T')[0], + Is_Official: faker.datatype.boolean(), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Module_Status_ID: faker.number.int({ min: undefined, max: undefined }), + Procedure_Data: faker.helpers.arrayElement([ + { + Announcement_Date: faker.date.past().toISOString().split('T')[0], + Steps: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Conclusion_Date: faker.date.past().toISOString().split('T')[0], + Step_Type: faker.helpers.arrayElement( + Object.values(ProcedureStepType) + ), + })), + }, + undefined, + ]), + Procedure_Type: faker.helpers.arrayElement(Object.values(ProcedureType)), + Publication_UUID: faker.string.uuid(), + PZH_Bill_Identifier: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + UUID: faker.string.uuid(), + Version_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), +}) + +export const getPublicationBillsBillUuidPackagesGetMock = () => ({ + limit: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + offset: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + results: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Announcement_Date: faker.date.past().toISOString().split('T')[0], + Bill_UUID: faker.string.uuid(), + Config_ID: faker.number.int({ min: undefined, max: undefined }), + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + FRBR_ID: faker.number.int({ min: undefined, max: undefined }), + FRBR_Info: faker.helpers.arrayElement([ + { + act_expression_date: faker.date + .past() + .toISOString() + .split('T')[0], + act_expression_lang: faker.word.sample(), + act_expression_misc: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + act_expression_version: faker.word.sample(), + act_work_country: faker.word.sample(), + act_work_date: faker.word.sample(), + act_work_misc: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + bill_expression_date: faker.date + .past() + .toISOString() + .split('T')[0], + bill_expression_lang: faker.word.sample(), + bill_expression_misc: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + bill_expression_version: faker.word.sample(), + bill_work_country: faker.word.sample(), + bill_work_date: faker.word.sample(), + bill_work_misc: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Created_Date: `${ + faker.date.past().toISOString().split('.')[0] + }Z`, + ID: faker.number.int({ min: undefined, max: undefined }), + }, + undefined, + ]), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Package_Event_Type: faker.helpers.arrayElement( + Object.values(PackageEventType) + ), + Publication_Bill: faker.helpers.arrayElement([ + { + Announcement_Date: faker.date + .past() + .toISOString() + .split('T')[0], + Bill_Data: faker.helpers.arrayElement([ + { + Amendment_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + Articles: faker.helpers.arrayElement([ + Array.from( + { + length: faker.number.int({ + min: 1, + max: 10, + }), + }, + (_, i) => i + 1 + ).map(() => ({ + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + })), + undefined, + ]), + Bill_Title: faker.word.sample(), + Closing: faker.word.sample(), + Preamble: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Regulation_Title: faker.word.sample(), + Signature: faker.word.sample(), + Time_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + Created_By_UUID: faker.string.uuid(), + Created_Date: `${ + faker.date.past().toISOString().split('.')[0] + }Z`, + Effective_Date: faker.date.past().toISOString().split('T')[0], + Is_Official: faker.datatype.boolean(), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${ + faker.date.past().toISOString().split('.')[0] + }Z`, + Module_Status_ID: faker.number.int({ + min: undefined, + max: undefined, + }), + Procedure_Data: faker.helpers.arrayElement([ + { + Announcement_Date: faker.date + .past() + .toISOString() + .split('T')[0], + Steps: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Conclusion_Date: faker.date + .past() + .toISOString() + .split('T')[0], + Step_Type: faker.helpers.arrayElement( + Object.values(ProcedureStepType) + ), + })), + }, + undefined, + ]), + Procedure_Type: faker.helpers.arrayElement( + Object.values(ProcedureType) + ), + Publication_UUID: faker.string.uuid(), + PZH_Bill_Identifier: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + UUID: faker.string.uuid(), + Version_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + }, + undefined, + ]), + Publication_Config: faker.helpers.arrayElement([ + { + Act_Componentname: faker.word.sample(), + Authority_ID: faker.word.sample(), + Created_Date: `${ + faker.date.past().toISOString().split('.')[0] + }Z`, + DSO_BHKV_VERSION: faker.word.sample(), + DSO_STOP_VERSION: faker.word.sample(), + DSO_TPOD_VERSION: faker.word.sample(), + Governing_Body_Type: faker.word.sample(), + ID: faker.number.int({ min: undefined, max: undefined }), + Jurisdiction: faker.word.sample(), + Province_ID: faker.word.sample(), + Subjects: faker.word.sample(), + Submitter_ID: faker.word.sample(), + }, + undefined, + ]), + Publication_Filename: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Reports: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Created_By_UUID: faker.string.uuid(), + Created_Date: `${ + faker.date.past().toISOString().split('.')[0] + }Z`, + ID: faker.number.int({ min: undefined, max: undefined }), + Messages: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Package_UUID: faker.string.uuid(), + Report_Timestamp: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + Report_Type: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Result: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + })), + undefined, + ]), + UUID: faker.string.uuid(), + Validation_Status: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + ZIP_File_Checksum: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + ZIP_File_Name: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + })), + total: faker.number.int({ min: undefined, max: undefined }), +}) + +export const getPublicationBillsBillUuidPackagesPostMock = () => ({ + Announcement_Date: faker.date.past().toISOString().split('T')[0], + Bill_UUID: faker.string.uuid(), + Config_ID: faker.number.int({ min: undefined, max: undefined }), + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + FRBR_ID: faker.number.int({ min: undefined, max: undefined }), + FRBR_Info: faker.helpers.arrayElement([ + { + act_expression_date: faker.date.past().toISOString().split('T')[0], + act_expression_lang: faker.word.sample(), + act_expression_misc: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + act_expression_version: faker.word.sample(), + act_work_country: faker.word.sample(), + act_work_date: faker.word.sample(), + act_work_misc: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + bill_expression_date: faker.date.past().toISOString().split('T')[0], + bill_expression_lang: faker.word.sample(), + bill_expression_misc: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + bill_expression_version: faker.word.sample(), + bill_work_country: faker.word.sample(), + bill_work_date: faker.word.sample(), + bill_work_misc: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + ID: faker.number.int({ min: undefined, max: undefined }), + }, + undefined, + ]), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Package_Event_Type: faker.helpers.arrayElement( + Object.values(PackageEventType) + ), + Publication_Bill: faker.helpers.arrayElement([ + { + Announcement_Date: faker.date.past().toISOString().split('T')[0], + Bill_Data: faker.helpers.arrayElement([ + { + Amendment_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + Articles: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + })), + undefined, + ]), + Bill_Title: faker.word.sample(), + Closing: faker.word.sample(), + Preamble: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Regulation_Title: faker.word.sample(), + Signature: faker.word.sample(), + Time_Article: faker.helpers.arrayElement([ + { + Content: faker.word.sample(), + Label: faker.word.sample(), + Number: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + }, + undefined, + ]), + }, + undefined, + ]), + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Effective_Date: faker.date.past().toISOString().split('T')[0], + Is_Official: faker.datatype.boolean(), + Modified_By_UUID: faker.string.uuid(), + Modified_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + Module_Status_ID: faker.number.int({ + min: undefined, + max: undefined, + }), + Procedure_Data: faker.helpers.arrayElement([ + { + Announcement_Date: faker.date + .past() + .toISOString() + .split('T')[0], + Steps: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Conclusion_Date: faker.date + .past() + .toISOString() + .split('T')[0], + Step_Type: faker.helpers.arrayElement( + Object.values(ProcedureStepType) + ), + })), + }, + undefined, + ]), + Procedure_Type: faker.helpers.arrayElement( + Object.values(ProcedureType) + ), + Publication_UUID: faker.string.uuid(), + PZH_Bill_Identifier: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + UUID: faker.string.uuid(), + Version_ID: faker.helpers.arrayElement([ + faker.number.int({ min: undefined, max: undefined }), + undefined, + ]), + }, + undefined, + ]), + Publication_Config: faker.helpers.arrayElement([ + { + Act_Componentname: faker.word.sample(), + Authority_ID: faker.word.sample(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + DSO_BHKV_VERSION: faker.word.sample(), + DSO_STOP_VERSION: faker.word.sample(), + DSO_TPOD_VERSION: faker.word.sample(), + Governing_Body_Type: faker.word.sample(), + ID: faker.number.int({ min: undefined, max: undefined }), + Jurisdiction: faker.word.sample(), + Province_ID: faker.word.sample(), + Subjects: faker.word.sample(), + Submitter_ID: faker.word.sample(), + }, + undefined, + ]), + Publication_Filename: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Reports: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1 + ).map(() => ({ + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + ID: faker.number.int({ min: undefined, max: undefined }), + Messages: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Package_UUID: faker.string.uuid(), + Report_Timestamp: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + Report_Type: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + Result: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + })), + undefined, + ]), + UUID: faker.string.uuid(), + Validation_Status: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + ZIP_File_Checksum: faker.helpers.arrayElement([ + faker.word.sample(), + undefined, + ]), + ZIP_File_Name: faker.helpers.arrayElement([faker.word.sample(), undefined]), +}) + +export const getPublicationPackagesPackageUuidReportPostMock = () => ({ + Created_By_UUID: faker.string.uuid(), + Created_Date: `${faker.date.past().toISOString().split('.')[0]}Z`, + ID: faker.number.int({ min: undefined, max: undefined }), + Messages: faker.helpers.arrayElement([faker.word.sample(), undefined]), + Package_UUID: faker.string.uuid(), + Report_Timestamp: faker.helpers.arrayElement([ + `${faker.date.past().toISOString().split('.')[0]}Z`, + undefined, + ]), + Report_Type: faker.helpers.arrayElement([faker.word.sample(), undefined]), + Result: faker.helpers.arrayElement([faker.word.sample(), undefined]), +}) + export const getLoginAccessTokenPostMock = () => ({ access_token: faker.word.sample(), identifier: { @@ -13727,6 +14576,24 @@ export const getOmgevingsbeleidAPIMock = () => [ } ) }), + http.post('*/playground/do-dso/:moduleId', async () => { + await delay(1000) + return new HttpResponse(null, { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }) + }), + http.get('*/playground/check-geo', async () => { + await delay(1000) + return new HttpResponse(null, { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }) + }), http.get('*/users', async () => { await delay(1000) return new HttpResponse(JSON.stringify(getUsersGetMock()), { @@ -14093,6 +14960,157 @@ export const getOmgevingsbeleidAPIMock = () => [ }, }) }), + http.get('*/publications', async () => { + await delay(1000) + return new HttpResponse(JSON.stringify(getPublicationsGetMock()), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }) + }), + http.post('*/publications', async () => { + await delay(1000) + return new HttpResponse(JSON.stringify(getPublicationsPostMock()), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }) + }), + http.get('*/publications/:publicationUuid', async () => { + await delay(1000) + return new HttpResponse( + JSON.stringify(getPublicationsPublicationUuidGetMock()), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + }), + http.patch('*/publications/:publicationUuid', async () => { + await delay(1000) + return new HttpResponse( + JSON.stringify(getPublicationsPublicationUuidPatchMock()), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + }), + http.get('*/publications/:publicationUuid/bills', async () => { + await delay(1000) + return new HttpResponse( + JSON.stringify(getPublicationsPublicationUuidBillsGetMock()), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + }), + http.post('*/publications/:publicationUuid/bills', async () => { + await delay(1000) + return new HttpResponse( + JSON.stringify(getPublicationsPublicationUuidBillsPostMock()), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + }), + http.get('*/publications/:publicationUuid/bills/:billUuid', async () => { + await delay(1000) + return new HttpResponse( + JSON.stringify( + getPublicationsPublicationUuidBillsBillUuidGetMock() + ), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + }), + http.patch('*/publications/:publicationUuid/bills/:billUuid', async () => { + await delay(1000) + return new HttpResponse( + JSON.stringify( + getPublicationsPublicationUuidBillsBillUuidPatchMock() + ), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + }), + http.get('*/publication-bills/:billUuid/packages', async () => { + await delay(1000) + return new HttpResponse( + JSON.stringify(getPublicationBillsBillUuidPackagesGetMock()), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + }), + http.post('*/publication-bills/:billUuid/packages', async () => { + await delay(1000) + return new HttpResponse( + JSON.stringify(getPublicationBillsBillUuidPackagesPostMock()), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + }), + http.post('*/publication-packages/:packageUuid/report', async () => { + await delay(1000) + return new HttpResponse( + JSON.stringify(getPublicationPackagesPackageUuidReportPostMock()), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + } + ) + }), + http.get( + '*/publication-packages/:packageUuid/report/download', + async () => { + await delay(1000) + return new HttpResponse(null, { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }) + } + ), + http.get('*/publication-packages/:packageUuid/download', async () => { + await delay(1000) + return new HttpResponse(null, { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }) + }), http.post('*/login/access-token', async () => { await delay(1000) return new HttpResponse(JSON.stringify(getLoginAccessTokenPostMock()), { diff --git a/src/api/fetchers.schemas.ts b/src/api/fetchers.schemas.ts index 0536d149..bdf074b3 100644 --- a/src/api/fetchers.schemas.ts +++ b/src/api/fetchers.schemas.ts @@ -13,6 +13,27 @@ export type PasswordResetPostParams = { new_password: string } +export type PublicationBillsBillUuidPackagesGetParams = { + package_event_type?: PackageEventType + is_successful?: boolean + offset?: number + limit?: number +} + +export type PublicationsPublicationUuidBillsGetParams = { + version_id?: number + module_status?: ModuleStatusCode + offset?: number + limit?: number +} + +export type PublicationsGetParams = { + document_type?: AppExtensionsPublicationsEnumsDocumentType + module_ID?: number + offset?: number + limit?: number +} + export type ObjectsValidGetParams = { owner_uuid?: string object_type?: string @@ -108,6 +129,13 @@ export type UsersGetParams = { sort_order?: SortOrder } +export type PlaygroundDoDsoModuleIdPostParams = { + work_version: string + document_type: DsoModelsDocumentType + geo_new?: boolean + opdracht_type?: OpdrachtType +} + export type WettelijkeTaakValidGetParams = { all_filters?: string any_filters?: string @@ -420,6 +448,31 @@ export type AmbitiesValidGetParams = { sort_order?: SortOrder } +/** + * An enumeration. + */ +export type DsoModelsDocumentType = + (typeof DsoModelsDocumentType)[keyof typeof DsoModelsDocumentType] + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const DsoModelsDocumentType = { + Programma: 'Programma', + Omgevingsvisie: 'Omgevingsvisie', +} as const + +/** + * An enumeration. + */ +export type AppExtensionsPublicationsEnumsDocumentType = + (typeof AppExtensionsPublicationsEnumsDocumentType)[keyof typeof AppExtensionsPublicationsEnumsDocumentType] + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const AppExtensionsPublicationsEnumsDocumentType = { + Omgevingsvisie: 'Omgevingsvisie', + Omgevingsprogramma: 'Omgevingsprogramma', + Omgevingsverordening: 'Omgevingsverordening', +} as const + export interface WriteRelation { Description?: string | null Object_ID: number @@ -791,6 +844,15 @@ export interface User { UUID: string } +/** + * tijd_artikel + */ +export interface TimeArticle { + Content: string + Label: string + Number?: string +} + /** * An enumeration. */ @@ -891,6 +953,156 @@ export interface ReadRelation { Title?: string | null } +export interface PublicationPackageReport { + Created_By_UUID: string + Created_Date: string + ID: number + Messages?: string + Package_UUID: string + Report_Timestamp?: string + Report_Type?: string + Result?: string +} + +export interface PublicationPackageCreate { + Announcement_Date?: string + Config_ID?: number + Package_Event_Type: PackageEventType +} + +export interface PublicationFRBR { + act_expression_date: string + act_expression_lang: string + act_expression_misc?: string + act_expression_version: string + act_work_country: string + act_work_date: string + act_work_misc?: string + bill_expression_date: string + bill_expression_lang: string + bill_expression_misc?: string + bill_expression_version: string + bill_work_country: string + bill_work_date: string + bill_work_misc?: string + Created_Date: string + ID: number +} + +export interface PublicationPackage { + Announcement_Date: string + Bill_UUID: string + Config_ID: number + Created_By_UUID: string + Created_Date: string + FRBR_ID: number + FRBR_Info?: PublicationFRBR + Modified_By_UUID: string + Modified_Date: string + Package_Event_Type: PackageEventType + Publication_Bill?: PublicationBill + Publication_Config?: PublicationConfig + Publication_Filename?: string + Reports?: PublicationPackageReport[] + UUID: string + Validation_Status?: string + ZIP_File_Checksum?: string + ZIP_File_Name?: string +} + +export interface PublicationEdit { + Official_Title?: string + Regulation_Title?: string + Template_ID?: number +} + +export interface PublicationCreate { + Document_Type: AppExtensionsPublicationsEnumsDocumentType + Module_ID: number + Official_Title: string + Regulation_Title: string + Template_ID?: number +} + +export interface PublicationConfig { + Act_Componentname: string + Authority_ID: string + Created_Date: string + DSO_BHKV_VERSION: string + DSO_STOP_VERSION: string + DSO_TPOD_VERSION: string + Governing_Body_Type: string + ID: number + Jurisdiction: string + Province_ID: string + Subjects: string + Submitter_ID: string +} + +export interface PublicationBillShort { + Created_Date: string + Is_Official: boolean + Modified_Date: string + Module_Status_ID: number + Procedure_Type: ProcedureType + Publication_UUID: string + UUID: string + Version_ID?: number +} + +export interface PublicationBillEdit { + Announcement_Date?: string + Bill_Data?: BillData + Effective_Date?: string + Procedure_Data?: ProcedureData +} + +export interface PublicationBillCreate { + Announcement_Date?: string + Bill_Data?: BillData + Effective_Date?: string + Is_Official: boolean + Module_Status_ID: number + Procedure_Data?: ProcedureData + Procedure_Type: ProcedureType + PZH_Bill_Identifier?: string +} + +/** + * STOP Besluit + */ +export interface PublicationBill { + Announcement_Date: string + Bill_Data?: BillData + Created_By_UUID: string + Created_Date: string + Effective_Date: string + Is_Official: boolean + Modified_By_UUID: string + Modified_Date: string + Module_Status_ID: number + Procedure_Data?: ProcedureData + Procedure_Type: ProcedureType + Publication_UUID: string + PZH_Bill_Identifier?: string + UUID: string + Version_ID?: number +} + +export interface Publication { + Created_By_UUID: string + Created_Date: string + Document_Type: AppExtensionsPublicationsEnumsDocumentType + Modified_By_UUID: string + Modified_Date: string + Module_ID: number + Official_Title: string + Regulation_Title: string + Template_ID?: number + UUID: string + Work_ID: number +} + export interface PublicModuleShort { Description: string Module_ID: number @@ -1002,6 +1214,52 @@ export interface ProgrammaAlgemeenBasic { UUID?: string } +/** + * An enumeration. + */ +export type ProcedureType = (typeof ProcedureType)[keyof typeof ProcedureType] + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const ProcedureType = { + Ontwerp: 'Ontwerp', + Definitief: 'Definitief', +} as const + +/** + * STOP ProcedureStappenDefinitief + */ +export type ProcedureStepType = + (typeof ProcedureStepType)[keyof typeof ProcedureStepType] + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const ProcedureStepType = { + Vaststelling: 'Vaststelling', + Ondertekening: 'Ondertekening', + Publicatie: 'Publicatie', + Einde_bezwaartermijn: 'Einde_bezwaartermijn', + Einde_beroepstermijn: 'Einde_beroepstermijn', + Start_beroepsprocedures: 'Start_beroepsprocedures', + Schorsing: 'Schorsing', + Opheffing_Schorsing: 'Opheffing_Schorsing', + Einde_beroepsprocedures: 'Einde_beroepsprocedures', +} as const + +/** + * STOP Procedurestap + */ +export interface ProcedureStep { + Conclusion_Date: string + Step_Type: ProcedureStepType +} + +/** + * STOP Procedureverloop + */ +export interface ProcedureData { + Announcement_Date: string + Steps: ProcedureStep[] +} + /** * Wrap any response schema and add pagination metadata. */ @@ -1102,6 +1360,36 @@ export interface PagedResponseSearchObject { total: number } +/** + * Wrap any response schema and add pagination metadata. + */ +export interface PagedResponsePublication { + limit?: number + offset?: number + results: Publication[] + total: number +} + +/** + * Wrap any response schema and add pagination metadata. + */ +export interface PagedResponsePublicationPackage { + limit?: number + offset?: number + results: PublicationPackage[] + total: number +} + +/** + * Wrap any response schema and add pagination metadata. + */ +export interface PagedResponsePublicationBillShort { + limit?: number + offset?: number + results: PublicationBillShort[] + total: number +} + /** * Wrap any response schema and add pagination metadata. */ @@ -1132,17 +1420,6 @@ export interface PagedResponseProgrammaAlgemeenBasic { total: number } -export interface NationaalBelangBasic { - Code?: string - Created_Date?: string - Modified_Date?: string - Object_ID?: number - Object_Type?: string - Title?: string - UUID?: string - Weblink?: string -} - /** * Wrap any response schema and add pagination metadata. */ @@ -1313,6 +1590,30 @@ export interface PagedResponseAmbitieBasic { total: number } +/** + * An enumeration. + */ +export type PackageEventType = + (typeof PackageEventType)[keyof typeof PackageEventType] + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const PackageEventType = { + Validatie: 'Validatie', + Publicatie: 'Publicatie', + Afbreken: 'Afbreken', +} as const + +/** + * An enumeration. + */ +export type OpdrachtType = (typeof OpdrachtType)[keyof typeof OpdrachtType] + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const OpdrachtType = { + PUBLICATIE: 'PUBLICATIE', + VALIDATIE: 'VALIDATIE', +} as const + export interface ObjectStaticShort { Client_1_UUID?: string Owner_1_UUID?: string @@ -1402,6 +1703,17 @@ export interface NationaalBelangCreate { Weblink?: string | null } +export interface NationaalBelangBasic { + Code?: string + Created_Date?: string + Modified_Date?: string + Object_ID?: number + Object_Type?: string + Title?: string + UUID?: string + Weblink?: string +} + /** * An enumeration. */ @@ -1910,6 +2222,10 @@ export interface CompleteModule { ObjectSpecifiekeGeldigheden?: ObjectSpecifiekeGeldigheid[] } +export interface BodyFastapiHandlerPublicationPackagesPackageUuidReportPost { + xml_file: Blob +} + export interface BodyFastapiHandlerLoginAccessTokenPost { client_id?: string client_secret?: string @@ -1919,6 +2235,26 @@ export interface BodyFastapiHandlerLoginAccessTokenPost { username: string } +/** + * tekst_artikel + */ +export interface BillArticle { + Content: string + Label: string + Number?: string +} + +export interface BillData { + Amendment_Article?: AmendmentArticle + Articles?: BillArticle[] + Bill_Title: string + Closing: string + Preamble?: string + Regulation_Title: string + Signature: string + Time_Article?: TimeArticle +} + export interface BeleidsregelUUID { Object_ID?: number UUID?: string @@ -2238,6 +2574,15 @@ export interface AreaBasic { UUID: string } +/** + * STOP WijzigingArtikel + */ +export interface AmendmentArticle { + Content: string + Label: string + Number?: string +} + export interface AmbitieUUID { Object_ID?: number UUID?: string diff --git a/src/api/fetchers.ts b/src/api/fetchers.ts index 75f219c5..4859452f 100644 --- a/src/api/fetchers.ts +++ b/src/api/fetchers.ts @@ -48,6 +48,7 @@ import type { BeleidsregelsValidGetParams, BeleidsregelsValidLineageIdGetParams, BodyFastapiHandlerLoginAccessTokenPost, + BodyFastapiHandlerPublicationPackagesPackageUuidReportPost, CompleteModule, EditAcknowledgedRelation, EditUser, @@ -128,6 +129,9 @@ import type { PagedResponseProgrammaAlgemeenBasic, PagedResponseProgrammaAlgemeenExtended, PagedResponsePublicModuleShort, + PagedResponsePublication, + PagedResponsePublicationBillShort, + PagedResponsePublicationPackage, PagedResponseSearchObject, PagedResponseUser, PagedResponseValidSearchObject, @@ -139,6 +143,7 @@ import type { PagedResponseWerkingsgebiedExtended, PagedResponseWettelijkeTaakBasic, PasswordResetPostParams, + PlaygroundDoDsoModuleIdPostParams, ProgrammaAlgemeenFull, ProgrammaAlgemeenPatch, ProgrammaAlgemeenStaticPostStatics, @@ -146,6 +151,18 @@ import type { ProgrammasAlgemeenValidGetParams, ProgrammasAlgemeenValidLineageIdGetParams, PublicModuleOverview, + Publication, + PublicationBill, + PublicationBillCreate, + PublicationBillEdit, + PublicationBillsBillUuidPackagesGetParams, + PublicationCreate, + PublicationEdit, + PublicationPackage, + PublicationPackageCreate, + PublicationPackageReport, + PublicationsGetParams, + PublicationsPublicationUuidBillsGetParams, ReadRelation, RequestAcknowledgedRelation, ResetPasswordResponse, @@ -14331,6 +14348,150 @@ export const useWettelijkeTaakStaticLineageIdPost = < return useMutation(mutationOptions) } +/** + * @summary Download DSO + */ +export const playgroundDoDsoModuleIdPost = ( + moduleId: number, + params: PlaygroundDoDsoModuleIdPostParams +) => { + return customInstance({ + url: `/playground/do-dso/${moduleId}`, + method: 'POST', + params, + }) +} + +export const getPlaygroundDoDsoModuleIdPostMutationOptions = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { moduleId: number; params: PlaygroundDoDsoModuleIdPostParams }, + TContext + > +}): UseMutationOptions< + Awaited>, + TError, + { moduleId: number; params: PlaygroundDoDsoModuleIdPostParams }, + TContext +> => { + const { mutation: mutationOptions } = options ?? {} + + const mutationFn: MutationFunction< + Awaited>, + { moduleId: number; params: PlaygroundDoDsoModuleIdPostParams } + > = props => { + const { moduleId, params } = props ?? {} + + return playgroundDoDsoModuleIdPost(moduleId, params) + } + + return { mutationFn, ...mutationOptions } +} + +export type PlaygroundDoDsoModuleIdPostMutationResult = NonNullable< + Awaited> +> + +export type PlaygroundDoDsoModuleIdPostMutationError = HTTPValidationError + +/** + * @summary Download DSO + */ +export const usePlaygroundDoDsoModuleIdPost = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { moduleId: number; params: PlaygroundDoDsoModuleIdPostParams }, + TContext + > +}) => { + const mutationOptions = + getPlaygroundDoDsoModuleIdPostMutationOptions(options) + + return useMutation(mutationOptions) +} + +/** + * @summary Check GEO + */ +export const playgroundCheckGeoGet = (signal?: AbortSignal) => { + return customInstance({ + url: `/playground/check-geo`, + method: 'GET', + signal, + }) +} + +export const getPlaygroundCheckGeoGetQueryKey = () => { + return [`/playground/check-geo`] as const +} + +export const getPlaygroundCheckGeoGetQueryOptions = < + TData = Awaited>, + TError = unknown +>(options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > +}) => { + const { query: queryOptions } = options ?? {} + + const queryKey = + queryOptions?.queryKey ?? getPlaygroundCheckGeoGetQueryKey() + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => playgroundCheckGeoGet(signal) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type PlaygroundCheckGeoGetQueryResult = NonNullable< + Awaited> +> +export type PlaygroundCheckGeoGetQueryError = unknown + +/** + * @summary Check GEO + */ +export const usePlaygroundCheckGeoGet = < + TData = Awaited>, + TError = unknown +>(options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > +}): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = getPlaygroundCheckGeoGetQueryOptions(options) + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey + } + + query.queryKey = queryOptions.queryKey + + return query +} + /** * @summary List the users */ @@ -17086,6 +17247,1206 @@ export const useObjectsValidGet = < return query } +/** + * @summary List the existing Publication + */ +export const publicationsGet = ( + params?: PublicationsGetParams, + signal?: AbortSignal +) => { + return customInstance({ + url: `/publications`, + method: 'GET', + params, + signal, + }) +} + +export const getPublicationsGetQueryKey = (params?: PublicationsGetParams) => { + return [`/publications`, ...(params ? [params] : [])] as const +} + +export const getPublicationsGetQueryOptions = < + TData = Awaited>, + TError = HTTPValidationError +>( + params?: PublicationsGetParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > + } +) => { + const { query: queryOptions } = options ?? {} + + const queryKey = + queryOptions?.queryKey ?? getPublicationsGetQueryKey(params) + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => publicationsGet(params, signal) + + return { queryKey, queryFn, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type PublicationsGetQueryResult = NonNullable< + Awaited> +> +export type PublicationsGetQueryError = HTTPValidationError + +/** + * @summary List the existing Publication + */ +export const usePublicationsGet = < + TData = Awaited>, + TError = HTTPValidationError +>( + params?: PublicationsGetParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = getPublicationsGetQueryOptions(params, options) + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey + } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * @summary Create a new publication + */ +export const publicationsPost = (publicationCreate: PublicationCreate) => { + return customInstance({ + url: `/publications`, + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + data: publicationCreate, + }) +} + +export const getPublicationsPostMutationOptions = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: PublicationCreate }, + TContext + > +}): UseMutationOptions< + Awaited>, + TError, + { data: PublicationCreate }, + TContext +> => { + const { mutation: mutationOptions } = options ?? {} + + const mutationFn: MutationFunction< + Awaited>, + { data: PublicationCreate } + > = props => { + const { data } = props ?? {} + + return publicationsPost(data) + } + + return { mutationFn, ...mutationOptions } +} + +export type PublicationsPostMutationResult = NonNullable< + Awaited> +> +export type PublicationsPostMutationBody = PublicationCreate +export type PublicationsPostMutationError = HTTPValidationError + +/** + * @summary Create a new publication + */ +export const usePublicationsPost = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: PublicationCreate }, + TContext + > +}) => { + const mutationOptions = getPublicationsPostMutationOptions(options) + + return useMutation(mutationOptions) +} + +/** + * @summary Get details of a publication + */ +export const publicationsPublicationUuidGet = ( + publicationUuid: string, + signal?: AbortSignal +) => { + return customInstance({ + url: `/publications/${publicationUuid}`, + method: 'GET', + signal, + }) +} + +export const getPublicationsPublicationUuidGetQueryKey = ( + publicationUuid: string +) => { + return [`/publications/${publicationUuid}`] as const +} + +export const getPublicationsPublicationUuidGetQueryOptions = < + TData = Awaited>, + TError = HTTPValidationError +>( + publicationUuid: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > + } +) => { + const { query: queryOptions } = options ?? {} + + const queryKey = + queryOptions?.queryKey ?? + getPublicationsPublicationUuidGetQueryKey(publicationUuid) + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => publicationsPublicationUuidGet(publicationUuid, signal) + + return { + queryKey, + queryFn, + enabled: !!publicationUuid, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type PublicationsPublicationUuidGetQueryResult = NonNullable< + Awaited> +> +export type PublicationsPublicationUuidGetQueryError = HTTPValidationError + +/** + * @summary Get details of a publication + */ +export const usePublicationsPublicationUuidGet = < + TData = Awaited>, + TError = HTTPValidationError +>( + publicationUuid: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = getPublicationsPublicationUuidGetQueryOptions( + publicationUuid, + options + ) + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey + } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * @summary Edit an existing publication + */ +export const publicationsPublicationUuidPatch = ( + publicationUuid: string, + publicationEdit: PublicationEdit +) => { + return customInstance({ + url: `/publications/${publicationUuid}`, + method: 'PATCH', + headers: { 'Content-Type': 'application/json' }, + data: publicationEdit, + }) +} + +export const getPublicationsPublicationUuidPatchMutationOptions = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { publicationUuid: string; data: PublicationEdit }, + TContext + > +}): UseMutationOptions< + Awaited>, + TError, + { publicationUuid: string; data: PublicationEdit }, + TContext +> => { + const { mutation: mutationOptions } = options ?? {} + + const mutationFn: MutationFunction< + Awaited>, + { publicationUuid: string; data: PublicationEdit } + > = props => { + const { publicationUuid, data } = props ?? {} + + return publicationsPublicationUuidPatch(publicationUuid, data) + } + + return { mutationFn, ...mutationOptions } +} + +export type PublicationsPublicationUuidPatchMutationResult = NonNullable< + Awaited> +> +export type PublicationsPublicationUuidPatchMutationBody = PublicationEdit +export type PublicationsPublicationUuidPatchMutationError = HTTPValidationError + +/** + * @summary Edit an existing publication + */ +export const usePublicationsPublicationUuidPatch = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { publicationUuid: string; data: PublicationEdit }, + TContext + > +}) => { + const mutationOptions = + getPublicationsPublicationUuidPatchMutationOptions(options) + + return useMutation(mutationOptions) +} + +/** + * @summary List the existing Publication Bills + */ +export const publicationsPublicationUuidBillsGet = ( + publicationUuid: string, + params?: PublicationsPublicationUuidBillsGetParams, + signal?: AbortSignal +) => { + return customInstance({ + url: `/publications/${publicationUuid}/bills`, + method: 'GET', + params, + signal, + }) +} + +export const getPublicationsPublicationUuidBillsGetQueryKey = ( + publicationUuid: string, + params?: PublicationsPublicationUuidBillsGetParams +) => { + return [ + `/publications/${publicationUuid}/bills`, + ...(params ? [params] : []), + ] as const +} + +export const getPublicationsPublicationUuidBillsGetQueryOptions = < + TData = Awaited>, + TError = HTTPValidationError +>( + publicationUuid: string, + params?: PublicationsPublicationUuidBillsGetParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > + } +) => { + const { query: queryOptions } = options ?? {} + + const queryKey = + queryOptions?.queryKey ?? + getPublicationsPublicationUuidBillsGetQueryKey(publicationUuid, params) + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + publicationsPublicationUuidBillsGet(publicationUuid, params, signal) + + return { + queryKey, + queryFn, + enabled: !!publicationUuid, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type PublicationsPublicationUuidBillsGetQueryResult = NonNullable< + Awaited> +> +export type PublicationsPublicationUuidBillsGetQueryError = HTTPValidationError + +/** + * @summary List the existing Publication Bills + */ +export const usePublicationsPublicationUuidBillsGet = < + TData = Awaited>, + TError = HTTPValidationError +>( + publicationUuid: string, + params?: PublicationsPublicationUuidBillsGetParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = getPublicationsPublicationUuidBillsGetQueryOptions( + publicationUuid, + params, + options + ) + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey + } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * @summary Create new publication Bill or version + */ +export const publicationsPublicationUuidBillsPost = ( + publicationUuid: string, + publicationBillCreate: PublicationBillCreate +) => { + return customInstance({ + url: `/publications/${publicationUuid}/bills`, + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + data: publicationBillCreate, + }) +} + +export const getPublicationsPublicationUuidBillsPostMutationOptions = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { publicationUuid: string; data: PublicationBillCreate }, + TContext + > +}): UseMutationOptions< + Awaited>, + TError, + { publicationUuid: string; data: PublicationBillCreate }, + TContext +> => { + const { mutation: mutationOptions } = options ?? {} + + const mutationFn: MutationFunction< + Awaited>, + { publicationUuid: string; data: PublicationBillCreate } + > = props => { + const { publicationUuid, data } = props ?? {} + + return publicationsPublicationUuidBillsPost(publicationUuid, data) + } + + return { mutationFn, ...mutationOptions } +} + +export type PublicationsPublicationUuidBillsPostMutationResult = NonNullable< + Awaited> +> +export type PublicationsPublicationUuidBillsPostMutationBody = + PublicationBillCreate +export type PublicationsPublicationUuidBillsPostMutationError = + HTTPValidationError + +/** + * @summary Create new publication Bill or version + */ +export const usePublicationsPublicationUuidBillsPost = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { publicationUuid: string; data: PublicationBillCreate }, + TContext + > +}) => { + const mutationOptions = + getPublicationsPublicationUuidBillsPostMutationOptions(options) + + return useMutation(mutationOptions) +} + +/** + * @summary Get details of a publication bill + */ +export const publicationsPublicationUuidBillsBillUuidGet = ( + publicationUuid: string, + billUuid: string, + signal?: AbortSignal +) => { + return customInstance({ + url: `/publications/${publicationUuid}/bills/${billUuid}`, + method: 'GET', + signal, + }) +} + +export const getPublicationsPublicationUuidBillsBillUuidGetQueryKey = ( + publicationUuid: string, + billUuid: string +) => { + return [`/publications/${publicationUuid}/bills/${billUuid}`] as const +} + +export const getPublicationsPublicationUuidBillsBillUuidGetQueryOptions = < + TData = Awaited< + ReturnType + >, + TError = HTTPValidationError +>( + publicationUuid: string, + billUuid: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType< + typeof publicationsPublicationUuidBillsBillUuidGet + > + >, + TError, + TData + > + > + } +) => { + const { query: queryOptions } = options ?? {} + + const queryKey = + queryOptions?.queryKey ?? + getPublicationsPublicationUuidBillsBillUuidGetQueryKey( + publicationUuid, + billUuid + ) + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + publicationsPublicationUuidBillsBillUuidGet( + publicationUuid, + billUuid, + signal + ) + + return { + queryKey, + queryFn, + enabled: !!(publicationUuid && billUuid), + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type PublicationsPublicationUuidBillsBillUuidGetQueryResult = + NonNullable< + Awaited> + > +export type PublicationsPublicationUuidBillsBillUuidGetQueryError = + HTTPValidationError + +/** + * @summary Get details of a publication bill + */ +export const usePublicationsPublicationUuidBillsBillUuidGet = < + TData = Awaited< + ReturnType + >, + TError = HTTPValidationError +>( + publicationUuid: string, + billUuid: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType< + typeof publicationsPublicationUuidBillsBillUuidGet + > + >, + TError, + TData + > + > + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = + getPublicationsPublicationUuidBillsBillUuidGetQueryOptions( + publicationUuid, + billUuid, + options + ) + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey + } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * @summary Edit an existing publication Bill or version + */ +export const publicationsPublicationUuidBillsBillUuidPatch = ( + publicationUuid: string, + billUuid: string, + publicationBillEdit: PublicationBillEdit +) => { + return customInstance({ + url: `/publications/${publicationUuid}/bills/${billUuid}`, + method: 'PATCH', + headers: { 'Content-Type': 'application/json' }, + data: publicationBillEdit, + }) +} + +export const getPublicationsPublicationUuidBillsBillUuidPatchMutationOptions = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited< + ReturnType + >, + TError, + { + publicationUuid: string + billUuid: string + data: PublicationBillEdit + }, + TContext + > +}): UseMutationOptions< + Awaited>, + TError, + { publicationUuid: string; billUuid: string; data: PublicationBillEdit }, + TContext +> => { + const { mutation: mutationOptions } = options ?? {} + + const mutationFn: MutationFunction< + Awaited< + ReturnType + >, + { publicationUuid: string; billUuid: string; data: PublicationBillEdit } + > = props => { + const { publicationUuid, billUuid, data } = props ?? {} + + return publicationsPublicationUuidBillsBillUuidPatch( + publicationUuid, + billUuid, + data + ) + } + + return { mutationFn, ...mutationOptions } +} + +export type PublicationsPublicationUuidBillsBillUuidPatchMutationResult = + NonNullable< + Awaited< + ReturnType + > + > +export type PublicationsPublicationUuidBillsBillUuidPatchMutationBody = + PublicationBillEdit +export type PublicationsPublicationUuidBillsBillUuidPatchMutationError = + HTTPValidationError + +/** + * @summary Edit an existing publication Bill or version + */ +export const usePublicationsPublicationUuidBillsBillUuidPatch = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited< + ReturnType + >, + TError, + { + publicationUuid: string + billUuid: string + data: PublicationBillEdit + }, + TContext + > +}) => { + const mutationOptions = + getPublicationsPublicationUuidBillsBillUuidPatchMutationOptions(options) + + return useMutation(mutationOptions) +} + +/** + * @summary List the existing publication Packages + */ +export const publicationBillsBillUuidPackagesGet = ( + billUuid: string, + params?: PublicationBillsBillUuidPackagesGetParams, + signal?: AbortSignal +) => { + return customInstance({ + url: `/publication-bills/${billUuid}/packages`, + method: 'GET', + params, + signal, + }) +} + +export const getPublicationBillsBillUuidPackagesGetQueryKey = ( + billUuid: string, + params?: PublicationBillsBillUuidPackagesGetParams +) => { + return [ + `/publication-bills/${billUuid}/packages`, + ...(params ? [params] : []), + ] as const +} + +export const getPublicationBillsBillUuidPackagesGetQueryOptions = < + TData = Awaited>, + TError = HTTPValidationError +>( + billUuid: string, + params?: PublicationBillsBillUuidPackagesGetParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > + } +) => { + const { query: queryOptions } = options ?? {} + + const queryKey = + queryOptions?.queryKey ?? + getPublicationBillsBillUuidPackagesGetQueryKey(billUuid, params) + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + publicationBillsBillUuidPackagesGet(billUuid, params, signal) + + return { + queryKey, + queryFn, + enabled: !!billUuid, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type PublicationBillsBillUuidPackagesGetQueryResult = NonNullable< + Awaited> +> +export type PublicationBillsBillUuidPackagesGetQueryError = HTTPValidationError + +/** + * @summary List the existing publication Packages + */ +export const usePublicationBillsBillUuidPackagesGet = < + TData = Awaited>, + TError = HTTPValidationError +>( + billUuid: string, + params?: PublicationBillsBillUuidPackagesGetParams, + options?: { + query?: Partial< + UseQueryOptions< + Awaited>, + TError, + TData + > + > + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = getPublicationBillsBillUuidPackagesGetQueryOptions( + billUuid, + params, + options + ) + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey + } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * @summary Create new Publication Package + */ +export const publicationBillsBillUuidPackagesPost = ( + billUuid: string, + publicationPackageCreate: PublicationPackageCreate +) => { + return customInstance({ + url: `/publication-bills/${billUuid}/packages`, + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + data: publicationPackageCreate, + }) +} + +export const getPublicationBillsBillUuidPackagesPostMutationOptions = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { billUuid: string; data: PublicationPackageCreate }, + TContext + > +}): UseMutationOptions< + Awaited>, + TError, + { billUuid: string; data: PublicationPackageCreate }, + TContext +> => { + const { mutation: mutationOptions } = options ?? {} + + const mutationFn: MutationFunction< + Awaited>, + { billUuid: string; data: PublicationPackageCreate } + > = props => { + const { billUuid, data } = props ?? {} + + return publicationBillsBillUuidPackagesPost(billUuid, data) + } + + return { mutationFn, ...mutationOptions } +} + +export type PublicationBillsBillUuidPackagesPostMutationResult = NonNullable< + Awaited> +> +export type PublicationBillsBillUuidPackagesPostMutationBody = + PublicationPackageCreate +export type PublicationBillsBillUuidPackagesPostMutationError = + HTTPValidationError + +/** + * @summary Create new Publication Package + */ +export const usePublicationBillsBillUuidPackagesPost = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { billUuid: string; data: PublicationPackageCreate }, + TContext + > +}) => { + const mutationOptions = + getPublicationBillsBillUuidPackagesPostMutationOptions(options) + + return useMutation(mutationOptions) +} + +/** + * @summary Record the submission response from lvbb of a publication package + */ +export const publicationPackagesPackageUuidReportPost = ( + packageUuid: string, + bodyFastapiHandlerPublicationPackagesPackageUuidReportPost: BodyFastapiHandlerPublicationPackagesPackageUuidReportPost +) => { + const formData = new FormData() + formData.append( + 'xml_file', + bodyFastapiHandlerPublicationPackagesPackageUuidReportPost.xml_file + ) + + return customInstance({ + url: `/publication-packages/${packageUuid}/report`, + method: 'POST', + headers: { 'Content-Type': 'multipart/form-data' }, + data: formData, + }) +} + +export const getPublicationPackagesPackageUuidReportPostMutationOptions = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { + packageUuid: string + data: BodyFastapiHandlerPublicationPackagesPackageUuidReportPost + }, + TContext + > +}): UseMutationOptions< + Awaited>, + TError, + { + packageUuid: string + data: BodyFastapiHandlerPublicationPackagesPackageUuidReportPost + }, + TContext +> => { + const { mutation: mutationOptions } = options ?? {} + + const mutationFn: MutationFunction< + Awaited>, + { + packageUuid: string + data: BodyFastapiHandlerPublicationPackagesPackageUuidReportPost + } + > = props => { + const { packageUuid, data } = props ?? {} + + return publicationPackagesPackageUuidReportPost(packageUuid, data) + } + + return { mutationFn, ...mutationOptions } +} + +export type PublicationPackagesPackageUuidReportPostMutationResult = + NonNullable< + Awaited> + > +export type PublicationPackagesPackageUuidReportPostMutationBody = + BodyFastapiHandlerPublicationPackagesPackageUuidReportPost +export type PublicationPackagesPackageUuidReportPostMutationError = + HTTPValidationError + +/** + * @summary Record the submission response from lvbb of a publication package + */ +export const usePublicationPackagesPackageUuidReportPost = < + TError = HTTPValidationError, + TContext = unknown +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { + packageUuid: string + data: BodyFastapiHandlerPublicationPackagesPackageUuidReportPost + }, + TContext + > +}) => { + const mutationOptions = + getPublicationPackagesPackageUuidReportPostMutationOptions(options) + + return useMutation(mutationOptions) +} + +/** + * @summary Download package reports + */ +export const publicationPackagesPackageUuidReportDownloadGet = ( + packageUuid: string, + signal?: AbortSignal +) => { + return customInstance({ + url: `/publication-packages/${packageUuid}/report/download`, + method: 'GET', + signal, + }) +} + +export const getPublicationPackagesPackageUuidReportDownloadGetQueryKey = ( + packageUuid: string +) => { + return [`/publication-packages/${packageUuid}/report/download`] as const +} + +export const getPublicationPackagesPackageUuidReportDownloadGetQueryOptions = < + TData = Awaited< + ReturnType + >, + TError = HTTPValidationError +>( + packageUuid: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType< + typeof publicationPackagesPackageUuidReportDownloadGet + > + >, + TError, + TData + > + > + } +) => { + const { query: queryOptions } = options ?? {} + + const queryKey = + queryOptions?.queryKey ?? + getPublicationPackagesPackageUuidReportDownloadGetQueryKey(packageUuid) + + const queryFn: QueryFunction< + Awaited< + ReturnType + > + > = ({ signal }) => + publicationPackagesPackageUuidReportDownloadGet(packageUuid, signal) + + return { + queryKey, + queryFn, + enabled: !!packageUuid, + ...queryOptions, + } as UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > & { queryKey: QueryKey } +} + +export type PublicationPackagesPackageUuidReportDownloadGetQueryResult = + NonNullable< + Awaited< + ReturnType + > + > +export type PublicationPackagesPackageUuidReportDownloadGetQueryError = + HTTPValidationError + +/** + * @summary Download package reports + */ +export const usePublicationPackagesPackageUuidReportDownloadGet = < + TData = Awaited< + ReturnType + >, + TError = HTTPValidationError +>( + packageUuid: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType< + typeof publicationPackagesPackageUuidReportDownloadGet + > + >, + TError, + TData + > + > + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = + getPublicationPackagesPackageUuidReportDownloadGetQueryOptions( + packageUuid, + options + ) + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey + } + + query.queryKey = queryOptions.queryKey + + return query +} + +/** + * @summary Download a generated publication package ZIP file + */ +export const publicationPackagesPackageUuidDownloadGet = ( + packageUuid: string, + signal?: AbortSignal +) => { + return customInstance({ + url: `/publication-packages/${packageUuid}/download`, + method: 'GET', + signal, + }) +} + +export const getPublicationPackagesPackageUuidDownloadGetQueryKey = ( + packageUuid: string +) => { + return [`/publication-packages/${packageUuid}/download`] as const +} + +export const getPublicationPackagesPackageUuidDownloadGetQueryOptions = < + TData = Awaited< + ReturnType + >, + TError = HTTPValidationError +>( + packageUuid: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + > + } +) => { + const { query: queryOptions } = options ?? {} + + const queryKey = + queryOptions?.queryKey ?? + getPublicationPackagesPackageUuidDownloadGetQueryKey(packageUuid) + + const queryFn: QueryFunction< + Awaited> + > = ({ signal }) => + publicationPackagesPackageUuidDownloadGet(packageUuid, signal) + + return { + queryKey, + queryFn, + enabled: !!packageUuid, + ...queryOptions, + } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: QueryKey } +} + +export type PublicationPackagesPackageUuidDownloadGetQueryResult = NonNullable< + Awaited> +> +export type PublicationPackagesPackageUuidDownloadGetQueryError = + HTTPValidationError + +/** + * @summary Download a generated publication package ZIP file + */ +export const usePublicationPackagesPackageUuidDownloadGet = < + TData = Awaited< + ReturnType + >, + TError = HTTPValidationError +>( + packageUuid: string, + options?: { + query?: Partial< + UseQueryOptions< + Awaited< + ReturnType + >, + TError, + TData + > + > + } +): UseQueryResult & { queryKey: QueryKey } => { + const queryOptions = + getPublicationPackagesPackageUuidDownloadGetQueryOptions( + packageUuid, + options + ) + + const query = useQuery(queryOptions) as UseQueryResult & { + queryKey: QueryKey + } + + query.queryKey = queryOptions.queryKey + + return query +} + /** * @summary Login an user and receive a JWT token */ diff --git a/src/api/instance.ts b/src/api/instance.ts index 6491530b..4e0996b3 100644 --- a/src/api/instance.ts +++ b/src/api/instance.ts @@ -6,7 +6,7 @@ export type Environment = 'dev' | 'test' | 'acc' | 'main' const environment = import.meta.env.VITE_API_ENV as Environment -const getAccessToken = () => +export const getAccessToken = () => localStorage.getItem(import.meta.env.VITE_KEY_API_ACCESS_TOKEN || '') const instance = axios.create({ diff --git a/src/components/Modals/ModuleModals/ModuleDecisionModal/ModuleDecisionModal.tsx b/src/components/Modals/ModuleModals/ModuleDecisionModal/ModuleDecisionModal.tsx deleted file mode 100644 index eaa8a0f2..00000000 --- a/src/components/Modals/ModuleModals/ModuleDecisionModal/ModuleDecisionModal.tsx +++ /dev/null @@ -1,185 +0,0 @@ -import { - Button, - Divider, - FormikDate, - FormikInput, - FormikRadioGroup, - FormikRte, - FormikSelect, - Text, -} from '@pzh-ui/components' -import { Form, Formik } from 'formik' - -import { - Accordion, - AccordionContent, - AccordionItem, - AccordionTrigger, -} from '@/components/Accordion' -import Modal from '@/components/Modal/Modal' -import useModalStore from '@/store/modalStore' - -const ModuleDecisionModal = () => { - const setActiveModal = useModalStore(state => state.setActiveModal) - - const handleFormSubmit = () => {} - - const initialValues = {} - - return ( - - -
-
- - -
- - -
- - - -
- Artikelen - -
- -
- - - - -
-
- -
- - -
- -
-
- ) -} - -const Articles = () => ( - - - - Artikel I - Genomen besluit ( wat het bestuursorgaan besluit - vast te stellen of te wijzigen ) - - - - - - - - Artikel II - Wijzigingen ( opsomming van gewijzigde artikelen ) - - - - - - - - Artikel III - Inwerkingtreding ( datum waarop het - wijzigingsbesluit geldig is ) - - - - - - -) - -export default ModuleDecisionModal diff --git a/src/components/Modals/ModuleModals/ModuleDecisionModal/index.ts b/src/components/Modals/ModuleModals/ModuleDecisionModal/index.ts deleted file mode 100644 index 830ed47a..00000000 --- a/src/components/Modals/ModuleModals/ModuleDecisionModal/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ModuleDecisionModal' diff --git a/src/components/Modals/PublicationModals/PublicationAddModal/PublicationAddModal.tsx b/src/components/Modals/PublicationModals/PublicationAddModal/PublicationAddModal.tsx new file mode 100644 index 00000000..bc85b13e --- /dev/null +++ b/src/components/Modals/PublicationModals/PublicationAddModal/PublicationAddModal.tsx @@ -0,0 +1,105 @@ +import { Button, Divider, FormikInput, FormikSelect } from '@pzh-ui/components' +import { useQueryClient } from '@tanstack/react-query' +import { Form, Formik } from 'formik' +import { useParams } from 'react-router-dom' + +import { getPublicationsGetQueryKey, usePublicationsPost } from '@/api/fetchers' +import { + AppExtensionsPublicationsEnumsDocumentType, + PublicationCreate, +} from '@/api/fetchers.schemas' +import Modal from '@/components/Modal/Modal' +import useModalStore from '@/store/modalStore' + +import { ModalStateMap } from '../../types' + +const PublicationAddModal = () => { + const queryClient = useQueryClient() + const { moduleId } = useParams() + + const modalState = useModalStore( + state => state.modalStates['publicationAdd'] + ) as ModalStateMap['publicationAdd'] + const setActiveModal = useModalStore(state => state.setActiveModal) + + const { mutate } = usePublicationsPost({ + mutation: { + onSuccess: data => { + queryClient.invalidateQueries({ + queryKey: getPublicationsGetQueryKey({ + document_type: data.Document_Type, + }), + }) + + setActiveModal(null) + }, + }, + }) + + const initialValues = { + Module_ID: parseInt(moduleId!), + Document_Type: modalState?.type, + } as PublicationCreate + + const options = ( + Object.keys( + AppExtensionsPublicationsEnumsDocumentType + ) as Array + ).map(type => ({ label: type, value: type })) + + const handleFormSubmit = (payload: PublicationCreate) => { + mutate({ data: payload }) + } + + return ( + + + {({ isSubmitting }) => ( +
+
+ + + + +
+ +
+ + +
+ + )} +
+
+ ) +} + +export default PublicationAddModal diff --git a/src/components/Modals/PublicationModals/PublicationAddModal/index.ts b/src/components/Modals/PublicationModals/PublicationAddModal/index.ts new file mode 100644 index 00000000..cd83af75 --- /dev/null +++ b/src/components/Modals/PublicationModals/PublicationAddModal/index.ts @@ -0,0 +1 @@ +export { default } from './PublicationAddModal' diff --git a/src/components/Modals/PublicationModals/PublicationVersionAddModal/PublicationVersionAddModal.tsx b/src/components/Modals/PublicationModals/PublicationVersionAddModal/PublicationVersionAddModal.tsx new file mode 100644 index 00000000..8fd5df06 --- /dev/null +++ b/src/components/Modals/PublicationModals/PublicationVersionAddModal/PublicationVersionAddModal.tsx @@ -0,0 +1,142 @@ +import { formatDate } from '@pzh-ui/components' +import { useQueryClient } from '@tanstack/react-query' + +import { + getPublicationsPublicationUuidBillsGetQueryKey, + usePublicationsPublicationUuidBillsBillUuidGet, + usePublicationsPublicationUuidBillsPost, +} from '@/api/fetchers' +import { PublicationBillCreate } from '@/api/fetchers.schemas' +import { LoaderSpinner } from '@/components/Loader' +import Modal from '@/components/Modal/Modal' +import PublicationVersionForm from '@/components/Publications/PublicationVersionForm' +import useModalStore from '@/store/modalStore' + +import { ModalStateMap } from '../../types' + +const PublicationVersionAddModal = () => { + const queryClient = useQueryClient() + + const setActiveModal = useModalStore(state => state.setActiveModal) + const modalState = useModalStore( + state => state.modalStates['publicationVersionAdd'] + ) as ModalStateMap['publicationVersionAdd'] + + const { data: prefill, isFetching } = + usePublicationsPublicationUuidBillsBillUuidGet( + modalState?.publication.UUID, + modalState?.prevUUID || '', + { + query: { + enabled: + !!modalState?.publication.UUID && + !!modalState?.prevUUID, + }, + } + ) + + const { mutate } = usePublicationsPublicationUuidBillsPost({ + mutation: { + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: getPublicationsPublicationUuidBillsGetQueryKey( + modalState.publication.UUID + ), + }) + + setActiveModal(null) + }, + }, + }) + + const handleFormSubmit = (payload: PublicationBillCreate) => { + payload.Is_Official = (payload.Is_Official as unknown) === 'true' + + payload.Effective_Date = + payload.Effective_Date && + formatDate(new Date(payload.Effective_Date), 'yyyy-MM-dd') + + if (payload.Procedure_Data?.Announcement_Date) { + payload.Procedure_Data.Announcement_Date = + formatDate( + new Date(payload.Procedure_Data.Announcement_Date), + 'yyyy-MM-dd' + ) || '' + payload.Announcement_Date = + formatDate( + new Date(payload.Procedure_Data.Announcement_Date), + 'yyyy-MM-dd' + ) || '' + } + + if (payload.Procedure_Data?.Steps?.[0]?.Conclusion_Date) { + payload.Procedure_Data.Steps[0].Conclusion_Date = formatDate( + new Date(payload.Procedure_Data.Steps[0].Conclusion_Date), + 'yyyy-MM-dd' + ) + } + + if (payload.Procedure_Data?.Steps?.[1]?.Conclusion_Date) { + payload.Procedure_Data.Steps[1].Conclusion_Date = formatDate( + new Date(payload.Procedure_Data.Steps[1].Conclusion_Date), + 'yyyy-MM-dd' + ) + } + + mutate({ publicationUuid: modalState.publication.UUID, data: payload }) + } + + const initialValues = !!prefill + ? { + ...prefill, + Is_Official: prefill.Is_Official ? 'true' : 'false', + } + : ({ + Bill_Data: { + Bill_Title: modalState?.publication?.Official_Title, + Regulation_Title: modalState?.publication?.Regulation_Title, + Amendment_Article: { + Label: 'Genomen besluit', + Number: '1', + }, + Articles: [ + { + Label: 'Wijzigingen', + Number: '2', + }, + ], + Time_Article: { + Label: 'Inwerkingtreding', + Number: '3', + }, + }, + Procedure_Data: { + Steps: [ + { + Step_Type: 'Vaststelling', + }, + { + Step_Type: 'Ondertekening', + }, + ], + }, + } as PublicationBillCreate) + + return ( + + {isFetching ? ( +
+ +
+ ) : ( + + )} +
+ ) +} + +export default PublicationVersionAddModal diff --git a/src/components/Modals/PublicationModals/PublicationVersionAddModal/index.ts b/src/components/Modals/PublicationModals/PublicationVersionAddModal/index.ts new file mode 100644 index 00000000..7fe4fbd3 --- /dev/null +++ b/src/components/Modals/PublicationModals/PublicationVersionAddModal/index.ts @@ -0,0 +1 @@ +export { default } from './PublicationVersionAddModal' diff --git a/src/components/Modals/PublicationModals/PublicationVersionEditModal/PublicationVersionEditModal.tsx b/src/components/Modals/PublicationModals/PublicationVersionEditModal/PublicationVersionEditModal.tsx new file mode 100644 index 00000000..dc5463d7 --- /dev/null +++ b/src/components/Modals/PublicationModals/PublicationVersionEditModal/PublicationVersionEditModal.tsx @@ -0,0 +1,119 @@ +import { formatDate } from '@pzh-ui/components' +import { useQueryClient } from '@tanstack/react-query' + +import { + getPublicationsPublicationUuidBillsBillUuidGetQueryKey, + getPublicationsPublicationUuidBillsGetQueryKey, + usePublicationsPublicationUuidBillsBillUuidGet, + usePublicationsPublicationUuidBillsBillUuidPatch, +} from '@/api/fetchers' +import { PublicationBillEdit } from '@/api/fetchers.schemas' +import { LoaderSpinner } from '@/components/Loader' +import Modal from '@/components/Modal/Modal' +import PublicationVersionForm from '@/components/Publications/PublicationVersionForm' +import useModalStore from '@/store/modalStore' + +import { ModalStateMap } from '../../types' + +const PublicationVersionEditModal = () => { + const queryClient = useQueryClient() + + const setActiveModal = useModalStore(state => state.setActiveModal) + const modalState = useModalStore( + state => state.modalStates['publicationVersionEdit'] + ) as ModalStateMap['publicationVersionEdit'] + + const { data, isFetching } = usePublicationsPublicationUuidBillsBillUuidGet( + modalState?.publication.UUID, + modalState?.UUID, + { + query: { + enabled: !!modalState?.publication.UUID && !!modalState?.UUID, + }, + } + ) + + const { mutate } = usePublicationsPublicationUuidBillsBillUuidPatch({ + mutation: { + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: getPublicationsPublicationUuidBillsGetQueryKey( + modalState.publication.UUID + ), + }) + queryClient.invalidateQueries({ + queryKey: + getPublicationsPublicationUuidBillsBillUuidGetQueryKey( + modalState.publication.UUID, + modalState.UUID + ), + }) + + setActiveModal(null) + }, + }, + }) + + const handleFormSubmit = (payload: PublicationBillEdit) => { + payload.Effective_Date = + payload.Effective_Date && + formatDate(new Date(payload.Effective_Date), 'yyyy-MM-dd') + + if (payload.Procedure_Data?.Announcement_Date) { + payload.Procedure_Data.Announcement_Date = + formatDate( + new Date(payload.Procedure_Data.Announcement_Date), + 'yyyy-MM-dd' + ) || '' + payload.Announcement_Date = + formatDate( + new Date(payload.Procedure_Data.Announcement_Date), + 'yyyy-MM-dd' + ) || '' + } + + if (payload.Procedure_Data?.Steps?.[0]?.Conclusion_Date) { + payload.Procedure_Data.Steps[0].Conclusion_Date = formatDate( + new Date(payload.Procedure_Data.Steps[0].Conclusion_Date), + 'yyyy-MM-dd' + ) + } + + if (payload.Procedure_Data?.Steps?.[1]?.Conclusion_Date) { + payload.Procedure_Data.Steps[1].Conclusion_Date = formatDate( + new Date(payload.Procedure_Data.Steps[1].Conclusion_Date), + 'yyyy-MM-dd' + ) + } + + mutate({ + publicationUuid: modalState.publication.UUID, + billUuid: modalState.UUID, + data: payload, + }) + } + + const initialValues = { + ...data, + Is_Official: data?.Is_Official ? 'true' : 'false', + } + + return ( + + {isFetching ? ( +
+ +
+ ) : ( + + )} +
+ ) +} + +export default PublicationVersionEditModal diff --git a/src/components/Modals/PublicationModals/PublicationVersionEditModal/index.ts b/src/components/Modals/PublicationModals/PublicationVersionEditModal/index.ts new file mode 100644 index 00000000..3fdfc207 --- /dev/null +++ b/src/components/Modals/PublicationModals/PublicationVersionEditModal/index.ts @@ -0,0 +1 @@ +export { default } from './PublicationVersionEditModal' diff --git a/src/components/Modals/PublicationModals/index.ts b/src/components/Modals/PublicationModals/index.ts new file mode 100644 index 00000000..9211093b --- /dev/null +++ b/src/components/Modals/PublicationModals/index.ts @@ -0,0 +1,9 @@ +import PublicationAddModal from './PublicationAddModal' +import PublicationVersionAddModal from './PublicationVersionAddModal' +import PublicationVersionEditModal from './PublicationVersionEditModal' + +export { + PublicationAddModal, + PublicationVersionAddModal, + PublicationVersionEditModal, +} diff --git a/src/components/Modals/types.ts b/src/components/Modals/types.ts index 305c2df6..37dd588e 100644 --- a/src/components/Modals/types.ts +++ b/src/components/Modals/types.ts @@ -1,3 +1,8 @@ +import { + AppExtensionsPublicationsEnumsDocumentType, + Publication, +} from '@/api/fetchers.schemas' + export type ModalType = | 'regulationAdd' | 'regulationDelete' @@ -11,7 +16,6 @@ export type ModalType = | 'moduleAddObject' | 'moduleEditObject' | 'moduleDeleteObject' - | 'moduleDecision' | 'areaAdd' | 'objectDetails' | 'objectAddConnection' @@ -24,3 +28,12 @@ export type ModalType = | 'userAdd' | 'userEdit' | 'userPasswordReset' + | 'publicationAdd' + | 'publicationVersionAdd' + | 'publicationVersionEdit' + +export interface ModalStateMap { + publicationAdd: { type: AppExtensionsPublicationsEnumsDocumentType } + publicationVersionAdd: { publication: Publication; prevUUID?: string } + publicationVersionEdit: { publication: Publication; UUID: string } +} diff --git a/src/components/Modules/ModuleVersionTable/ModuleVersionTable.tsx b/src/components/Modules/ModuleVersionTable/ModuleVersionTable.tsx deleted file mode 100644 index 1d3fdc5c..00000000 --- a/src/components/Modules/ModuleVersionTable/ModuleVersionTable.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import { Button } from '@pzh-ui/components' -import { Check, FileWord, Xmark } from '@pzh-ui/icons' - -interface ModuleVersion { - version: number - status: string - type: string - purpose: string - uploadDate?: string - isPending?: boolean -} - -interface ModuleVersionTableProps { - versions: ModuleVersion[] -} - -const ModuleVersionTable = ({ versions }: ModuleVersionTableProps) => ( - - - - - - - - - - - - {versions.map( - ({ version, status, type, purpose, uploadDate, isPending }) => ( - - - - - - - - ) - )} - -
VersieGebaseerd op ModulestatusType besluitDoelActie
{version}{status}{type}{purpose} -
- {uploadDate ? ( - `Levering succesvol geüpload op ${uploadDate}` - ) : isPending ? ( - <> - - -
-
- - ) : ( - <> - - - - )} -
-
-) - -export default ModuleVersionTable diff --git a/src/components/Modules/ModuleVersionTable/index.ts b/src/components/Modules/ModuleVersionTable/index.ts deleted file mode 100644 index d2cba5c7..00000000 --- a/src/components/Modules/ModuleVersionTable/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ModuleVersionTable' diff --git a/src/components/Publications/Publication/Publication.tsx b/src/components/Publications/Publication/Publication.tsx new file mode 100644 index 00000000..b7ab4c02 --- /dev/null +++ b/src/components/Publications/Publication/Publication.tsx @@ -0,0 +1,82 @@ +import { Button, Heading } from '@pzh-ui/components' +import { Plus } from '@pzh-ui/icons' +import { useParams } from 'react-router-dom' + +import { + usePublicationsGet, + usePublicationsPublicationUuidBillsGet, +} from '@/api/fetchers' +import { AppExtensionsPublicationsEnumsDocumentType } from '@/api/fetchers.schemas' +import { LoaderSpinner } from '@/components/Loader' +import useModalStore from '@/store/modalStore' + +import PublicationVersions from '../PublicationVersions' + +interface PublicationProps { + type: AppExtensionsPublicationsEnumsDocumentType +} + +const Publication = ({ type }: PublicationProps) => { + const { moduleId } = useParams() + const setActiveModal = useModalStore(state => state.setActiveModal) + + const { data: publication, isPending } = usePublicationsGet( + { document_type: type, module_ID: parseInt(moduleId!) }, + { query: { enabled: !!moduleId, select: data => data.results?.[0] } } + ) + + const { data: latest } = usePublicationsPublicationUuidBillsGet( + publication?.UUID || '', + undefined, + { + query: { + enabled: !!publication?.UUID, + select: data => data.results?.slice(-1)[0], + }, + } + ) + + return ( +
+ + {type} + + + {isPending ? ( + + ) : ( + <> + {!!publication && ( + + )} + + {!!!publication ? ( + + ) : ( + + )} + + )} +
+ ) +} + +export default Publication diff --git a/src/components/Publications/Publication/index.ts b/src/components/Publications/Publication/index.ts new file mode 100644 index 00000000..869b92da --- /dev/null +++ b/src/components/Publications/Publication/index.ts @@ -0,0 +1 @@ +export { default } from './Publication' diff --git a/src/components/Publications/PublicationVersionForm/PublicationVersionForm.tsx b/src/components/Publications/PublicationVersionForm/PublicationVersionForm.tsx new file mode 100644 index 00000000..72e2b29f --- /dev/null +++ b/src/components/Publications/PublicationVersionForm/PublicationVersionForm.tsx @@ -0,0 +1,219 @@ +import { + Button, + Divider, + FormikDate, + FormikInput, + FormikRadioGroup, + FormikSelect, + FormikTextArea, + Text, + formatDate, +} from '@pzh-ui/components' +import { Form, Formik, FormikConfig, FormikValues } from 'formik' +import { useParams } from 'react-router-dom' + +import { useModulesModuleIdStatusGet } from '@/api/fetchers' +import { + Accordion, + AccordionContent, + AccordionItem, + AccordionTrigger, +} from '@/components/Accordion' +import useModalStore from '@/store/modalStore' + +interface PublicationVersionFormProps { + submitLabel: string + isEdit?: boolean +} + +const PublicationVersionForm = ({ + submitLabel, + isEdit, + ...rest +}: PublicationVersionFormProps & FormikConfig) => { + const { moduleId } = useParams() + + const setActiveModal = useModalStore(state => state.setActiveModal) + + const { data: statusOptions } = useModulesModuleIdStatusGet( + parseInt(moduleId!), + { + query: { + enabled: !!moduleId, + select: data => + data + .filter(status => status.Status !== 'Niet-Actief') + .map(status => ({ + label: `${status.Status} (${formatDate( + new Date(status.Created_Date + 'Z'), + 'dd-MM-yyyy' + )})`, + value: status.ID, + })), + }, + } + ) + + return ( + +
+
+ + +
+ + +
+ +
+ Artikelen + +
+ + +
+ + + + + +
+
+ +
+ + +
+ +
+ ) +} + +const Articles = () => ( + + + + Artikel I - Genomen besluit ( wat het bestuursorgaan besluit + vast te stellen of te wijzigen ) + + + + + + + + Artikel II - Wijzigingen ( opsomming van gewijzigde artikelen ) + + + + + + + + Artikel III - Inwerkingtreding ( datum waarop het + wijzigingsbesluit geldig is ) + + + + + + +) + +export default PublicationVersionForm diff --git a/src/components/Publications/PublicationVersionForm/index.ts b/src/components/Publications/PublicationVersionForm/index.ts new file mode 100644 index 00000000..73bbe06e --- /dev/null +++ b/src/components/Publications/PublicationVersionForm/index.ts @@ -0,0 +1 @@ +export { default } from './PublicationVersionForm' diff --git a/src/components/Publications/PublicationVersions/PublicationVersions.tsx b/src/components/Publications/PublicationVersions/PublicationVersions.tsx new file mode 100644 index 00000000..bf48f2cf --- /dev/null +++ b/src/components/Publications/PublicationVersions/PublicationVersions.tsx @@ -0,0 +1,153 @@ +import { Button, Tooltip } from '@pzh-ui/components' +import { FileWord } from '@pzh-ui/icons' +import { useQuery } from '@tanstack/react-query' +import { useParams } from 'react-router-dom' + +import { + useModulesModuleIdStatusGet, + usePublicationsPublicationUuidBillsGet, +} from '@/api/fetchers' +import { Publication, PublicationBillShort } from '@/api/fetchers.schemas' +import useModalStore from '@/store/modalStore' +import downloadFile from '@/utils/downloadFile' +import { toastNotification } from '@/utils/toastNotification' + +interface PublicationVersionsProps { + publication: Publication +} + +const PublicationVersions = ({ publication }: PublicationVersionsProps) => { + const { moduleId } = useParams() + + const { data } = usePublicationsPublicationUuidBillsGet( + publication!.UUID, + undefined, + { + query: { + enabled: !!publication, + }, + } + ) + + const { data: statusOptions } = useModulesModuleIdStatusGet( + parseInt(moduleId!), + { + query: { + enabled: !!moduleId, + select: data => + data.map(status => ({ + label: status.Status, + value: status.ID, + })), + }, + } + ) + + return ( + + + + + + + + + + + + {data?.results.map(bill => { + const status = statusOptions?.find( + option => option.value === bill.Module_Status_ID + ) + + return ( + + ) + })} + +
VersieGebaseerd op ModulestatusType besluitDoelActie
+ ) +} + +const VersionRow = ({ + publication, + Version_ID, + Procedure_Type, + Is_Official, + status, + UUID, + Module_Status_ID, +}: PublicationBillShort & { publication: Publication; status?: string }) => { + const { moduleId } = useParams() + + const setActiveModal = useModalStore(state => state.setActiveModal) + + const downloadDiff = async ({ + moduleId, + Module_Status_ID, + }: { + moduleId?: string + Module_Status_ID: number + }) => { + toastNotification('downloadStarted') + + return downloadFile( + `modules/${moduleId}/diff?output_format=doc&status_id=${Module_Status_ID}` + ) + } + + const { isFetching, refetch: download } = useQuery({ + queryKey: ['downloadDiff', moduleId, Module_Status_ID, UUID], + queryFn: () => downloadDiff({ moduleId, Module_Status_ID }), + enabled: false, + }) + + return ( + + {Version_ID} + {status} + {Procedure_Type} + {Is_Official ? 'Officiële' : 'Interne'} publicatie + +
+ + +
+
+
+
+ + + ) +} + +export default PublicationVersions diff --git a/src/components/Publications/PublicationVersions/index.ts b/src/components/Publications/PublicationVersions/index.ts new file mode 100644 index 00000000..fff16603 --- /dev/null +++ b/src/components/Publications/PublicationVersions/index.ts @@ -0,0 +1 @@ +export { default } from './PublicationVersions' diff --git a/src/config/notifications.ts b/src/config/notifications.ts index ffb96c02..0e1b23d3 100644 --- a/src/config/notifications.ts +++ b/src/config/notifications.ts @@ -20,6 +20,7 @@ export type ToastType = | 'userActivated' | 'userDeactivated' | 'userPasswordGenerated' + | 'downloadStarted' type MessageType = 'default' | 'success' | 'error' | 'warning' | 'info' @@ -108,4 +109,8 @@ export const notifications: Record< message: 'Het nieuwe wachtwoord voor de gebruiker is opgeslagen', type: 'success', }, + downloadStarted: { + message: 'De download wordt gegeneerd, dit kan even duren', + type: 'info', + }, } diff --git a/src/pages/protected/Modules/ModuleDetail/ModuleDetail.tsx b/src/pages/protected/Modules/ModuleDetail/ModuleDetail.tsx index 978e94d3..06dab5fb 100644 --- a/src/pages/protected/Modules/ModuleDetail/ModuleDetail.tsx +++ b/src/pages/protected/Modules/ModuleDetail/ModuleDetail.tsx @@ -10,11 +10,14 @@ import { Tabs, Text, } from '@pzh-ui/components' -import { Plus } from '@pzh-ui/icons' import classNames from 'classnames' -import { useState } from 'react' +import { Fragment, useState } from 'react' -import { Module, ModuleObjectShort } from '@/api/fetchers.schemas' +import { + AppExtensionsPublicationsEnumsDocumentType, + Module, + ModuleObjectShort, +} from '@/api/fetchers.schemas' import Avatar from '@/components/Avatar' import { LoaderContent } from '@/components/Loader' import { @@ -25,14 +28,18 @@ import { ModuleLockModal, ModuleObjectDeleteConfirmationModal, } from '@/components/Modals/ModuleModals' -import ModuleDecisionModal from '@/components/Modals/ModuleModals/ModuleDecisionModal' +import { + PublicationAddModal, + PublicationVersionAddModal, + PublicationVersionEditModal, +} from '@/components/Modals/PublicationModals' import ModuleCompleteCard from '@/components/Modules/ModuleCompleteCard' import ModuleInactiveCard from '@/components/Modules/ModuleInactiveCard' import ModuleItemList from '@/components/Modules/ModuleItemList' import ModuleLock from '@/components/Modules/ModuleLock' import ModuleTimeline from '@/components/Modules/ModuleTimeline' import ModuleVersionCard from '@/components/Modules/ModuleVersionCard' -import ModuleVersionTable from '@/components/Modules/ModuleVersionTable' +import Publication from '@/components/Publications/Publication' import useModule from '@/hooks/useModule' import useModuleManagers from '@/hooks/useModuleManagers' import usePermissions from '@/hooks/usePermissions' @@ -239,7 +246,9 @@ const TabObjects = () => { } const TabDecisions = () => { - const setActiveModal = useModalStore(state => state.setActiveModal) + const documentTypes = Object.keys( + AppExtensionsPublicationsEnumsDocumentType + ) as Array return ( <> @@ -254,80 +263,20 @@ const TabDecisions = () => { leveringen zie leveringen. -
- - Visie - - - - - -
+ {documentTypes.map((type, index) => ( + + - - -
- - Programma - - - - - -
- - - -
- - Verordening - - -
+ {index + 1 !== documentTypes.length && ( + + )} +
+ ))} - + + + + ) } diff --git a/src/store/modalStore.ts b/src/store/modalStore.ts index 6bf248b0..bcab5784 100644 --- a/src/store/modalStore.ts +++ b/src/store/modalStore.ts @@ -1,17 +1,40 @@ import { create } from 'zustand' -import { ModalType } from '@/components/Modals/types' +import { ModalStateMap, ModalType } from '@/components/Modals/types' interface ModalState { /** Active modal id */ activeModal: ModalType | null + /** State of modals */ + modalStates: Partial> /** Set active modal id */ - setActiveModal: (id: ModalType | null) => void + setActiveModal: ( + id: ModalType | null, + state?: Partial + ) => void } const useModalStore = create(set => ({ activeModal: null, - setActiveModal: activeModal => set(state => ({ ...state, activeModal })), + modalStates: {}, + setActiveModal: (activeModal, modalState) => + set(state => ({ + ...state, + activeModal, + modalStates: { + ...state.modalStates, + ...(activeModal !== null + ? { + [activeModal]: state.modalStates[activeModal] + ? { + ...state.modalStates[activeModal], + ...modalState, + } + : modalState, + } + : {}), + }, + })), })) export default useModalStore diff --git a/src/utils/downloadFile.ts b/src/utils/downloadFile.ts new file mode 100644 index 00000000..833f2909 --- /dev/null +++ b/src/utils/downloadFile.ts @@ -0,0 +1,40 @@ +import { getAccessToken } from '@/api/instance' + +import getApiUrl from './getApiUrl' + +const downloadFile = async (path: string) => { + try { + const response = await fetch(`${getApiUrl()}/${path}`, { + method: 'GET', + headers: { + Authorization: `Bearer ${getAccessToken()}`, + }, + }) + + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`) + } + + const blob = await response.blob() + const contentDisposition = response.headers.get('content-disposition') + let fileName = 'downloaded_file' + if (contentDisposition) { + fileName = contentDisposition.split('=')[1] + } + + const url = URL.createObjectURL(blob) + const link = document.createElement('a') + link.href = url + link.setAttribute('download', fileName) + document.body.appendChild(link) + link.click() + + // Clean up + link.parentNode?.removeChild(link) + URL.revokeObjectURL(url) + } catch (error) { + console.error(`Error fetching data: ${error}`) + } +} + +export default downloadFile diff --git a/yarn.lock b/yarn.lock index 5bc29801..15e6ba0c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1542,7 +1542,18 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.21.3, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.19, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.23.4, @babel/types@npm:^7.23.6, @babel/types@npm:^7.23.9, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.21.3, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.19, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.23.4, @babel/types@npm:^7.23.6, @babel/types@npm:^7.4.4, @babel/types@npm:^7.8.3": + version: 7.23.6 + resolution: "@babel/types@npm:7.23.6" + dependencies: + "@babel/helper-string-parser": "npm:^7.23.4" + "@babel/helper-validator-identifier": "npm:^7.22.20" + to-fast-properties: "npm:^2.0.0" + checksum: 07e70bb94d30b0231396b5e9a7726e6d9227a0a62e0a6830c0bd3232f33b024092e3d5a7d1b096a65bbf2bb43a9ab4c721bf618e115bfbb87b454fa060f88cbf + languageName: node + linkType: hard + +"@babel/types@npm:^7.23.9": version: 7.23.9 resolution: "@babel/types@npm:7.23.9" dependencies: @@ -2470,9 +2481,9 @@ __metadata: languageName: node linkType: hard -"@pzh-ui/components@npm:^0.0.463": - version: 0.0.463 - resolution: "@pzh-ui/components@npm:0.0.463" +"@pzh-ui/components@npm:^0.0.465": + version: 0.0.465 + resolution: "@pzh-ui/components@npm:0.0.465" dependencies: "@floating-ui/react": "npm:^0.24.8" "@headlessui/react": "npm:^1.5.0" @@ -2522,7 +2533,7 @@ __metadata: react-stately: "npm:^3.18.0" react-table: "npm:^7.8.0" react-toastify: "npm:^9.1.2" - checksum: c7afdde70501bc6ff443757fc0b6d8f15adf7f91c8d2cd3bfa80c9086773562f5b19a2890b86425243a6691f0d042f332fd43881324676cf0d9acd5ddf61f8f8 + checksum: c58dc32aa107819994b6240749e9871c0288a18c3d8baa30cc1714501f82a08c92481c8ce874bb2e0a5cb21055bc0041a939856c7a3cda22ff70cc7cb78e714c languageName: node linkType: hard @@ -2554,9 +2565,9 @@ __metadata: languageName: node linkType: hard -"@pzh-ui/css@npm:^0.0.79": - version: 0.0.79 - resolution: "@pzh-ui/css@npm:0.0.79" +"@pzh-ui/css@npm:^0.0.80": + version: 0.0.80 + resolution: "@pzh-ui/css@npm:0.0.80" dependencies: "@rollup/plugin-typescript": "npm:^8.3.1" "@tailwindcss/custom-forms": "npm:^0.2.1" @@ -2565,7 +2576,7 @@ __metadata: "@tailwindcss/typography": "npm:^0.5.9" react-datepicker: "npm:^4.7.0" react-toastify: "npm:^9.1.2" - checksum: 65f08cd2a33108adf63a83cbe680f6f72733385cff6608d082a7c47d93f5457cb595a15d90c8057553877737be658a21c670ca1693f96a8595c03da232b00614 + checksum: f33cfa8697ac1840659461e1bc574a74d7ce26a6194bd4c159c7256073734c5f72e20c6a19535e5d767f0997902bd632ecce8a95342aafff32177effc70a9211 languageName: node linkType: hard @@ -12352,9 +12363,9 @@ __metadata: "@axe-core/react": "npm:^4.8.2" "@faker-js/faker": "npm:^8.3.1" "@headlessui/react": "npm:^1.7.17" - "@pzh-ui/components": "npm:^0.0.463" + "@pzh-ui/components": "npm:^0.0.465" "@pzh-ui/config": "npm:^0.0.56" - "@pzh-ui/css": "npm:^0.0.79" + "@pzh-ui/css": "npm:^0.0.80" "@pzh-ui/icons": "npm:^0.0.50" "@react-hookz/web": "npm:^24.0.2" "@tanstack/react-query": "npm:^5.14.2"