Skip to content

The open alternative to Salesforce, designed for AI.

550 B
Raw Blame
import { type TabLayouts } from '@/page-layout/types/TabLayouts';

export const getUpdatedTabLayouts = (
  allTabLayouts: TabLayouts,
  activeTabId: string,
  newLayout: { i: string; x: number; y: number; w: number; h: number },
): TabLayouts => {
  const currentTabLayouts = allTabLayouts[activeTabId];

  return {
    ...allTabLayouts,
    [activeTabId]: {
      desktop: [...(currentTabLayouts?.desktop ?? []), newLayout],
      mobile: [
        ...(currentTabLayouts?.mobile ?? []),
        { ...newLayout, w: 1, x: 0 },
      ],
    },
  };
};