[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
@@ -1,7 +1,7 @@
import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
import { usePageLayoutWidgetCreate } from '@/settings/page-layout/hooks/usePageLayoutWidgetCreate';
import { useCreatePageLayoutWidget } from '@/settings/page-layout/hooks/useCreatePageLayoutWidget';
import {
GraphSubType,
GraphType,
WidgetType,
} from '@/settings/page-layout/mocks/mockWidgets';
import styled from '@emotion/styled';
@@ -30,22 +30,22 @@ const StyledSectionTitle = styled.div`
const graphTypeOptions = [
{
type: GraphSubType.BAR,
type: GraphType.BAR,
icon: IconChartBar,
title: 'Bar Chart',
},
{
type: GraphSubType.PIE,
type: GraphType.PIE,
icon: IconChartPie,
title: 'Pie Chart',
},
{
type: GraphSubType.GAUGE,
type: GraphType.GAUGE,
icon: IconGauge,
title: 'Gauge',
},
{
type: GraphSubType.NUMBER,
type: GraphType.NUMBER,
icon: IconNumber,
title: 'Number',
},
@@ -53,10 +53,10 @@ const graphTypeOptions = [
export const CommandMenuPageLayoutGraphTypeSelect = () => {
const { closeCommandMenu } = useCommandMenu();
const { handleCreateWidget } = usePageLayoutWidgetCreate();
const { createPageLayoutWidget } = useCreatePageLayoutWidget();
const handleSelectGraphType = (graphType: GraphSubType) => {
handleCreateWidget(WidgetType.GRAPH, graphType);
const handleSelectGraphType = (graphType: GraphType) => {
createPageLayoutWidget(WidgetType.GRAPH, graphType);
closeCommandMenu();
};
@@ -1,7 +1,7 @@
import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
import { FormTextFieldInput } from '@/object-record/record-field/ui/form-types/components/FormTextFieldInput';
import { useCreatePageLayoutIframeWidget } from '@/settings/page-layout/hooks/useCreatePageLayoutIframeWidget';
import { usePageLayoutWidgetUpdate } from '@/settings/page-layout/hooks/usePageLayoutWidgetUpdate';
import { useUpdatePageLayoutWidget } from '@/settings/page-layout/hooks/useUpdatePageLayoutWidget';
import { pageLayoutDraftState } from '@/settings/page-layout/states/pageLayoutDraftState';
import { pageLayoutEditingWidgetIdState } from '@/settings/page-layout/states/pageLayoutEditingWidgetIdState';
import styled from '@emotion/styled';
@@ -34,7 +34,7 @@ const StyledButtonContainer = styled.div`
export const CommandMenuPageLayoutIframeConfig = () => {
const { closeCommandMenu } = useCommandMenu();
const { createPageLayoutIframeWidget } = useCreatePageLayoutIframeWidget();
const { handleUpdateWidget } = usePageLayoutWidgetUpdate();
const { updatePageLayoutWidget } = useUpdatePageLayoutWidget();
const [pageLayoutEditingWidgetId, setPageLayoutEditingWidgetId] =
useRecoilState(pageLayoutEditingWidgetIdState);
const pageLayoutDraft = useRecoilValue(pageLayoutDraftState);
@@ -77,7 +77,7 @@ export const CommandMenuPageLayoutIframeConfig = () => {
}
if (isEditMode && pageLayoutEditingWidgetId !== null) {
handleUpdateWidget(pageLayoutEditingWidgetId, {
updatePageLayoutWidget(pageLayoutEditingWidgetId, {
title: title.trim(),
configuration: {
...editingWidget?.configuration,