PageSourceSearch

https://printarex.com/assets/CameraUploadPage-quZOu7Nb.js

js printarex.com collected 2026-10-02 06:28:59 UTC 8,635 bytes, 15 lines download raw bytes

1import{j as e,cw as ne,aP as ie,a as le,a6 as ce,t as de,b as c,h as me,a0 as ue,B as N,af as pe,aF as xe}from"./index-COb3BWG8.js";import{U as fe}from"./returns-CNCTRRtN.js";import{P as he}from"./progress-B1h2wEL6.js";import{q as Ee,r as Ne}from"./support-queries-Dj-9UKZV.js";import{g as Re}from"./unauthenticated-apollo-client-hg84hwiD.js";import{R as X,a as q,b as je,c as Ie,e as ve,f as Ce,g as W}from"./evidence-DPvJe72G.js";import{L as J}from"./loader-circle-OXwY4kRz.js";import{C as we}from"./circle-alert-CCGVUS_b.js";import{C as K}from"./camera-DUiGx1gE.js";import{V as Z}from"./video-OjlM7fhR.js";import{C as T}from"./circle-check-BvfgDFVk.js";import{I as Te}from"./image-plus-BJx8oGza.js";import{u as A}from"./useMutation-BQY-xsoU.js";import"./useIsomorphicLayoutEffect-D8rpVvO2.js";const Ae=pe`
2  mutation UploadSupportCameraFile($input: FileUploadInput!, $file: Upload!) {
3    uploadFile(input: $input, file: $file) {
4      success
5      message
6      file {
7        fileId
8        fileName
9        fileSize
10        fileType
11        uploadedAt
12      }
13    }
14  }
15`,R=Re(),Ue=r=>new Promise((n,f)=>{const s=URL.createObjectURL(r),a=document.createElement("video");a.preload="metadata",a.onloadedmetadata=()=>{URL.revokeObjectURL(s),n(a.duration)},a.onerror=()=>{URL.revokeObjectURL(s),f(new Error("Unable to read video duration."))},a.src=s}),ge=async(r,n,f)=>{const s=je.has(r.type),a=Ie.has(r.type);if(!s&&!a)return n("Use a photo or MP4/MOV video.");if(s&&r.size>ve)return n("Photos must be 10 MB or smaller.");if(a&&r.size>Ce)return n("Videos must be 50 MB or smaller.");if(a)try{if(await Ue(r)>W)return`${n("Videos must be")} ${f(W)} ${n("seconds or shorter.")}`}catch{return n("Unable to read video duration.")}return null},Pe=()=>{var O,V,L,M,k;const{token:r}=ie(),{locale:n,direction:f}=le(),s=ce.useCallback(t=>de(t,n),[n]),a=t=>xe(t,n),p=c.useRef(null),[d,i]=c.useState("LOADING"),[U,j]=c.useState(0),[u,ee]=c.useState(0),[v,h]=c.useState(""),[g,C]=c.useState(!1),[P,I]=c.useState("photo"),{data:o,loading:_,error:S}=me(Ee,{variables:{token:r||""},client:R,skip:!r}),[se]=A(Ae,{client:R}),[te]=A(fe,{client:R}),[ae]=A(Ne,{client:R}),w=(O=o==null?void 0:o.cameraSessionInfo)==null?void 0:O.valid,y=(V=o==null?void 0:o.cameraSessionInfo)==null?void 0:V.expired,m=(((L=o==null?void 0:o.cameraSessionInfo)==null?void 0:L.purpose)||"SUPPORT_ATTACHMENT")==="RETURN_EVIDENCE",b=(M=o==null?void 0:o.cameraSessionInfo)==null?void 0:M.ownerType;c.useEffect(()=>{if(!_){if(S||w===void 0){i("INVALID"),h(s("Unable to validate session. Please try again."));return}if(!w){i("INVALID"),h(s(y?"This session has expired. Please scan a new QR code.":"Invalid session link."));return}i("READY")}},[_,S,w,y,s]),c.useEffect(()=>{var t;d==="READY"&&g&&(C(!1),(t=p.current)==null||t.click())},[d,g]);const D=((k=o==null?void 0:o.cameraSessionInfo)==null?void 0:k.customerId)||"",oe=async t=>{const x=t.type.startsWith("image/");return m?ge(t,s,a):x?null:s("Use a photo file.")},F=async t=>{var Y,G,z,H,Q;const x=(Y=t.target.files)==null?void 0:Y[0];if(t.target.value="",!x||!r)return;const B=await oe(x);if(B){h(B);return}i("UPLOADING"),j(0),h("");const $=setInterval(()=>{j(l=>Math.min(l+15,85))},200);try{if(b!=="USER")throw new Error("Unable to verify the camera session owner. Please scan a new QR code.");const l=await(m?te:se)({variables:{input:m?{category:"USER_AVATAR",subcategory:"return-evidence",ownerId:D,ownerType:"USER",accessLevel:"PRIVATE",isPublic:!1,metadata:{source:"camera-session",cameraSessionToken:r,cameraSessionPurpose:"RETURN_EVIDENCE"}}:{category:"SUPPORT_ATTACHMENT",ownerId:D,ownerType:b,accessLevel:"PRIVATE",isPublic:!1,metadata:{source:"camera-session",cameraSessionToken:r,cameraSessionPurpose:"SUPPORT_ATTACHMENT"}},file:x}});if(clearInterval($),!((z=(G=l.data)==null?void 0:G.uploadFile)!=null&&z.success)||!l.data.uploadFile.file)throw new Error(((Q=(H=l.data)==null?void 0:H.uploadFile)==null?void 0:Q.message)||"Upload failed");const E=l.data.uploadFile.file;j(90),await ae({variables:{token:r,input:{fileId:E.fileId,fileName:E.fileName,...m?{fileUrl:E.storageUrl}:{},fileSize:E.fileSize,fileType:x.type||E.fileType}}}),j(100),ee(re=>re+1),i("PHOTO_SENT")}catch(l){clearInterval($),i("READY"),h(s(l instanceof Error?l.message:"Upload failed. Please try again."))}};return e.jsx("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 to-emerald-50/30 flex items-center justify-center p-4",dir:f,children:e.jsxs(ue,{className:"w-full max-w-sm p-8 rounded-[28px] shadow-[0_10px_24px_rgba(0,0,0,0.08)] text-center space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[#15B6
157F]",children:"PrintaRex"}),e.jsx("p",{className:"text-sm text-slate-500 mt-1",children:s(m?"Return Evidence Upload":"Camera Upload")})]}),d==="LOADING"&&e.jsxs("div",{className:"py-8",children:[e.jsx(J,{className:"h-10 w-10 text-[#15B67F] animate-spin mx-auto"}),e.jsx("p",{className:"text-slate-500 mt-4",children:s("Validating session...")})]}),d==="INVALID"&&e.jsxs("div",{className:"py-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-red-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(we,{className:"h-8 w-8 text-red-500"})}),e.jsx("p",{className:"text-slate-700 font-medium",children:v})]}),d==="READY"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl bg-[#15B67F]/10 flex items-center justify-center mx-auto",children:e.jsx(K,{className:"h-10 w-10 text-[#15B67F]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-700 font-medium",children:s(m?"Add return evidence from your phone":"Take a photo to attach to your support ticket")}),u>0&&e.jsx("p",{className:"text-sm text-[#15B67F] mt-2 font-medium",children:u===1?s("1 file sent"):`${a(u)} ${s("files sent")}`})]}),v&&e.jsx("p",{className:"text-sm text-red-500",children:v}),e.jsx("input",{type:"file",ref:p,accept:P==="video"?X:q,capture:"environment",className:"hidden",onChange:F}),e.jsxs(N,{onClick:()=>{I("photo"),window.setTimeout(()=>{var t;return(t=p.current)==null?void 0:t.click()},0)},className:"w-full bg-[#15B67F] hover:bg-[#12a372] text-white rounded-[14px] h-[48px] text-base font-medium",children:[e.jsx(K,{className:"h-5 w-5 mr-2"}),s("Take Photo")]}),m&&e.jsxs(N,{onClick:()=>{I("video"),window.setTimeout(()=>{var t;return(t=p.current)==null?void 0:t.click()},0)},variant:"outline",className:"w-full rounded-[14px] h-[48px] text-base font-medium",children:[e.jsx(Z,{className:"h-5 w-5 mr-2"}),s("Record Video")]})]}),d==="UPLOADING"&&e.jsxs("div",{className:"py-4 space-y-4",children:[e.jsx(J,{className:"h-10 w-10 text-[#15B67F] animate-spin mx-auto"}),e.jsx("p",{className:"text-slate-700 font-medium",children:s("Uploading file...")}),e.jsx(he,{value:U,className:"h-2"}),e.jsxs("p",{className:"text-sm text-slate-500",children:[a(U),"%"]})]}),d==="PHOTO_SENT"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl bg-[#15B67F]/10 flex items-center justify-center mx-auto",children:e.jsx(T,{className:"h-10 w-10 text-[#15B67F]"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-slate-700 font-medium",children:s("File sent!")}),e.jsxs("p",{className:"text-sm text-slate-500 mt-1",children:[u===1?s("1 file uploaded."):`${a(u)} ${s("files uploaded.")}`," ",s("You can add more or close this page.")]})]}),e.jsx("input",{type:"file",ref:p,accept:P==="video"?X:q,capture:"environment",className:"hidden",onChange:F}),e.jsxs(N,{onClick:()=>{I("photo"),C(!0),i("READY")},className:"w-full bg-[#15B67F] hover:bg-[#12a372] text-white rounded-[14px] h-[48px] text-base font-medium",children:[e.jsx(Te,{className:"h-5 w-5 mr-2"}),s("Take Another Photo")]}),m&&e.jsxs(N,{variant:"outline",onClick:()=>{I("video"),C(!0),i("READY")},className:"w-full rounded-[14px] h-[48px] text-base font-medium",children:[e.jsx(Z,{className:"h-5 w-5 mr-2"}),s("Record Video")]}),e.jsxs(N,{variant:"outline",onClick:()=>{window.close(),i("DONE")},className:"w-full rounded-[14px] h-[48px] text-base font-medium",children:[e.jsx(T,{className:"h-5 w-5 mr-2"}),s("Done — Close")]})]}),d==="DONE"&&e.jsxs("div",{className:"py-8",children:[e.jsx("div",{className:"w-20 h-20 rounded-2xl bg-[#15B67F]/10 flex items-center justify-center mx-auto",children:e.jsx(T,{className:"h-10 w-10 text-[#15B67F]"})}),e.jsx("p",{className:"text-slate-700 font-medium mt-4",children:u===1?s("1 file sent successfully!"):`${a(u)} ${s("files sent successfully!")}`}),e.jsx("p",{className:"text-sm text-slate-500 mt-2",children:s("You can safely close this tab now.")})]})]})})},ze=()=>e.jsx(ne,{client:R,children:e.jsx(Pe,{})});export{ze 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.