[Page Layout] - Review Refactor (#14348)

addressing the review on
https://github.com/twentyhq/twenty/pull/14318#pullrequestreview-3191930203
This commit is contained in:
nitin
2025-09-08 17:50:43 +05:30
committed by GitHub
parent 8fa1821e1a
commit 894db2645a
36 changed files with 863 additions and 442 deletions
@@ -0,0 +1,23 @@
import { useRecoilCallback } from 'recoil';
import { type PageLayoutWidget } from '../states/savedPageLayoutsState';
import { pageLayoutDraftState } from '../states/pageLayoutDraftState';
export const useUpdatePageLayoutWidget = () => {
const updatePageLayoutWidget = useRecoilCallback(
({ set }) =>
(widgetId: string, updates: Partial<PageLayoutWidget>) => {
set(pageLayoutDraftState, (prev) => ({
...prev,
tabs: prev.tabs.map((tab) => ({
...tab,
widgets: tab.widgets.map((widget) =>
widget.id === widgetId ? { ...widget, ...updates } : widget,
),
})),
}));
},
[],
);
return { updatePageLayoutWidget };
};