The resource upload details consists of 3 types of uploads:
Upload Target Data
Facility Upload
User Upload
This screen will come after a user selects the boundaries.
When a user clicks on the download template button, an Excel will get downloaded which will contain readMe, Boundary Data sheet along with the sheets with districts, where the user has to fill the target at the lowest level. After the file is uploaded, it will go for validation. Once validated, a user can go to the next page, where the user can delete the file and move to the next page to upload facility date.
This screen will come after the target upload screen.
In this screen, when a user clicks on the download template, an Excel get downloaded that contains readMe, Facility sheet, and BoundaryData sheet. A user has to fill in the boundary codes and from that sheet, the user has to fill in the facility sheet.
This screen will appear after the facility Details screen.
When a user clicks on the download template, an Excel gets downloaded that consists of with readMe, User Sheet and BoundaryData. The user has to fill the user sheet only.
All the 3 downloads are happening through the Generate and Download APIs. For the Generate API, the following hook is used: https://github.com/egovernments/DIGIT-Frontend/blob/campaign/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useGenerateIdCampaign.js
This hook will return the ID which is stored in the local storage according to the type:
Next, /project-factory/v1/data/_download is used to download the template.
After uploading the templates, UI validation is done through schema stored in the MDMS: Schema Data link : https://github.com/egovernments/egov-mdms-data/blob/UNIFIED-DEV/data/mz/health/hcm-admin-console/adminSchema.json
Schema Module = adminSchema Below is the admin schema-
By using AJV Validation , we are validating the headers of the facility sheet. We are also doing some basic validations for the data such as-
Facility Type can only be Warehouse/Health Facility
Facility Name can only be string
Facility Status can only be Temporary or Permanent etc.
Apart from this, we are also validating sheet names in all the 3 uploads.
For target validation, we use schema only for validating the header of the target and boundary codes. Here, we also validate the target at the lowest level, where the value should be between:
Before calling we are using base time out which is fetched from the MDMS
For the backend validation, we use the following hook: https://github.com/egovernments/DIGIT-Frontend/blob/campaign/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useResourceData.js
The screens are using the given below components for upload and validation-
Preview component: https://github.com/egovernments/DIGIT-Frontend/blob/campaign/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/XlsPreview.js
A new popup has been added which display the option to download the template in all the three upload screens.
Use Case :
when the user comes after clicking next on the delivery screen and the file is not uploaded then this pop up is displayed.
End Point | Method | Payload |
---|---|---|
/project-factory/v1/data/_generate
POST
Params will be different for different types- 1) facilityWithBoundary
tenantId:mz
type:facilityWithBoundary
forceUpdate:true
hierarchyType:ADMIN
campaignId:13175791-db53-4d10-be90-2dba1c138756 2) boundary tenantId:mz
type:boundary
forceUpdate:true
hierarchyType:ADMIN
campaignId:13175791-db53-4d10-be90-2dba1c138756 3)userWithBoundary tenantId:mz
type:userWithBoundary
forceUpdate:true
hierarchyType:ADMIN
campaignId:13175791-db53-4d10-be90-2dba1c138756
/project-factory/v1/data/_download
POST
Params will be different for different types- 1)boundary tenantId:mz
type:boundary
hierarchyType:ADMIN
id:987eadc3-55a0-4553-925d-bf8087f57e5a 2)facilityWithBoundary tenantId:mz
type:facilityWithBoundary
hierarchyType:ADMIN
id:052f59fc-18a7-4e07-816a-f5d8062b56b5 3)userWithBoundary tenantId:mz
type:userWithBoundary
hierarchyType:ADMIN
id:fbfbd393-d053-4f51-9e12-1068b97da292
/project-factory/v1/data/_create
POST
1) type: boundaryWithTarget { "type": "boundaryWithTarget", "hierarchyType": "ADMIN", "tenantId": "mz", "fileStoreId": "ad9efbdb-b2c5-434e-b86e-1cb02d61e758", "action": "validate", "campaignId": "13175791-db53-4d10-be90-2dba1c138756", "additionalDetails": {} } 2) type: facility { "type": "facility", "hierarchyType": "ADMIN", "tenantId": "mz", "fileStoreId": "a5ca723c-e463-4428-86b4-e0f706973857", "action": "validate", "campaignId": "13175791-db53-4d10-be90-2dba1c138756", "additionalDetails": {} } 3) type: user { "type": "user", "hierarchyType": "ADMIN", "tenantId": "mz", "fileStoreId": "3f6348b0-7e10-4f1a-8f48-dcfb0c9afdff", "action": "validate", "campaignId": "13175791-db53-4d10-be90-2dba1c138756", "additionalDetails": {} }