import PixModule from "pix-module";
import { useEffect } from "react";

import "./App.css";

const pixModule = PixModule({
  accessToken: "teste",
  baseURL: "https://api.com",
  isMock: true,
});

/* const pixModule = PixModule({
  accessToken: "b1f2b3ebb8eb2f3153a7f909e304f9b364252092",
  baseURL: "https://stage.api.contaescola.com.br/pix",
  isMock: false,
});
 */
function App() {
  const fetch = async () => {
    const { services } = pixModule;

    /* const extract = await services.extract.get();
    const charge = await services.charge_someone.post({
      description: "Teste",
      key_id: 22,
      amount: 1000,
    });
    const key = await services.key.post({
      key: "test@test.com",
      bank_account: 1,
      type: 1,
    }); */
    /* const limit = await services.limit.post({
      limit_day_amount: 5000,
      limit_night_amount: 2000,
    }); */
    /* const checkqrcode = await services.checkqrcode.post({
      code: "testcode",
    }); */
    // const payqrcode = await services.payqrcode.post({});
    // const receipts = await services.receipt.get();

    /* const keyPUT = await services.key.put(1, {
      type_origin_account: "poupança",
    }); */

    /* console.log("# Extract: ", extract);
    console.log("# Charge: ", charge);
    console.log("# Key: ", key);
    console.log("# Key PUT: ", keyPUT);
    console.log("# Limit: ", limit);
    console.log("# Receipt: ", receipts);
    console.log("# Check QR Code: ", checkqrcode); */

    const transfer = await services.transfer.post({
      type: "key",
      key: "tarcisio.thallys@prosperitainova.com.br",
      amount: 10,
      sender_account: 4,
    });

    console.log("# Transfer: ", transfer);
    // console.log("# Pay QR Code: ", payqrcode);
  };

  useEffect(() => {
    fetch();
  }, []);

  return (
    <div className="App">
      Olá, aplicação de teste está funcionando!
      <br></br>
      accessToken: {pixModule.activeAccessToken}
      baseURL: {pixModule.activeBaseURL}
    </div>
  );
}

export default App;
