Create fields widget (#16403)
https://github.com/user-attachments/assets/b150815a-5d54-4d4a-b984-20dcf7b29aa7
This commit is contained in:
committed by
GitHub
parent
7b98804ec1
commit
fd54a2af5c
+25
@@ -0,0 +1,25 @@
|
||||
import { type PageLayoutWidget } from '@/page-layout/types/PageLayoutWidget';
|
||||
import { assertIsDefinedOrThrow } from 'twenty-shared/utils';
|
||||
import { type BarChartConfiguration } from '~/generated/graphql';
|
||||
|
||||
type AssertBarChartWidgetOrThrow = (
|
||||
widget: PageLayoutWidget,
|
||||
) => asserts widget is PageLayoutWidget & {
|
||||
objectMetadataId: string;
|
||||
configuration: BarChartConfiguration;
|
||||
};
|
||||
|
||||
export const assertBarChartWidgetOrThrow: AssertBarChartWidgetOrThrow = (
|
||||
widget: PageLayoutWidget,
|
||||
) => {
|
||||
assertIsDefinedOrThrow(
|
||||
widget.objectMetadataId,
|
||||
new Error('Widget objectMetadataId is required'),
|
||||
);
|
||||
|
||||
if (widget.configuration?.__typename !== 'BarChartConfiguration') {
|
||||
throw new Error(
|
||||
`Expected BarChartConfiguration but got ${widget.configuration?.__typename}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user