import { useEffect, useState } from "react"; import PocketBase from 'pocketbase'; import { ThemesRecord } from "../types/pocketbase-types"; import ConfettiExplosion from 'react-confetti-explosion'; import { LinkIcon } from "@heroicons/react/24/outline"; import { ToastContainer, toast } from 'react-toastify'; import browser from 'webextension-polyfill'; import 'react-toastify/dist/ReactToastify.css'; import localforage from "localforage"; const pb = new PocketBase('https://betterseqta.pockethost.io'); const Theme = () => { const [isLoading, setIsLoading] = useState(true); const [theme, setTheme] = useState(null); const [themeID, setThemeID] = useState(''); const [justCreated, setJustCreated] = useState(false); const [displayConfetti, setDisplayConfetti] = useState(true); const [currentThemes, setCurrentThemes] = useState([]); useEffect(() => { const timer = setTimeout(() => { setDisplayConfetti(false); }, 5000); return () => clearTimeout(timer); }, []); useEffect(() => { const urlParams = new URLSearchParams(window.location.search); const themeID = urlParams.get('id'); const justCreated = urlParams.get('justCreated'); if (themeID) { setThemeID(themeID); } const getTheme = async (themeID: string) => { const theme = await pb.collection('themes').getOne(themeID); console.log(theme); setIsLoading(false); setTheme(theme); const availableThemes = await localforage.getItem('availableThemes') as string[]; setCurrentThemes(availableThemes) } if (themeID && themeID !== 'null') { getTheme(themeID); setJustCreated(justCreated === 'true'); } }, []) return ( <> { isLoading && (
)} { theme && (
{ justCreated ? ( <> { displayConfetti && ( ) } <>

Theme Created Successfully!

Share the install link below with your friends to install the theme!

{`https://share.betterseqta/theme?id=${themeID}`}
) : ( <>

{theme.name}

{theme.description}

{ currentThemes.includes((theme.theme as { id: string }).id) ? : } )}
)} ); }; export default Theme;