1import{r as a,j as e}from"./react-CRjXmzdu.js";import{a as B}from"./http-3ukMoIbY.js";import{S as b}from"./SecureTextField-DanQiLjW.js";import{Q as G,r as _,v as z,l as N,L as U}from"./index-De75rBSf.js";import{B as i,T as n,G as g,as as Y,b8 as J,aC as Q,aD as V,aQ as X,a8 as q,b9 as H,s as L,ax as K}from"./mui-CNr6W-ty.js";import"./vendor-IdvdfVCJ.js";import"./redux-Dts5QXDw.js";import"./iconify-BNxKwMGw.js";import"./react-query-Cwaq9TKo.js";import"./router-BDpR9Pxq.js";import"./lodash-CpjO0APP.js";import"./ui-utils-DqNXFlDe.js";import"./date-utils-Cj6NCtA4.js";import"./sanitize-RB1-lMRI.js";import"./validation-B8dh9o27.js";import"./i18n-89tvej9L.js";import"./emotion-CfcNTy1E.js";import"./firebase-UICncsdF.js";const{getAdminApiUrl:Z}=N,$=new U("MigrationFeedbackForm"),ee=5*1024*1024,F=["image/jpeg","image/png","image/webp"],te=["Drive","Email","Contacts","Calendar"],I="Products",re=L(K)(({theme:l})=>({[l.breakpoints.down("sm")]:{alignItems:"flex-start",width:"100%",height:"100lvh"}})),ae=L(i)(({theme:l})=>({width:"560px",background:"#FFFFFF",padding:"36px 40px",borderRadius:"16px",boxShadow:"0 2px 12px rgba(0,0,0,0.06)",[l.breakpoints.down("sm")]:{width:"100%",borderRadius:"0px",padding:"24px"}})),Ee=()=>{const{isLoading:l,isAuthenticated:T,user:p}=G(),[x,y]=a.useState(""),[c,j]=a.useState(""),[v,f]=a.useState(""),[d,A]=a.useState([]),[h,D]=a.useState(""),[o,u]=a.useState(null),[S,m]=a.useState(""),[E,C]=a.useState(!1),[P,R]=a.use
1State(!1),[w,k]=a.useState(""),s=a.useRef(null);a.useEffect(()=>{p&&(y(t=>t||p.name||""),j(t=>t||p.email||""))},[p]);const W=t=>{const r=t.target.files?.[0];if(!r){u(null),m("");return}if(!F.includes(r.type)){m("Only JPEG, PNG, or WEBP images are allowed."),u(null),s.current&&(s.current.value="");return}if(r.size>ee){m("Image must be smaller than 5MB."),u(null),s.current&&(s.current.value="");return}m(""),u(r)},O=()=>{u(null),m(""),s.current&&(s.current.value="")},M=a.useCallback(async t=>{if(t.preventDefault(),!x.trim()||!c.trim()||!d.length||!h.trim())return _("Please fill in your name, email, product, and a description of the issue.");if(!z(c.trim())){f("Enter a valid email address.");return}f("");try{C(!0),k("");const r=new FormData;r.append("name",x.trim()),r.append("email",c.trim()),r.append("products",JSON.stringify(d)),r.append("description",h.trim()),o&&r.append("image",o),await B.create({baseURL:Z(),withCredentials:!0}).post("v1/migrationFeedback/submit",r),R(!0)}catch(r){$.error(r?.message),k(r?.response?.data?.message||"Something went wrong. Please try again.")}finally{C(!1)}},[x,c,d,h,o]);return e.jsx(re,{sx:{display:"flex",alignItems:"center",justifyContent:"center",height:"100vh",background:{xs:"#fff",sm:"#F7F8F9"}},children:e.jsx(ae,{children:l?e.jsx(i,{textAlign:"center",children:e.jsx(n,{variant:"body2",color:"text.secondary",children:"Checking your sessionâ¦"})}):T?P?e.jsxs(i,{textAlign:"center",children:[e.jsx(n,{variant:"h6",fontWeight:600,sx:{mb:1},children:"Thanks for letting us know"}),e.jsx(n,{variant:"body2",color:"text.secondary",children:"We've received your report and our team will look into it shortly."})]}):e.jsxs("form",{onSubmit:M,children:[e.jsxs(i,{display:"flex",flexDirection:"column",gap:"8px",sx:{mb:"24px"},children:[e.jsx(n,{variant:"h6",fontWeight:600,children:"Report a migration issue"}),e.jsx(n,{variant:"body2",color:"text.secondary",children:"Ran into a problem during your migration? Let us know the details below and, if you have one, attach a screenshot."})]}),e.jsxs(i,{display:"flex",flexDirection:"column",gap:"16px",children:[e.jsx(b,{label:"Your name",value:x,onChange:t=>y(t.target.value),sanitize:!0,validate:!0,securityOptions:{trim:!1},maxLength:120,fullWidth:!0}),e.jsx(b,{label:"Email address",type:"email",value:c,onChange:t=>{f(""),j(t.target.value)},error:!!v,helperText:v,sanitize:!0,validate:!0,maxLength:255,fullWidth:!0}),e.jsxs(Y,{fullWidth:!0,children:[e.jsx(J,{id:"migration-feedback-products-label",children:I}),e.jsx(Q,{labelId:"migration-feedback-products-label",multiple:!0,value:d,onChange:t=>A(t.target.value),input:e.jsx(H,{label:I}),renderValue:t=>t.join(", "),children:te.map(t=>e.jsxs(V,{value:t,children:[e.jsx(X,{checked:d.includes(t)}),e.jsx(q,{primary:t})]},t))})]}),e.jsx(b,{label:"What happened?",placeholder:"Describe the issue you ran into during the migration",value:h,onChange:t=>D(t.target.value),sanitize:!0,validate:!0,securityOptions:{trim:!1},maxLength:5e3,multiline:!0,minRows:4,fullWidth:!0}),e.jsxs(i,{children:[e.jsxs(g,{variant:"outlined",component:"label",sx:{textTransform:"none"},children:[o?"Change screenshot":"Attach a screenshot (optional)",e.jsx("input",{ref:s,type:"file",hidden:!0,accept:F.join(","),onChange:W})]}),o&&e.jsxs(i,{display:"flex",alignItems:"center",gap:"8px",sx:{mt:"8px"},children:[e.jsx(n,{variant:"body2",color:"text.secondary",children:o.name}),e.jsx(g,{size:"small",onClick:O,sx:{textTransform:"none"},children:"Remove"})]}),S&&e.jsx(n,{variant:"body2",color:"error",sx:{mt:"4px"},children:S})]}),w&&e.jsx(n,{variant:"body2",color:"error",children:w}),e.jsx(g,{type:"submit",variant:"contained",disabled:E,sx:{textTransform:"none",py:"10px"},children:E?"Submitting...":"Submit report"})]})]}):e.jsxs(i,{textAlign:"center",children:[e.jsx(n,{variant:"h6",fontWeight:600,sx:{mb:1},children:"Please log in to continue"}),e.jsx(n,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"You need to be signed in to your account to submit a migration issue report."}),e.jsx(g,{variant:"contained",sx:{textTransform:"none"},onClick:()=>{window.location.href="/login"},children:"Go to login"})]})})})};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.