import lightTheme from "@/utils/themes/light";
import { Box, ThemeProvider, Typography } from "@mui/material";
import { useEffect, useRef } from "react";
import { BannerWidget as Widget } from "./widgets";

const widgetProps: ConstructorParameters<typeof Widget>[0] = {
  quizId: "3c49550d-8c77-4788-bc2d-42586a261514",
  position: "bottomright",
};

export default function WidgetDev() {
  const widgetRef = useRef<Widget | null>(null);

  useEffect(() => {
    if (!widgetRef.current) {
      widgetRef.current = new Widget(widgetProps);
    } else {
      widgetRef.current.render(widgetProps);
    }
  });

  return (
    <ThemeProvider theme={lightTheme}>
      <Box
        sx={{
          height: "100dvh",
          p: "16px",
        }}
      >
        <Lorem />
        <Box id="widget-button"></Box>
        <Box
          id="widget-container"
          sx={{
            height: "500px",
          }}
        ></Box>
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
        <Lorem />
      </Box>
    </ThemeProvider>
  );
}

const lorem =
  "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qu";

function Lorem() {
  return (
    <Box
      sx={{
        py: "16px",
      }}
    >
      <Typography fontSize={"24px"}>{lorem}</Typography>
    </Box>
  );
}
