PageSourceSearch

https://bovistas.com/assets/CompanySettings-DA6AWCtR.js

js bovistas.com collected 2026-10-07 15:09:33 UTC 19,693 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/signatureUtils-DeC_7co_.js","assets/pdf-DDFMIuq6.js"])))=>i.map(i=>d[i]);
2import{_ as ue}from"./pdf-DDFMIuq6.js";import{j as e,d as F,e as C,aX as U,aY as R,aZ as z,a2 as i,a3 as m,B as v,a8 as h,a9 as me,a4 as g}from"./index-XQyBZDTl.js";import{r as f}from"./react-BOHO1DJm.js";import{u as he,a as ge,o as pe,s as d,_ as O}from"./schemas-B7yYgvZK.js";import{S as W,a as Z,b as q,c as K,d as N}from"./select-C3kVhmvh.js";import{U as xe}from"./upload-BcaHOKyE.js";import"./supabase-Di0cMgX3.js";import"./index-CR_WZPb4.js";import"./index-C6N3FhlB.js";import"./chevron-up-DhbJ38Ap.js";const fe=pe({company_name:d().min(1,"Firmenname ist erforderlich"),salutation:O(["Herr","Frau"]).optional().nullable(),contact_name:d().optional(),street:d().min(1,"Straße ist erforderlich"),zip:d().min(1,"PLZ ist erforderlich"),city:d().min(1,"Ort ist erforderlich"),country:d().min(1,"Land ist erforderlich"),phone:d().optional(),email:d().email("Ungültige E-Mail"),website:d().optional(),tax_id:d().optional(),vat_id:d().optional(),register_court:d().optional(),register_number:d().optional(),bank_name:d().optional(),iban:d().optional(),bic:d().optional(),logo_url:d().optional(),signature_type:O(["typed","drawn","uploaded"]).optional(),signature_typed_name:d().optional(),signature_image_url:d().optional(),representative_name:d().optional(),representative_title:d().optional()}),Q={company_name:"",salutation:void 0,contact_name:"",street:"",zip:"",city:"",country:"CH",phone:"",email:"",website:"",tax_id:"",vat_id:"",register_court:"",register_number:"",bank_name:"",iban:"",bic:"",logo_url:"",signature_type:"typed",signature_typed_name:"",signature_image_url:"",representative_name:"",representative_title:""};function Ee(){var $;const[ee,te]=f.useState(!0),[T,X]=f.useState(!1),[_,H]=f.useState(null),[se,B]=f.useState(!1),[G,Y]=f.useState(!1),[V,A]=f.useState(!1),D=f.useRef(null),E=f.useRef(null),b=f.useRef(null),[w,S]=f.useState(!1),[je,P]=f.useState(0),[ye,L]=f.useState(0),{register:u,handleSubmit:re,formState:{errors:p},reset:M,setValue:y,watch:j}=he({resolver:ge(fe),defaultValues:Q}),k=j("logo_url"),I=async()=>{const s=b.current;if(!s)return;const t=s.getContext("2d");if(!(!t||!t.getImageData(0,0,s.width,s.height).data.some((n,a)=>a%4!==3&&n!==0)))try{const n=await new Promise((le,de)=>{s.toBlob(J=>{J?le(J):de(new Error("Failed to create blob"))},"image/png")}),l=`signatures/${`signature-${Date.now()}.png`}`,{error:c}=await g.storage.from("company-signatures").upload(l,n,{upsert:!0});if(c)throw c;const{data:{publicUrl:x}}=g.storage.from("company-signatures").getPublicUrl(l);y("signature_image_url",x,{shouldDirty:!0}),h.success("Signatur gespeichert")}catch(n){console.error("Error saving signature:",n),h.error("Fehler beim Speichern der Signatur")}},ae=s=>{const t="/storage/v1/object/public/";if(!s.includes(t))return null;const[,r]=s.split(t),o=r.split("/"),n=o[0],a=o.slice(1).join("/");return{bucket:n,path:a}},ne=async(s,t)=>{const r=s.name.split(".").pop(),n=`logos/${`company-logo-${Date.now()}.${r}`}`,{error:a}=await g.storage.from(t).upload(n,s,{upsert:!0});if(a)throw a;const{data:{publicUrl:l}}=g.storage.from(t).getPublicUrl(n);return{publicUrl:l,bucket:t,path:n}},ie=async s=>{var t;if(s){Y(!0);try{const r=["company-assets","accommodations"];let o=null;for(const n of r)try{o=await ne(s,n);break}catch(a){if((t=a==null?void 0:a.message)!=null&&t.includes("Bucket not found"))continue;throw a}if(!o)throw new Error("Kein gültiger Storage-Bucket gefunden (company-assets oder accommodations).");if(_){const{error:n}=await g.from("company_settings").update({logo_url:o.publicUrl}).eq("id",_);if(n)throw n}y("logo_url",o.publicUrl,{shouldDirty:!0}),h.success("Logo hochgeladen")}catch(r){console.error("Error uploading logo:",r),h.error("Logo-Upload fehlgeschlagen",{description:r==null?void 0:r.message})}finally{Y(!1),D.current&&(D.current.value="")}}},oe=async()=>{if(!k)return;const s=ae(k);try{if(s&&await g.storage.from(s.bucket).remove([s.path]),_){const{error:t}=await g.from("company_settings").update({logo_url:null}).eq("id",_);if(t)throw t}y("logo_url","",{shouldDirty:!0}),h.success("Logo entfernt")}catch(t){console.error("Error removing logo:",t),h.error("Logo konnte nicht entfernt werden",{description:t==null?void 0:t.message})}};f.useEffect(()=>{(async()=>{try{const{data:t,error:r}
2=await g.from("company_settings").select("*").maybeSingle();if(r)throw r;t?(H(t.id),B(!0),M({company_name:t.company_name,salutation:t.salutation||void 0,contact_name:t.contact_name||"",street:t.street,zip:t.zip,city:t.city,country:t.country,phone:t.phone||"",email:t.email,website:t.website||"",tax_id:t.tax_id||"",vat_id:t.vat_id||"",register_court:t.register_court||"",register_number:t.register_number||"",bank_name:t.bank_name||"",iban:t.iban,bic:t.bic||"",logo_url:t.logo_url||"",signature_type:t.signature_type||"typed",signature_typed_name:t.signature_typed_name||"",signature_image_url:t.signature_image_url||"",representative_name:t.representative_name||"",representative_title:t.representative_title||""})):(B(!1),M(Q))}catch(t){console.error("Error loading company settings:",t),h.error("Stammdaten konnten nicht geladen werden",{description:t==null?void 0:t.message})}finally{te(!1)}})()},[M]);const ce=async s=>{X(!0);try{if(_){const{error:t}=await g.from("company_settings").update(s).eq("id",_);if(t)throw t;try{await g.from("offers").update({pdf_url:null,company_snapshot:null}),await g.from("contracts").update({pdf_url:null}),await g.from("invoices").update({pdf_url:null})}catch(r){console.warn("Fehler beim Aktualisieren verknüpfter Dokumente:",r)}h.success("Unternehmenseinstellungen aktualisiert",{description:"Verknüpfte Dokumente werden beim nächsten Öffnen mit neuen Daten aktualisiert."})}else{const{data:t,error:r}=await g.from("company_settings").insert(s).select().single();if(r)throw r;H(t.id),B(!0),h.success("Unternehmenseinstellungen gespeichert")}}catch(t){console.error("Error saving company settings:",t),h.error("Fehler beim Speichern",{description:t==null?void 0:t.message})}finally{X(!1)}};return ee?e.jsxs("div",{className:"space-y-12",children:[e.jsx("div",{className:"h-16 w-64 bg-muted animate-pulse rounded"}),e.jsx(F,{className:"shadow-soft border-border/40 bg-card",children:e.jsxs(C,{className:"p-6 space-y-4",children:[e.jsx("div",{className:"h-8 w-72 bg-muted animate-pulse rounded"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx("div",{className:"h-10 bg-muted animate-pulse rounded"}),e.jsx("div",{className:"h-10 bg-muted animate-pulse rounded"}),e.jsx("div",{className:"h-10 bg-muted animate-pulse rounded"}),e.jsx("div",{className:"h-10 bg-muted animate-pulse rounded"})]})]})})]}):e.jsxs("div",{className:"space-y-12",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-body text-3xl font-bold text-foreground mb-3",children:"Unternehmenseinstellungen"}),e.jsx("p",{className:"text-muted-foreground font-body text-lg max-w-2xl",children:"Pflegen Sie hier die Stammdaten, die in Angeboten und Rechnungen genutzt werden."})]}),!se&&e.jsx("div",{className:"rounded-lg border border-dashed border-amber-300 bg-amber-50 p-4 text-sm text-amber-800",children:"Es sind noch keine Unternehmensdaten hinterlegt. Bitte füllen Sie die Pflichtfelder aus, damit PDFs korrekt erzeugt werden können."}),e.jsxs("form",{onSubmit:re(ce),className:"space-y-8",children:[e.jsxs(F,{className:"shadow-soft border-border/40 bg-card",children:[e.jsxs(U,{className:"pb-5",children:[e.jsx(R,{className:"font-body text-xl font-semibold text-foreground",children:"Firmendaten"}),e.jsx(z,{className:"font-body text-sm text-muted-foreground mt-2",children:"Basisinformationen zur Firma"})]}),e.jsxs(C,{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"company_name",children:"Firmenname *"}),e.jsx(m,{id:"company_name",...u("company_name"),placeholder:"BOVISTAS GmbH"}),p.company_name&&e.jsx("p",{className:"text-sm text-destructive",children:p.company_name.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"salutation",children:"Anrede"}),e.jsxs(W,{value:j("salutation")||void 0,onValueChange:s=>y("salutation",s==="_none"?void 0:s),children:[e.jsx(Z,{children:e.jsx(q,{placeholder:"Anrede auswählen"})}),e.jsxs(K,{children:[e.jsx(N,{value:"_none",children:"Keine Anrede"}),e.jsx(N,{value:"Herr",children:"Herr"}),e.jsx(N,{value:"Frau",children:"Frau"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"contact_name",children:"Name"}),e.jsx(m,{id:"contact_name",...u("contact_name"),placeholder:"Max Mustermann"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Wird unter dem Firmennamen in Verträgen, Angeboten und Rechnungen angezeigt."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("input",{ref:D,type:"file",accept:"image/*",className:"hidden",onChange:s=>{var t;return ie((t=s.target.files)==null?void 0:t[0])}}),e.jsx(v,{type:"button",variant:"secondary",onClick:()=>{var s;return(s=D.current)==null?void 0:s.click()},disabled:G,children:G?"Lädt...":"Logo hochladen"}),k&&e.jsx(v,{type:"button",variant:"ghost",onClick:oe,children:"Entfernen"})]}),k&&e.jsx("div",{className:"mt-2",children:e.jsx("div",{className:"h-20 w-20 rounded-md bg-muted overflow-hidden flex items-center justify-center border border-gray-200",children:e.jsx("img",{src:k,alt:"Logo Preview",className:"max-h-full max-w-full object-contain"})})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG oder JPG, wird in Supabase Storage gespeichert."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"street",children:"Straße *"}),e.jsx(m,{id:"street",...u("street"),placeholder:"Musterstraße 1"}),p.street&&e.jsx("p",{className:"text-sm text-destructive",children:p.street.message})]}),e.jsxs("div",{className:"space-y-2 grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(i,{htmlFor:"zip",children:"PLZ *"}),e.jsx(m,{id:"zip",...u("zip"),placeholder:"8000"}),p.zip&&e.jsx("p",{className:"text-sm text-destructive",children:p.zip.message})]}),e.jsxs("div",{children:[e.jsx(i,{htmlFor:"city",children:"Ort *"}),e.jsx(m,{id:"city",...u("city"),placeholder:"Zürich"}),p.city&&e.jsx("p",{className:"text-sm text-destructive",children:p.city.message})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"country",children:"Land *"}),e.jsx(m,{id:"country",...u("country"),placeholder:"Schweiz"}),p.country&&e.jsx("p",{className:"text-sm text-destructive",children:p.country.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"email",children:"E-Mail *"}),e.jsx(m,{id:"email",type:"email",...u("email"),placeholder:"[email protected]"}),p.email&&e.jsx("p",{className:"text-sm text-destructive",children:p.email.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"phone",children:"Telefon"}),e.jsx(m,{id:"phone",...u("phone"),placeholder:"+41 44 123 45 67"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"website",children:"Website"}),e.jsx(m,{id:"website",...u("website"),placeholder:"https://bovistas.com"})]})]})]}),e.jsxs(F,{className:"shadow-soft border-border/40 bg-card",children:[e.jsxs(U,{className:"pb-5",children:[e.jsx(R,{className:"font-body text-xl font-semibold text-foreground",children:"Rechtliches"}),e.jsx(z,{className:"font-body text-sm text-muted-foreground mt-2",children:"Register- und Steuerinformationen"})]}),e.jsxs(C,{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"tax_id",children:"Steuernummer"}),e.jsx(m,{id:"tax_id",...u("tax_id"),placeholder:"123/456/789"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"vat_id",children:"USt-ID"}),e.jsx(m,{id:"vat_id",...u("vat_id"),placeholder:"CHE-123.456.789 MWST"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"register_court",children:"Registergericht"}),e.jsx(m,{id:"register_court",...u("register_court"),placeholder:"Amtsgericht XY"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"register_number",children:"Register-Nr."}),e.jsx(m,{id:"register_number",...u("register_number"),placeholder:"HRB 123456"})]})]})]}),e.jsxs(F,{className:"shadow-soft border-border/40 bg-card",children:[e.jsxs(U,{className:"pb-5",children:[e.jsx(R,{className:"font-body text-xl font-semibold text-foreground",children:"Bankverbindung"}),e.jsx(z,{className:"font-body text-sm text-muted-foreground mt-2",children:"Bankdaten für Fußzeile"})]}),e.jsxs(C,{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"bank_name",children:"Kontoinhaber:"}),e.jsx(m,{id:"bank_name",...u("bank_name"),placeholder:"Max Mustermann"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"iban",children:"IBAN"}),e.jsx(m,{id:"iban",...u("iban"),placeholder:"CH00 0000 0000 0000 0000 0"}),p.iban&&e.jsx("p",{className:"text-sm text-destructive",children:p.iban.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"bic",children:"BIC"}),e.jsx(m,{id:"bic",...u("bic"),placeholder:"POFICHBEXXX"})]})]})]}),e.jsxs(F,{className:"shadow-soft border-border/40 bg-card",children:[e.jsxs(U,{className:"pb-5",children:[e.jsx(R,{className:"font-body text-xl font-semibold text-foreground",children:"Dienstleister-Signatur"}),e.jsx(z,{className:"font-body text-sm text-muted-foreground mt-2",children:"Diese Signatur wird automatisch für Verträge verwendet."})]}),e.jsxs(C,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"representative_name",children:"Name des Unterzeichners"}),e.jsx(m,{id:"representative_name",...u("representative_name"),placeholder:"Max Mustermann"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"representative_title",children:"Position / Titel (optional)"}),e.jsx(m,{id:"representative_title",...u("representative_title"),placeholder:"Geschäftsführer"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Signaturart"}),e.jsxs(W,{value:j("signature_type")||"typed",onValueChange:s=>y("signature_type",s,{shouldDirty:!0}),children:[e.jsx(Z,{className:"w-full md:w-64",children:e.jsx(q,{placeholder:"Signaturart wählen"})}),e.jsxs(K,{children:[e.jsx(N,{value:"typed",children:"Getippt (Name)"}),e.jsx(N,{value:"drawn",children:"Gezeichnet"}),e.jsx(N,{value:"uploaded",children:"Hochgeladen (PNG/JPG)"})]})]})]}),j("signature_type")==="typed"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{htmlFor:"signature_typed_name",children:"Signatur-Name"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(m,{id:"signature_typed_name",...u("signature_typed_name"),placeholder:"Max Mustermann",className:"font-signature text-xl italic"}),e.jsx(v,{type:"button",variant:"outline",onClick:async()=>{const s=j("signature_typed_name");if(!(s!=null&&s.trim())){h.error("Bitte geben Sie zuerst einen Namen ein");return}try{const{generateSignatureFromName:t,saveSignatureToStorage:r}=await ue(async()=>{const{generateSignatureFromName:a,saveSignatureToStorage:l}=await import("./signatureUtils-DeC_7co_.js");return{generateSignatureFromName:a,saveSignatureToStorage:l}},__vite__mapDeps([0,1])),o=await t(s,"allura",400,150),n=await r(o);y("signature_image_url",n,{shouldDirty:!0}),h.success("Signatur automatisch generiert")}catch(t){console.error("Error generating signature:",t),h.error("Fehler beim Generieren der Signatur",{description:t.message})}},disabled:!(($=j("signature_typed_name"))!=null&&$.trim()),children:"Signatur generieren"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:'Geben Sie Ihren Namen ein und klicken Sie auf "Signatur generieren", um automatisch eine Signatur zu erstellen (wie bei DocuSign).'})]}),j("signature_type")==="drawn"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Signatur zeichnen"}),e.jsx("div",{className:"border border-border rounded-md bg-white relative",children:e.jsx("canvas",{ref:b,width:400,height:150,className:"w-full cursor-crosshair touch-none",onMouseDown:s=>{S(!0);const t=b.current;if(!t)return;const r=t.getBoundingClientRect(),o=t.width/r.width,n=t.height/r.height,a=(s.clientX-r.left)*o,l=(s.clientY-r.top)*n,c=t.getContext("2d");c&&(c.strokeStyle="#000000",c.lineWidth=2,c.lineCap="round",c.lineJoin="round",c.beginPath(),c.moveTo(a,l),P(a),L(l))},onMouseMove:s=>{if(!w)return;const t=b.current;if(!t)return;const r=t.getBoundingClientRect(),o=t.width/r.width,n=t.height/r.height,a=(s.clientX-r.left)*o,l=(s.clientY-r.top)*n,c=t.getContext("2d");c&&(c.lineTo(a,l),c.stroke(),P(a),L(l))},onMouseUp:async()=>{w&&(S(!1),await I())},onMouseLeave:async()=>{w&&(S(!1),await I())},onTouchStart:s=>{s.preventDefault(),S(!0);const t=b.current;if(!t)return;const r=t.getBoundingClientRect(),o=t.width/r.width,n=t.height/r.height,a=s.touches[0],l=(a.clientX-r.left)*o,c=(a.clientY-r.top)*n,x=t.getContext("2d");x&&(x.strokeStyle="#000000",x.lineWidth=2,x.lineCap="round",x.lineJoin="round",x.beginPath(),x.moveTo(l,c),P(l),L(c))},onTouchMove:s=>{if(s.preventDefault(),!w)return;const t=b.current;if(!t)return;const r=t.getBoundingClientRect(),o=t.width/r.width,n=t.height/r.height,a=s.touches[0],l=(a.clientX-r.left)*o,c=(a.clientY-r.top)*n,x=t.getContext("2d");x&&(x.lineTo(l,c),x.stroke(),P(l),L(c))},onTouchEnd:async s=>{s.preventDefault(),w&&(S(!1),await I())}})}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(v,{type:"button",variant:"outline",size:"sm",onClick:()=>{const s=b.current;if(!s)return;const t=s.getContext("2d");t&&(t.clearRect(0,0,s.width,s.height),y("signature_image_url","",{shouldDirty:!0}))},children:[e.jsx(me,{className:"mr-2 h-4 w-4"}),"Löschen"]})})]}),j("signature_type")==="uploaded"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Signatur hochladen"}),e.jsx("input",{ref:E,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:async s=>{var r;const t=(r=s.target.files)==null?void 0:r[0];if(t){A(!0);try{const o=t.name.split(".").pop(),a=`signatures/${`signature-${Date.now()}.${o}`}`,{error:l}=await g.storage.from("company-signatures").upload(a,t,{upsert:!0});if(l)throw l;const{data:{publicUrl:c}}=g.storage.from("company-signatures").getPublicUrl(a);y("signature_image_url",c,{shouldDirty:!0}),h.success("Signatur hochgeladen")}catch(o){console.error("Error uploading signature:",o),h.error("Fehler beim Hochladen der Signatur")}finally{A(!1),E.current&&(E.current.value="")}}}}),e.jsxs(v,{type:"button",variant:"outline",onClick:()=>{var s;return(s=E.current)==null?void 0:s.click()},disabled:V,children:[e.jsx(xe,{className:"mr-2 h-4 w-4"}),V?"Lädt...":"Signatur hochladen"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG oder JPG, transparent bevorzugt"})]}),j("signature_image_url")&&e.jsxs("div",{className:"mt-4 p-4 bg-muted rounded-md",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Vorschau:"}),e.jsx("img",{src:j("signature_image_url"),alt:"Signatur",className:"max-h-20 object-contain"})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(v,{type:"submit",disabled:T,className:"bg-primary text-primary-foreground hover:bg-primary-hover transition-smooth font-body tracking-wide shadow-soft hover:shadow-medium",children:T?"Speichern...":"Speichern"})})]})]})}export{Ee 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.