1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[581],{63259:(e,t,s)=>{Promise.resolve().then(s.bind(s,89592))},89592:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>v});var a=s(95155),i=s(12115),r=s(76046),c=s(65423),l=s(50572),n=s(73312),d=s(67396),o=s(41598),u=s(22783),m=s(76426),p=s(27058),x=s(44595),h=s(65564),f=s(87081),j=s(46087),b=s(12687);function v(){let{user:e,loading:t,isAdmin:s}=(0,c.A)(),v=(0,r.useRouter)(),N=(0,r.useParams)(),{toast:g}=(0,h.dj)(),[w,y]=(0,i.useState)(null),[E,A]=(0,i.useState)(!0),[k,D]=(0,i.useState)(!1),S=N.id;(0,i.useEffect)(()=>{if(!t){if(!e){v.push("/login");return}S&&(async()=>{if(A(!0),!e)return;let t=(0,p.H9)(x.db,"receipts",S);try{let s=await (0,p.x7)(t);if(s.exists()&&s.data().userId===e.uid){let e=s.data(),t=(e.notes||[]).map(e=>({...e,createdAt:e.createdAt.toDate()}));y({id:s.id,...e,purchaseDate:e.purchaseDate.toDate(),createdAt:e.createdAt?e.createdAt.toDate():void 0,updatedAt:e.updatedAt?e.updatedAt.toDate():void 0,notes:t,tags:e.tags||[]})}else g({variant:"destructive",title:"Error",description:"Receipt not found or you do not have permission to edit it."}),v.push("/?tab=receipts")}catch(e){console.error("Error fetching receipt:",e),g({variant:"destructive",title:"Error",description:"Failed to fetch receipt details."})}finally{A(!1)}})()}},[S,e,t,v,g]);let C=async(t,s)=>{if(!w||!e)return;D(!0);let{initialNote:a,tags:i,...r}=t,c={...r,imageUrl:s};a&&(c.notes=[...w.notes||[],{text:a,createdAt:new Date}]);let l=await (0,b.pp)(e.uid,"receipts",c,i||[],w.id);if(l.success){(0,j.F$)();let e="The receipt for ".concat(t.vendor," has been successfully updated.");v.push("/?tab=receipts&confirmation=".concat(encodeURIComponent(e)))}else g({variant:"destructive",title:"Update Failed",description:l.error||"Could not save the receipt and its tags."}),D(!1)},F=(e,s)=>E||t?(0,a.jsxs)("div",{className:"max-w-2xl mx-auto space-y-6 px-4 md:px-6 pt-6",children:[(0,a.jsx)(f.E,{className:"h-48 w-full"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(f.E,{className:"h-4 w-1/4"}),(0,a.jsx)(f.E,{className:"h-10 w-full"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(f.E,{className:"h-4 w-1/4"}),(0,a.jsx)(f.E,{className:"h-10 w-full"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(f.E,{className:"h-4 w-1/4"}),(0,a.jsx)(f.E,{className:"h-10 w-full"})]})]}):w?(0,a.jsx)("div",{className:"px-4 md:px-6 pt-6 pb-24 max-w-2xl mx-auto w-full",children:(0,a.jsx)(l.C,{form:e,isProcessing:s})}):null;return(0,a.jsx)(l.F,{onSubmit:C,initialData:w,isSubmitting:k,children:e=>{let{form:t,isSubmitting:s}=e;return(0,a.jsxs)("div",{className:"min-h-screen bg-muted/40 flex flex-col",children:[(0,a.jsx)("header",{className:"px-4 py-2 md:py-4 border-b bg-card/80 backdrop-blur-sm sticky top-0 z-30 pt-[calc(0.5rem+env(safe-area-inset-top))] md:pt-[calc(1rem+env(safe-area-inset-top))]",children:(0,a.jsx)("div",{className:"container mx-auto flex items-center justify-between gap-3 px-4",children:(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsx)(n.$,{variant:"outline",size:"icon",asChild:!0,children:(0,a.jsx)(d.default,{href:"/?tab=receipts",children:(0,a.jsx)(o.A,{})})}),(0,a.jsx)("h1",{className:"text-xl font-semibold text-foreground",children:"Edit Receipt"})]})})}),(0,a.jsx)("main",{className:"flex-1 overflow-y-auto",children:F(t,s)}),(0,a.jsx)("footer",{className:"p-4 border-t bg-card/80 backdrop-blur-sm sticky bottom-0 z-30 flex justify-center pb-[calc(1rem+env(safe-area-inset-bottom))]",children:(0,a.jsx)(n.$,{type:"submit",className:"w-full max-w-2xl",size:"lg",disabled:s,children:s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u.A,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m.A,{className:"mr-2 h-4 w-4"}),"Save Changes"]})})})]})}})}}},e=>{var t=t=>e(e.s=t);e.O(0,[2992,3644,4324,69,4900,9122,5565,4722,40,4621,8150,8207,5424,8441,8590,7358],()=>t(63259)),_N_E=e.O()}]);
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.