1import{w as U,u as B,r as n,A as D,j as e,P as T,l as $,h as C,L as S,i as k,k as W,F as t,O as _}from"./index-DKr66--M.js";import{uploadBytesResumable as M,getDownloadURL as z}from"./index.esm-DoTe_umu.js";import{A as H}from"./Alert-DtORJ-W2.js";import{B as q}from"./Button-bkW_oL3h.js";const J=({firebase:r})=>{const{t:s}=B(),o=n.useContext(D),[i,u]=n.useState(!0),[l,y]=n.useState(null),[m,d]=n.useState(null),[x,g]=n.useState(!1),[p,I]=n.useState(""),[N,L]=n.useState(""),[j,E]=n.useState(""),[f,O]=n.useState(""),[h,G]=n.useState(null);n.useEffect(()=>{if(!o){u(!1);return}r.cloud("getMyOrgOffer")().then(a=>{y(a.data),u(!1)}).catch(a=>{d(a.message),u(!1)})},[o,r]);const w=`?redirect=${encodeURIComponent(_)}`,P=async a=>{a.preventDefault(),g(!0),d(null);try{let c="";if(h){const v=await r.uploadImage(o.uid,"org-logos"),A=M(v,h,{contentType:h.type});await new Promise((F,R)=>{A.on("state_changed",null,R,F)}),c=await z(v)}const b=await r.createCheckoutSession(l.priceId,{orgName:p,orgDescription:N,orgWebsite:j,orgContactEmail:f,orgImageUrl:c});b.url?window.location.assign(b.url):g(!1)}catch(c){d(c.message),g(!1)}};return e.jsxs("div",{className:"auth-page",children:[e.jsx(T,{title:s("organisationNew.title"),noindex:!0}),e.jsxs("div",{className:"auth-card",children:[e.jsx("div",{className:"auth-card-header",children:e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[e.jsx("img",{alt:"prosurfingtools-icon",title:"Prosurfingtools",src:"/logo192.png",className:"auth-logo"}),e.jsxs("h2",{className:"auth-title",children:[e.jsx($,{})," ",s("organisationNew.title")]})]})}),e.jsxs("div",{className:"auth-card-body",children:[i&&e.jsx("div",{className:"text-center py-3",children:e.jsx(C,{animation:"border",size:"sm"})}),!i&&!o&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"auth-subtitle",children:s("organisationNew.signInHint")}),e.jsxs("div",{className:"d-grid gap-2 pb-3",children:[e.jsx(S,{to:`${k}${w}`,className:"btn btn-primary",children:s("auth.signInBtn")}),e.jsx(S,{to:`${W}${w}`,className:"btn btn-outline-secondary",children:s("auth.registerHere")})]})]}),!i&&o&&!l&&!m&&e.jsx(H,{variant:"warning",children:s("organisationNew.noOffer")}),!i&&o&&l&&e.jsxs(t,{onSubmit:P,children:[e.jsx("p",{className:"auth-subtitle",children:s("organisationNew.intro",{productName:l.productName})}),e.jsxs(t.Group,{className:"form-element",controlId:"orgName",children:[e.jsx(t.Label,{children:s("organisationNew.name")}
1),e.jsx(t.Control,{required:!0,value:p,onChange:a=>I(a.target.value)})]}),e.jsxs(t.Group,{className:"form-element",controlId:"orgDescription",children:[e.jsx(t.Label,{children:s("organisationNew.description")}),e.jsx(t.Control,{as:"textarea",rows:3,value:N,onChange:a=>L(a.target.value)})]}),e.jsxs(t.Group,{className:"form-element",controlId:"orgWebsite",children:[e.jsx(t.Label,{children:s("organisationNew.website")}),e.jsx(t.Control,{type:"url",value:j,onChange:a=>E(a.target.value)})]}),e.jsxs(t.Group,{className:"form-element",controlId:"orgContactEmail",children:[e.jsx(t.Label,{children:s("organisationNew.contactEmail")}),e.jsx(t.Control,{type:"email",value:f,onChange:a=>O(a.target.value)})]}),e.jsxs(t.Group,{className:"form-element",controlId:"orgLogo",children:[e.jsx(t.Label,{children:s("organisationNew.logo")}),e.jsx(t.Control,{type:"file",accept:"image/*",onChange:a=>G(a.target.files[0]||null)})]}),m&&e.jsx("p",{className:"text-danger",children:m}),e.jsx(q,{variant:"primary",type:"submit",className:"w-100 mt-2",disabled:x,children:x?e.jsx(C,{as:"span",animation:"border",size:"sm",role:"status"}):s("organisationNew.continueToPayment")})]})]})]})]})},Y=U(J);export{Y 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.