Correction des redirections
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { api } from '../api.js';
|
||||
import { useInvestisseur } from '../context/InvestisseurContext.jsx';
|
||||
import { useUi } from '../context/UiContext.jsx';
|
||||
@@ -272,6 +272,8 @@ export default function Plateformes() {
|
||||
const { activeId, activeView, investisseurs } = useInvestisseur();
|
||||
const { displayMode, chartInterets, chartCapital, chartCashback } = useUi();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
|
||||
/* ── État données ── */
|
||||
const [allRows, setAllRows] = useState([]);
|
||||
@@ -283,7 +285,9 @@ export default function Plateformes() {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
/* ── État sélecteurs ── */
|
||||
const [selectedPlatName, setSelectedPlatName] = useState(null);
|
||||
/* selectedPlatName et activeTab sont dans l'URL pour survivre au retour arrière */
|
||||
const selectedPlatName = searchParams.get('plat') || null;
|
||||
const setSelectedPlatName = (nom) => setSearchParams(p => { const n = new URLSearchParams(p); n.set('plat', nom); return n; }, { replace: true });
|
||||
const [selectedDetenteurId, setSelectedDetenteurId] = useState('all');
|
||||
const [selectedYear, setSelectedYear] = useState(String(new Date().getFullYear()));
|
||||
const [windowStart, setWindowStart] = useState(0);
|
||||
@@ -320,7 +324,8 @@ export default function Plateformes() {
|
||||
const [pfuRates, setPfuRates] = useState([]);
|
||||
|
||||
/* ── État UI ── */
|
||||
const [activeTab, setActiveTab] = useState('depots-retraits');
|
||||
const activeTab = searchParams.get('tab') || 'depots-retraits';
|
||||
const setActiveTab = (tab) => setSearchParams(p => { const n = new URLSearchParams(p); n.set('tab', tab); return n; }, { replace: true });
|
||||
const [listFocused, setListFocused] = useState(false);
|
||||
|
||||
/* ── Chargement ── */
|
||||
@@ -1020,7 +1025,7 @@ export default function Plateformes() {
|
||||
const rowTotal = months.reduce((s, v) => s + (v?.value ?? 0), 0);
|
||||
return (
|
||||
<tr key={inv.id} className="tip-row-plat" style={{ cursor: 'pointer' }}
|
||||
onClick={() => navigate(`/investissements/${inv.id}`)}>
|
||||
onClick={() => navigate(`/investissements/${inv.id}`, { state: { from: { path: location.pathname, search: location.search, label: 'Plateformes' } } })}>
|
||||
<td className="tip-td-name" style={{ whiteSpace: 'normal', maxWidth: '40ch', wordBreak: 'break-word' }}>
|
||||
{inv.nom_projet || '—'}
|
||||
</td>
|
||||
@@ -1423,6 +1428,7 @@ export default function Plateformes() {
|
||||
allRembs={allRembs}
|
||||
allReinvests={allReinvests}
|
||||
year={selectedYear}
|
||||
originFrom={{ path: location.pathname, search: location.search, label: 'Plateformes' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1473,7 +1479,7 @@ export default function Plateformes() {
|
||||
: (rembParInv[r.id]?.interets_bruts || 0);
|
||||
return (
|
||||
<tr key={r.id} style={{ cursor: 'pointer' }}
|
||||
onClick={() => navigate(`/investissements/${r.id}`)}>
|
||||
onClick={() => navigate(`/investissements/${r.id}`, { state: { from: { path: location.pathname, search: location.search, label: 'Plateformes' } } })}>
|
||||
<td style={{ fontWeight: 500 }}>{r.nom_projet}</td>
|
||||
<td className="text-muted" style={{ fontSize: 'var(--fs-sm)' }}>{r.emetteur || '—'}</td>
|
||||
<td className="num" style={{ fontSize: 'var(--fs-sm)', color: 'var(--text-muted)' }}>{fmtDate(r.date_souscription)}</td>
|
||||
|
||||
Reference in New Issue
Block a user