Skip to content

Commit

Permalink
feat: vaccine management repository front
Browse files Browse the repository at this point in the history
  • Loading branch information
beygorghor authored Nov 19, 2024
2 parents 995c187 + e677809 commit a104883
Show file tree
Hide file tree
Showing 27 changed files with 960 additions and 32 deletions.
42 changes: 35 additions & 7 deletions hat/assets/js/apps/Iaso/components/files/pdf/PdfPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import {
IconButton,
} from '@mui/material';
import { LoadingSpinner, useSafeIntl } from 'bluesquare-components';
import React, { FunctionComponent, useCallback, useState } from 'react';
import React, {
ComponentType,
FunctionComponent,
useCallback,
useState,
} from 'react';
import { Document, Page, pdfjs } from 'react-pdf';
import { SxStyles } from '../../../types/general';
import PdfSvgComponent from '../../svg/PdfSvgComponent';
Expand All @@ -25,6 +30,11 @@ if (!pdfjs.GlobalWorkerOptions.workerSrc) {

type PdfPreviewProps = {
pdfUrl?: string;
OpenButtonComponent?: ComponentType<{
onClick: () => void;
disabled: boolean;
}>;
buttonProps?: Record<string, unknown>;
};

const styles: SxStyles = {
Expand Down Expand Up @@ -62,13 +72,31 @@ const styles: SxStyles = {
},
};

export const PdfPreview: FunctionComponent<PdfPreviewProps> = ({ pdfUrl }) => {
const DefaultOpenButton: FunctionComponent<{
onClick: () => void;
disabled: boolean;
}> = ({ onClick, disabled }) => (
<IconButton
onClick={onClick}
aria-label="preview document"
disabled={disabled}
>
<PdfSvgComponent />
</IconButton>
);

export const PdfPreview: FunctionComponent<PdfPreviewProps> = ({
pdfUrl,
OpenButtonComponent,
buttonProps,
}) => {
const [open, setOpen] = useState(false);
const [numPages, setNumPages] = useState<number | null>(null);
const [pageNumber, setPageNumber] = useState(1);

const { formatMessage } = useSafeIntl();
const handleOpen = () => {
console.log('handleOpen');
setOpen(true);
};

Expand Down Expand Up @@ -103,15 +131,15 @@ export const PdfPreview: FunctionComponent<PdfPreviewProps> = ({ pdfUrl }) => {
});
};

const OpenButton = OpenButtonComponent || DefaultOpenButton;

return (
<>
<IconButton
<OpenButton
onClick={handleOpen}
aria-label="preview document"
disabled={!pdfUrl}
>
<PdfSvgComponent />
</IconButton>
{...buttonProps}
/>
{open && (
<Dialog
fullWidth
Expand Down
1 change: 0 additions & 1 deletion hat/assets/js/apps/Iaso/domains/app/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,6 @@
"iaso.planning.title": "Planning",
"iaso.plannings.label.duplicatePlanning": "Duplicate planning",
"iaso.plannings.label.selectOrgUnit": "Please select org unit",
"iaso.polio.label.document": "Document CHECKME",
"iaso.projects.appId": "App ID",
"iaso.projects.create": "Create project",
"iaso.projects.false": "User doesn't need authentication",
Expand Down
1 change: 0 additions & 1 deletion hat/assets/js/apps/Iaso/domains/app/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,6 @@
"iaso.planning.title": "Planning",
"iaso.plannings.label.duplicatePlanning": "Dupliquer planning",
"iaso.plannings.label.selectOrgUnit": "Sélectionner une unité d'org.",
"iaso.polio.label.document": "Document CHECKME",
"iaso.projects.appId": "Identifiant de l'App",
"iaso.projects.create": "Créer un projet",
"iaso.projects.false": "L'utilisateur n'a pas besoin d'authentification",
Expand Down
3 changes: 2 additions & 1 deletion hat/dashboard/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

app_name = "dashboard"
urlpatterns = [
re_path(r"^polio/embeddedCalendar/.*$", views.embeddable_iaso, name="embedded"),
re_path(r"^polio/embeddedCalendar/.*$", views.embeddable_iaso, name="embedded_calendar"),
re_path(r"^polio/embeddedVaccineRepository/.*$", views.embeddable_iaso, name="embedded_vaccine_repository"),
path("home/", views.home_iaso, name="home_iaso"),
re_path(r"^.*$", views.iaso, name="iaso"),
]
8 changes: 7 additions & 1 deletion plugins/polio/api/vaccines/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ def get_vrf_data(self, obj):
"file": vrf.document.url if vrf.document else None,
"is_missing": vrf.vrf_type == VaccineRequestFormType.MISSING,
"is_not_required": vrf.vrf_type == VaccineRequestFormType.NOT_REQUIRED,
"id": vrf.id,
}
for vrf in vrfs
]

def get_pre_alert_data(self, obj):
pre_alerts = VaccinePreAlert.objects.filter(request_form__campaign=obj.campaign, request_form__rounds=obj)
return [
{"date": pa.date_pre_alert_reception, "file": pa.document.url if pa.document else None} for pa in pre_alerts
{
"date": pa.date_pre_alert_reception,
"file": pa.document.url if pa.document else None,
"vrf_id": pa.request_form.id,
}
for pa in pre_alerts
]

def get_form_a_data(self, obj):
Expand Down
8 changes: 8 additions & 0 deletions plugins/polio/js/src/constants/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import GroupWork from '@mui/icons-material/GroupWork';
import HomeIcon from '@mui/icons-material/Home';
import HomeWorkIcon from '@mui/icons-material/HomeWork';
import DataSourceIcon from '@mui/icons-material/ListAltTwoTone';
import InventoryIcon from '@mui/icons-material/Inventory';
import LocalShippingIcon from '@mui/icons-material/LocalShipping';
import MenuBookIcon from '@mui/icons-material/MenuBook';
import NotificationsActiveIcon from '@mui/icons-material/NotificationsActive';
Expand Down Expand Up @@ -38,6 +39,7 @@ import {
reasonsForDelayConfigPath,
stockManagementPath,
supplychainPath,
vaccineRepositoryPath,
} from './routes';

export const menu: MenuItem[] = [
Expand Down Expand Up @@ -142,6 +144,12 @@ export const menu: MenuItem[] = [
permissions: stockManagementPath.permissions,
icon: props => <StorageIcon {...props} />,
},
{
label: MESSAGES.vaccineRepository,
key: 'repository',
permissions: vaccineRepositoryPath.permissions,
icon: props => <InventoryIcon {...props} />,
},
{
label: MESSAGES.chronogram,
key: 'chronogram',
Expand Down
12 changes: 12 additions & 0 deletions plugins/polio/js/src/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,18 @@ const MESSAGES = defineMessages({
id: 'iaso.polio.notShowTestCampaigns',
defaultMessage: 'Do not show test campaigns',
},
fileType: {
id: 'iaso.polio.label.fileType',
defaultMessage: 'File type',
},
campaignStatus: {
id: 'iaso.polio.label.campaignStatus',
defaultMessage: 'Campaign status',
},
vaccineRepository: {
id: 'iaso.polio.repository.title',
defaultMessage: 'Vaccine Management Repository',
},
});

export default MESSAGES;
60 changes: 40 additions & 20 deletions plugins/polio/js/src/constants/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,49 @@
import React from 'react';
import {
AnonymousRoutePath,
RoutePath,
} from '../../../../../hat/assets/js/apps/Iaso/constants/routes';
import { BudgetProcessList } from '../domains/Budget';
import { BudgetProcessDetails } from '../domains/Budget/BudgetDetails/BudgetDetails';
import { Calendar } from '../domains/Calendar/Calendar';
import { Dashboard } from '../domains/Campaigns/CampaignsList/Dashboard';
import { CampaignHistory } from '../domains/Campaigns/campaignHistory/CampaignHistory';
import { Chronogram } from '../domains/Chronogram/Chronogram';
import { ChronogramDetails } from '../domains/Chronogram/ChronogramDetails';
import { ChronogramTemplateTask } from '../domains/Chronogram/ChronogramTemplateTask';
import { CountryNotificationsConfig } from '../domains/Config/CountryNotification/CountryNotificationsConfig';
import { ReasonsForDelay } from '../domains/Config/ReasonsForDelay/ReasonsForDelay';
import { GroupedCampaigns } from '../domains/GroupedCampaigns/GroupedCampaigns';
import { Calendar } from '../domains/Calendar/Calendar';
import { ImStats } from '../domains/LQAS-IM/IM';
import { Lqas } from '../domains/LQAS-IM/LQAS';
import { LqasAfroOverview } from '../domains/LQAS-IM/LQAS/LqasAfroOverview/LqasAfroOverview';
import { ImStats } from '../domains/LQAS-IM/IM';
import { BudgetProcessList } from '../domains/Budget';
import { BudgetProcessDetails } from '../domains/Budget/BudgetDetails/BudgetDetails';
import { Nopv2Authorisations } from '../domains/VaccineModule/Nopv2Authorisations/Nopv2Authorisations';
import { Notifications } from '../domains/Notifications';
import { Nopv2AuthorisationsDetails } from '../domains/VaccineModule/Nopv2Authorisations/Details/Nopv2AuthorisationsDetails';
import { VaccineSupplyChain } from '../domains/VaccineModule/SupplyChain/VaccineSupplyChain';
import { VaccineStockManagement } from '../domains/VaccineModule/StockManagement/VaccineStockManagement';
import { Nopv2Authorisations } from '../domains/VaccineModule/Nopv2Authorisations/Nopv2Authorisations';
import { VaccineRepository } from '../domains/VaccineModule/Repository/VaccineRepository';
import { VaccineStockManagementDetails } from '../domains/VaccineModule/StockManagement/Details/VaccineStockManagementDetails';
import { VaccineStockVariation } from '../domains/VaccineModule/StockManagement/StockVariation/VaccineStockVariation';
import { VaccineStockManagement } from '../domains/VaccineModule/StockManagement/VaccineStockManagement';
import { VaccineSupplyChainDetails } from '../domains/VaccineModule/SupplyChain/Details/VaccineSupplyChainDetails';
import { CountryNotificationsConfig } from '../domains/Config/CountryNotification/CountryNotificationsConfig';
import { ReasonsForDelay } from '../domains/Config/ReasonsForDelay/ReasonsForDelay';
import { EMBEDDED_CALENDAR_URL, baseUrls } from './urls';
import { VaccineSupplyChain } from '../domains/VaccineModule/SupplyChain/VaccineSupplyChain';
import {
BUDGET,
BUDGET_ADMIN,
CHRONOGRAM,
CHRONOGRAM_RESTRICTED_WRITE,
NOTIFICATION,
POLIO,
POLIO_ADMIN,
STOCK_MANAGEMENT_WRITE,
STOCK_MANAGEMENT_READ,
STOCK_MANAGEMENT_WRITE,
SUPPLYCHAIN_READ,
SUPPLYCHAIN_WRITE,
CHRONOGRAM,
CHRONOGRAM_RESTRICTED_WRITE,
} from './permissions';
import {
AnonymousRoutePath,
RoutePath,
} from '../../../../../hat/assets/js/apps/Iaso/constants/routes';
import { Notifications } from '../domains/Notifications';
import { Chronogram } from '../domains/Chronogram/Chronogram';
import { ChronogramTemplateTask } from '../domains/Chronogram/ChronogramTemplateTask';
import { ChronogramDetails } from '../domains/Chronogram/ChronogramDetails';
EMBEDDED_CALENDAR_URL,
EMBEDDED_VACCINE_REPOSITORY_URL,
baseUrls,
} from './urls';

// We store the path in a variable so we can import it and use its permissions
export const campaignsPath: RoutePath = {
Expand Down Expand Up @@ -70,6 +75,12 @@ export const calendarPath: RoutePath = {
element: <Calendar />,
permissions: [POLIO, POLIO_ADMIN],
};
export const vaccineRepositoryPath: RoutePath = {
baseUrl: baseUrls.vaccineRepository,
routerUrl: `${baseUrls.vaccineRepository}/*`,
element: <VaccineRepository />,
permissions: [POLIO, POLIO_ADMIN],
};

export const embeddedCalendarPath: AnonymousRoutePath = {
allowAnonymous: true,
Expand All @@ -78,6 +89,13 @@ export const embeddedCalendarPath: AnonymousRoutePath = {
element: <Calendar />,
isRootUrl: false,
};
export const embeddedVaccineRepositoryPath: AnonymousRoutePath = {
allowAnonymous: true,
baseUrl: EMBEDDED_VACCINE_REPOSITORY_URL,
routerUrl: `${EMBEDDED_VACCINE_REPOSITORY_URL}/*`,
element: <VaccineRepository />,
isRootUrl: false,
};

export const lqasCountryPath: RoutePath = {
baseUrl: baseUrls.lqasCountry,
Expand Down Expand Up @@ -223,6 +241,8 @@ export const routes: (RoutePath | AnonymousRoutePath)[] = [
groupedCampaignsPath,
calendarPath,
embeddedCalendarPath,
vaccineRepositoryPath,
embeddedVaccineRepositoryPath,
lqasCountryPath,
lqasAfroPath,
imGlobalPath,
Expand Down
7 changes: 7 additions & 0 deletions plugins/polio/js/src/constants/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
"iaso.polio.label.campaignCategory": "Campaign category",
"iaso.polio.label.campaignDropdownLabel": "Modification date",
"iaso.polio.label.campaigns": "Campaigns",
"iaso.polio.label.campaignStatus": "Campaign status",
"iaso.polio.label.campaignsToLink": "Campaigns to link",
"iaso.polio.label.campaignType": "Campaign type",
"iaso.polio.label.campaignTypes": "Types",
Expand Down Expand Up @@ -434,6 +435,7 @@
"iaso.polio.label.feedback": "Feedback",
"iaso.polio.label.files": "file(s)",
"iaso.polio.label.filesUpload": "Files",
"iaso.polio.label.fileType": "File type",
"iaso.polio.label.filter": "Filter",
"iaso.polio.label.finished": "Finished",
"iaso.polio.label.form_a_reception_date": "Form A reception (RRT)",
Expand Down Expand Up @@ -530,10 +532,12 @@
"iaso.polio.label.note": "Note",
"iaso.polio.label.notes": "Comments",
"iaso.polio.label.notifications": "Virus notification",
"iaso.polio.label.notRequired": "Not required",
"iaso.polio.label.noValidData": "No valid data",
"iaso.polio.label.numberCaregiversInformed": "Number of caregivers informed",
"iaso.polio.label.onDate": "on {date}",
"iaso.polio.label.ongoing": "Ongoing",
"iaso.polio.label.ongoingCampaigns": "Ongoing campaigns",
"iaso.polio.label.Opinion_leader": "Opinion leader",
"iaso.polio.label.other": "Other",
"iaso.polio.label.OTHER_ACTIVITIES": "Integrate with other vaccination activities",
Expand All @@ -542,6 +546,7 @@
"iaso.polio.label.oversampled": "Oversampled",
"iaso.polio.label.parentAbsent": "Parent absent",
"iaso.polio.label.passed": "Passed",
"iaso.polio.label.pastCampaigns": "Past campaigns",
"iaso.polio.label.paymentMode": "Payment Mode",
"iaso.polio.label.pending": "Pending",
"iaso.polio.label.PENDING_LIQUIDATION_OF_PREVIOUS_SIA_FUNDING": "Pending liquidation of previous SIA funding",
Expand All @@ -558,6 +563,7 @@
"iaso.polio.label.preparednesSpreadsheetUrl": "Preparedness spreadsheet url",
"iaso.polio.label.preparednessSomeWarningsDuringTheParsing": "Warning the application encountered problems while parsing the preparedness sheet",
"iaso.polio.label.preparednesSyncStatus": "Preparedness status",
"iaso.polio.label.preparing": "Preparing",
"iaso.polio.label.previousEndDate": "Previous end date",
"iaso.polio.label.previousStartDate": "Previous start date",
"iaso.polio.label.provinceOption": "PROVINCE",
Expand Down Expand Up @@ -763,6 +769,7 @@
"iaso.polio.preparednessRoundStarted": "Preparedness can't be edited if round already started",
"iaso.polio.PREPARING": "Preparing",
"iaso.polio.raStatus": "RA Status",
"iaso.polio.repository.title": "Vaccine Management Repository",
"iaso.polio.restoreCampaign": "Restore campaign",
"iaso.polio.ROUND1DONE": "Round 1 completed",
"iaso.polio.ROUND1START": "Round 1 started",
Expand Down
7 changes: 7 additions & 0 deletions plugins/polio/js/src/constants/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
"iaso.polio.label.campaignCategory": "Catégorie de campagne",
"iaso.polio.label.campaignDropdownLabel": "Date de modification",
"iaso.polio.label.campaigns": "Campagnes",
"iaso.polio.label.campaignStatus": "Status de la campagne",
"iaso.polio.label.campaignsToLink": "Campagnes à lier",
"iaso.polio.label.campaignType": "Type de campagne",
"iaso.polio.label.campaignTypes": "Types",
Expand Down Expand Up @@ -433,6 +434,7 @@
"iaso.polio.label.feedback": "Feedback",
"iaso.polio.label.files": "fichier(s)",
"iaso.polio.label.filesUpload": "Fichiers",
"iaso.polio.label.fileType": "Type de fichier",
"iaso.polio.label.filter": "Filtrer",
"iaso.polio.label.finished": "Terminé",
"iaso.polio.label.form_a_reception_date": "Réception Form A (RRT)",
Expand Down Expand Up @@ -529,10 +531,12 @@
"iaso.polio.label.note": "Note",
"iaso.polio.label.notes": "Commentaires",
"iaso.polio.label.notifications": "Notification des virus",
"iaso.polio.label.notRequired": "Non-requis",
"iaso.polio.label.noValidData": "Aucunes données valides",
"iaso.polio.label.numberCaregiversInformed": "Nombre de parents informés",
"iaso.polio.label.onDate": "le {date}",
"iaso.polio.label.ongoing": "En cours",
"iaso.polio.label.ongoingCampaigns": "Campagnes en cours",
"iaso.polio.label.Opinion_leader": "Leader d'opinion",
"iaso.polio.label.other": "Autre",
"iaso.polio.label.OTHER_ACTIVITIES": "Intégration à d'autres activités de vaccination",
Expand All @@ -541,6 +545,7 @@
"iaso.polio.label.oversampled": "Suréchantillonné",
"iaso.polio.label.parentAbsent": "Parent absent",
"iaso.polio.label.passed": "Succès",
"iaso.polio.label.pastCampaigns": "Campagnes passées",
"iaso.polio.label.paymentMode": "Mode de paiement",
"iaso.polio.label.pending": "En attente",
"iaso.polio.label.PENDING_LIQUIDATION_OF_PREVIOUS_SIA_FUNDING": "Liquidation des fonds de la SIA précédente en attente",
Expand All @@ -557,6 +562,7 @@
"iaso.polio.label.preparednesSpreadsheetUrl": "Url spreadsheet de la préparation",
"iaso.polio.label.preparednessSomeWarningsDuringTheParsing": "Avertissement : l'application a rencontré des problèmes lors de l'analyse de la feuille de préparation.",
"iaso.polio.label.preparednesSyncStatus": "Status de la préparation",
"iaso.polio.label.preparing": "En préparation",
"iaso.polio.label.previousEndDate": "Date de fin précédente",
"iaso.polio.label.previousStartDate": "Date de début précédente",
"iaso.polio.label.provinceOption": "PROVINCE",
Expand Down Expand Up @@ -762,6 +768,7 @@
"iaso.polio.preparednessRoundStarted": "La préparation de campagne ne peut être éditée après le début du round",
"iaso.polio.PREPARING": "En préparation",
"iaso.polio.raStatus": "Statut RA",
"iaso.polio.repository.title": "Archives de la gestion des vaccins",
"iaso.polio.restoreCampaign": "Restaurer la campagne",
"iaso.polio.ROUND1DONE": "Round 1 terminé",
"iaso.polio.ROUND1START": "Round 1 commencé",
Expand Down
Loading

0 comments on commit a104883

Please sign in to comment.