Skip to content

Commit

Permalink
Merge pull request #3057 from chelsey-g/load-all-websites-edit
Browse files Browse the repository at this point in the history
fix: loads all websites in order to edit them
  • Loading branch information
mikecao authored Nov 18, 2024
2 parents 1a5ae45 + 8d63d23 commit bebe15d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/app/(main)/dashboard/DashboardEdit.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) {
Expand Down

0 comments on commit bebe15d

Please sign in to comment.