import { BugReportOutlined } from "@mui/icons-material";
import { Box, Button, IconButton, useTheme } from "@mui/material";
import { fetch } from "@tauri-apps/plugin-http";
import { useState } from "react";
import { defaultSettings } from "../../lib/settings";
import { FloatingDialog } from "../Generic/FloatingDialog";

export const Testing = () => {
  // contexts
  const theme = useTheme();

  // states
  const [openState, setOpenState] = useState(false);
  const [maximisedState, setMaximisedState] = useState(false);

  // functions
  const close = () => setOpenState(false);

  const testing = () => {
    fetch("https://ip.vomitblood.com/ping").then((response) => {
      console.log(response);
    });
  };

  return (
    <FloatingDialog
      body={
        <Box
          sx={{
            border: "1px solid " + theme.palette.grey[700],
            borderRadius: defaultSettings.style.radius + "px",
            display: "flex",
            flexDirection: "column",
            flexGrow: 1,
            my: 2,
            overflow: "hidden",
            p: 0,
          }}
        >
          <Box>
            <Button
              onClick={() => {
                testing();
              }}
            >
              test
            </Button>
          </Box>
        </Box>
      }
      close={close}
      maximisedState={maximisedState}
      openButton={
        <IconButton
          onClick={() => setOpenState(true)}
          size='small'
        >
          <BugReportOutlined />
        </IconButton>
      }
      openState={openState}
      setMaximisedState={setMaximisedState}
      title='Testing'
    />
  );
};
