Skip to content

Commit

Permalink
targeting hh fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Szewczyk committed Dec 23, 2024
1 parent 90af108 commit bd87b7b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ReactElement } from 'react';
export function TargetingHouseholds({ id, canViewDetails }): ReactElement {
const { businessArea } = useBaseUrl();

//TODO: display HH data here from allpayments query
return (
<TargetPopulationHouseholdTable
id={id}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import TableCell from '@mui/material/TableCell';
import { HouseholdNode } from '@generated/graphql';
import { PaymentNode } from '@generated/graphql';
import { ClickableTableRow } from '@components/core/Table/ClickableTableRow';
import { AnonTableCell } from '@components/core/Table/AnonTableCell';
import { BlackLink } from '@components/core/BlackLink';
import { useBaseUrl } from '@hooks/useBaseUrl';
import { ReactElement } from 'react';

interface TargetPopulationHouseholdTableRowProps {
household: HouseholdNode;
payment: PaymentNode;
canViewDetails?: boolean;
}

export function TargetPopulationHouseholdTableRow({
household,
payment,
canViewDetails,
}): ReactElement<TargetPopulationHouseholdTableRowProps> {
const { baseUrl } = useBaseUrl();
const householdDetailsPath = `/${baseUrl}/population/household/${household.id}`;
const householdDetailsPath = `/${baseUrl}/population/household/${payment.household.id}`;
const handleClick = (): void => {
const win = window.open(householdDetailsPath, '_blank');
if (win != null) {
Expand All @@ -30,22 +30,26 @@ export function TargetPopulationHouseholdTableRow({
onClick={canViewDetails ? handleClick : undefined}
role="checkbox"
data-cy="target-population-household-row"
key={household.id}
key={payment.household.id}
>
<TableCell align="left">
{canViewDetails ? (
<BlackLink to={householdDetailsPath}>{household.unicefId}</BlackLink>
<BlackLink to={householdDetailsPath}>
{payment.household.unicefId}
</BlackLink>
) : (
household.unicefId
payment.household.unicefId
)}
</TableCell>
<AnonTableCell>{household.headOfHousehold?.fullName}</AnonTableCell>
<TableCell align="left">{household.size}</TableCell>
<TableCell align="left">{household.adminArea?.name || '-'}</TableCell>
<AnonTableCell>
{payment.household.headOfHousehold?.fullName}
</AnonTableCell>
<TableCell align="left">{payment.household.size}</TableCell>
<TableCell align="left">
{household.selection?.vulnerabilityScore == null
? '-'
: household.selection?.vulnerabilityScore}
{payment.household.admin2?.name || '-'}
</TableCell>
<TableCell align="left">
{payment.vulnerabilityScore == null ? '-' : payment.vulnerabilityScore}
</TableCell>
</ClickableTableRow>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function TargetPopulationHouseholdTable({
renderRow={(row) => (
<TargetPopulationHouseholdTableRow
key={(row as { id: string }).id}
household={row}
payment={row}
canViewDetails={canViewDetails}
/>
)}
Expand Down

0 comments on commit bd87b7b

Please sign in to comment.