import {useTheme} from "next-themes"; import React, {useLayoutEffect, useState} from "react"; import {Switch} from "@nextui-org/react"; import {Moon, SunDim} from "@phosphor-icons/react"; import {themes} from "Frontend/theming/themes"; import {Theme} from "Frontend/theming/theme"; import ThemePreview from "Frontend/components/theming/ThemePreview"; export function ThemeSelector() { const {theme, setTheme} = useTheme(); const [isSelected, setIsSelected] = useState(theme ? theme.includes("light") : false); const [currentTheme, setCurrentTheme] = useState(theme?.substring(0, theme?.lastIndexOf("-"))); useLayoutEffect(() => setTheme(`${currentTheme}-${mode()}`), [isSelected]); function mode(): "light" | "dark" { return isSelected ? "light" : "dark"; } return (