Merge branch 'dev' into patch-1

This commit is contained in:
Mike Cao 2022-09-03 23:15:03 -07:00 committed by GitHub
commit ee3c9debb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
130 changed files with 3107 additions and 2583 deletions

View file

@ -3,7 +3,7 @@ import { defineMessages, useIntl } from 'react-intl';
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
import classNames from 'classnames';
import Button from 'components/common/Button';
import { sortArrayByMap } from 'lib/array';
import { firstBy } from 'thenby';
import useDashboard, { saveDashboard } from 'store/dashboard';
import styles from './DashboardEdit.module.css';
@ -21,8 +21,13 @@ export default function DashboardEdit({ websites }) {
const { formatMessage } = useIntl();
const [order, setOrder] = useState(websiteOrder || []);
const ordered = useMemo(() => sortArrayByMap(websites, order, 'website_id'), [websites, order]);
const ordered = useMemo(
() =>
websites
.map(website => ({ ...website, order: order.indexOf(website.website_id) }))
.sort(firstBy('order')),
[websites, order],
);
function handleWebsiteDrag({ destination, source }) {
if (!destination || destination.index === source.index) return;