<reponame>Amazon-Connect-Equipo-1/AWS<filename>FrontHttpsDiscord/ac-front-test/src/components/AgentMain/ConfirmationUberEats.js<gh_stars>0/* O
Authors:
        A01777771 Stephen Strange*/

//Import Modules
import "../../styles/AgentMain/ThirdParty.css";
import uberlogo from "../../images/uber.png";
import { createContext, Suspense, useState } from "react";

const ConfirmationUberEats = (props) => {
  const token =
    "vqbpgud2ghvjgm1n5hdgjnn5818fzsf27ilihvw-XalwJ39c6WILiETkIB_UIxBJo6coX5SXNMr_zSExJvodAA8qiKUqN5ruPcT8HU69dxCN-t28n3AeyCsU3c6ZRZ0kny2mR8uCWhTTYIlr_FRk3PvaQAjK4bqYKokzS_v9GM2ibxI-nbIP2cwUXAkLCowldZKWL8O9kWuRYW6XtMrIvbgkgm4fp-cATp9vrHuTs5RV7BaU4aFQtqjEg_THoNcxbkM8J3GdMqkRVC09R8rnA6Vot91voqZic3GK9_IJESL6u6r1ZMuKjrns5O9KFXm48Cw-If2R6Bp3KSA-X6F6ucJ_At53GLlMgHwyhjdrhusuo-ZrqWSKvQ";

  const [conf, setConf] = useState("no");
  const changeConfig = () => {
    setConf("yes");
  };
  const pruebaBackTPS = (event) => {
    const myHeaders = new Headers();
    myHeaders.append("Content-Type", "application/json");
    myHeaders.append("Authorization", `Bearer ${token}`);

    const raw = JSON.stringify({
      service: "UberEats",
      service_data: {
        client: "Miguel Perez",
        client_email: "lyhxr@example.com",
        client_cellphone: "+525530323376",
        client_location: "Club Mamitas",
        order: {
          papas: {
            price: 5,
            quantity: 2,
          },
          absolut: {
            price: 200,
            quantity: 2,
          },
        },
        total: 410,
        delivery_name: "Alvaro Obregon ",
        delivery_time: 25,
        timestamp: "2022-05-30 15:16:53.006495",
      },
    });

    const requestOptions = {
      method: "POST",
      headers: myHeaders,
      body: raw,
      redirect: "follow",
    };

    fetch("http://35.88.250.238:8080/tps/sendService", requestOptions)
      .then((response) => response.text())
      .then((result) => console.log(result))
      .catch((error) => console.log("error", error));
  };

  return (
    <div className="tp-confirmation">
      <div className="tp-title">
        Service Confirmation
        {conf === "yes" && (
          <div>
            <div className="tp-confirmation-text">Informacion Enviada!</div>
            <div className="tp-confirmation-button-container">
              <button
                className="tp-confirmation-button"
                onClick={pruebaBackTPS}
              >
                confirmado
              </button>
            </div>
          </div>
        )}
        {conf === "no" && (
          <div>
            <div className="tp-confirmation-text">INFORMACION UBER EATS</div>
            <div className="tp-confirmation-button-container">
              <button
                className="tp-confirmation-button"
                //onClick={props.onChange()}
              >
                Regresar
              </button>
              <button className="tp-confirmation-button" onClick={changeConfig}>
                Mandar info
              </button>
            </div>
          </div>
        )}
      </div>
    </div>
  );
};
export default ConfirmationUberEats;
