21/03/2024 - 23h30

recette2
cherif 2024-03-21 23:19:55 +01:00
parent 2bb666e222
commit 3ccb50267d
4 changed files with 305 additions and 11 deletions

View File

@ -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() {
<Route path="/page-inconnue/" exact component={NotFound} />
<Route path="/formation-inconnue/" exact component={Training_Inactive_Or_Not_Found} />
<Route path="/E_Signature/:document_id" exact component={ESign} />
<Route path="/E_Document/:document_id/:partner_owner_recid/:secret_key_signature" exact component={ESignDiplayDignedDocument} />
<Route component={NotFound} />
</Switch>
</BrowserRouter>

View File

@ -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 (
<div className="esign">
{/* POUR SIGNATURE E-DOCUMENT */}
<Dialog
open={Dialog_SIGN_VALIDATION_open}
onClose={Dialog_SIGN_VALIDATION_handleClose}
className="esign"
>
{!erreur_recup_e_doc && <DialogTitle>Signature </DialogTitle>}
{erreur_recup_e_doc && <DialogTitle>Signature - <font color="red"> Identifiants invalides </font></DialogTitle>}
<DialogContent className="DialogContent_width">
<div className="div_row_dialog">
<div className="session_caract_Dialog" > <b> Email </b>
<TextField
autoFocus
margin="dense"
id="new_login"
//label="Prix Unitaire"
fullWidth
//variant="standard"
value={selected_e_doc_email}
onChange={(e) => {
setselected_e_doc_email(e.target.value);
}
}
/>
</div>
</div>
<div className="div_row_dialog">
<div className="session_caract_Dialog" > <b>Clé de signature </b>
<TextField
autoFocus
margin="dense"
id="secrete_key"
//label="Prix Unitaire"
fullWidth
//variant="standard"
value={selected_e_doc_secret}
onChange={(e) => {
setselected_e_doc_secret(e.target.value);
}
}
/>
</div>
</div>
</DialogContent>
<DialogActions>
<div className="div_row">
<div className="div_row_gauche">
<Button onClick={Signature_E_Document} className="bton_enreg_dialog">Valider &nbsp;</Button>
</div>
<div className="div_row_droite" style={{ "textAlign": 'center' }}>
<Button onClick={Dialog_SIGN_VALIDATION_handleClose_buton} className="bton_annule_dialog" >Annuler</Button>
</div>
</div>
</DialogActions>
</Dialog>
{/* FIN POUR SIGNATURE E-DOCUMENT */}
{/* POUR OUVERTURE E-DOCUMENT */}
<Dialog
open={Dialog_1_open}
onClose={Dialog_1_handleClose}
@ -246,7 +340,7 @@ function ESign() {
<div className="div_row_dialog">
<div className="session_caract_Dialog" > Email :
<div className="session_caract_Dialog" > <b>Email </b>
<TextField
autoFocus
margin="dense"
@ -266,7 +360,7 @@ function ESign() {
</div>
<div className="div_row_dialog">
<div className="session_caract_Dialog" > Clé Secrete
<div className="session_caract_Dialog" > <b> Clé d'ouverture </b>
<TextField
autoFocus
margin="dense"
@ -303,6 +397,7 @@ function ESign() {
</DialogActions>
</Dialog>
{/* FIN POUR OUVERTURE E-DOCUMENT */}
<Dialog
open={Dialog_Message_open}
onClose={Dialog_Message_handleClose}
@ -364,13 +459,15 @@ function ESign() {
<div className="div_row_gauche" style={{ "textAlign": 'left', 'marginLeft': '15px' }}>
<Button variant="contained" className="bton_enreg" onClick={Signature_E_Document}>Signer
<Button variant="contained" className="bton_enreg" onClick={(e) => {
setDialog_SIGN_VALIDATION_open(true);
}}>Signer
</Button>
</div>
<div className="div_row_droite" style={{ "textAlign": 'right', 'marginRight': '15px' }} >
<Button variant="contained" className="bton_annule" onClick={"Annule_Add_One_New_Doc"}>Annuler
<Button variant="contained" className="bton_annule" onClick={Dialog_Message_handleClose_buton}>Annuler
</Button>
</div>
</div>

View File

@ -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 (
<div className="esign">
{isLoading && <div className="loader-container">
<div className="mysy_spinner"> <img src={img_loading_spin} /> </div>
</div>}
<Header />
<h3> Document Electronique </h3>
{is_valide_e_document && <div>
<div style={{ width: "80%", "marginLeft": "auto", "marginRight": "auto" }}>
<embed src={get_E_Document_PDF} width='100%' height='700px' type="application/pdf" />
</div>
<div className="div_row">
&nbsp;
</div>
</div>}
{!is_valide_e_document && <div style={{ height: "40vh" }}>
&nbsp;
</div>}
<div className="div_row">
&nbsp;
</div>
<div className="pieddepage">
<Footer />
</div>
</div>
);
}
export default ESignDiplayDignedDocument;

View File

@ -0,0 +1,17 @@
import Link from "next/link";
import Navigation from "../components/Navigation";
import ESignDiplayDignedDocument from "../components/ESignDiplayDignedDocument";
export default function Login() {
return (
<div>
<Navigation />
<div>
<ESignDiplayDignedDocument />
</div>
</div>
);
}