import { Trans } from "@lingui/macro" import { Button, Group, Stack, Textarea } from "@mantine/core" import { useForm } from "@mantine/form" import { useEffect } from "react" import { useAsyncCallback } from "react-async-hook" import { TbDeviceFloppy } from "react-icons/tb" import { client } from "../../app/client" import { redirectToSelectedSource } from "../../app/slices/redirect" import { useAppDispatch, useAppSelector } from "../../app/store" interface FormData { customCss: string } export function CustomCss() { const settings = useAppSelector(state => state.user.settings) const customCss = settings?.customCss const dispatch = useAppDispatch() const form = useForm() const { setValues } = form const saveCustomCss = useAsyncCallback(client.user.saveSettings, { onSuccess: () => { window.location.reload() }, }) useEffect(() => { if (!customCss) return setValues({ customCss, }) }, [setValues, customCss]) return (
{ if (!settings) return saveCustomCss .execute({ ...settings, customCss: data.customCss, }) .then(() => window.location.reload()) })} >