// components/pages/private/ItemPage/index.jsx import { useEffect } from 'react'; import { useParams } from 'react-router-dom'; import { Page, Block, Spinner } from '@cap-rel/smartcommon'; import { useApi, useStates } from '@cap-rel/smartcommon'; export const ItemPage = () => { const { id } = useParams(); const api = useApi(); const st = useStates({ initialStates: { item: null, loading: true, error: null } }); useEffect(() => { const fetchItem = async () => { try { const data = await api.private.get(`items/${id}`).json(); st.set('item', data); } catch (err) { st.set('error', err.message); } finally { st.set('loading', false); } }; fetchItem(); }, [id]); if (st.get('loading')) { return ; } if (st.get('error')) { return Erreur : {st.get('error')}; } const item = st.get('item'); return (

{item.description}

); };