fix sort on dashboard (#1600)

This commit is contained in:
Brian Cao 2022-10-25 16:48:39 -07:00 committed by GitHub
parent 8b64ef1a4e
commit 7f3db334f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,7 @@ export default function DashboardEdit({ websites }) {
const ordered = useMemo( const ordered = useMemo(
() => () =>
websites websites
.map(website => ({ ...website, order: order.indexOf(website.websiteId) })) .map(website => ({ ...website, order: order.indexOf(website.websiteUuid) }))
.sort(firstBy('order')), .sort(firstBy('order')),
[websites, order], [websites, order],
); );
@ -36,7 +36,7 @@ export default function DashboardEdit({ websites }) {
const [removed] = orderedWebsites.splice(source.index, 1); const [removed] = orderedWebsites.splice(source.index, 1);
orderedWebsites.splice(destination.index, 0, removed); orderedWebsites.splice(destination.index, 0, removed);
setOrder(orderedWebsites.map(website => website?.websiteId || 0)); setOrder(orderedWebsites.map(website => website?.websiteUuid || 0));
} }
function handleSave() { function handleSave() {
@ -76,8 +76,12 @@ export default function DashboardEdit({ websites }) {
ref={provided.innerRef} ref={provided.innerRef}
style={{ marginBottom: snapshot.isDraggingOver ? 260 : null }} style={{ marginBottom: snapshot.isDraggingOver ? 260 : null }}
> >
{ordered.map(({ websiteId, name, domain }, index) => ( {ordered.map(({ websiteUuid, name, domain }, index) => (
<Draggable key={websiteId} draggableId={`${dragId}-${websiteId}`} index={index}> <Draggable
key={websiteUuid}
draggableId={`${dragId}-${websiteUuid}`}
index={index}
>
{(provided, snapshot) => ( {(provided, snapshot) => (
<div <div
ref={provided.innerRef} ref={provided.innerRef}