PageSourceSearch

https://responsiblepackagingexpo.co.uk/assets/SpeakerContact-BX68tBfH.js

js responsiblepackagingexpo.co.uk collected 2026-09-30 21:53:22 UTC 7,380 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-Cmvb7Owm.js";import{s as m,bu as N,v as Y,w as L,x as J,Q as B,y as X,aU as $,B as f,R as x,I as k,aR as A,X as D,ak as Z,L as H,a7 as O,a8 as w,a9 as p}from"./index-5g62s0Db.js";import{r as o}from"./vendor-react-DT3EBgZv.js";import{c as V}from"./vendor-data-EeBZkdt7.js";import{u as Q,t as G}from"./zod-CvOYkvwr.js";import"./vendor-charts-Ly3mFSe7.js";import"./vendor-editor-D2klMk7-.js";import"./vendor-dnd-B5czVS4k.js";const K=O({subject:w().trim().min(5,"Subject must be at least 5 characters").max(200,"Subject must be less than 200 characters"),message:w().trim().min(10,"Message must be at least 10 characters").max(5e3,"Message must be less than 5000 characters")});function oe(){const[d,v]=o.useState(null),[I,C]=o.useState(!0),[l,j]=o.useState(!1),[M,b]=o.useState(!1),[c,h]=o.useState(null),[g,P]=o.useState([]),{register:y,handleSubmit:F,formState:{errors:u},reset:E}=Q({resolver:G(K)});o.useEffect(()=>{U(),T()},[]);const U=async()=>{const n=sessionStorage.getItem("impersonation_token"),t=sessionStorage.getItem("impersonation_refresh");let s=m;n&&t&&(s=V("https://bncyctvyvwicqlcdzgtj.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImJuY3ljdHZ5dndpY3FsY2R6Z3RqIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjgyMjEzNTcsImV4cCI6MjA4Mzc5NzM1N30.cXVY34NkgLPa6kfDx0iLeRW1aSXc0P70k7bPcv-Kh-U",{auth:{storage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{}},persistSession:!1,autoRefreshToken:!0}}),await s.auth.setSession({access_token:n,refresh_token:t}));const{data:{session:r}}=await s.auth.getSession();if(r){const{data:a}=await s.from("speakers").select("*").eq("user_id",r.user.id).maybeSingle();a&&v(a)}C(!1)},T=async()=>{try{const{data:n,error:t}=await m.from("user_roles").select("user_id").eq("role","project_manager");if(t||!n||n.length===0)return;const{data:s,error:r}=await m.from("user_profiles").select("display_name, email").in("user_id",n.map(a=>a.user_id));if(r)return;s&&s.length>0&&P(s.map(a=>({name:a.display_name||"Project Manager",email:a.email||""})))}catch(n){console.error("Error loading project managers:",n)}},_=n=>{var s;const t=(s=n.target.files)==null?void 0:s[0];if(t){if(t.size>20*1024*1024){p.error("File size must be less than 20MB");return}h(t)}},R=()=>{h(null)},z=async n=>{if(!d){p.error("Speaker information not found");return}j(!0);try{let t=null,s=null;if(c){const a=c.name.split(".").pop(),i=`${d.id}/${Date.now()}.${a}`,{error:S}=await m.storage.from("support-attachments").upload(i,c);if(S)throw new Error(`Failed to upload file: ${S.message}`);const{data:{publicUrl:q}}=m.storage.from("support-attachments").getPublicUrl(i);t=q,s=c.name}const{error:r}=await m.functions.invoke("send-speaker-contact",{body:{speakerName:d.name,speakerEmail:d.email,subject:n.subject,message:n.message,projectManagers:g,fileUrl:t,fileName:s,speakerId:d.id}});if(r)throw r;b(!0),E(),h(null),p.success("Message sent successfully!")}catch(t){console.error("Error sending message:",t);let s="Unable to Send Message",r="",a="";if(t instanceof Error){const i=t.message.toLowerCase();i.includes("network")||i.includes("fetch")||i.includes("failed to fetch")?(s="Connection Error",r="Unable to connect to the server.",a="Please check your internet connection and try again."):i.includes("timeout")?(s="Request Timeout",r="The server took too long to respond.",a="Please wait a moment and try again."):i.includes("upload")||i.includes("file")?(s="File Upload Failed",r=t.message,a="Please try removing the attachment and submitting again, or use a smaller file."):i.includes("rate limit")||i.includes("too many")?(s="Too Many Requests",r="You've made too many requests in a short time.",a="Please wait a few minutes before trying again."):i.includes("server")||i.includes("500")||i.includes("internal")?(s="Server Error",r="Something went wrong on our end.",a="Please try again later. If the problem persists, contact support."):(r=t.message,a="Please try again. If the problem continues, contact us directly.")}else r="An unexpected error occurred while sending your message.",a="Please try again. If the problem continues, contact us directly.";p.error(s,{description:`${r} ${a}`,duration:8e3})}finally{j(!1)}};return I?e.jsxs(e.Fragment,{children:[e.jsx(N,{children:e.jsx("title",{children:"Contact Us - 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(N,{children:e.jsx("title",{children:"Contact Us - Speaker Portal"})}),e.jsx("h1",{className:"text-3xl font-bold mb-6",children:"Contact Us"}),e.jsxs(Y,{children:[e.jsxs(L,{children:[e.jsx(J,{children:"Contact Your Project Manager"}),e.jsx(B,{children:"Send a message to your project manager and our team"})]}),e.jsx(X,{children:M?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($,{className:"w-20 h-20 text-green-500 mx-auto"})}),e.jsx("h2",{className:"text-2xl font-bold mb-2 text-foreground",children:"Message Sent Successfully!"}),e.jsx("p",{className:"text-muted-foreground mb-6 max-w-md",children:"Your message has been sent to your project manager. They will get back to you as soon as possible."}),e.jsx(f,{onClick:()=>b(!1),children:"Send Another Message"})]}):e.jsxs("form",{onSubmit:F(z),className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"subject",children:"Subject *"}),e.jsx(k,{id:"subject",...y("subject"),placeholder:"Brief description of your inquiry",disabled:l,className:"bg-background"}),u.subject&&e.jsx("p",{className:"text-sm text-destructive",children:u.subject.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"message",children:"Message *"}),e.jsx(A,{id:"message",...y("message"),placeholder:"Please provide detailed information about your inquiry...",rows:8,disabled:l,className:"bg-background"}),u.message&&e.jsx("p",{className:"text-sm text-destructive",children:u.message.message})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"attachment",children:"Attachment (optional)"}),e.jsxs("div",{className:"space-y-3",children:[c&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-md",children:[e.jsx("span",{className:"text-sm flex-1 truncate",children:c.name}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",onClick:R,disabled:l,children:e.jsx(D,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(k,{id:"attachment",type:"file",onChange:_,disabled:l,className:"cursor-pointer"}),e.jsx(Z,{className:"h-5 w-5 text-muted-foreground"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Maximum file size: 20MB"})]})]}),g.length>0&&e.jsxs("div",{className:"bg-muted p-4 rounded-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Your message will be sent to:"}),e.jsx("ul",{className:"text-sm space-y-1",children:g.map((n,t)=>e.jsx("li",{className:"font-medium",children:n.name},t))})]}),e.jsx(f,{type:"submit",disabled:l,className:"w-auto",children:l?e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"mr-2 h-4 w-4 animate-spin"}),"Sending Message..."]}):"Send Message"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"* Required fields"})]})})]})]})}export{oe 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.