diff --git a/targets/frontend/src/pages/alerts/[[...params]].js b/targets/frontend/src/pages/alerts/[[...params]].js index e1c3fb9aa..e6e1fae1d 100644 --- a/targets/frontend/src/pages/alerts/[[...params]].js +++ b/targets/frontend/src/pages/alerts/[[...params]].js @@ -1,3 +1,4 @@ +/** @jsxImportSource theme-ui */ import { Accordion } from "@reach/accordion"; import slugify from "@socialgouv/cdtn-slugify"; import { getRouteBySource } from "@socialgouv/cdtn-sources"; @@ -12,7 +13,7 @@ import { Stack } from "src/components/layout/Stack"; import { Pagination } from "src/components/pagination"; import { withCustomUrqlClient } from "src/hoc/CustomUrqlClient"; import { withUserProvider } from "src/hoc/UserProvider"; -import { Card, Container, Divider, Message } from "theme-ui"; +import { Box, Card, Container, Divider, Message, NavLink } from "theme-ui"; import { useQuery } from "urql"; const getAlertQuery = ` @@ -107,80 +108,117 @@ export function AlertPage() { - {alerts.map((alert) => ( - - - - - {getTitle(alert)} - - - {alert.changes.added.length > 0 && ( + {alerts.map((alert) => { + const openIndices = []; + // Pre-open documents panel If there are documents targeted by the alert + if (alert.changes.documents && alert.changes.documents.length > 0) { + openIndices.push(0); + } + return ( + + + + + {getTitle(alert)} + + { + const [title, anchor] = item.document.title.split("#"); + + return ( +
  • + + {title} + + + {jsxJoin( + item.references.map((node) => ( + + {node.title} + + )), + ", " + )} + +
  • + ); + }} + /> + + {alert.changes.documents?.length > 0 && + alert.changes.added.length > 0 && } + + {alert.changes.added.length > 0 && ( + + renderChange( + changes, + `${alert.id}-added-${i}`, + alert.info.type + ) + } + /> + )} + + {alert.changes.added.length > 0 && + alert.changes.modified.length > 0 && } + + renderChange( changes, - `${alert.id}-added-${i}`, + `${alert.id}-modified-${i}`, alert.info.type ) } /> - )} - {alert.changes.added.length > 0 && - alert.changes.modified.length > 0 && } - - renderChange( - changes, - `${alert.id}-modified-${i}`, - alert.info.type - ) - } - /> - {alert.changes.removed.length > 0 && } - - renderChange( - changes, - `${alert.id}-removed-${i}`, - alert.info.type - ) - } - /> - {alert.changes.documents?.length > 0 && } - { - const [title, anchor] = item.document.title.split("#"); - - return ( -
  • - - {title} - -
  • - ); - }} - /> -
    -
    -
    -
    - ))} + + {alert.changes.modified.length > 0 && + alert.changes.removed.length > 0 && } + + + renderChange( + changes, + `${alert.id}-removed-${i}`, + alert.info.type + ) + } + /> +
    +
    +
    +
    + ); + })} 0 + ? array.reduce((result, item) => ( + <> + {result} + {str} + {item} + + )) + : null; +}