import{f as z,o as u,i as k,j as I,b as t,a as x,U,c as g,d as y,E as f,s as A,z as D,S as E,r as c,ar as V}from"./vendor-BDR7yMJi.js";import{u as M,a as S,s as a,S as $}from"./index-BSaHX2oa.js";const N={class:"p-0 bt-0 h-full"},T={class:"p-4 min-h-75"},q={key:0,class:"flex flex-col gap-4 text-center"},L={key:1,class:"flex flex-col gap-6 justify-center items-center h-full"},O={class:"flex flex-col gap-3 w-full max-w-md"},P={class:"flex items-center gap-3"},W={class:"flex items-center gap-3"},F={key:2,class:"flex flex-col justify-center items-center h-full py-20"},H={key:1,class:"block text-xl font-bold text-gray-800"},R={class:"flex w-full p-4 gap-2 border-t"},K={__name:"sauvegarde",setup(Y){const{showError:h,showWarn:w}=M(),p=c(!0),l=V({lecture:!1,ajout:!1,modif:!1,supp:!1,devalidation:!1,validation:!1}),b=c(!1),r=c(1),o=c("bak"),_=c([{label:"Bienvenue"},{label:"Choix du mode de sauvegarde"},{label:"Sauvegarde"}]),C=async()=>{try{const e=(await S.post(`${a.lienApi}/verifierDroit/${a.state.dbCommun6}`,{id_utilisateur:a.userId,id_page:108,mail:a.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;e&&Object.keys(e).length>0&&(l.lecture=e.lecture,l.ajout=e.ajout,l.modif=e.modif,l.supp=e.supp,l.devalidation=e.devalidation,l.validation=e.validation),l.lecture||(w("Vous n'avez pas le droit, veuillez consulter l'administrateur"),p.value=!1,$("sauvegarde"))}catch(s){h("Une erreur est survenue : "+(s.response?.data?.message||s.message))}finally{a.state.afficher_in_progress=!1}};z(async()=>{await C()});const B=async()=>{if(r.value++,r.value===3){b.value=!0;const s=new Date,e=`${s.getFullYear()}${String(s.getMonth()+1).padStart(2,"0")}${String(s.getDate()).padStart(2,"0")}_${String(s.getHours()).padStart(2,"0")}${String(s.getMinutes()).padStart(2,"0")}${String(s.getSeconds()).padStart(2,"0")}`,v=`Omag_V6_${a.state.enreg_societe.Nom}_${e}`;try{const i=await S.post(`${a.lienApi}/sauvegardeDB/${a.db}/${a.state.dbCommun6}`,{nomFichier:v,IdClients:a.cloudId,typeSauvegarde:o.value},{headers:{"Content-Type":"application/json"},responseType:"blob",timeout:6e5}),n=window.URL.createObjectURL(new Blob([i.data])),d=document.createElement("a");d.href=n,d.setAttribute("download",`${v}.zip`),document.body.appendChild(d),d.click()}catch(i){const n=i.response?.data?.message||i.message;h({title:"Erreur",text:"Une erreur est survenue : "+n})}finally{b.value=!1}}},j=()=>{p.value=!1,$("sauvegarde")};return(s,e)=>{const v=U,i=A,n=D,d=E;return u(),k(d,{visible:p.value,"onUpdate:visible":e[3]||(e[3]=m=>p.value=m),modal:"",header:"Assistant de sauvegarde",style:{width:"70vw",maxWidth:"700px"},closable:!0,onHide:j},{default:I(()=>[t("div",N,[x(v,{model:_.value,activeIndex:r.value-1},null,8,["model","activeIndex"]),t("div",T,[e[8]||(e[8]=t("div",{class:"h-8"},null,-1)),r.value===1?(u(),g("div",q,[...e[4]||(e[4]=[t("p",null," L'assistant vous permet de sauvegarder et conserver les données de votre entreprise pour pouvoir les récupérer en cas de sinistre ou de défaillance du système. ",-1),t("p",null,"Cet assistant permet de générer la sauvegarde ou (backup) de votre société.",-1),t("p",null," Après la fin du traitement pensez à copier vos fichiers de sauvegarde sur un support externe physique (clé USB, disque dur externe ...) ",-1)])])):y("",!0),r.value===2?(u(),g("div",L,[e[7]||(e[7]=t("div",{class:"text-center text-lg"},[t("p",null,"Choisissez le type de sauvegarde :")],-1)),t("div",O,[t("div",{onClick:e[0]||(e[0]=m=>o.value="bak"),class:f(["p-4 border rounded-lg cursor-pointer transition-all",o.value==="bak"?"border-primary bg-primary/10":"border-gray-300 hover:border-primary/50"])},[t("div",P,[t("i",{class:f(["pi",o.value==="bak"?"pi-check-circle text-primary":"pi-circle text-gray-400"])},null,2),e[5]||(e[5]=t("div",null,[t("p",{class:"font-semibold"},"Base de données uniquement"),t("p",{class:"text-sm text-gray-500"},"Sauvegarde rapide (fichiers .bak)")],-1))])],2),t("div",{onClick:e[1]||(e[1]=m=>o.value="complet"),class:f(["p-4 border rounded-lg cursor-pointer transition-all",o.value==="complet"?"border-primary bg-primary/10":"border-gray-300 hover:border-primary/50"])},[t("div",W,[t("i",{class:f(["pi",o.value==="complet"?"pi-check-circle text-primary":"pi-circle text-gray-400"])},null,2),e[6]||(e[6]=t("div",null,[t("p",{class:"font-semibold"},"Sauvegarde complète"),t("p",{class:"text-sm text-gray-500"},"Base de données + documents (rapports, images...)")],-1))])],2)])])):y("",!0),r.value===3?(u(),g("div",F,[b.value?(u(),k(i,{key:0,strokeWidth:"3",style:{width:"45px",height:"45px"}})):(u(),g("h1",H," Sauvegarde terminée avec succès "))])):y("",!0)]),t("div",R,[x(n,{disabled:r.value===1,onClick:e[2]||(e[2]=m=>r.value--),icon:"pi pi-chevron-left",label:"Précédent",text:"",class:"self-end ml-auto"},null,8,["disabled"]),x(n,{disabled:r.value===_.value.length,onClick:B,iconPos:"right",icon:"pi pi-chevron-right",label:"Suivant",text:""},null,8,["disabled"])])])]),_:1},8,["visible"])}}};export{K as default};
