diff --git a/src/app/tools/embed/[embed]/host/page.tsx b/src/app/tools/embed/[embed]/host/page.tsx index 0000f1fb2..78483421f 100644 --- a/src/app/tools/embed/[embed]/host/page.tsx +++ b/src/app/tools/embed/[embed]/host/page.tsx @@ -1,8 +1,11 @@ 'use client'; -import { Code, Text } from '@radix-ui/themes'; +import { Code, Heading } from '@radix-ui/themes'; +import { useMemo } from 'react'; import PageWrapper from '../../../../../components/PageWrapper'; +import * as EmbedState from '../../../../../stores/embedState'; import { configurations } from '../../configurations'; +import { extractEmbedConfigDefaults } from '../../utilities'; export interface EmbedPreviewControllerProps { configKey: string; @@ -15,14 +18,26 @@ export default function Page({ params: { embed: keyof typeof configurations }; searchParams: { state: string }; }) { - return ( - - {params.embed} + const config = configurations[params.embed]; + const initialState = useMemo( + () => ({ + ...extractEmbedConfigDefaults(config), + ...(JSON.parse(searchParams.state) as EmbedState.EmbedState), + }), + [params.embed], + ); - - - {JSON.stringify(JSON.parse(searchParams['state']), null, 2)} - - + return ( + + + + {params.embed} + + + + {JSON.stringify(initialState, null, 2)} + + + ); }
- {JSON.stringify(JSON.parse(searchParams['state']), null, 2)} -
{JSON.stringify(JSON.parse(searchParams['state']), null, 2)}
{params.embed}
+ {JSON.stringify(initialState, null, 2)} +
{JSON.stringify(initialState, null, 2)}