1import{j as e}from"./vendor-ui-Cmvb7Owm.js";import{s as N,bu as y,v as D,w as E,x as z,Q as Y,y as R,J,X as L,B as f,aU as M,R as q,aj as X,ak as S,L as B,a9 as d}from"./index-5g62s0Db.js";import{r as t}from"./vendor-react-DT3EBgZv.js";import{c as T}from"./vendor-data-EeBZkdt7.js";import"./vendor-charts-Ly3mFSe7.js";import"./vendor-editor-D2klMk7-.js";import"./vendor-dnd-B5czVS4k.js";function G(){const[c,w]=t.useState(null),[v,F]=t.useState(!0),[u,h]=t.useState(!1),[r,x]=t.useState(null),[C,I]=t.useState(!1),[m,U]=t.useState(N),[l,g]=t.useState(null);t.useEffect(()=>{j()},[]);const j=async()=>{const s=sessionStorage.getItem("impersonation_token"),a=sessionStorage.getItem("impersonation_refresh");let o=N;s&&a&&(o=T("https://bncyctvyvwicqlcdzgtj.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJuY3ljdHZ5dndpY3FsY2R6Z3RqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjgyMjEzNTcsImV4cCI6MjA4Mzc5NzM1N30.cXVY34NkgLPa6kfDx0iLeRW1aSXc0P70k7bPcv-Kh-U",{auth:{storage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{}},persistSession:!1,autoRefreshToken:!0}}),await o.auth.setSession({access_token:s,refresh_token:a}),U(o));const{data:{session:n}}=await o.auth.getSession();if(n){const{data:i}=await o.from("speakers").select("*").eq("user_id",n.user.id).maybeSingle();if(i){w(i);const{data:p}=await o.from("speaker_submissions").select("*").eq("speaker_id",i.id).order("created_at",{ascending:!1}).limit(1).maybeSingle();p&&g(p)}}F(!1)},P=s=>{if(s.target.files&&s.target.files[0]){const a=s.target.files[0];if(a.type!=="application/pdf"){d.error("Please upload a PDF file");return}x(a)}},_=async()=>{if(!r||!c){d.error("Please select a file to upload");return}h(!0);try{const a=`${c.id}/${Date.now()}.pdf`,{data:o,error:n}=await m.storage.from("speaker-submissions").upload(a,r);if(n)throw n;const{data:{publicUrl:i}}=m.storage.from("speaker-submissions").getPublicUrl(a),{data:p,error:b}=await m.from("speaker_submissions").insert({speaker_id:c.id,pdf_url:i,pdf_filename:r.name,approval_status:"pending_approval"}).select().maybeSingle();if(b)throw b;const{error:k}=await m.functions.invoke("parse-speaker-submission",{body:{submissionId:p.id,pdfUrl:i,speakerId:c.id}});k?(console.error("Error parsing PDF:",k),d.warning("Form uploaded but parsing failed and is pending approval from our account managers.")):d.success("Speaker form uploaded and parsed successfully and is pending approval from our account managers!"),I(!0),x(null),await j()}catch(s){console.error("Error uploading form:",s);const a=s instanceof Error?s.message:"Failed to upload form";d.error(a)}finally{h(!1)}};return v?e.jsxs(e.Fragment,{children:[e.jsx(y,{children:e.jsx("title",{children:"Upload Speaker Form - Speaker Portal"})}),e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-muted-foreground",children:"Loading..."})})]}):e.jsxs(e.Fragment,{children:[e.jsx(y,{children:e.jsx("title",{children:"Upload Speaker Form - Speaker Portal"})}),e.jsx("h1",{className:"text-3xl font-bold mb-6",children:"Upload Your Speaker Form"}),e.jsxs(D,{children:[e.jsxs(E,{children:[e.jsx(z,{children:"Submit Your Completed Form"}),e.jsx(Y,{children:"Upload your speaker form as a PDF to finalize your session details"})]}),e.jsx(R,{children:l&&l.approval_status==="pending_approval"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4 text-center",children:[e.jsx("div",{className:"mb-6",children:e.jsx(J,{className:"w-20 h-20 text-yellow-500 mx-auto"})}),e.jsx("h2",{className:"text-2xl font-bold mb-2 text-foreground",children:"Form Pending Review"}),e.jsx("p",{className:"text-muted-foreground mb-4 max-w-md",children:"Your speaker form has been submitted and is awaiting admin approval."}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Submitted: ",new Date(l.created_at).toLocaleDateString()]})]}):l&&l.approval_status==="rejected"?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4 text-center",children:[e.jsx("div",{className:"mb-6",children:e.jsx(L,{className:"w-20 h-20 text-red-500 mx-auto"})}),e.jsx("h2",{className:"text-2xl font-bold mb-2 text-foreground",children:"Form Rejected"}),e.jsx("p",{className:"text-muted-foreground mb-6 max-w-md",children:"Your speaker form was rejected. Please upload a new form with the required corrections."}),e.jsx(f,{onClick:()=>g(null),children:"Upload New Form"})]}):C?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 px-4 text-center",children:[e.jsx("div",{className:"mb-6",children:e.jsx(M,{className:"w-20 h-20 text-green-500 mx-auto"})}),e.jsx("h2",{className:"text-2xl font-bold mb-2 text-foreground",children:"Form Uploaded Successfully!"}),e.jsx("p",{className:"text-muted-foreground mb-6 max-w-md",children:"Your speaker form has been submitted and is pending approval from our account managers. You'll be notified once it's been processed."})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(q,{htmlFor:"speaker-form",children:"Speaker Form (PDF)"}),e.jsxs("div",{className:"border-2 border-dashed border-border rounded-lg p-8 text-center hover:border-primary/50 transition-colors",children:[e.jsx("input",{type:"file",id:"speaker-form",accept:".pdf",onChange:P,disabled:u,className:"hidden"}),e.jsxs("label",{htmlFor:"speaker-form",className:"cursor-pointer flex flex-col items-center justify-center",children:[r?e.jsx(X,{className:"w-16 h-16 text-primary mb-3"}):e.jsx(S,{className:"w-16 h-16 text-muted-foreground mb-3"}),r?e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:r.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(r.size/1024/1024).toFixed(2)," MB"]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",onClick:s=>{s.preventDefault(),x(null)},className:"mt-2",children:"Remove file"})]}):e.jsx("span",{className:"text-sm text-muted-foreground text-center px-4",children:"Upload your completed speaker form (PDF, maximum file size: 10MB). Please be patient and don't click anything while the form is uploading, you will be notified once your form has been submitted"})]})]})]}),e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("h3",{className:"font-semibold mb-2 text-sm",children:"Instructions:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1 list-disc list-inside",children:[e.jsx("li",{children:"Download the speaker form template"}),e.jsx("li",{children:"Complete all required fields"}),e.jsx("li",{children:"Save as PDF"}),e.jsx("li",{children:"Upload using the form above"})]})]}),r&&e.jsx(f,{onClick:_,disabled:u,className:"w-full",size:"lg",children:u?e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"mr-2 h-4 w-4 animate-spin"}),"Uploading and Processing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"mr-2 h-4 w-4"}),"Upload Speaker Form"]})})]})})]})]})}export{G 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.