Skip to content

Commit

Permalink
Add support for widget type from search parameters in WidgetBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma committed Feb 16, 2025
1 parent fae0d65 commit 7d40862
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/components/widget-builder.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useSearchParams } from "@remix-run/react";
import { useQuery } from "@tanstack/react-query";
import { type ReactElement, useEffect, useState } from "react";
import type { Variable } from "~/components/command/CommandBuilder";
Expand All @@ -21,7 +22,8 @@ type HEX = `#${string}`;
type PreviewBackgroundColor = RGB | RGBA | HEX;

export default function WidgetBuilder({ region, accountId }: WidgetBuilderProps) {
const [widgetType, setWidgetType] = useState<string>(widgetTypes[0]);
const [searchParams] = useSearchParams();
const [widgetType, setWidgetType] = useState<string>(searchParams.get("widget-type") ?? widgetTypes[0]);
const [theme, setTheme] = useState<Theme>("dark");
const [widgetUrl, setWidgetUrl] = useState<string | null>(null);
const [widgetPreview, setWidgetPreview] = useState<ReactElement | null>(null);
Expand Down

0 comments on commit 7d40862

Please sign in to comment.