Skip to content

Commit

Permalink
next part
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Szewczyk committed Dec 12, 2024
1 parent 81b15cb commit f425928
Show file tree
Hide file tree
Showing 26 changed files with 112 additions and 107 deletions.
2 changes: 2 additions & 0 deletions src/frontend/src/__generated__/graphql.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/frontend/src/apollo/queries/targeting/TargetPopulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ export const TARGET_POPULATION_QUERY = gql`
buildStatus
totalHouseholdsCount
totalIndividualsCount
finalizedBy
changeDate
finalizedAt
excludedIds
exclusionReason
vulnerabilityScoreMin
vulnerabilityScoreMax
steficonRule {
__typename
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
import { PaymentPlanStatus } from '@generated/graphql';
import {
createHandleApplyFilterChange,
targetPopulationStatusMapping,
paymentPlanStatusMapping,
} from '@utils/utils';
import { DatePickerFilter } from '@core/DatePickerFilter';
import { FiltersSection } from '@core/FiltersSection';
Expand Down Expand Up @@ -82,7 +82,7 @@ export function LookUpTargetPopulationFiltersCommunication({
>
{preparedStatusChoices.sort().map((key) => (
<MenuItem key={key} value={key}>
{targetPopulationStatusMapping(key)}
{paymentPlanStatusMapping(key)}
</MenuItem>
))}
</SelectFilter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
import { PaymentPlanStatus } from '@generated/graphql';
import {
createHandleApplyFilterChange,
targetPopulationStatusMapping,
paymentPlanStatusMapping,
} from '@utils/utils';
import { DatePickerFilter } from '@core/DatePickerFilter';
import { FiltersSection } from '@core/FiltersSection';
Expand Down Expand Up @@ -85,7 +85,7 @@ export function LookUpTargetPopulationFiltersSurveys({
>
{preparedStatusChoices.sort().map((key) => (
<MenuItem key={key} value={key}>
{targetPopulationStatusMapping(key)}
{paymentPlanStatusMapping(key)}
</MenuItem>
))}
</SelectFilter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ export function PaymentDetails({
<Grid item xs={3}>
<LabelizedField label={t('TARGET POPULATION')}>
<BlackLink
to={`/${businessArea}/programs/${programId}/target-population/${payment.targetPopulation.id}`}
to={`/${businessArea}/programs/${programId}/target-population/${payment.parent.id}`}
>
{payment.targetPopulation?.name}
{payment.parent?.name}
</BlackLink>
</LabelizedField>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, Button } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { Link, useParams } from 'react-router-dom';
import { TargetPopulationQuery } from '@generated/graphql';
import { PaymentPlanQuery } from '@generated/graphql';
import { BreadCrumbsItem } from '@core/BreadCrumbs';
import { LoadingButton } from '@core/LoadingButton';
import { PageHeader } from '@core/PageHeader';
Expand All @@ -11,7 +11,7 @@ interface EditTargetPopulationProps {
handleSubmit: () => Promise<void>;
values;
baseUrl: string;
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];
loading: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ChartContainer = styled.div`
`;

interface ResultsProps {
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];

Check failure on line 54 in src/frontend/src/components/targeting/ResultsForHouseholds.tsx

View workflow job for this annotation

GitHub Actions / frontend_tests

'PaymentPlanQuery' is not defined
}

export function ResultsForHouseholds({
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/targeting/ResultsForPeople.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const SummaryValue = styled.div`
`;

interface ResultsProps {
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];

Check failure on line 53 in src/frontend/src/components/targeting/ResultsForPeople.tsx

View workflow job for this annotation

GitHub Actions / frontend_tests

'PaymentPlanQuery' is not defined
}

export function ResultsForPeople({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import styled from 'styled-components';
import { hasPermissions, PERMISSIONS } from '../../config/permissions';
import { UniversalActivityLogTable } from '@containers/tables/UniversalActivityLogTable';
import {
PaymentPlanQuery,
TargetPopulationBuildStatus,
TargetPopulationQuery,
useTargetPopulationHouseholdsQuery,
} from '@generated/graphql';
import { PaperContainer } from './PaperContainer';
Expand All @@ -24,7 +24,7 @@ const Label = styled.p`

interface TargetPopulationCoreProps {
id: string;
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];
permissions: string[];
screenBeneficiary: boolean;
isStandardDctType: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Grid, Typography } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { targetPopulationStatusToColor } from '@utils/utils';
import { TargetPopulationQuery } from '@generated/graphql';
import { paymentPlanStatusToColor } from '@utils/utils';
import { PaymentPlanQuery } from '@generated/graphql';
import { ContainerColumnWithBorder } from '@core/ContainerColumnWithBorder';
import { LabelizedField } from '@core/LabelizedField';
import { OverviewContainer } from '@core/OverviewContainer';
Expand All @@ -11,7 +11,7 @@ import { UniversalMoment } from '@core/UniversalMoment';
import { ReactElement } from 'react';

