diff --git a/frontend/src/components/periodicDataUpdates/PeriodicDataUpdates.tsx b/frontend/src/components/periodicDataUpdates/PeriodicDataUpdates.tsx index 5831a1592e..2257981eb3 100644 --- a/frontend/src/components/periodicDataUpdates/PeriodicDataUpdates.tsx +++ b/frontend/src/components/periodicDataUpdates/PeriodicDataUpdates.tsx @@ -7,10 +7,12 @@ import { PeriodicDataUpdatesTemplatesList } from './PeriodicDataUpdatesTemplates import { PeriodicDataUpdatesUpdatesList } from './PeriodicDataUpdatesUpdatesList'; import { useBaseUrl } from '@hooks/useBaseUrl'; import { PeriodDataUpdatesUploadDialog } from './PeriodicDataUpdatesUploadDialog'; +import { useProgramContext } from 'src/programContext'; export const PeriodicDataUpdates = (): React.ReactElement => { const [value, setValue] = useState(0); const { baseUrl } = useBaseUrl(); + const { isSocialDctType } = useProgramContext(); const handleChange = ( _event: React.ChangeEvent, @@ -19,6 +21,10 @@ export const PeriodicDataUpdates = (): React.ReactElement => { setValue(newValue); }; + const newTemplatePath = isSocialDctType + ? `/${baseUrl}/population/people/new-template` + : `/${baseUrl}/population/individuals/new-template`; + return ( { variant="contained" color="primary" component={Link} - to={`/${baseUrl}/population/household-members/new-template`} + to={newTemplatePath} startIcon={} > New Template diff --git a/frontend/src/containers/pages/householdMembers/HouseholdMembersToMovePage.tsx b/frontend/src/containers/pages/householdMembers/HouseholdMembersToMovePage.tsx deleted file mode 100644 index 9b02383f8a..0000000000 --- a/frontend/src/containers/pages/householdMembers/HouseholdMembersToMovePage.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { useState } from 'react'; -import { useNavigate } from 'react-router-dom'; -import { PageHeader } from '@components/core/PageHeader'; -import { Tabs, Tab } from '@core/Tabs'; -import { PeriodicDataUpdates } from '@components/periodicDataUpdates/PeriodicDataUpdates'; -import { useBaseUrl } from '@hooks/useBaseUrl'; - -export const HouseholdMembersToMovePage = () => { - const { baseUrl } = useBaseUrl(); - const navigate = useNavigate(); - - const [selectedTab, setSelectedTab] = useState(0); - - const individualsPath = `/${baseUrl}/population/household-members/individuals`; - const periodicDataUpdatesPath = `/${baseUrl}/population/household-members/periodic-data-updates`; - - const handleTabChange = (newValue) => { - setSelectedTab(newValue); - navigate(newValue === 0 ? individualsPath : periodicDataUpdatesPath); - }; - - const renderTabContent = () => { - switch (selectedTab) { - case 0: - return
Individuals Content
; - case 1: - return ; - default: - return null; - } - }; - - return ( - <> - handleTabChange(newValue)} - indicatorColor="primary" - textColor="primary" - variant="scrollable" - scrollButtons="auto" - aria-label="tabs" - > - - - - } - title="Household Members" - /> - {renderTabContent()} - - ); -}; diff --git a/frontend/src/containers/pages/householdMembers/NewTemplatePage.tsx b/frontend/src/containers/pages/householdMembers/NewTemplatePage.tsx index 32cee259d8..5b936311bd 100644 --- a/frontend/src/containers/pages/householdMembers/NewTemplatePage.tsx +++ b/frontend/src/containers/pages/householdMembers/NewTemplatePage.tsx @@ -45,7 +45,7 @@ export const NewTemplatePage = (): React.ReactElement => { const breadCrumbsItems: BreadCrumbsItem[] = [ { title: t('Household Members'), - to: `/${baseUrl}/population/household-members`, + to: `/${baseUrl}/population/individuals`, }, ]; @@ -107,7 +107,7 @@ export const NewTemplatePage = (): React.ReactElement => { variant="outlined" color="secondary" component={Link} - to={`/${baseUrl}/population/household-members`} + to={`/${baseUrl}/population/individuals`} style={{ marginRight: '10px' }} > Cancel diff --git a/frontend/src/containers/pages/householdMembers/NewTemplatePeoplePage.tsx b/frontend/src/containers/pages/householdMembers/NewTemplatePeoplePage.tsx new file mode 100644 index 0000000000..ae718f73ea --- /dev/null +++ b/frontend/src/containers/pages/householdMembers/NewTemplatePeoplePage.tsx @@ -0,0 +1,138 @@ +import { useState } from 'react'; +import { Link, useLocation } from 'react-router-dom'; +import { BreadCrumbsItem } from '@components/core/BreadCrumbs'; +import { PageHeader } from '@components/core/PageHeader'; +import { useBaseUrl } from '@hooks/useBaseUrl'; +import { usePermissions } from '@hooks/usePermissions'; +import { useTranslation } from 'react-i18next'; +import { hasPermissions, PERMISSIONS } from 'src/config/permissions'; +import { BaseSection } from '@components/core/BaseSection'; +import { Button, Stepper, Step, StepLabel, Box } from '@mui/material'; +import { getFilterFromQueryParams } from '@utils/utils'; +import { FilterIndividuals } from '@components/periodicDataUpdates/FilterIndividuals'; +import { FieldsToUpdate } from '@components/periodicDataUpdates/FieldsToUpdate'; +import { Formik } from 'formik'; + +export const NewTemplatePeoplePage = (): React.ReactElement => { + const { t } = useTranslation(); + const { baseUrl } = useBaseUrl(); + const permissions = usePermissions(); + const location = useLocation(); + + const initialFilter = { + registrationDataImport: '', + genderIdentity: '', + ageMin: null, + ageMax: null, + hasGrievanceTicket: '', + receivedAssistance: '', + householdSizeMin: null, + householdSizeMax: null, + }; + + const [filter, setFilter] = useState( + getFilterFromQueryParams(location, initialFilter), + ); + const [appliedFilter, setAppliedFilter] = useState( + getFilterFromQueryParams(location, initialFilter), + ); + + const initialValues = { + ...appliedFilter, + selectedFields: [], + }; + + const breadCrumbsItems: BreadCrumbsItem[] = [ + { + title: t('People'), + to: `/${baseUrl}/population/people`, + }, + ]; + + const [activeStep, setActiveStep] = useState(0); + const steps = ['Filter Individuals', 'Fields to Update']; + + const handleNext = () => { + setActiveStep((prevActiveStep) => prevActiveStep + 1); + }; + + const handleBack = () => { + setActiveStep((prevActiveStep) => prevActiveStep - 1); + }; + + return ( + { + console.log('values', values); + }} + > + {({ values, setFieldValue, submitForm }) => ( + <> + + + + {steps.map((label) => ( + + {label} + + ))} + + {activeStep === 0 && ( + + )} + {activeStep === 1 && ( + + )} + + + + + {activeStep === 1 && ( + + + + )} + + + + + + + )} + + ); +}; diff --git a/frontend/src/containers/routers/PopulationRoutes.tsx b/frontend/src/containers/routers/PopulationRoutes.tsx index 76d1c4d398..e8d0ac7e2b 100644 --- a/frontend/src/containers/routers/PopulationRoutes.tsx +++ b/frontend/src/containers/routers/PopulationRoutes.tsx @@ -7,6 +7,7 @@ import { PeoplePage } from '@containers/pages/people/PeoplePage'; import { PeopleDetailsPage } from '@containers/pages/people/PeopleDetailsPage'; import { NewTemplatePage } from '@containers/pages/householdMembers/NewTemplatePage'; import { HouseholdMembersPage } from '@containers/pages/population/HouseholdMembersPage'; +import { NewTemplatePeoplePage } from '@containers/pages/householdMembers/NewTemplatePeoplePage'; export const PopulationRoutes = (): React.ReactElement => { const populationRoutes = [ @@ -35,9 +36,13 @@ export const PopulationRoutes = (): React.ReactElement => { element: , }, { - path: 'population/household-members/new-template', + path: 'population/individuals/new-template', element: , }, + { + path: 'population/people/new-template', + element: , + }, ]; return useRoutes(populationRoutes);