From e42836c3c668cb178de51b8bd2c35e70075e4f28 Mon Sep 17 00:00:00 2001 From: LionelB Date: Thu, 9 Jan 2020 11:38:00 +0100 Subject: [PATCH] feat(ccn): save ccn when navigate to ccn page --- .../src/conventions/Convention/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/code-du-travail-frontend/src/conventions/Convention/index.js b/packages/code-du-travail-frontend/src/conventions/Convention/index.js index 152febddc9..5cb9d6028f 100644 --- a/packages/code-du-travail-frontend/src/conventions/Convention/index.js +++ b/packages/code-du-travail-frontend/src/conventions/Convention/index.js @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import PropTypes from "prop-types"; import styled from "styled-components"; import { @@ -11,8 +11,16 @@ import { Info } from "./Info"; import { Articles } from "./Articles"; import { TextSearch } from "./TextSearch"; import { Contributions } from "./Contributions"; +import { useLocalStorage } from "../../lib/useLocalStorage"; const Convention = ({ convention }) => { + const [, setCcInfo] = useLocalStorage("convention", {}); + + useEffect(() => { + const { slug, id, num, title, shortTitle } = convention; + setCcInfo({ convention: { id, slug, title, shortTitle, num } }); + }, [convention, setCcInfo]); + return (