From 0aabb0b99f4005b6072c1a2fb0d9b2f581c29a37 Mon Sep 17 00:00:00 2001 From: cherif Date: Thu, 16 May 2024 13:03:56 +0200 Subject: [PATCH] zz --- src/App.js | 2 +- src/pages/automaticquotation.js | 112 +++++++++++++++++++++++---- src/styles/components/_notfound.scss | 34 ++++++++ 3 files changed, 133 insertions(+), 15 deletions(-) diff --git a/src/App.js b/src/App.js index 3a72fcc..52e778b 100644 --- a/src/App.js +++ b/src/App.js @@ -129,7 +129,7 @@ function App() { - + diff --git a/src/pages/automaticquotation.js b/src/pages/automaticquotation.js index bd6adb7..ada1cd1 100644 --- a/src/pages/automaticquotation.js +++ b/src/pages/automaticquotation.js @@ -1,33 +1,102 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useRef } from "react"; import Navigation from "../components/Navigation"; import bannerimg2 from "./../mysy_img/MYSY-LOGO-BLUE.png"; import ok_png from "./../mysy_img/Ok_PNG.png"; import { Helmet } from "react-helmet"; import Footer from "./../components/Fotter"; import Header from "./../components/Header"; -import { useParams } from 'react-router-dom' +import { useParams } from 'react-router-dom'; +import img_loading_spin from "./../mysy_img/mysy_spin_loading.gif"; +import axios from "axios"; const Automaticquotation = () => { - const { objid , partner_owner_recid} = useParams(); + const { objid, partner_owner_recid } = useParams(); const [tempo, settempo] = useState("."); - setInterval(check, 2300); - -/* - window.setTimeout(function () { - window.location.href = process.env.REACT_APP_BASE_URL - }, 7000); + //setInterval(check, 2300); + + /* + window.setTimeout(function () { + window.location.href = process.env.REACT_APP_BASE_URL + }, 7000); + */ -*/ function check() { var val = tempo + " ."; //alert(" val = "+val); - settempo(val); + //settempo(val); } + + const [isLoading, setLoading] = useState(); + + + const [Create_Automatic_Quotation_api, setCreate_Automatic_Quotation_api] = useState(); + const [Create_Automatic_Quotation_message, setCreate_Automatic_Quotation_message] = useState(); + const [Create_Automatic_Quotation_result, setCreate_Automatic_Quotation_result] = useState(); + function Create_Automatic_Quotation() { + var form = new FormData(); + //form.append("token","K3cw63eKokKSbV4spjQ48SUNnfy80yrXfA"); + + + form.append("partner_owner_recid", partner_owner_recid); + form.append("lead_website_id", objid); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Create_Automatic_Quotation/"; + + // setLoading(true); + + + + axios.post(myurl, form).then(res => { + console.log(" In Create_Automatic_Quotation res.data.status = " + res.data.status); + console.log(" In Create_Automatic_Quotation res.data.message r_class = " + res.data.message); + + // setLoading(false); + if (String(res.data.status) === String("true")) { + setCreate_Automatic_Quotation_api("true"); + setCreate_Automatic_Quotation_result(res.data.message); + + //myRef_head.current.scrollIntoView({ behavior: "smooth" }); + + } + else { + setCreate_Automatic_Quotation_api("false"); + setCreate_Automatic_Quotation_message(res.data.message); + alert(res.data.message); + } + + }).catch((error) => { + + //setLoading(false); + console.warn('UpdateStagiaireData : Not good man :( Create_Automatic_Quotation = ' + error); + setCreate_Automatic_Quotation_api("false"); + alert(" Impossible de créer le devis"); + + }) + } + const initialized = useRef(false) + + useEffect(() => { + + if (!initialized.current) { + initialized.current = true + console.log(" aaaaaa") + Create_Automatic_Quotation(); + } + + }, [Create_Automatic_Quotation_api]); + + return (
+ + {isLoading &&
+
+
} + +
@@ -43,12 +112,27 @@ const Automaticquotation = () => {
-
Votre devis est en cours de création
+ {isLoading &&
+
+
} + {/*
Votre devis est en cours de création
*/}
- Vous allez être redirigé vers le moteur de recherche dans quelques secondes. {tempo} + Votre devis est en cours de création . {tempo} + Create_Automatic_Quotation_api = {Create_Automatic_Quotation_api} - objid = {objid} + {Create_Automatic_Quotation_api && String(Create_Automatic_Quotation_api) === "false" && +
+ Impossible de créer le devis : {Create_Automatic_Quotation_message} +
+ } + + {Create_Automatic_Quotation_api && String(Create_Automatic_Quotation_api) === "true" && +
+ + {Create_Automatic_Quotation_message} +
+ }
diff --git a/src/styles/components/_notfound.scss b/src/styles/components/_notfound.scss index 3d350ce..8e18306 100644 --- a/src/styles/components/_notfound.scss +++ b/src/styles/components/_notfound.scss @@ -1,4 +1,38 @@ .notfound { + + .loader-container { + width: 100%; + height: 100vh; + display: flex; + justify-content: center; + align-items: center; + position: fixed; + background: white; + background-color: transparent; + z-index: 1; + top: 0px; + opacity: 80%; + left: 0px; + } + +.spinner { + width: 20rem; + height: 10rem; + border: 8px solid; + border-color: #3d5af1 transparent #3d5af1 transparent; + border-radius: 50%; + animation: spin-anim 1.2s linear infinite; + background-color: red; + color: black; +} + +.mysy_spinner { + border-radius: 5px; + //border: 1px solid black; + opacity: 100%; +} + + @media only screen and (max-width: 600px) { .nom_prenom { font-family: "verdana", "Quicksand", "Signika", sans-serif;