From adb31add665be88209541a824c0a15cd674ba333 Mon Sep 17 00:00:00 2001 From: Betsy Carina Traran Date: Thu, 4 Apr 2024 14:09:29 +0200 Subject: [PATCH] Liten fix paa stort problem --- .../js/src/pages/tenorSoek/TenorSoekPage.tsx | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/dolly-frontend/src/main/js/src/pages/tenorSoek/TenorSoekPage.tsx b/apps/dolly-frontend/src/main/js/src/pages/tenorSoek/TenorSoekPage.tsx index cd11f533361..d2915b5f2a9 100644 --- a/apps/dolly-frontend/src/main/js/src/pages/tenorSoek/TenorSoekPage.tsx +++ b/apps/dolly-frontend/src/main/js/src/pages/tenorSoek/TenorSoekPage.tsx @@ -22,23 +22,33 @@ export default () => { }, [request]) useEffect(() => { - if (response && state.personListe?.length === 0) { + if (response?.data?.data?.personer?.length === 0) { setState({ ...state, - personListe: response?.data?.data?.personer, - seed: response?.data?.data?.seed, + personListe: [], nesteSide: response?.data?.data?.nesteSide, }) - } else if ( - state.personListe?.length > 0 && - response?.data?.data?.personer?.length > 0 && - state.side > 0 - ) { + } else if (response && state.personListe?.length === 0) { setState({ ...state, - personListe: [...state.personListe, ...response?.data?.data?.personer], + personListe: response?.data?.data?.personer, + seed: response?.data?.data?.seed, nesteSide: response?.data?.data?.nesteSide, }) + } else if (state.personListe?.length > 0 && response?.data?.data?.personer?.length > 0) { + if (state.side > 0) { + setState({ + ...state, + personListe: [...state.personListe, ...response?.data?.data?.personer], + nesteSide: response?.data?.data?.nesteSide, + }) + } else { + setState({ + ...state, + personListe: response?.data?.data?.personer, + nesteSide: response?.data?.data?.nesteSide, + }) + } } }, [response])