From 3ccb50267db0e8df0bbf06f9f17eb751b2b2318c Mon Sep 17 00:00:00 2001 From: cherif Date: Thu, 21 Mar 2024 23:19:55 +0100 Subject: [PATCH] 21/03/2024 - 23h30 --- src/App.js | 2 + src/components/ESign.js | 119 +++++++++++-- src/components/ESignDiplayDignedDocument.js | 178 ++++++++++++++++++++ src/pages/edigndiplaydigneddocument.js | 17 ++ 4 files changed, 305 insertions(+), 11 deletions(-) create mode 100644 src/components/ESignDiplayDignedDocument.js create mode 100644 src/pages/edigndiplaydigneddocument.js diff --git a/src/App.js b/src/App.js index 6ec7b2b..89c9578 100644 --- a/src/App.js +++ b/src/App.js @@ -46,6 +46,7 @@ import Test_Drag_Drop from "./pages/test_drag_drop"; import Test_Drag_Drop2 from "./pages/test_dnd"; import ESign from "./pages/eSigne"; +import ESignDiplayDignedDocument from "./pages/edigndiplaydigneddocument"; function App() { @@ -120,6 +121,7 @@ function App() { + diff --git a/src/components/ESign.js b/src/components/ESign.js index 44eb0c3..c235a0f 100644 --- a/src/components/ESign.js +++ b/src/components/ESign.js @@ -50,7 +50,7 @@ import { Document, Page } from 'react-pdf' function ESign() { const history = useHistory(); - const { document_id } = useParams(); + const { document_id, local_secret_key_signature, local_partner_owner_recid } = useParams(); const [isLoading, setLoading] = useState(); const [get_E_Document_PDF, setget_E_Document_PDF] = useState(); @@ -72,7 +72,7 @@ function ESign() { const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("e_doc_id", document_id); - form.append("secret_key", selected_e_doc_secret); + form.append("secret_key_open", selected_e_doc_secret); form.append("user_email", user_email); @@ -92,10 +92,14 @@ function ESign() { var document_data = "data:application/pdf;base64," + JSON.parse(res.data.message).document_data; setget_E_Document_PDF(document_data); setselected_e_doc_id(JSON.parse(res.data.message)._id); - setselected_e_doc_email(JSON.parse(res.data.message).email_destinataire); - setselected_e_doc_secret(JSON.parse(res.data.message).secret_key); + //setselected_e_doc_email(JSON.parse(res.data.message).email_destinataire); + //setselected_e_doc_secret(JSON.parse(res.data.message).secret_key_open); setDialog_1_open(false); seterreur_recup_e_doc(); + setselected_e_doc_secret(""); + setselected_e_doc_email(""); + + } @@ -133,7 +137,7 @@ function ESign() { const stored_cookie = getCookie('tokenmysypart'); form.append("token", stored_cookie); form.append("e_doc_id", selected_e_doc_id); - form.append("secret_key", selected_e_doc_secret); + form.append("secret_key_signature", selected_e_doc_secret); form.append("email_destinataire", selected_e_doc_email); setLoading(true); @@ -147,7 +151,7 @@ function ESign() { setSignature_E_Document_api("true"); setDialog_Message_open(true); - // alert(" Le document a été correctement signé"); + // alert(" Le document a été correctement signé"); } else if (String(res.data.status) === String("Err_Connexion")) { @@ -157,7 +161,8 @@ function ESign() { } else { setSignature_E_Document_api("false"); - Signature_E_Document_message(res.data.message) + Signature_E_Document_message(res.data.message); + seterreur_recup_e_doc(res.data.message); alert(res.data.message); } @@ -193,6 +198,7 @@ function ESign() { const [Dialog_1_message, setDialog_1_message] = React.useState(false); + const [Dialog_1_open, setDialog_1_open] = React.useState(true); function Dialog_1_handle_change_participant_session(message) { setDialog_1_message(message); @@ -229,10 +235,98 @@ function ESign() { }; + const [Dialog_SIGN_VALIDATION_open, setDialog_SIGN_VALIDATION_open] = React.useState(false); + + + const Dialog_SIGN_VALIDATION_handleClose = () => { + //alert(" Utiliser le bouton 'fermer' "); + //setOpen(false); + }; + + const Dialog_SIGN_VALIDATION_handleClose_buton = () => { + setDialog_SIGN_VALIDATION_open(false); + history.push("/"); + }; + + return (
+ {/* POUR SIGNATURE E-DOCUMENT */} + + + {!erreur_recup_e_doc && Signature } + {erreur_recup_e_doc && Signature - Identifiants invalides } + + + +
+
Email + { + setselected_e_doc_email(e.target.value); + + } + } + /> +
+
+ +
+
Clé de signature + { + setselected_e_doc_secret(e.target.value); + + } + } + /> +
+
+ + + +
+ + +
+
+ +
+
+ +
+ +
+ +
+
+ + {/* FIN POUR SIGNATURE E-DOCUMENT */} + + + {/* POUR OUVERTURE E-DOCUMENT */} -
Email : +
Email
-
Clé Secrete +
Clé d'ouverture
+ {/* FIN POUR OUVERTURE E-DOCUMENT */} -
-
diff --git a/src/components/ESignDiplayDignedDocument.js b/src/components/ESignDiplayDignedDocument.js new file mode 100644 index 0000000..f073850 --- /dev/null +++ b/src/components/ESignDiplayDignedDocument.js @@ -0,0 +1,178 @@ +import React, { useRef, useState, useEffect } from "react"; +import TextField from '@mui/material/TextField'; +import MenuItem from '@mui/material/MenuItem'; +import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css +import Button from '@mui/material/Button'; +import axios from "axios"; +import { getCookie, setCookie } from 'react-use-cookie'; +import { useHistory } from "react-router-dom"; +import CheckOut from "./CheckOut"; +import { DataGrid, GridToolbar, frFR } from '@mui/x-data-grid'; +import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css"; +import { Editor } from '@tinymce/tinymce-react'; +import parse from 'html-react-parser'; +import { FcViewDetails, FcDisapprove } from "react-icons/fc"; +import 'react-tooltip/dist/react-tooltip.css' +import { Tooltip } from 'react-tooltip' +import add_plus from "../mysy_img/plus.png"; +import excel_icone from "../mysy_img/excel_icone.png"; +import participants from "../mysy_img/participants.png"; +import fileDownload from 'js-file-download' +import Autocomplete from '@mui/material/Autocomplete'; +import Popup from 'reactjs-popup'; +import 'reactjs-popup/dist/index.css'; +import img_loading_spin from "./../mysy_img/mysy_spin_loading.gif"; +import { FcCancel, FcApproval, FcAcceptDatabase, FcPrint } from "react-icons/fc"; +import DatePicker from "react-datepicker"; +import "react-datepicker/dist/react-datepicker.css"; +import { format } from 'date-fns' +import moment from "moment"; +import InputAdornment from '@mui/material/InputAdornment'; +import { AiFillCloseCircle } from "react-icons/ai"; +import Box from '@mui/material/Box'; +import { Typography, LinearProgress } from '@mui/material'; +import styled from 'styled-components'; +import { CiTrash } from "react-icons/ci"; +import { MdAddCircleOutline, MdRemoveCircleOutline } from "react-icons/md"; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; +import { TransitionProps } from '@mui/material/transitions'; +import { IoAddCircleOutline, IoCloseCircleOutline } from "react-icons/io5"; +import { useParams } from 'react-router-dom' +import Header from "./Header"; +import Footer from "./Fotter"; +import { FcInfo } from "react-icons/fc"; +import { Document, Page } from 'react-pdf' + +function ESignDiplayDignedDocument() { + + const history = useHistory(); + const { document_id, secret_key_signature, partner_owner_recid } = useParams(); + const [isLoading, setLoading] = useState(); + + const [get_E_Document_PDF, setget_E_Document_PDF] = useState(); + const [selected_e_doc_id, setselected_e_doc_id] = useState(); + const [selected_e_doc_email, setselected_e_doc_email] = useState(); + const [selected_e_doc_secret, setselected_e_doc_secret] = useState(); + + const [is_valide_e_document, setis_valide_e_document] = useState(false); + + const [get_E_Document_api, setget_E_Document_api] = useState(); + const [get_E_Document_message, setget_E_Document_message] = useState(); + const [get_E_Document_result, setget_E_Document_result] = useState(); + function get_E_Document() { + + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Get_Given_E_Document_Signed_No_Token/"; + + var form = new FormData(); + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("e_doc_id", document_id); + form.append("secret_key_signature", secret_key_signature); + form.append("partner_owner_recid", partner_owner_recid); + + + + setLoading(true); + axios.post(myurl, form).then(res => { + + setLoading(false); + //console.log(" get_E_Document : In test res.data.status = " + res.data.status); + //console.log(" get_E_Document: res.data.message.img = " + res.data.message); + + if (String(res.data.status) === "true") { + setget_E_Document_api("true"); + + if (JSON.parse(res.data.message).document_data_signed) { + setis_valide_e_document(true); + var document_data_signed = "data:application/pdf;base64," + JSON.parse(res.data.message).document_data_signed; + setget_E_Document_PDF(document_data_signed); + setselected_e_doc_id(JSON.parse(res.data.message)._id); + //setselected_e_doc_email(JSON.parse(res.data.message).email_destinataire); + //setselected_e_doc_secret(JSON.parse(res.data.message).secret_key_open); + + + } + + + } + else if (String(res.data.status) === String("Err_Connexion")) { + alert('Erreur: ' + res.data.message); + history.push("/Connexion"); + return; + } + else { + setget_E_Document_api("false"); + get_E_Document_message(res.data.message) + alert(res.data.message); + + } + }).catch((error) => { + setLoading(false); + console.warn('get_E_Document ee: Not good man :( = ', error); + setget_E_Document_api("false"); + get_E_Document_message(" Impossible de recuperer le E-Document") + }) + + } + + + + useEffect(() => { + + get_E_Document(); + + window.scrollTo({ + top: 0, + behavior: "smooth", + }); + }, []) + + + + return ( +
+ + + {isLoading &&
+
+
} + + +
+ +

Document Electronique

+ + {is_valide_e_document &&
+
+ + + +
+
+   +
+ + +
} + + {!is_valide_e_document &&
+   + +
} + +
+   +
+
+
+
+
+ ); +} + +export default ESignDiplayDignedDocument; \ No newline at end of file diff --git a/src/pages/edigndiplaydigneddocument.js b/src/pages/edigndiplaydigneddocument.js new file mode 100644 index 0000000..dae1e63 --- /dev/null +++ b/src/pages/edigndiplaydigneddocument.js @@ -0,0 +1,17 @@ +import Link from "next/link"; +import Navigation from "../components/Navigation"; +import ESignDiplayDignedDocument from "../components/ESignDiplayDignedDocument"; + + + +export default function Login() { + return ( +
+ +
+ + +
+
+ ); +}