PageSourceSearch

https://petshiwu.onrender.com/assets/js/Returns-1PW3gAVK.js

js petshiwu.onrender.com collected 2026-10-03 11:42:39 UTC 10,839 bytes, 2 lines download raw bytes

1var p=(t,n,d)=>new Promise((u,o)=>{var m=l=>{try{i(d.next(l))}catch(s){o(s)}},x=l=>{try{i(d.throw(l))}catch(s){o(s)}},i=l=>l.done?u(l.value):Promise.resolve(l.value).then(m,x);i((d=d.apply(t,n)).next())});import{j as e,a as L}from"./query-vendor-CGNNROSo.js";import{a as g,g as k,d as O,z as S,S as j,aj as P,f as A}from"./product-DhvCMyVu.js";import{r as c,L as b}from"./react-vendor-DuOU6Nda.js";import{g as D,u as M,r as T,a as U,C}from"./ui-vendor-HNhY3Ait.js";import"./state-vendor-DsXnpHkF.js";const F={createReturn:t=>p(null,null,function*(){return(yield g.post("/orders/returns",t)).data.data}),getMyReturns:()=>p(null,null,function*(){return(yield g.get("/orders/returns/my")).data.data}),getReturn:t=>p(null,null,function*(){return(yield g.get(`/orders/returns/${t}`)).data.data})},q=["Unused item — changed my mind","Damaged in delivery","Defective or not as described","Wrong item received","Opened food/treat — arrived damaged or incorrect","Other"];function Y(t=new Date){const n=t.toISOString().slice(0,10).replace(/-/g,""),d=Math.random().toString(36).slice(2,6).toUpperCase();return`RET-${n}-${d}`}function z(t){return[`Return request ${t.reference}`,`Order number: ${t.orderNumber}`,`Reason: ${t.reason}`,t.details.trim()?`Details: ${t.details.trim()}`:"Details: (none)"].join(`
2`)}const f=()=>{const{user:t}=k(),[n,d]=c.useState((t==null?void 0:t.firstName)||""),[u,o]=c.useState((t==null?void 0:t.email)||""),[m,x]=c.useState(""),[i,l]=c.useState(q[0]),[s,a]=c.useState(""),[h,y]=c.useState(!1),[N,v]=c.useState(""),[w,E]=c.useState(""),$=r=>p(null,null,function*(){r.preventDefault(),y(!0),v("");const R=Y();try{yield g.post("/v1/contact/general",{name:n.trim(),email:u.trim(),subject:"return",message:z({reference:R,orderNumber:m.trim(),reason:i,details:s})},{skipAuth:!0}),E(R)}catch(W){v("Could not send the request. Email [email protected] with your order number.")}finally{y(!1)}});return w?e.jsxs("div",{className:"rounded-2xl border border-emerald-200 bg-emerald-50 p-6",role:"status",children:[e.jsx("h2",{className:"text-xl font-bold text-emerald-900 mb-2",children:"Return request received"}),e.jsxs("p",{className:"text-emerald-900 mb-3",children:["Your reference number is ",e.jsx("strong",{children:w}),". Save it. We email"," ",u.trim()||"you"," after we review the order."]}),e.jsx("p",{className:"text-sm text-emerald-800",children:"Unused items: 365 days from delivery. Opened food, treats, or supplements only if they arrived damaged, defective, or incorrect. Photos help — reply to our email with them."})]}):e.jsxs("form",{onSubmit:$,className:"rounded-2xl border border-stone-200 bg-white p-6 space-y-4",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"block text-sm font-semibold text-stone-800",children:["Name",e.jsx("input",{required:!0,value:n,onChange:r=>d(r.target.value),className:"mt-1 w-full h-11 rounded-xl border border-stone-200 px-3",autoComplete:"name"})]}),e.jsxs("label",{className:"block text-sm font-semibold text-stone-800",children:["Email",e.jsx("input",{required:!0,type:"email",value:u,onChange:r=>o(r.target.value),className:"mt-1 w-full h-11 rounded-xl border border-stone-200 px-3",autoComplete:"email"})]})]}),e.jsxs("label",{className:"block text-sm font-semibold text-stone-800",children:["Order number",e.jsx("input",{required:!0,value:m,onChange:r=>x(r.target.value),placeholder:"ORD-…",className:"mt-1 w-full h-11 rounded-xl border border-stone-200 px-3"})]}),e.jsxs("label",{className:"block text-sm font-semibold text-stone-800",children:["Reason",e.jsx("select",{value:i,onChange:r=>l(r.target.value),className:"mt-1 w-full h-11 rounded-xl border border-stone-200 px-3 bg-white",children:q.map(r=>e.jsx("option",{value:r,children:r},r))})]}),e.jsxs("label",{className:"block text-sm font-semibold text-stone-800",children:["Details (optional)",e.jsx("textarea",{value:s,onChange:r=>a(r.target.value),rows:4,className:"mt-1 w-full rounded-xl border border-stone-200 px-3 py-2",placeholder:"What should we know? Attach photos after we reply."})]}),N?e.jsx("p",{className:"text-sm text-red-600",children:N}):null,e.jsx("button",{type:"submit",disabled:h,className:"w-full sm:w-auto px-6 py-3 rounded-xl bg-[#1E3A8A] text-white font-semibold disabled:opacity-60",children:h?"Sending…":"Submit return request"}),e.jsxs("p",{className:"text-xs text-stone-500",children:["Guest or signed-in — no account required. Policy:"," ",e.jsx(b,{to:"/return-policy",className:"text-[#1E3A8A] underline",children:"365-day returns"}),"."]})]})},B=()=>{const{toast:t,hideToast:n}=O(),{isAuthenticated:d,isLoading:u}=k(),{data:o,isLoading:m}=L({queryKey:["returns"],queryFn:()=>F.getMyReturns(),enabled:d}),x=s=>{switch(s){case"completed":return e.jsx(C,{className:"w-5 h-5 text-green-600"});case"approved":return e.jsx(C,{className:"w-5 h-5 text-blue-600"});case"rejected":return e.jsx(U,{className:"w-5 h-5 text-red-600"});case"processing":return e.jsx(T,{className:"w-5 h-5 text-yellow-600 animate-spin"});default:return e.jsx(M,{className:"w-5 h-5 text-gray-600"})}},i=s=>{switch(s){case"completed":return"bg-green-100 text-green-800";
2case"approved":return"bg-blue-100 text-blue-800";case"rejected":return"bg-red-100 text-red-800";case"processing":return"bg-yellow-100 text-yellow-800";default:return"bg-gray-100 text-gray-800"}},l=s=>{switch(s){case"refunded":return"bg-green-100 text-green-800";case"processing":return"bg-yellow-100 text-yellow-800";case"failed":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}};return u?e.jsx("div",{className:"container mx-auto px-4 py-12",children:e.jsx(S,{size:"lg",ariaLabel:"Loading returns"})}):d?m?e.jsx("div",{className:"container mx-auto px-4 py-12",children:e.jsx(S,{size:"lg",ariaLabel:"Loading returns"})}):!o||o.length===0?e.jsxs(e.Fragment,{children:[e.jsx(j,{title:"My Returns | Petshiwu",description:"Track your Petshiwu return requests.",url:"/returns",noindex:!0}),e.jsxs("div",{className:"container mx-auto px-4 py-12",children:[e.jsx("h1",{className:"text-3xl font-bold mb-6",children:"Start a return"}),e.jsx("div",{className:"max-w-2xl mb-10",children:e.jsx(f,{})}),e.jsx(P,{icon:D,title:"No Returns Yet",description:"You haven't requested any returns. Eligible unused items can be returned within 365 days of delivery."}),e.jsx("p",{className:"text-center mt-4",children:e.jsx(b,{to:"/return-policy",className:"text-primary-600 hover:underline font-medium",children:"Read the 365-day return policy"})}),t.isVisible&&e.jsx(A,{message:t.message,type:t.type,onClose:n})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{title:"My Returns | Petshiwu",description:"Track your Petshiwu return requests.",url:"/returns",noindex:!0}),e.jsxs("div",{className:"container mx-auto px-4 py-12",children:[e.jsx("h1",{className:"text-3xl font-bold mb-6",children:"Start a return"}),e.jsx("div",{className:"max-w-2xl mb-10",children:e.jsx(f,{})}),e.jsx("h2",{className:"text-xl font-bold mb-4",children:"Your return requests"}),e.jsx("div",{className:"space-y-6",children:o.map(s=>e.jsxs("div",{className:"bg-white rounded-lg shadow-lg p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[x(s.status),e.jsxs("h2",{className:"text-xl font-semibold",children:["Return #",s.returnNumber||s.rmaNumber||s._id.slice(-8)]})]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Order: ",e.jsxs(b,{to:`/orders/${s.orderId}`,className:"text-primary-600 hover:underline",children:["#",s.orderId.slice(-8)]})]}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Created: ",new Date(s.createdAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:`px-3 py-1 rounded-full text-sm font-semibold ${i(s.status)}`,children:s.status.charAt(0).toUpperCase()+s.status.slice(1)}),s.refundStatus&&e.jsxs("span",{className:`px-3 py-1 rounded-full text-sm font-semibold ${l(s.refundStatus)}`,children:["Refund: ",s.refundStatus.charAt(0).toUpperCase()+s.refundStatus.slice(1)]})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx("h3",{className:"font-semibold mb-3",children:"Return Items:"}),e.jsx("div",{className:"space-y-3",children:s.items.map((a,h)=>e.jsxs("div",{className:"flex items-center gap-4 p-3 bg-gray-50 rounded-lg",children:[e.jsx("img",{src:typeof a.productId=="object"?a.productId.image:"/placeholder.png",alt:typeof a.productId=="object"?a.productId.name:"Product",className:"w-16 h-16 object-cover rounded"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(b,{to:`/products/${typeof a.productId=="object"?a.productId.slug:""}`,className:"font-semibold text-primary-600 hover:underline",children:typeof a.productId=="object"?a.productId.name:"Product"}),e.jsxs("p",{className:"text-sm text-gray-600",children:["Quantity: ",a.quantity]}),e.jsxs("p",{className:"text-sm text-gray-600",children:["Reason: ",a.reason]}),a.refundAmount&&e.jsxs("p",{className:"text-sm font-semibold text-green-600",children:["Refund: $",a.refundAmount.toFixed(2)]})]})]},h))})]}),s.reason&&e.jsx("div",{className:"mt-4 p-3 bg-blue-50 rounded-lg",children:e.jsxs("p",{className:"text-sm text-blue-800",children:[e.jsx("strong",{children:"Return Reason:"})," ",s.reason]})}),s.returnAddress&&e.jsxs("div",{className:"mt-4 p-3 bg-gray-50 rounded-lg",children:[e.jsx("p",{className:"text-sm font-semibold mb-2",children:"Return Address:"}),e.jsxs("p",{className:"text-sm text-gray-700",children:[s.returnAddress.firstName," ",s.returnAddress.lastName,e.jsx("br",{}),s.returnAddress.address,e.jsx("br",{}),s.returnAddress.city,", ",s.returnAddress.state," ",s.returnAddress.zipCode]})]}),s.refundAmount>0&&e.jsxs("div",{className:"mt-4 p-3 bg-green-50 rounded-lg",children:[e.jsxs("p",{className:"text-sm font-semibold text-green-800",children:["Total Refund Amount: $",s.refundAmount.toFixed(2)]}),e.jsxs("p",{className:"text-xs text-green-700 mt-1",children:["Refund Method: ",s.refundMethod==="original"?"Original Payment Method":"Store Credit"]})]})]},s._id))}),t.isVisible&&e.jsx(A,{message:t.message,type:t.type,onClose:n})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{title:"Start a Return | Petshiwu",description:"Start a Petshiwu return with your order number and email. Unused items can be returned within 365 days of delivery.",url:"/returns",noindex:!0}),e.jsxs("div",{className:"container mx-auto px-4 py-12 max-w-2xl",children:[e.jsx("h1",{className:"text-3xl font-bold mb-4",children:"Start a return"}),e.jsx("p",{className:"text-gray-700 mb-6",children:"Enter your order number and email. You get a reference number immediately. Unused items in original packaging can be returned within 365 days of delivery."}),e.jsx(f,{})]})]})};export{B 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.