From 8d63d23c165bb693a717a2da8ae1ff5c4667eea0 Mon Sep 17 00:00:00 2001 From: chelsey-g <97612806+chelsey-g@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:41:20 -0500 Subject: [PATCH] loads all websites in order to edit them --- src/app/(main)/dashboard/DashboardEdit.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/(main)/dashboard/DashboardEdit.tsx b/src/app/(main)/dashboard/DashboardEdit.tsx index d702612f..9e4e8ec1 100644 --- a/src/app/(main)/dashboard/DashboardEdit.tsx +++ b/src/app/(main)/dashboard/DashboardEdit.tsx @@ -1,4 +1,4 @@ -import { useState, useMemo } from 'react'; +import { useState, useMemo, useEffect } from 'react'; import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd'; import classNames from 'classnames'; import { Button, Loading } from 'react-basics'; @@ -14,12 +14,25 @@ export function DashboardEdit({ teamId }: { teamId: string }) { const { websiteOrder } = settings; const { formatMessage, labels } = useMessages(); const [order, setOrder] = useState(websiteOrder || []); + const [websites, setWebsites] = useState([]); + const { result, query: { isLoading }, + setParams, } = useWebsites({ teamId }); - const websites = result?.data; + useEffect(() => { + if (result?.data) { + setWebsites(prevWebsites => { + const newWebsites = [...prevWebsites, ...result.data]; + if (newWebsites.length < result.count) { + setParams(prevParams => ({ ...prevParams, page: prevParams.page + 1 })); + } + return newWebsites; + }); + } + }, [result]); const ordered = useMemo(() => { if (websites) {