e80c552ae7
Closes https://github.com/twentyhq/core-team-issues/issues/1438 - Reorganized PageLayout module - Created `DashboardRenderer` and `PageLayoutRenderer` - Created stories for the `PageLayoutRenderer` - Refactored the Widget components https://github.com/user-attachments/assets/27e9ac8f-b237-4c21-8494-3fab6d65af3a
24 lines
762 B
TypeScript
24 lines
762 B
TypeScript
import { pageLayoutDraftState } from '@/page-layout/states/pageLayoutDraftState';
|
|
import { type PageLayoutWidgetWithData } from '@/page-layout/types/pageLayoutTypes';
|
|
import { useRecoilCallback } from 'recoil';
|
|
|
|
export const useUpdatePageLayoutWidget = () => {
|
|
const updatePageLayoutWidget = useRecoilCallback(
|
|
({ set }) =>
|
|
(widgetId: string, updates: Partial<PageLayoutWidgetWithData>) => {
|
|
set(pageLayoutDraftState, (prev) => ({
|
|
...prev,
|
|
tabs: prev.tabs.map((tab) => ({
|
|
...tab,
|
|
widgets: tab.widgets.map((widget) =>
|
|
widget.id === widgetId ? { ...widget, ...updates } : widget,
|
|
),
|
|
})),
|
|
}));
|
|
},
|
|
[],
|
|
);
|
|
|
|
return { updatePageLayoutWidget };
|
|
};
|