import { BugReport } from "@mui/icons-material";
import { Box, Button, IconButton, TextField, Typography } from "@mui/material";
import { useRouter } from "next/router";
import { useState } from "react";
import { SettingsItem } from "../components/HeaderBar/Settings/SettingsItem";
import { useSettings } from "../contexts/SettingsContext";
import { testing } from "../lib/testing";
import { invoke } from "@tauri-apps/api/tauri";

export default function Testing() {
  // contexts
  const router = useRouter();
  const { settings, settingsLoading, updateSettings, resetSettings } = useSettings();

  // states
  const [text, setText] = useState("");
  const [color, setColor] = useState("#000000");

  return (
    <Box>
      <IconButton
        onClick={() => {
          router.push("/");
        }}
      >
        <BugReport />
      </IconButton>
      <button
        onClick={() => {
          resetSettings();
        }}
      >
        reset settings
      </button>
      <button>update settings</button>
      <button
        onClick={() => {
          console.log(settings);
        }}
      >
        log settings
      </button>
      <button
        onClick={() => {
          console.log(testing());
        }}
      >
        testing
      </button>
      <button
        onClick={async () => {
          try {
            const bruh = await invoke("process_wallpaper_image", {
              filePathString: "/home/vomitblood/Downloads/asasdf.gif",
            });
          } catch (error) {
            console.error("deec nuts", error);
          }
        }}
      >
        invoke tauri shit
      </button>
      <Typography>{text}</Typography>
      <SettingsItem
        defaultText="#8ab4f8"
        description="Accent color"
        input={
          <TextField
            name="accent_color"
            onChange={(e) => {
              setColor(e.target.value);
            }}
            sx={{
              width: "100%",
            }}
            size="small"
            type="color"
            value={color}
            variant="standard"
          />
        }
      />
    </Box>
  );
}
