PageSourceSearch

https://floraflor.lovable.app/assets/Configuracion-TlR2nLz_.js

js floraflor.lovable.app collected 2026-10-03 03:32:17 UTC 12,046 bytes, 12 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jszip.min-myVaNbDi.js","assets/index-RxDZGo8S.js","assets/index-Ays8TZtQ.css","assets/_commonjs-dynamic-modules-TDtrdbi3.js"])))=>i.map(i=>d[i]);
2import{n as J,f as ee,r as D,b,_ as T,J as p,j as a,B as E,C as z,c as ae,d as te,ar as se,e as oe,a as U,g as Z,m as H,X as re,t as ne,s as y}from"./index-RxDZGo8S.js";import{P as le}from"./progress-Dp_Y5uLR.js";import{A as ce}from"./arrow-left-0370NIGe.js";import{I as G}from"./image-CCcYU7a4.js";import{F as K}from"./file-text-jf7w95e0.js";import{L as ie}from"./loader-circle-CaA3DVt2.js";import{D as de}from"./download-C_n9HF-k.js";import{f as x}from"./format-DuJJlbci.js";/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const ue=J("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
8 * @license lucide-react v0.462.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const V=J("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);
12function xe(){const Q=ee(),[f,u]=D.useState(null),g=D.useRef(!1),{data:v=[]}=b({queryKey:["backup-orchid-photos"],queryFn:async()=>{const{data:s,error:o}=await y.from("orchid_gallery").select("id, name, photo_urls").order("name");if(o)throw o;return s||[]}}),{data:j=[]}=b({queryKey:["backup-general-photos"],queryFn:async()=>{const{data:s,error:o}=await y.from("general_photos").select("id, file_url, file_name, category, description").order("created_at",{ascending:!1});if(o)throw o;return s||[]}}),{data:w=[]}=b({queryKey:["backup-boleta-files"],queryFn:async()=>{const{data:s,error:o}=await y.from("boletas").select("id, numero_venta, fecha_venta, file_url").not("file_url","is",null).order("fecha_venta",{ascending:!1});if(o)throw o;return s||[]}}),{data:N=[]}=b({queryKey:["backup-invoice-files"],queryFn:async()=>{const{data:s,error:o}=await y.from("invoices_new").select("id, invoice_number, invoice_date, file_url").not("file_url","is",null).order("invoice_date",{ascending:!1});if(o)throw o;return s||[]}}),{data:$=[]}=b({queryKey:["backup-observation-photos"],queryFn:async()=>{const{data:s,error:o}=await y.from("orchid_observations").select("id, entry_date, photo_urls, comments").not("photo_urls","is",null).order("entry_date",{ascending:!1});if(o)throw o;return s||[]}}),{data:O=[]}=b({queryKey:["backup-sales-order-files"],queryFn:async()=>{const{data:s,error:o}=await y.from("invoices").select("id, file_name, file_url, order_id").order("uploaded_at",{ascending:!1});if(o)throw o;return s||[]}}),S=[{value:"general",label:"General"},{value:"marketing",label:"Marketing"},{value:"producto",label:"Producto"},{value:"evento",label:"Evento"},{value:"redes_sociales",label:"Redes Sociales"}],L=v.reduce((s,o)=>{var n;return s+(((n=o.photo_urls)==null?void 0:n.length)||0)},0),q=j.length,M=w.length,A=N.length,R=$.reduce((s,o)=>{var n;return s+(((n=o.photo_urls)==null?void 0:n.length)||0)},0),X=O.length,B=L+q+M+A+R+X,I=async(s,o,n)=>{try{const l=await fetch(o);if(!l.ok)return;const m=await l.blob();s.file(n,m)}catch{}},h=s=>s.replace(/[/\\?%*:|"<>]/g,"-").trim(),W=D.useCallback(async()=>{var _,F,k,C,P;g.current=!1;const s=(await T(async()=>{const{default:e}=await import("./jszip.min-myVaNbDi.js").then(t=>t.j);return{default:e}},__vite__mapDeps([0,1,2,3]))).default,o=new s,n=[];for(const e of v){const t=h(e.name);(e.photo_urls||[]).forEach((r,d)=>{var i;const c=((i=r.split(".").pop())==null?void 0:i.split("?")[0])||"jpg";n.push({url:r,path:`Orquideas/${t}/foto_${d+1}.${c}`})})}for(const e of j){const t=((_=S.find(c=>c.value===e.category))==null?void 0:_.label)||e.category,r=h(e.description||e.file_name).substring(0,50),d=((F=e.file_url.split(".").pop())==null?void 0:F.split("?")[0])||"jpg";n.push({url:e.file_url,path:`Fotos_Generales/${t}/${r}_${e.id.substring(0,6)}.${d}`})}for(const e of w)if(e.file_url){const t=((k=e.file_url.split(".").pop())==null?void 0:k.split("?")[0])||"pdf",r=e.fecha_venta?x(new Date(e.fecha_venta),"yyyy-MM-dd"):"sin-fecha";n.push({url:e.file_url,path:`Boletas/${r}_${h(e.numero_venta)}.${t}`})}for(const e of N)if(e.file_url){const t=((C=e.file_url.split(".").pop())==null?void 0:C.split("?")[0])||"pdf";n.push({url:e.file_url,path:`Facturas/${h(e.invoice_number)}.${t}`})}for(const e of $){const t=e.entry_date?x(new Date(e.entry_date),"yyyy-MM-dd"):"sin-fecha";(e.photo_urls||[]).forEach((r,d)=>{var i;const c=((i=r.split(".").pop())==null?void 0:i.split("?")[0])||"jpg";n.push({url:r,path:`Observaciones/${t}_${e.id.substring(0,6)}/foto_${d+1}.${c}`})})}for(const e of O)if(e.file_url){const t=((P=e.file_url.split(".").pop())==null?void 0:P.split("?")[0])||"pdf";n.push({url:e.file_url,path:`Facturas_Pedidos/${h(e.file_name||e.id)}.${t}`})}if(n.length===0){p.error("No hay archivos para descargar");return}u({current:0,total:n.length,status:"Descargando archivos..."});const l=5;let m=0;for(let e=0;e<n.length;e+=l){if(g.current){u(null),p.info("Descarga cancelada");return}const t=n.slice(e,e+l);await Promise.allSettled(t.map(r=>I(o,r.url,r.path))),m+=t.length,u({current:Math.min(m,n.length),total:n.length,status:"Descargando archivos..."}),await new Promise(r=>setTimeout(r,50))}if(g.current){u(null),p.info("Descarga cancelada");return}u({current:n.length,total:n.length,status:"Generando archivo ZIP..."});try{const e=await o.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:6}}),r=`FloraFlor_Backup_Completo_${x(new Date,"yyyy-MM-dd")}.zip`,d=URL.createObjectURL(e),c=document.createElement("a");c.href=d,c.download=r,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(d),p.success(`Backup completo descargado: ${m} archivos`)}catch(e){p.error("Error al generar ZIP: "+e.message)}finally{u(null)}},[v,j,w,N,$,O]),Y=D.useCallback(async s=>{var F,k,C,P;g.current=!1;const o=(await T(async()=>{const{default:e}=await import("./jszip.min-myVaNbDi.js").then(t=>t.j);return{default:e}},__vite__mapDeps([0,1,2,3]))).default,n=new o,l=[];
12if(s==="orchids")for(const e of v){const t=h(e.name);(e.photo_urls||[]).forEach((r,d)=>{var i;const c=((i=r.split(".").pop())==null?void 0:i.split("?")[0])||"jpg";l.push({url:r,path:`${t}/foto_${d+1}.${c}`})})}else if(s==="general")for(const e of j){const t=((F=S.find(c=>c.value===e.category))==null?void 0:F.label)||e.category,r=h(e.description||e.file_name).substring(0,50),d=((k=e.file_url.split(".").pop())==null?void 0:k.split("?")[0])||"jpg";l.push({url:e.file_url,path:`${t}/${r}_${e.id.substring(0,6)}.${d}`})}else if(s==="boletas"){for(const e of w)if(e.file_url){const t=((C=e.file_url.split(".").pop())==null?void 0:C.split("?")[0])||"pdf",r=e.fecha_venta?x(new Date(e.fecha_venta),"yyyy-MM-dd"):"sin-fecha";l.push({url:e.file_url,path:`${r}_${h(e.numero_venta)}.${t}`})}}else if(s==="facturas"){for(const e of N)if(e.file_url){const t=((P=e.file_url.split(".").pop())==null?void 0:P.split("?")[0])||"pdf";l.push({url:e.file_url,path:`${h(e.invoice_number)}.${t}`})}}else if(s==="observaciones")for(const e of $){const t=e.entry_date?x(new Date(e.entry_date),"yyyy-MM-dd"):"sin-fecha";(e.photo_urls||[]).forEach((r,d)=>{var i;const c=((i=r.split(".").pop())==null?void 0:i.split("?")[0])||"jpg";l.push({url:r,path:`${t}_${e.id.substring(0,6)}/foto_${d+1}.${c}`})})}if(l.length===0){p.error("No hay archivos en esta categoría");return}u({current:0,total:l.length,status:"Descargando..."});const m=5;let _=0;for(let e=0;e<l.length;e+=m){if(g.current){u(null),p.info("Cancelado");return}const t=l.slice(e,e+m);await Promise.allSettled(t.map(r=>I(n,r.url,r.path))),_+=t.length,u({current:Math.min(_,l.length),total:l.length,status:"Descargando..."}),await new Promise(r=>setTimeout(r,50))}if(g.current){u(null),p.info("Cancelado");return}u({current:l.length,total:l.length,status:"Generando ZIP..."});try{const e=await n.generateAsync({type:"blob",compression:"DEFLATE",compressionOptions:{level:6}}),t=x(new Date,"yyyy-MM-dd"),d=`FloraFlor_${{orchids:"Orquideas",general:"Fotos_Generales",boletas:"Boletas",facturas:"Facturas",observaciones:"Observaciones"}[s]}_${t}.zip`,c=URL.createObjectURL(e),i=document.createElement("a");i.href=c,i.download=d,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(c),p.success(`${_} archivos descargados`)}catch(e){p.error("Error: "+e.message)}finally{u(null)}},[v,j,w,N,$]);return a.jsxs("div",{className:"min-h-screen bg-background pb-24",children:[a.jsxs("div",{className:"w-full p-4 max-w-4xl mx-auto",children:[a.jsxs("div",{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[a.jsx(E,{variant:"ghost",size:"icon",onClick:()=>Q("/"),className:"h-10 w-10",children:a.jsx(ce,{className:"h-5 w-5"})}),a.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Configuración"})]}),a.jsx("p",{className:"text-muted-foreground ml-14",children:"Opciones de administración del sistema"})]}),a.jsxs(z,{children:[a.jsxs(ae,{children:[a.jsxs(te,{className:"flex items-center gap-2",children:[a.jsx(se,{className:"h-5 w-5"}),"Copia de seguridad completa"]}),a.jsx(oe,{children:"Descarga todos los archivos del sistema en un ZIP organizado por carpetas"})]}),a.jsxs(U,{className:"space-y-5",children:[a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3",children:[{icon:Z,label:"Fotos orquídeas",count:L},{icon:G,label:"Fotos generales",count:q},{icon:H,label:"Boletas",count:M},{icon:K,label:"Facturas",count:A},{icon:V,label:"Observaciones",count:R},{icon:ue,label:"Total archivos",count:B}].map(({icon:s,label:o,count:n})=>a.jsx(z,{children:a.jsxs(U,{className:"p-3 text-center",children:[a.jsx(s,{className:"h-5 w-5 mx-auto mb-1 text-primary"}),a.jsx("div",{className:"text-lg font-bold",children:n}),a.jsx("div",{className:"text-[10px] text-muted-foreground",children:o})]})},o))}),f&&a.jsxs("div",{className:"space-y-2 p-4 rounded-lg border bg-muted/30",children:[a.jsxs("div",{className:"flex items-center justify-between text-sm",children:[a.jsx("span",{className:"text-muted-foreground",children:f.status}),a.jsxs("span",{className:"font-medium",children:[f.current,"/",f.total]})]}),a.jsx(le,{value:f.current/f.total*100,className:"h-2"}),a.jsxs(E,{variant:"outline",size:"sm",onClick:()=>{g.current=!0},children:[a.jsx(re,{className:"h-3 w-3 mr-1"})," Cancelar"]})]}),a.jsxs(E,{onClick:W,disabled:!!f,className:"w-full gap-2",size:"lg",children:[f?a.jsx(ie,{className:"h-4 w-4 animate-spin"}):a.jsx(de,{className:"h-4 w-4"}),"Descargar backup completo (",B," archivos)"]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm font-medium text-muted-foreground mb-3",children:"O descarga por categoría:"}),a.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:[{type:"orchids",icon:Z,label:"Orquídeas",count:L},{type:"general",icon:G,label:"Fotos generales",count:q},{type:"boletas",icon:H,label:"Boletas",count:M},{type:"facturas",icon:K,label:"Facturas",count:A},{type:"observaciones",icon:V,label:"Observaciones",count:R}].map(({type:s,icon:o,label:n,count:l})=>a.jsxs(E,{variant:"outline",onClick:()=>Y(s),disabled:!!f||l===0,className:"gap-2 justify-start h-auto py-3",children:[a.jsx(o,{className:"h-4 w-4 shrink-0"}),a.jsxs("div",{className:"text-left",children:[a.jsx("div",{className:"text-xs font-medium",children:n}),a.jsxs("div",{className:"text-[10px] text-muted-foreground",children:[l," archivos"]})]})]},s))})]}),a.jsx("p",{className:"text-xs text-muted-foreground",children:"💡 La descarga se procesa en lotes para no saturar tu navegador. Puedes cancelar en cualquier momento."})]})]})]}),a.jsx(ne,{})]})}
12export{xe as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.