Add configuration types for widgets (#14717)

closes https://github.com/twentyhq/core-team-issues/issues/1532
This commit is contained in:
nitin
2025-09-29 17:11:26 +05:30
committed by GitHub
parent 2685f4a5b9
commit ea144c434b
88 changed files with 2829 additions and 1487 deletions
@@ -1,4 +1,5 @@
import { ChartSkeletonLoader } from '@/page-layout/widgets/graph/components/ChartSkeletonLoader';
import { type PageLayoutWidget } from '~/generated-metadata/graphql';
import styled from '@emotion/styled';
import { useState } from 'react';
@@ -57,14 +58,21 @@ const StyledErrorUrl = styled.div`
`;
export type IframeWidgetProps = {
url: string;
title?: string;
widget: PageLayoutWidget;
};
export const IframeWidget = ({
url,
title = 'Embedded Content',
}: IframeWidgetProps) => {
export const IframeWidget = ({ widget }: IframeWidgetProps) => {
const configuration = widget.configuration;
if (!configuration || !('url' in configuration)) {
throw new Error(
`Invalid configuration for widget ${widget.id}: missing url`,
);
}
const url = configuration.url;
const title = widget.title;
const [isLoading, setIsLoading] = useState(true);
const [hasError, setHasError] = useState(false);