Skip to content

Commit

Permalink
POLIO-1803: fix vaccine dropdown
Browse files Browse the repository at this point in the history
- show individual vaccines for bOPV & nOPV2 campaigns
- Include subactivities vaccines
  • Loading branch information
quang-le committed Dec 19, 2024
1 parent 3241675 commit d40e273
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions plugins/polio/js/src/constants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ export type RoundDateHistoryEntry = {

export type Round = {
id: number;
vaccine_names_extended:string;
started_at: Nullable<string>;
ended_at: Nullable<string>;
mop_up_started_at: Nullable<string>; // date
Expand Down Expand Up @@ -308,6 +309,7 @@ export type Campaign = {
created_at: string;
updated_at: string;
deleted_at: Nullable<string>;
single_vaccines?: string;
rounds: Round[];
org_unit: {
id: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ export const defaultVaccineOptions = [
value: 'nOPV2 & bOPV',
},
];

export const singleVaccinesList = [
{
label: 'nOPV2',
value: 'nOPV2',
},
{
label: 'mOPV2',
value: 'mOPV2',
},
{
label: 'bOPV',
value: 'bOPV',
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
CampaignCategory,
useGetCampaigns,
} from '../../../../Campaigns/hooks/api/useGetCampaigns';
import { apiUrl, defaultVaccineOptions } from '../../constants';
import { apiUrl, defaultVaccineOptions, singleVaccinesList } from '../../constants';
import MESSAGES from '../../messages';
import {
CampaignDropdowns,
Expand Down Expand Up @@ -133,15 +133,15 @@ export const useCampaignDropDowns = (
label: c.obr_name,
value: c.obr_name,
}));
const vaccines = selectedCampaign?.vaccines
? selectedCampaign.vaccines.split(',').map(vaccineName => ({
const vaccines = selectedCampaign?.single_vaccines
? selectedCampaign.single_vaccines.split(',').map(vaccineName => ({
label: vaccineName,
value: vaccineName,
}))
: defaultVaccineOptions;
: singleVaccinesList;
const rounds = vaccine
? (selectedCampaign?.rounds ?? [])
.filter(round => round.vaccine_names.includes(vaccine))
.filter(round => round.vaccine_names_extended.includes(vaccine))
.map(round => ({
label: `Round ${round.number}`,
value: `${round.number}`,
Expand Down

0 comments on commit d40e273

Please sign in to comment.