Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

817 B
Raw Blame
import type { Board } from "~/app/[locale]/boards/_types";

export interface MoveItemToSectionInput {
  itemId: string;
  layoutId: string;
  sectionId: string;
  xOffset: number;
  yOffset: number;
  width: number;
  height: number;
}

export const moveItemToSectionCallback =
  ({ itemId, layoutId, ...layoutInput }: MoveItemToSectionInput) =>
  (board: Board): Board => {
    return {
      ...board,
      items: board.items.map((item) =>
        item.id !== itemId
          ? item
          : {
              ...item,
              layouts: item.layouts.map((layout) =>
                layout.layoutId !== layoutId
                  ? layout
                  : {
                      ...layout,
                      ...layoutInput,
                    },
              ),
            },
      ),
    };
  };