import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'

async function App() {
  const [count, setCount] = useState(0)

  // getting data
  const username = "aadil";
  const password = "9dc04fffe0c1c915be487f26a7f8d90f52d47b9861036e6093e8d932c162";

  const url = "https://kanboard.autonomic.zone/jsonrpc.php";
  const options = {
    method: "POST",
    headers: {
      "Access-Control-Allow-Origin": "http://localhost",
      "Content-Type": "application/json",
      Authorization: "Basic " + btoa(username + ":" + password),
    },
    body: JSON.stringify({
      jsonrpc: "2.0",
      method: "getMyDashboard",
      id: 1,
    }),
  };

  const request = await fetch(url, options);
  const data = await request.json();

  return (
    <>
      <div>
        <a href="https://vitejs.dev" target="_blank">
          <img src={viteLogo} className="logo" alt="Vite logo" />
        </a>
        <a href="https://react.dev" target="_blank">
          <img src={reactLogo} className="logo react" alt="React logo" />
        </a>
      </div>
      <h1>Vite + React</h1>
      <div className="card">
        <button onClick={() => setCount((count) => count + 1)}>
          count is {count}
        </button>
        <p>
          Edit <code>src/App.jsx</code> and save to test HMR
        </p>
      </div>
      <p className="read-the-docs">
        Click on the Vite and React logos to learn more
      </p>
    </>
  )
}

export default App
