From 77368feb32d7e642760420d14d30c0ddd554457b Mon Sep 17 00:00:00 2001 From: cherif Date: Mon, 7 Oct 2024 20:17:16 +0200 Subject: [PATCH] 07/10/2024 - 20h30 --- src/components/Fotter_Catalog_Pub.js | 9 + src/components/Mon_Catalogue_Public.js | 5 + src/components/UpdatePartnerInfo.js | 304 +++++++++++++++++- src/styles/components/_updateparnterinfo.scss | 137 +++++++- 4 files changed, 425 insertions(+), 30 deletions(-) diff --git a/src/components/Fotter_Catalog_Pub.js b/src/components/Fotter_Catalog_Pub.js index adae336..08bfa36 100644 --- a/src/components/Fotter_Catalog_Pub.js +++ b/src/components/Fotter_Catalog_Pub.js @@ -48,6 +48,13 @@ const Fotter_Catalog_Pub = (props) => { downloadLink.click(); } + function Display_Mention_Legale_File() { + const downloadLink = document.createElement("a"); + const fileName = "file.pdf"; + downloadLink.href = props.partner_data.catalog_pub_mention_legale_pdf; + downloadLink.download = fileName; + downloadLink.click(); + } return ( @@ -61,6 +68,8 @@ const Fotter_Catalog_Pub = (props) => {
Copyright © 2024 {props.partner_data.nom} . Tous droits réservés.   + + diff --git a/src/components/Mon_Catalogue_Public.js b/src/components/Mon_Catalogue_Public.js index 403e1b4..c205d61 100644 --- a/src/components/Mon_Catalogue_Public.js +++ b/src/components/Mon_Catalogue_Public.js @@ -2649,7 +2649,11 @@ const Mon_Catalogue_Public = (props) => { if (JSON.parse(x).catalog_pub_cgu_pdf) catalog_pub_cgu_pdf = JSON.parse(x).catalog_pub_cgu_pdf; + var catalog_pub_mention_legale_pdf = "" + if (JSON.parse(x).catalog_pub_mention_legale_pdf) + catalog_pub_mention_legale_pdf = JSON.parse(x).catalog_pub_mention_legale_pdf; + var catalog_pub_message_1_taille = "12" if (JSON.parse(x).catalog_pub_message_1_taille) @@ -2783,6 +2787,7 @@ const Mon_Catalogue_Public = (props) => { "catalog_pub_cgv_pdf": catalog_pub_cgv_pdf, "catalog_pub_cgu_pdf": catalog_pub_cgu_pdf, + "catalog_pub_mention_legale_pdf": catalog_pub_mention_legale_pdf, "catalog_pub_logo": catalog_pub_logo, "catalog_pub_banniere_img": catalog_pub_banniere_img, diff --git a/src/components/UpdatePartnerInfo.js b/src/components/UpdatePartnerInfo.js index f70c94d..41770f7 100644 --- a/src/components/UpdatePartnerInfo.js +++ b/src/components/UpdatePartnerInfo.js @@ -1948,6 +1948,11 @@ function UpdateParnterInfo(props) { local_cgv = JSON.parse(res.data.message).cgv_pdf; setp_detail_cgv_file_pdf(local_cgv); + var local_mentions_legales = ""; + if (JSON.parse(res.data.message).mention_legale_pdf) + local_mentions_legales = JSON.parse(res.data.message).mention_legale_pdf; + setp_detail_mention_legale_file_pdf(local_mentions_legales); + var theme_id_preview = "data:image/png;base64," + JSON.parse(res.data.message).theme_preview; setselected_catalog_pub_theme_preview(theme_id_preview); @@ -2694,6 +2699,9 @@ function UpdateParnterInfo(props) { const [p_detail_cgv_file_pdf, setp_detail_cgv_file_pdf] = React.useState(""); const [p_detail_cgu_file_pdf, setp_detail_cgu_file_pdf] = React.useState(""); + const [p_detail_mention_legale_file_pdf, setp_detail_mention_legale_file_pdf] = React.useState(""); + + const [p_text2_taille, setp_text2_taille] = React.useState("12"); const [p_text2_gras, setp_text2_gras] = React.useState(false); @@ -2835,6 +2843,10 @@ function UpdateParnterInfo(props) { }) } + function Cancel_Add_Update_Catalog_Pub_CGV() { + setpdf_cgv_file_pdf(""); + } + const [Supprimer_Catalog_Pub_CGV_api, setSupprimer_Catalog_Pub_CGV_api] = useState(); const [Supprimer_Catalog_Pub_CGV_message, setSupprimer_Catalog_Pub_CGV_message] = useState(); const [Supprimer_Catalog_Pub_CGV_result, setSupprimer_Catalog_Pub_CGV_result] = useState(); @@ -2980,6 +2992,11 @@ function UpdateParnterInfo(props) { }) } + + function Cancel_Add_Update_Catalog_Pub_CGU() { + setpdf_cgu_file_pdf(""); + } + const [Supprimer_Catalog_Pub_CGU_api, setSupprimer_Catalog_Pub_CGU_api] = useState(); const [Supprimer_Catalog_Pub_CGU_message, setSupprimer_Catalog_Pub_CGU_message] = useState(); const [Supprimer_Catalog_Pub_CGU_result, setSupprimer_Catalog_Pub_CGU_result] = useState(); @@ -3037,6 +3054,154 @@ function UpdateParnterInfo(props) { downloadLink.click(); } + // ==> Mentions Legales + const changeHandler2_mention_legale = (event) => { + hiddenFileInput_mention_legale.current.click(); + }; + + + const [mention_legale_file_name, setmention_legale_file_name] = useState(); + const hiddenFileInput_mention_legale = React.useRef(null); + const [handleSubmission_mention_legale_api, sethandleSubmission_mention_legale_api] = useState(); + const [handleSubmission_mention_legale_result, sethandleSubmission_mention_legale_result] = useState(); + const [handleSubmission_mention_legale_message, sethandleSubmission_mention_legale_message] = useState(); + + function Cancel_Add_Update_Catalog_Pub_Mention_Legale() { + setpdf_mention_legale_file_pdf(""); + } + + const handleSubmission_mention_legale = event => { + const fileUploaded = event.target.files[0]; + let file_size = event.target.files[0].size; + let file_type = event.target.files[0].type; + + sethandleSubmission_mention_legale_message(""); + + sethandleSubmission_mention_legale_api(""); + + // console.log("file_size = ", file_size, " file_type = ", file_type, " naturalWidth = ", fileUploaded.naturalWidth); + if (file_size > 1000000) { + alert("Le fichier ne doit pas dépasser un 1 Méga octets"); + return; + } + + setmention_legale_file_name(event.target.files[0].name); + + reader(event.target.files[0], (err, res) => { + // console.log("#### res === ", res); // Base64 `data:image/...` String result. + setpdf_mention_legale_file_pdf(res); + }); + + + + }; + + + const [pdf_mention_legale_file_pdf, setpdf_mention_legale_file_pdf] = useState(); + + const [Add_Update_Catalog_Pub_Mention_Legale_api, setAdd_Update_Catalog_Pub_Mention_Legale_api] = useState(); + const [Add_Update_Catalog_Pub_Mention_Legale_message, setAdd_Update_Catalog_Pub_Mention_Legale_message] = useState(); + const [Add_Update_Catalog_Pub_Mention_Legale_result, setAdd_Update_Catalog_Pub_Mention_Legale_result] = useState(); + function Add_Update_Catalog_Pub_Mention_Legale() { + var form = new FormData(); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("_id", selected_catalog_pub_config_id); + form.append("mention_legale_pdf", pdf_mention_legale_file_pdf); + + //console.log(" form == ", form); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Update_Partner_Catalog_Pub_Config/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + setLoading(false); + //console.log(" In Add_Update_Catalog_Pub_CGU res.data.status = " + res.data.status); + //console.log(" In Add_Update_Catalog_Pub_CGU res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + setAdd_Update_Catalog_Pub_Mention_Legale_api("true"); + setAdd_Update_Catalog_Pub_Mention_Legale_result(res.data.message); + + setcgv_file_name(""); + setpdf_mention_legale_file_pdf(""); + Get_Partner_Catalog_Pub_Config(); + alert(res.data.message); + + } + else { + setAdd_Update_Catalog_Pub_Mention_Legale_api("false"); + setAdd_Update_Catalog_Pub_Mention_Legale_message(res.data.message); + alert(res.data.message); + } + + }).catch((error) => { + setLoading(false); + console.warn('UpdateStagiaireData : Not good man :( Add_Update_Catalog_Pub_CGU = ' + error); + setAdd_Update_Catalog_Pub_Mention_Legale_api("false"); + alert(" Impossible de supprimer le fichier CGV "); + + }) + } + + const [Supprimer_Catalog_Pub_Mention_Legale_api, setSupprimer_Catalog_Pub_Mention_Legale_api] = useState(); + const [Supprimer_Catalog_Pub_Mention_Legale_message, setSupprimer_Catalog_Pub_Mention_Legale_message] = useState(); + const [Supprimer_Catalog_Pub_Mention_Legale_result, setSupprimer_Catalog_Pub_Mention_Legale_result] = useState(); + function Supprimer_Catalog_Pub_Mention_Legale() { + var form = new FormData(); + + + const stored_cookie = getCookie('tokenmysypart'); + form.append("token", stored_cookie); + form.append("_id", selected_catalog_pub_config_id); + form.append("mention_legale_pdf", ""); + + //console.log(" form == ", form); + + var myurl = process.env.REACT_APP_API_URL + "myclass/api/Add_Update_Partner_Catalog_Pub_Config/"; + + setLoading(true); + axios.post(myurl, form).then(res => { + setLoading(false); + //console.log(" In Supprimer_Catalog_Pub_CGU res.data.status = " + res.data.status); + //console.log(" In Supprimer_Catalog_Pub_CGU res.data.message r_class = " + res.data.message); + + if (String(res.data.status) === String("true")) { + setSupprimer_Catalog_Pub_Mention_Legale_api("true"); + setSupprimer_Catalog_Pub_Mention_Legale_result(res.data.message); + + setcgv_file_name(""); + setpdf_mention_legale_file_pdf(""); + Get_Partner_Catalog_Pub_Config(); + alert(res.data.message); + + } + else { + setSupprimer_Catalog_Pub_Mention_Legale_api("false"); + setSupprimer_Catalog_Pub_Mention_Legale_message(res.data.message); + alert(res.data.message); + } + + }).catch((error) => { + setLoading(false); + console.warn('UpdateStagiaireData : Not good man :( Supprimer_Catalog_Pub_CGU = ' + error); + setSupprimer_Catalog_Pub_Mention_Legale_api("false"); + alert(" Impossible de supprimer le fichier CGU "); + + }) + } + + + function Display_Mention_Legale_File() { + + const downloadLink = document.createElement("a"); + const fileName = "file.pdf"; + downloadLink.href = p_detail_mention_legale_file_pdf; + downloadLink.download = fileName; + downloadLink.click(); + } return (
@@ -4726,16 +4891,16 @@ function UpdateParnterInfo(props) {
-
+
{p_detail_cgv_file_pdf &&
-   +   Supprimer + } modal @@ -4818,12 +4983,12 @@ function UpdateParnterInfo(props) {
{
-
-
-
+
@@ -4837,16 +5002,16 @@ function UpdateParnterInfo(props) {
}
-
+
{p_detail_cgu_file_pdf &&
-   +   Supprimer + } modal @@ -4923,19 +5088,130 @@ function UpdateParnterInfo(props) {
- {pdf_cgu_file_pdf &&
+ {pdf_cgu_file_pdf &&
 
{
-
-
-
- + +
+ +
} +
+   +
+ +
} +
+ +
+ {p_detail_mention_legale_file_pdf &&
+ +
+   + + Supprimer + + } + modal + nested + position="center center" + > + {close => ( +
+ +
MySy Information
+
+ {' '} + + En confirmant cette opération, le fichier sera définitivement supprimé.
+ +
+
+
+ + +
+
+ +
+
+
+ )} +
+ + +
+ +
} + +
+ + {cgu_file_name && } + + + + + {String(Add_Update_Catalog_Pub_Mention_Legale_api) === "true" &&
La mise à jour a été correctement faite
} + {String(Add_Update_Catalog_Pub_Mention_Legale_api) === "false" &&
{Add_Update_Catalog_Pub_Mention_Legale_message}
} + +
+ + {pdf_mention_legale_file_pdf &&
+
+   +
+ {
+ +
+ +
+ +
+
diff --git a/src/styles/components/_updateparnterinfo.scss b/src/styles/components/_updateparnterinfo.scss index 2dd97aa..8f2a0fa 100644 --- a/src/styles/components/_updateparnterinfo.scss +++ b/src/styles/components/_updateparnterinfo.scss @@ -6,30 +6,30 @@ font-size: small !important; } - .css-1q6at85-MuiInputBase-root-MuiOutlinedInput-root{ + .css-1q6at85-MuiInputBase-root-MuiOutlinedInput-root { padding-right: 0.2rem !important; height: 3rem !important; margin-bottom: 1rem; } - .css-1o9s3wi-MuiInputBase-input-MuiOutlinedInput-input{ + .css-1o9s3wi-MuiInputBase-input-MuiOutlinedInput-input { height: 2.5rem !important; font-size: small; } - .css-1ixds2g{ + .css-1ixds2g { height: 2.5rem !important; font-size: small !important; } - .css-1v4ccyo{ + .css-1v4ccyo { font-size: small !important; } - .text_pwd_crit{ + .text_pwd_crit { font-size: small; } - + .texte_area { float: left; width: 100% !important; @@ -68,7 +68,7 @@ text-align: center; margin-bottom: 0.8rem; color: white; - cursor:unset; + cursor: unset; font-style: italic; background-color: gray; font-weight: normal; @@ -264,12 +264,39 @@ overflow-y: scroll; padding-right: 1rem !important; } + + .block_cgv_pj { + width: 100%; + float: left; + text-align: center; + } + + .block_cgv_pj_telecharger { + width: 50%; + float: left; + text-align: center; + cursor: pointer; + color: green; + font-size: 12px; + + } + + .block_cgv_pj_supprimer { + width: 50%; + float: left; + text-align: center; + cursor: pointer; + color: orangered; + font-size: 12px; + + } + } @media only screen and (min-width: 601px) and (max-width: 991px) { text-align: left; - .text_pwd_crit{ + .text_pwd_crit { font-size: small; } @@ -308,7 +335,7 @@ text-align: center; margin-bottom: 0.8rem; color: white; - cursor:unset; + cursor: unset; font-style: italic; background-color: gray; font-weight: normal; @@ -500,12 +527,38 @@ overflow-y: scroll; padding-right: 1rem !important; } - } + + .block_cgv_pj { + width: 100%; + float: left; + text-align: center; + } + + .block_cgv_pj_telecharger { + width: 45%; + float: left; + text-align: center; + cursor: pointer; + color: green; + font-size: 12px; + + } + + .block_cgv_pj_supprimer { + width: 45%; + float: left; + text-align: center; + cursor: pointer; + color: orangered; + font-size: 12px; + + } + } @media only screen and (min-width: 992px) and (max-width: 1199px) { text-align: left; - .text_pwd_crit{ + .text_pwd_crit { font-size: small; } @@ -543,7 +596,7 @@ text-align: center; margin-bottom: 0.8rem; color: white; - cursor:unset; + cursor: unset; font-style: italic; background-color: gray; font-weight: normal; @@ -735,6 +788,31 @@ overflow-y: scroll; padding-right: 1rem !important; } + + .block_cgv_pj { + width: 33%; + float: left; + } + + .block_cgv_pj_telecharger { + width: 45%; + float: left; + text-align: center; + cursor: pointer; + color: green; + font-size: 12px; + + } + + .block_cgv_pj_supprimer { + width: 45%; + float: left; + text-align: center; + cursor: pointer; + color: orangered; + font-size: 12px; + + } } @media only screen and (min-width: 1200px) { @@ -778,7 +856,7 @@ font-size: medium; text-align: center; color: white; - cursor:unset; + cursor: unset; font-style: italic; background-color: gray; font-weight: normal; @@ -988,8 +1066,35 @@ padding-right: 1rem !important; } + .block_cgv_pj { + width: 33%; + float: left; + } + + .block_cgv_pj_telecharger { + width: 45%; + float: left; + text-align: center; + cursor: pointer; + color: green; + font-size: 12px; + + } + + .block_cgv_pj_supprimer { + width: 45%; + float: left; + text-align: center; + cursor: pointer; + color: orangered; + font-size: 12px; + + } + } - + + // end media + .css-mnn31 { font-size: small !important; } @@ -998,12 +1103,12 @@ padding-left: 5px !important; } - .css-1ixds2g{ + .css-1ixds2g { font-size: small !important; height: 2rem !important; } - .css-1v4ccyo{ + .css-1v4ccyo { font-size: small !important; }