Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into open-api-types
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Szewczyk committed Oct 9, 2024
2 parents ffb7a93 + b024d0d commit cc7c96d
Show file tree
Hide file tree
Showing 30 changed files with 673 additions and 391 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ jobs:
-f ./.github/helpers/docker-compose.selenium.yml \
run backend bash -c "
waitforit -host=db -port=5432 -timeout=30
pytest -svvv $extra_options ./tests/selenium --cov-report xml:test-coverage/coverage.xml --html-report=./tests/selenium/output_data/report/report.html --randomly-seed=42
pytest -x -svvv $extra_options ./tests/selenium --cov-report xml:test-coverage/coverage.xml --html-report=./tests/selenium/output_data/report/report.html --randomly-seed=42
"
- name: Upload Artifact
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"styled-components": "^6.1.8",
"ts-node": "^10.9.2",
"use-deep-compare-effect": "^1.8.1",
"vite": "^5.0.8",
"vite": "^5.2.14",
"vite-tsconfig-paths": "^4.3.1",
"waait": "^1.0.5",
"yup": "^1.3.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function ExcludeSection({
excludeHouseholdError,
} = paymentPlan;

const initialExcludedIds = paymentPlan?.excludedIndividuals?.map(
const initialExcludedIds = paymentPlan?.excludedHouseholds?.map(
(el) => el.unicefId,
);
const [isExclusionsOpen, setExclusionsOpen] = useState(initialOpen);
Expand All @@ -67,7 +67,7 @@ export function ExcludeSection({
const getTooltipText = (): string => {
if (!hasOpenOrLockedStatus) {
return t(
'Beneficiaries can only be excluded from a Payment Plan in status open or locked',
'Households can only be excluded from a Payment Plan in status open or locked',
);
}
if (!hasExcludePermission) {
Expand Down Expand Up @@ -115,7 +115,7 @@ export function ExcludeSection({
awaitRefetchQueries: true,
});
if (!error) {
showMessage(t('Beneficiaries exclusion started'));
showMessage(t('Households exclusion started'));
setExclusionsOpen(false);
}
} catch (e) {
Expand All @@ -125,7 +125,7 @@ export function ExcludeSection({

const handleApply = (): void => {
const idRegex =
/^(\s*IND-\d{2}-\d{4}\.\d{4}\s*)(,\s*IND-\d{2}-\d{4}\.\d{4}\s*)*$/;
/^(\s*HH-\d{2}-\d{4}\.\d{4}\s*)(,\s*HH-\d{2}-\d{4}\.\d{4}\s*)*$/;
const ids = idsValue.trim().split(/,\s*|\s+/);
const invalidIds: string[] = [];
const alreadyExcludedIds: string[] = [];
Expand Down Expand Up @@ -311,7 +311,7 @@ export function ExcludeSection({
<Grid item xs={6}>
<Box mr={2}>
<StyledTextField
label={t('Beneficiaries Ids')}
label={t('Households Ids')}
value={idsValue}
onChange={handleIdsChange}
fullWidth
Expand Down Expand Up @@ -368,7 +368,7 @@ export function ExcludeSection({
<Box mt={2} mb={2}>
<GreyText>
{`${numberOfExcluded} ${
numberOfExcluded === 1 ? 'Beneficiary' : 'Beneficiaries'
numberOfExcluded === 1 ? 'Household' : 'Households'
} excluded`}
</GreyText>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function ExcludeSection({
const getTooltipText = (): string => {
if (!hasOpenOrLockedStatus) {
return t(
'Households can only be excluded from a Payment Plan in status open or locked',
'Beneficiaries can only be excluded from a Payment Plan in status open or locked',
);
}
if (!hasExcludePermission) {
Expand Down Expand Up @@ -115,7 +115,7 @@ export function ExcludeSection({
awaitRefetchQueries: true,
});
if (!error) {
showMessage(t('Households exclusion started'));
showMessage(t('Beneficiaries exclusion started'));
setExclusionsOpen(false);
}
} catch (e) {
Expand Down Expand Up @@ -311,7 +311,7 @@ export function ExcludeSection({
<Grid item xs={6}>
<Box mr={2}>
<StyledTextField
label={t('Household Ids')}
label={t('Beneficiaries Ids')}
value={idsValue}
onChange={handleIdsChange}
fullWidth
Expand Down Expand Up @@ -368,7 +368,7 @@ export function ExcludeSection({
<Box mt={2} mb={2}>
<GreyText>
{`${numberOfExcluded} ${
numberOfExcluded === 1 ? 'Household' : 'Households'
numberOfExcluded === 1 ? 'Beneficiary' : 'Beneficiaries'
} excluded`}
</GreyText>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,20 @@ export const IndividualAdditionalRegistrationInformation = ({
);
});
return (
<div>
<Overview>
<Title>
<Typography variant="h6">
{t('Additional Registration information')}
</Typography>
</Title>
<Grid container spacing={6}>
{fields.map((field, i) => (
/* eslint-disable-next-line react/no-array-index-key */
<Grid key={i} item xs={4}>
{field}
</Grid>
))}
</Grid>
</Overview>
</div>
<Overview>
<Title>
<Typography variant="h6">
{t('Additional Registration information')}
</Typography>
</Title>
<Grid container spacing={6}>
{fields.map((field, i) => (
/* eslint-disable-next-line react/no-array-index-key */
<Grid key={i} item xs={4}>
{field}
</Grid>
))}
</Grid>
</Overview>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,84 @@

exports[`components/population/IndividualAdditionalRegistrationInformation should render 1`] = `
<div>
<div>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 sc-fsYfdN ctuPcH css-1ps6pg7-MuiPaper-root"
>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 sc-fsYfdN ctuPcH css-1ps6pg7-MuiPaper-root"
class="sc-dmyCSP ljiJAm"
>
<div
class="sc-dmyCSP ljiJAm"
<h6
class="MuiTypography-root MuiTypography-h6 css-1j53xw6-MuiTypography-root"
>
<h6
class="MuiTypography-root MuiTypography-h6 css-1j53xw6-MuiTypography-root"
>
Additional Registration information
</h6>
</div>
Additional Registration information
</h6>
</div>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-6 css-zow5z4-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-container MuiGrid-spacing-xs-6 css-zow5z4-MuiGrid-root"
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-4 css-gj1fbr-MuiGrid-root"
>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-4 css-gj1fbr-MuiGrid-root"
>
<div>
<div>
<span
class="sc-beySPh gbuZtJ"
color="textSecondary"
>
muac
</span>
<div
data-cy="label-muac"
>
<span
class="sc-beySPh gbuZtJ"
class="sc-guDLey cyWTlF"
color="textSecondary"
>
muac
334
</span>
<div
data-cy="label-muac"
>
<span
class="sc-guDLey cyWTlF"
color="textSecondary"
>
334
</span>
</div>
</div>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-4 css-gj1fbr-MuiGrid-root"
>
<div>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-4 css-gj1fbr-MuiGrid-root"
>
<div>
<span
class="sc-beySPh gbuZtJ"
color="textSecondary"
>
school enrolled
</span>
<div
data-cy="label-school enrolled"
>
<span
class="sc-beySPh gbuZtJ"
class="sc-guDLey cyWTlF"
color="textSecondary"
>
school enrolled
Yes
</span>
<div
data-cy="label-school enrolled"
>
<span
class="sc-guDLey cyWTlF"
color="textSecondary"
>
Yes
</span>
</div>
</div>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-4 css-gj1fbr-MuiGrid-root"
>
<div>
</div>
<div
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-4 css-gj1fbr-MuiGrid-root"
>
<div>
<span
class="sc-beySPh gbuZtJ"
color="textSecondary"
>
school enrolled before
</span>
<div
data-cy="label-school enrolled before"
>
<span
class="sc-beySPh gbuZtJ"
class="sc-guDLey cyWTlF"
color="textSecondary"
>
school enrolled before
No
</span>
<div
data-cy="label-school enrolled before"
>
<span
class="sc-guDLey cyWTlF"
color="textSecondary"
>
No
</span>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { DividerLine } from '@components/core/DividerLine';
import { IndividualNode } from '@generated/graphql';
import { Grid, Paper, Typography } from '@mui/material';
import { Title } from '@core/Title';
import { t } from 'i18next';
import React from 'react';
import styled from 'styled-components';
import { LabelizedField } from '@components/core/LabelizedField';
import { renderSomethingOrDash } from '@utils/utils';
import { usePermissions } from '@hooks/usePermissions';
import { hasPermissions, PERMISSIONS } from 'src/config/permissions';

interface IndividualDeliveryMechanismsProps {
individual: IndividualNode;
}

const Overview = styled(Paper)`
padding: ${({ theme }) => theme.spacing(8)}
${({ theme }) => theme.spacing(11)};
margin-top: ${({ theme }) => theme.spacing(6)};
margin-bottom: ${({ theme }) => theme.spacing(4)};
`;

export const IndividualDeliveryMechanisms: React.FC<
IndividualDeliveryMechanismsProps
> = ({ individual }) => {
const permissions = usePermissions();
const canViewDeliveryMechanisms = hasPermissions(
PERMISSIONS.POPULATION_VIEW_INDIVIDUAL_DELIVERY_MECHANISMS_SECTION,
permissions,
);
if (!individual.deliveryMechanismsData.length || !canViewDeliveryMechanisms) {
return null;
}
return (
<Overview>
<Title>
<Typography variant="h6">
{t('Individual Delivery Mechanisms')}
</Typography>
</Title>
<Grid container spacing={6}>
{individual.deliveryMechanismsData.map((mechanism, index) => {
const tabData = JSON.parse(mechanism.individualTabData);
return (
<Grid item xs={12} key={index}>
<Typography variant="h6">{mechanism.name}</Typography>
<Grid container spacing={3}>
{Object.entries(tabData).map(([key, value], idx) => (
<Grid key={idx} item xs={3}>
<LabelizedField label={key.replace(/_/g, ' ')}>
{renderSomethingOrDash(value)}
</LabelizedField>
</Grid>
))}
</Grid>
{index < individual.deliveryMechanismsData.length - 1 && (
<DividerLine />
)}
</Grid>
);
})}
</Grid>
</Overview>
);
};
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Box, Grid, Typography } from '@mui/material';
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import styled from 'styled-components';
import { ProgrammeChoiceDataQuery, ProgramQuery } from '@generated/graphql';
import { MiśTheme } from '../../../theme';
import { choicesToDict, programStatusToColor } from '@utils/utils';
import { PartnerAccess } from '@components/programs/constants';
import { ContainerColumnWithBorder } from '@core/ContainerColumnWithBorder';
import { DividerLine } from '@core/DividerLine';
import { LabelizedField } from '@core/LabelizedField';
import { OverviewContainer } from '@core/OverviewContainer';
import { StatusBox } from '@core/StatusBox';
import { Title } from '@core/Title';
import { UniversalMoment } from '@core/UniversalMoment';
import { PartnerAccess } from '@components/programs/constants';
import { DividerLine } from '@core/DividerLine';
import { ProgrammeChoiceDataQuery, ProgramQuery } from '@generated/graphql';
import { Box, Grid, Typography } from '@mui/material';
import { choicesToDict, programStatusToColor } from '@utils/utils';
import * as React from 'react';
import { useTranslation } from 'react-i18next';
import styled from 'styled-components';
import { MiśTheme } from '../../../theme';

const NumberOfHouseHolds = styled.div`
padding: ${({ theme }) => theme.spacing(8)};
Expand Down
Loading

0 comments on commit cc7c96d

Please sign in to comment.