-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1892 from BaseAdresseNationale/feat/multiple-quic…
…k-fix Feat/multiple quick fix
- Loading branch information
Showing
30 changed files
with
529 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/app/carte-base-adresse-nationale/components/address/AsideFooterAddress.styles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use client' | ||
|
||
import styled from 'styled-components' | ||
|
||
export const AsideFooterWrapper = styled.div`` | ||
|
||
export const ActionWrapper = styled.ul` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.25rem; | ||
margin: 0; | ||
padding: 0; | ||
list-style: none; | ||
` | ||
|
||
export const ActionList = styled.ul` | ||
display: block; | ||
padding: 0; | ||
margin: 0; | ||
list-style: none; | ||
` |
88 changes: 88 additions & 0 deletions
88
src/app/carte-base-adresse-nationale/components/address/AsideFooterAddress.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { useMemo } from 'react' | ||
|
||
import { isNumeroCertifiable } from '@/lib/ban' | ||
import { useFocusOnMap } from '../ban-map/BanMap.context' | ||
|
||
import Button from '@codegouvfr/react-dsfr/Button' | ||
|
||
import DownloadCertificate from './download-certificate' | ||
|
||
import { | ||
AsideFooterWrapper, | ||
ActionWrapper, | ||
ActionList, | ||
} from './AsideFooterAddress.styles' | ||
|
||
import type { TypeAddressExtended } from '../../types/LegacyBan.types' | ||
|
||
interface AsideFooterAddressProps { | ||
banItem: TypeAddressExtended | ||
withCertificate: boolean | ||
children?: React.ReactNode | ||
} | ||
|
||
function AsideFooterAddress({ banItem: address, withCertificate, children }: AsideFooterAddressProps) { | ||
const focusOnMap = useFocusOnMap(address) | ||
|
||
const isCertifiable = useMemo(() => isNumeroCertifiable({ | ||
banId: address.banId ?? '', | ||
sources: Array.isArray(address.sourcePosition) ? address.sourcePosition : [address.sourcePosition], | ||
certifie: address.certifie, | ||
parcelles: address.parcelles, | ||
}), [address]) | ||
|
||
const handleClick = (evt: React.MouseEvent<HTMLButtonElement>) => { | ||
evt.preventDefault() | ||
focusOnMap() | ||
} | ||
|
||
return ( | ||
<AsideFooterWrapper> | ||
{children} | ||
{!withCertificate && ( | ||
<div> | ||
Les certifications d’adresses sur la commune de {address.commune.nom} sont | ||
réalisées directement par la mairie. | ||
Contactez-la pour obtenir un certificat d’adressage ou toute autre information. | ||
</div> | ||
)} | ||
{withCertificate && !isCertifiable && ( | ||
<div> | ||
Cette adresse ne remplit pas les critères minimums pour obtenir une certification. | ||
Veuillez contacter votre mairie pour obtenir un certificat d’adressage ou toute autre information. | ||
</div> | ||
)} | ||
<ActionWrapper> | ||
<ActionList> | ||
<Button | ||
iconId="ri-focus-3-line" | ||
onClick={handleClick} | ||
priority="tertiary no outline" | ||
> | ||
Centrer la carte sur l’adresse | ||
</Button> | ||
|
||
</ActionList> | ||
|
||
{ withCertificate && ( | ||
isCertifiable | ||
? ( | ||
<ActionList className="certificate"> | ||
<DownloadCertificate | ||
id={address.id} | ||
/> | ||
</ActionList> | ||
) | ||
: ( | ||
<ActionList className="certificate"> | ||
<div /> | ||
<span>Certificat d'adressage indisponible pour cette adresse, veuillez contacter votre mairie.</span> | ||
</ActionList> | ||
) | ||
)} | ||
</ActionWrapper> | ||
</AsideFooterWrapper> | ||
) | ||
} | ||
|
||
export default AsideFooterAddress |
Oops, something went wrong.