interface ProgramDetailsProps {
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];
}

export function TargetPopulationDetails({
Expand Down Expand Up @@ -52,7 +52,7 @@ export function TargetPopulationDetails({
<StatusBox
dataCy="target-population-status"
status={targetPopulation.status}
statusToColor={targetPopulationStatusToColor}
statusToColor={paymentPlanStatusToColor}
/>
</LabelizedField>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Grid, MenuItem } from '@mui/material';
import { Group, Person } from '@mui/icons-material';
import { useTranslation } from 'react-i18next';
import { useLocation, useNavigate } from 'react-router-dom';
import { TargetPopulationStatus } from '@generated/graphql';
import { PaymentPlanStatus } from '@generated/graphql';
import {
createHandleApplyFilterChange,
targetPopulationStatusMapping,
Expand Down Expand Up @@ -52,8 +52,8 @@ export const TargetPopulationForPeopleFilters = ({
};

const preparedStatusChoices = isAccountability
? Object.values(TargetPopulationStatus).filter((key) => key !== 'OPEN')
: Object.values(TargetPopulationStatus);
? Object.values(PaymentPlanStatus).filter((key) => key !== 'OPEN')
: Object.values(PaymentPlanStatus);

return (
<FiltersSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Grid, MenuItem } from '@mui/material';
import { Group, Person } from '@mui/icons-material';
import { useTranslation } from 'react-i18next';
import { useLocation, useNavigate } from 'react-router-dom';
import { TargetPopulationStatus } from '@generated/graphql';
import { PaymentPlanStatus } from '@generated/graphql';
import {
createHandleApplyFilterChange,
targetPopulationStatusMapping,
paymentPlanStatusMapping,
} from '@utils/utils';
import { DatePickerFilter } from '@core/DatePickerFilter';
import { NumberTextField } from '@core/NumberTextField';
Expand Down Expand Up @@ -55,8 +55,8 @@ export const TargetPopulationTableFilters = ({
};

const preparedStatusChoices = isAccountability
? Object.values(TargetPopulationStatus).filter((key) => key !== 'OPEN')
: Object.values(TargetPopulationStatus);
? Object.values(PaymentPlanStatus).filter((key) => key !== 'OPEN')
: Object.values(PaymentPlanStatus);

return (
<FiltersSection
Expand Down Expand Up @@ -84,7 +84,7 @@ export const TargetPopulationTableFilters = ({
>
{preparedStatusChoices.sort().map((key) => (
<MenuItem key={key} value={key}>
{targetPopulationStatusMapping(key)}
{paymentPlanStatusMapping(key)}
</MenuItem>
))}
</SelectFilter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TargetingCriteriaForm } from '@containers/forms/TargetingCriteriaForm';
import {
DataCollectingTypeType,
TargetPopulationQuery,
PaymentPlanQuery,
useAllCollectorFieldsAttributesQuery,
} from '@generated/graphql';
import { useBaseUrl } from '@hooks/useBaseUrl';
Expand Down Expand Up @@ -75,7 +75,7 @@ const AddCriteria = styled.div`
interface AddFilterTargetingCriteriaDisplayProps {
rules?;
helpers?;
targetPopulation?: TargetPopulationQuery['targetPopulation'];
targetPopulation?: PaymentPlanQuery['paymentPlan'];
isEdit?: boolean;
screenBeneficiary: boolean;
isSocialDctType: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import styled from 'styled-components';
import { TARGET_POPULATION_QUERY } from '../../../apollo/queries/targeting/TargetPopulation';
import { useSnackbar } from '@hooks/useSnackBar';
import {
TargetPopulationHouseholdsDocument,
TargetPopulationQuery,
TargetPopulationStatus,
PaymentPlanQuery,
useAllSteficonRulesQuery,
useSetSteficonRuleOnTargetPopulationMutation,
useUpdateTpMutation,
Expand Down Expand Up @@ -97,7 +95,7 @@ const ApplyScoreRange = styled.div`
export function VulnerabilityScoreComponent({
targetPopulation,
}: {
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];
}): ReactElement {
const { t } = useTranslation();
const { businessArea } = useBaseUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Button, DialogContent, DialogTitle, Typography } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { LoadingButton } from '@components/core/LoadingButton';
import { useSnackbar } from '@hooks/useSnackBar';
import { useFinalizeTpMutation } from '@generated/graphql';
import { Dialog } from '../Dialog';
import { DialogActions } from '../DialogActions';
import { DialogDescription } from '../DialogDescription';
Expand All @@ -12,6 +11,8 @@ import { useBaseUrl } from '@hooks/useBaseUrl';
import { useNavigate } from 'react-router-dom';
import { useProgramContext } from '../../../programContext';
import { ReactElement } from 'react';
import { Action } from '@generated/graphql';
import { usePaymentPlanAction } from '@hooks/usePaymentPlanAction';

export interface FinalizeTargetPopulationPaymentPlanProps {
open: boolean;
Expand All @@ -30,18 +31,17 @@ export const FinalizeTargetPopulationPaymentPlan = ({
const { t } = useTranslation();
const { showMessage } = useSnackbar();
const { baseUrl } = useBaseUrl();
const [mutate, { loading }] = useFinalizeTpMutation();
const { mutatePaymentPlanAction: finish, loading: loadingFinish } =
usePaymentPlanAction(
Action.TPFinalize,
targetPopulationId,
() => showMessage(t('Target Population Finalized')),
() => setOpen(false),
);
const { isSocialDctType } = useProgramContext();
const onSubmit = (id: string): void => {
mutate({
variables: {
id,
},
}).then(() => {
setOpen(false);
showMessage(t('Target Population Finalized'));
navigate(`/${baseUrl}/target-population/${id}`);
});
const onSubmit = (): void => {
finish();
navigate(`/${baseUrl}/target-population/${targetPopulationId}`);
};
return (
<Dialog
Expand All @@ -68,11 +68,11 @@ export const FinalizeTargetPopulationPaymentPlan = ({
<DialogActions>
<Button onClick={() => setOpen(false)}>{t('CANCEL')}</Button>
<LoadingButton
onClick={() => onSubmit(targetPopulationId)}
onClick={() => onSubmit()}
color="primary"
variant="contained"
loading={loading}
disabled={loading || !totalHouseholds}
loading={loadingFinish}
disabled={loadingFinish || !totalHouseholds}
data-cy="button-target-population-modal-send-to-hope"
>
{t('Mark Ready')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const IconContainer = styled.span`
`;

export interface FinalizedTargetPopulationHeaderButtonsPropTypes {
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];
canDuplicate: boolean;
businessAreaData: BusinessAreaDataQuery;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const IconContainer = styled.span`
`;

export interface ApprovedTargetPopulationHeaderButtonsPropTypes {
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];
canUnlock: boolean;
canDuplicate: boolean;
canSend: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { t } from 'i18next';
import { useSnackbar } from '@hooks/useSnackBar';

export interface InProgressTargetPopulationHeaderButtonsPropTypes {
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];
canDuplicate: boolean;
canRemove: boolean;
canEdit: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const StatusWrapper = styled.div`
`;

export interface ProgramDetailsPageHeaderPropTypes {
targetPopulation: TargetPopulationQuery['targetPopulation'];
targetPopulation: PaymentPlanQuery['paymentPlan'];
canEdit: boolean;
canRemove: boolean;
canDuplicate: boolean;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import TableCell from '@mui/material/TableCell';
import { useNavigate } from 'react-router-dom';
import { Radio } from '@mui/material';
import { TargetPopulationNode } from '@generated/graphql';
import { PaymentPlanNode } from '@generated/graphql';
import { useBusinessArea } from '@hooks/useBusinessArea';
import { ClickableTableRow } from '@components/core/Table/ClickableTableRow';
import { StatusBox } from '@components/core/StatusBox';
import {
targetPopulationStatusToColor,
paymentPlanStatusToColor,
targetPopulationStatusMapping,
} from '@utils/utils';
import { UniversalMoment } from '@components/core/UniversalMoment';
import { BlackLink } from '@components/core/BlackLink';
import { ReactElement } from 'react';

interface LookUpTargetPopulationTableRowCommunicationProps {
targetPopulation: TargetPopulationNode;
targetPopulation: PaymentPlanNode;
canViewDetails: boolean;
selectedTargetPopulation?;
radioChangeHandler?: (id: string) => void;
Expand Down Expand Up @@ -69,7 +69,7 @@ export function LookUpTargetPopulationTableRowCommunication({
<TableCell align="left">
<StatusBox
status={targetPopulation.status}
statusToColor={targetPopulationStatusToColor}
statusToColor={paymentPlanStatusToColor}
statusNameMapping={targetPopulationStatusMapping}
/>
</TableCell>
Expand Down
Loading

0 comments on commit f425928

Please sign in to comment.