Skip to content

Commit

Permalink
Merge pull request #932 from MTES-MCT/fix-display-dgfip-address
Browse files Browse the repository at this point in the history
Display the DGFIP address when the BAN address is missing
  • Loading branch information
Falinor authored Oct 3, 2024
2 parents 9f6681a + 1330243 commit c61d9fc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
56 changes: 27 additions & 29 deletions frontend/src/components/OwnerCard/OwnerCard.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { fr } from '@codegouvfr/react-dsfr';
import Alert from '@codegouvfr/react-dsfr/Alert';
import Button from '@codegouvfr/react-dsfr/Button';
import Card from '@codegouvfr/react-dsfr/Card';
import Typography from '@mui/material/Typography';
import { ReactNode } from 'react';

import { HousingOwner, Owner } from '../../models/Owner';
import { birthdate } from '../../utils/dateUtils';
import { mailto } from '../../utils/stringUtils';
import AppLink from '../_app/AppLink/AppLink';
import styles from './owner-card.module.scss';
import Card from '@codegouvfr/react-dsfr/Card';
import Button from '@codegouvfr/react-dsfr/Button';
import classNames from 'classnames';
import { isBanEligible } from '../../models/Address';
import Typography from '@mui/material/Typography';
import OtherOwnerCard from './OtherOwnerCard';
import Alert from '@codegouvfr/react-dsfr/Alert';
import { fr } from '@codegouvfr/react-dsfr';
import Label from '../Label/Label';

interface OwnerCardProps {
Expand Down Expand Up @@ -60,7 +59,7 @@ function OwnerCard(props: OwnerCardProps) {
</Typography>
)}

<Typography component="p" mb={1}>
<section className={fr.cx('fr-mb-2w')}>
<span
className={fr.cx(
'fr-icon-home-4-line',
Expand All @@ -70,32 +69,31 @@ function OwnerCard(props: OwnerCardProps) {
aria-hidden={true}
/>
<Label as="span">Adresse postale</Label>
<Typography component="p">
{props.owner.banAddress?.label}
{[props.owner, ...(props.coOwners ?? [])].find(
(owner) => !isBanEligible(owner.banAddress)
) && (
<Alert
severity="info"
className={classNames(styles.addressNotice, 'fr-mt-2w')}
title={
<>
<div className="fr-mb-2w">Adresse à vérifier</div>
</>
}
description={
<>
<Typography mb={1}>
{props.owner.banAddress
? props.owner.banAddress.label
: props.owner.rawAddress.join(' ')}
</Typography>
{!isBanEligible(props.owner.banAddress) && (
<Alert
severity="info"
classes={{ title: fr.cx('fr-mb-2w') }}
title="Adresse à vérifier"
description={
<>
<Typography>
Cette adresse issue de la BAN est différente de l’adresse
fiscale.
<br />
</Typography>
<Typography>
Cliquez sur “Modifier” pour valider l’adresse que vous
souhaitez utiliser.
</>
}
></Alert>
)}
</Typography>
</Typography>
</Typography>
</>
}
/>
)}
</section>

{props.owner.additionalAddress && (
<Typography component="p" mb={1}>
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/components/OwnerCard/owner-card.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,4 @@
margin-top: 1rem;
}

.addressNotice > div:first-child {
padding-left: 1rem;
padding-right: 1rem;
}


Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export async function seed(knex: Knex): Promise<void> {

const owners = await Owners(knex).select('id');
const addresses = owners
// Create a BAN address for 75% of the owners
.filter(() => faker.datatype.boolean(0.75))
.map((owner) => owner.id)
.map<AddressDBO>((id) => ({
ref_id: id,
Expand Down

0 comments on commit c61d9fc

Please sign in to comment.