Skip to content

Commit

Permalink
Merge branch 'master' into fufeck_feat_popup-new-bal-already-exist
Browse files Browse the repository at this point in the history
  • Loading branch information
fufeck committed Jan 17, 2024
2 parents 8094d3e + 6b697a9 commit cc223a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
22 changes: 20 additions & 2 deletions components/sub-header/bal-status/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import PropTypes from "prop-types";
import { Pane, Button } from "evergreen-ui";

import usePublishProcess from '@/hooks/publish-process'

import { pauseSync, resumeSync } from "@/lib/bal-api";

import StatusBadge from "@/components/status-badge";
Expand All @@ -17,6 +19,10 @@ function BALStatus({
handleHabilitation,
reloadBaseLocale,
}) {
const {
handleShowHabilitationProcess,
} = usePublishProcess(commune)

const handlePause = async () => {
await pauseSync(baseLocale._id, token);
await reloadBaseLocale();
Expand Down Expand Up @@ -53,7 +59,18 @@ function BALStatus({
isHabilitationValid={isHabilitationValid}
/>
) : (
baseLocale.status === "draft" && (
<>
{baseLocale.status === "published" && baseLocale.sync?.status == 'outdated' && !isHabilitationValid && (
<Button
marginRight={8}
height={24}
appearance="primary"
onClick={handleShowHabilitationProcess}
>
Habiliter la BAL
</Button>
)}
{baseLocale.status === "draft" && (
<Button
marginRight={8}
height={24}
Expand All @@ -62,7 +79,8 @@ function BALStatus({
>
Publier
</Button>
)
)}
</>
))}
</>
);
Expand Down
5 changes: 3 additions & 2 deletions hooks/habilitation.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ export default function useHabilitation(baseLocale, token) {
const isExpired = new Date(habilitation.expiresAt) < new Date()

if (baseLocale.sync && isFirstLoad.current) {
const description = 'Les prochaines modifications ne seront pas prises en compte dans la Base Adresse Nationale. Cliquez sur "Habiliter la Base Adresse Locale" pour renouveler l’habilitation.'
if (!isAccepted) {
toaster.danger('Aucune habilitation valide trouvée', {
description: 'Les prochaines modifications ne seront pas prises en compte dans la Base Adresse Nationale. Cliquez sur "Publier" ou "Habiliter la Base Adresse Locale" pour renouveler l’habilitation.',
description,
duration: 10
})
} else if (isExpired) {
toaster.danger('L’habilitaton est expirée', {
description: 'Les prochaines modifications ne seront pas prises en compte dans la Base Adresse Nationale. Cliquez sur "Publier" ou "Habiliter la Base Adresse Locale" pour renouveler l’habilitation.',
description,
duration: 10
})
}
Expand Down

0 comments on commit cc223a6

Please sign in to comment.