Skip to content

Commit

Permalink
feat: earmarked stocks make campaign and round selection not mandator…
Browse files Browse the repository at this point in the history
…y, remove earmark tab

Refs: IA-3980, POLIO-1857
  • Loading branch information
mathvdh authored Mar 11, 2025
1 parent 3d5ee92 commit ec9928c
Show file tree
Hide file tree
Showing 13 changed files with 1,146 additions and 350 deletions.
449 changes: 336 additions & 113 deletions plugins/polio/api/vaccines/stock_management.py

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions plugins/polio/js/src/constants/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@
"iaso.polio.label.targetPopulation": "Target population",
"iaso.polio.label.targetPopulationMessage": "Target population can be edited in \"Campaigns\" > \"Rounds\" tab",
"iaso.polio.label.Teachers_Student": "Teachers",
"iaso.polio.label.temporary_campaign_name": "Temporary campaign name",
"iaso.polio.label.testCampaign": "Test campaign/On hold",
"iaso.polio.label.testRound": "Test round / On hold",
"iaso.polio.label.timesSelected": "Times selected",
Expand Down
1 change: 1 addition & 0 deletions plugins/polio/js/src/constants/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@
"iaso.polio.label.targetPopulation": "Population cible",
"iaso.polio.label.targetPopulationMessage": "La population cible peut être éditée dans \"Campagnes\" > onglet \"Rounds\"",
"iaso.polio.label.Teachers_Student": "Professeurs",
"iaso.polio.label.temporary_campaign_name": "Nom de campagne provisoire",
"iaso.polio.label.testCampaign": "Campagne de test/en pause",
"iaso.polio.label.testRound": "Round de test / En pause",
"iaso.polio.label.timesSelected": "Nombre de sélections",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { FunctionComponent } from 'react';
import { Table, TableBody } from '@mui/material';
import { makeStyles } from '@mui/styles';
import { useSafeIntl } from 'bluesquare-components';
import classnames from 'classnames';
import React, { FunctionComponent } from 'react';
import WidgetPaper from '../../../../../../../../../hat/assets/js/apps/Iaso/components/papers/WidgetPaperComponent';
import { PaperTableRow } from '../../../../../../../../../hat/assets/js/apps/Iaso/components/tables/PaperTableRow';
import MESSAGES from '../../messages';
Expand Down Expand Up @@ -62,7 +62,7 @@ export const VaccineStockManagementSummary: FunctionComponent<Props> = ({
isLoading={isLoading}
/>
)}
<PaperTableRow
{/* <PaperTableRow
label={formatMessage(MESSAGES.earmarked_vials)}
value={data?.total_earmarked_vials}
isLoading={isLoading}
Expand All @@ -71,7 +71,7 @@ export const VaccineStockManagementSummary: FunctionComponent<Props> = ({
label={formatMessage(MESSAGES.earmarked_doses)}
value={data?.total_earmarked_doses}
isLoading={isLoading}
/>
/> */}
</TableBody>
</Table>
</WidgetPaper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import ExcellSvg from '../../../../../../../../hat/assets/js/apps/Iaso/component
import { useTabs } from '../../../../../../../../hat/assets/js/apps/Iaso/hooks/useTabs';
import { useParamsObject } from '../../../../../../../../hat/assets/js/apps/Iaso/routing/hooks/useParamsObject';
import { baseUrls } from '../../../../constants/urls';
import { EARMARKED, UNUSABLE_VIALS, USABLE_VIALS } from '../constants';
import { UNUSABLE_VIALS, USABLE_VIALS } from '../constants';
import {
useGetEarmarked,
// useGetEarmarked,
useGetStockManagementSummary,
useGetUnusableVials,
useGetUsableVials,
Expand Down Expand Up @@ -62,8 +62,8 @@ export const VaccineStockManagementDetails: FunctionComponent = () => {
const { data: unusableVials, isFetching: isFetchingUnusable } =
useGetUnusableVials(params, tab === UNUSABLE_VIALS);

const { data: earmarked, isFetching: isFetchingEarmarked } =
useGetEarmarked(params, tab === EARMARKED);
// const { data: earmarked, isFetching: isFetchingEarmarked } =
// useGetEarmarked(params, tab === EARMARKED);

const { data: summary, isLoading: isLoadingSummary } =
useGetStockManagementSummary(params.id);
Expand Down Expand Up @@ -91,9 +91,9 @@ export const VaccineStockManagementDetails: FunctionComponent = () => {
case UNUSABLE_VIALS:
xlsxUrl = `${xlsxUrl}/get_unusable_vials/?export_xlsx=true`;
break;
case EARMARKED:
xlsxUrl = `${xlsxUrl}/get_unusable_vials/?export_xlsx=true`;
break;
// case EARMARKED:
// xlsxUrl = `${xlsxUrl}/get_unusable_vials/?export_xlsx=true`;
// break;
default:
break;
}
Expand Down Expand Up @@ -164,11 +164,11 @@ export const VaccineStockManagementDetails: FunctionComponent = () => {
label={formatMessage(MESSAGES.unusable)}
/>
)}
<Tab
{/* <Tab
key={EARMARKED}
value={EARMARKED}
label={formatMessage(MESSAGES.earmarked)}
/>
/> */}
</Tabs>
<Paper elevation={2} className={classes.marginTop}>
<Box pt={2} px={2}>
Expand All @@ -193,14 +193,14 @@ export const VaccineStockManagementDetails: FunctionComponent = () => {
isFetching={isFetchingUnusable}
/>
)}
{tab === EARMARKED && (
{/* {tab === EARMARKED && (
<VaccineStockManagementDetailsTableUnusable
params={params}
paramsPrefix={tab}
data={earmarked}
isFetching={isFetchingEarmarked}
/>
)}
)} */}
</Box>
</Paper>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const CreateEditEarmarked: FunctionComponent<Props> = ({
campaign: earmark?.campaign,
round_number: earmark?.round_number,
comment: earmark?.comment,
temporary_campaign_name: earmark?.temporary_campaign_name,
vials_earmarked: earmark?.vials_earmarked || 0,
doses_earmarked: earmark?.doses_earmarked || 0,
vaccine_stock: vaccineStockId,
Expand Down Expand Up @@ -108,7 +109,6 @@ export const CreateEditEarmarked: FunctionComponent<Props> = ({
label={formatMessage(MESSAGES.campaign)}
name="campaign"
component={SingleSelect}
required
options={campaignOptions}
withMarginTop
isLoading={isFetching}
Expand All @@ -120,7 +120,6 @@ export const CreateEditEarmarked: FunctionComponent<Props> = ({
label={formatMessage(MESSAGES.round)}
name="round_number"
component={SingleSelect}
required
options={roundNumberOptions}
withMarginTop
isLoading={isFetching}
Expand All @@ -145,6 +144,14 @@ export const CreateEditEarmarked: FunctionComponent<Props> = ({
shrinkLabel={false}
/>
</Box>
<Box mb={2}>
<Field
label={formatMessage(MESSAGES.temporary_campaign_name)}
name="temporary_campaign_name"
component={TextInput}
shrinkLabel={false}
/>
</Box>
</ConfirmCancelModal>
</FormikProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,9 @@ export const useEarmarkValidation = () => {
.string()
.nullable()
.required(formatMessage(MESSAGES.requiredField)), // can be made more strict with accepted values from dropdown
campaign: yup
.string()
.nullable()
.required(formatMessage(MESSAGES.requiredField)),
round_number: yup
.number()
.integer()
.positive()
.nullable()
.required(formatMessage(MESSAGES.requiredField)),
campaign: yup.string().nullable(),
temporary_campaign_name: yup.string().nullable(),
round_number: yup.number().integer().positive().nullable(),
vials_earmarked: yup
.number()
.required(formatMessage(MESSAGES.requiredField))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,14 @@ export const useEarmarkedTableColumns = (
accessor: 'campaign',
id: 'campaign',
sortable: true,
Cell: BreakWordCell,
Cell: settings => {
if (settings.row.original.campaign) {
return settings.row.original.campaign;
}
return settings.row.original.temporary_campaign_name
? `(${settings.row.original.temporary_campaign_name})`
: textPlaceholder;
},
},
{
Header: formatMessage(MESSAGES.round),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ const MESSAGES = defineMessages({
id: 'iaso.label.returned',
defaultMessage: 'Returned',
},
temporary_campaign_name: {
id: 'iaso.polio.label.temporary_campaign_name',
defaultMessage: 'Temporary campaign name',
},
});

export default MESSAGES;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Generated by Django 4.2.17 on 2025-03-11 12:46

import django.db.models.deletion

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("polio", "0223_destructionreport_created_at_and_more"),
]

operations = [
migrations.AddField(
model_name="earmarkedstock",
name="temporary_campaign_name",
field=models.CharField(blank=True, max_length=255),
),
migrations.AlterField(
model_name="earmarkedstock",
name="campaign",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="polio.campaign",
),
),
migrations.AlterField(
model_name="earmarkedstock",
name="round",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="polio.round",
),
),
]
Loading

0 comments on commit ec9928c

Please sign in to comment.