PageSourceSearch

https://crm-flow-academy-global.vercel.app/_next/static/chunks/pag…/credit-notes/[id]-8bddaa8b86cdd161.js

js crm-flow-academy-global.vercel.app collected 2026-10-03 06:42:33 UTC 15,483 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1694],{9878:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>I});var a=s(37876),r=s(14232),i=s(89099),n=s(94246),l=s(41762),c=s(62125),d=s(28567),o=s(32764),x=s(78769),h=s(31452),m=s(34572),u=s(37596),j=s(29454),g=s(55792),p=s(54254),y=s(96668),v=s(63393),N=s(78464),f=s(46476),w=s(28022),b=s(610),k=s(36525),A=s(99204),C=s(68560);let I=()=>{var e,t,s,I,E,D,B,Z,_;let T=(0,i.useRouter)(),{id:R}=T.query,{user:L,loading:P}=(0,n.A)(),[S,F]=(0,r.useState)(null),[W,O]=(0,r.useState)(!1),[$,q]=(0,r.useState)(!1),[z,G]=(0,r.useState)(!1),[H,M]=(0,r.useState)(null),Y=null==L?void 0:L.role,U=(0,m.OG)(Y);(0,m.vT)(Y),(0,m.Sm)(Y);let V=async e=>{let t=j.A.get("tkn"),s=await fetch(e,{headers:{Authorization:"Bearer ".concat(t),"Content-Type":"application/json"}});if(!s.ok)throw Error((await s.json()).error||"Failed to fetch data");return s.json()},{data:X,error:Q,mutate:J}=(0,u.Ay)(R?"/api/credit-notes/".concat(R):null,V),K=null==X?void 0:X.creditNote,ee=async()=>{if(confirm("Are you sure you want to delete this credit note? This action cannot be undone.")){O(!0);try{let e=j.A.get("tkn"),t=await fetch("/api/credit-notes/".concat(R),{method:"DELETE",headers:{Authorization:"Bearer ".concat(e)}});if(!t.ok){let e=await t.json();throw Error(e.error||"Failed to delete credit note")}(null==K?void 0:K.originalInvoice)?T.push("/dashboard/invoices/".concat(K.originalInvoice._id)):T.push("/dashboard/invoices")}catch(e){console.error("Error deleting credit note:",e),F(e.message)}finally{O(!1)}}},et=async()=>{if(K){q(!0);try{let e=await (0,A.l3)(K);M(e),G(!0)}catch(e){console.error("Error generating PDF:",e),F("Failed to generate PDF preview")}finally{q(!1)}}},es=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"\xa3",s=parseFloat(e||0).toLocaleString("en-GB",{minimumFractionDigits:2,maximumFractionDigits:2});return"".concat(t).concat(s)},ea=e=>e?new Date(e).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"}):"N/A";if(P)return(0,a.jsx)("div",{children:"Loading..."});if(!L)return T.push("/auth/login"),null;if(!U)return(0,a.jsx)(l.A,{children:(0,a.jsx)("div",{className:"space-y-6 mt-2 mb-2",children:(0,a.jsx)(h.A,{title:"Access Denied",message:"You don't have permission to view credit note details.",requiredRoles:"Admin or Manager",redirectPath:"/dashboard/invoices",redirectText:"Back to Invoices"})})});if(Q)return(0,a.jsx)(l.A,{children:(0,a.jsxs)(x.F,{variant:"danger",children:[(0,a.jsx)(v.A,{className:"h-5 w-5"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium",children:"Error"}),(0,a.jsx)("p",{className:"text-sm",children:Q.message})]})]})});if(!K)return(0,a.jsx)(l.A,{children:(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)(g.A,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"Credit Note not found"}),(0,a.jsx)("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:"The credit note you're looking for doesn't exist or has been deleted."}),(0,a.jsxs)(c.$,{onClick:()=>T.push("/dashboard/invoices"),children:[(0,a.jsx)(N.A,{className:"w-4 h-4 mr-2"}),"Back to Invoices"]})]})});let er=(e=>{switch(e){case"draft":return{variant:"secondary",icon:g.A,label:"Draft"};case"issued":return{variant:"primary",icon:p.A,label:"Issued"};case"applied":return{variant:"success",icon:y.A,label:"Applied"};default:return{variant:"default",icon:g.A,label:e}}})(K.status),ei=er.icon;return(0,a.jsx)(l.A,{children:(0,a.jsxs)("div",{className:"space-y-6 mt-2",children:[(0,a.jsxs)("div",{className:"flex justify-between items-start",children:[(0,a.jsxs)("div",{className:"flex items-center gap-4",children:[(0,a.jsxs)(c.$,{variant:"outline",onClick:()=>T.push("/dashboard/invoices/".concat(K.originalInvoice._id)),children:[(0,a.jsx)(N.A,{className:"w-4 h-4 mr-2"}),"Back to Invoice"]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:K.creditNoteNumber}),(0,a.jsx)("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Credit Note Details"})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)(o.E,{variant:er.variant,className:"flex items-center gap-2",children:[(0,a.jsx)(ei,{className:"w-4 h-4"}),er.label]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(c.$,{variant:"outline",size:"sm",onClick:et,loading:$,children:[(0,a.jsx)(f.A,{className:"w-4 h-4 mr-2"}),"Preview PDF"]}),(0,a.jsxs)(c.$,{variant:"danger",size:"sm",onClick:ee,loading:W,children:[(0,a.jsx)(w.A,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})]}),S&&(0,a.jsxs)(x.F,{variant:"danger",children:[(0,a.jsx)(v.A,{className:"h-5 w-5"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-medium",children:"Error"}),(0,a.jsx)("p",{className:"text-sm",children:S})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,a.jsxs)("div",{className:"lg:col-span-2 space-y-6",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,a.jsxs)(d.Zp,{children:[(0,a.jsx)(d.aR,{children:(0,a.jsxs)(d.ZB,{className:"flex items-center gap-2",children:[(0,a.jsx)(b.A,{className:"w-5 h-5"}),"From"]})}),(0,a.jsx)(d.Wu,{children:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h4",{className:"font-semibold text-gray-900 dark:text-white",children:"Your Company"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Company address and details"})]})})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsx)(d.aR,{children:(0,a.jsxs)(d.ZB,{className:"flex items-center gap-2",children:[(0,a.jsx)(k.A,{className:"w-5 h-5"}),"Bill To"]})}),(0,a.jsx)(d.Wu,{children:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("h4",{className:"font-semibold text-gray-900 dark:text-white",children:(null==(e=K.clientInfo)?void 0:e.name)||"N/A"}),(null==(t=K.clientInfo)?void 0:t.address)&&(0,a.jsx)("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:K.clientInfo.address}),(0,a.jsxs)("div",{className:"space-y-1 text-sm text-gray-600 dark:text-gray-400",children:[(null==(s=K.clientInfo)?void 0:s.phone)&&(0,a.jsxs)("p",{children:["Phone: ",K.clientInfo.phone]}),(null==(I=K.clientInfo)?void 0:I.email)&&(0,a.jsxs)("p",{children:["Email: ",K.clientInfo.email]}),(null==(E=K.clientInfo)?void 0:E.postcode)&&(0,a.jsxs)("p",{children:["Postcode: ",K.clientInfo.postcode]})]})]})})]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsx)(d.aR,{children:(0,a.jsx)(d.ZB,{children:"Line Items"})}),(0,a.jsx)(d.Wu,{children:(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"w-full",children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:"border-b border-gray-200 dark:border-gray-700",children:[(0,a.jsx)("th",{className:"text-left py-3 px-4 font-medium text-gray-900 dark:text-white",children:"Description"}),(0,a.jsx)("th",{className:"text-right py-3 px-4 font-medium text-gray-900 dark:text-white",children:"Qty"}),(0,a.jsx)("th",{className:"text-right py-3 px-4 font-medium text-gray-900 dark:text-white",children:"Unit Price"}),(0,a.jsx)("th",{className:"text-right py-3 px-4 font-medium text-gray-900 dark:text-white",children:"Total"})]})}),(0,a.jsx)("tbody",{children:null==(D=K.items)?void 0:D.map((e,t)=>{var s,r;return(0,a.jsxs)("tr",{className:"border-b border-gray-100 dark:border-gray-800",children:[(0,a.jsx)("td",{className:"py-3 px-4 text-gray-900 dark:text-white",children:e.description}),(0,a.jsx)("td",{className:"py-3 px-4 text-right text-gray-600 dark:text-gray-400",children:e.quantity}),(0,a.jsx)("td",{className:"py-3 px-4 text-right text-gray-600 dark:text-gray-400",children:es(e.unitPrice,(null==(s=K.originalInvoice)?void 0:s.currency)||"\xa3")}),(0,a.jsx)("td",{className:"py-3 px-4 text-right font-medium text-gray-900 dark:text-white",children:es(e.quantity*e.unitPrice,(null==(r=K.originalInvoice)?void 0:r.currency)||"\xa3")})]},t)})})]})})})]}),K.notes&&(0,a.jsxs)(d.Zp,{children:[(0,a.jsx)(d.aR,{children:(0,a.jsx)(d.ZB,{children:"Notes"})}),(0,a.jsx)(d.Wu,{children:(0,a.jsx)("p",{className:"text-gray-600 dark:text-gray-400 whitespace-pre-wrap",children:K.notes})})]})]}),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)(d.Zp,{children:[(0,a.jsx)(d.aR,{children:(0,a.jsx)(d.ZB,{children:"Credit Note Summary"})}),(0,a.jsx)(d.Wu,{className:"space-y-4",children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:"Subtotal:"}),(0,a.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:es(K.subTotal,(null==(B=K.originalInvoice)?void 0:B.currency)||"\xa3")})]}),K.totalTax>0&&(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:"Tax:"}),(0,a.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:es(K.totalTax,(null==(Z=K.originalInvoice)?void 0:Z.currency)||"\xa3")})]}),(0,a.jsxs)("div",{className:"flex justify-between text-lg font-bold border-t border-gray-200 dark:border-gray-700 pt-3",children:[(0,a.jsx)("span",{children:"Total Credit:"}),(0,a.jsx)("span",{children:es(K.total,(null==(_=K.originalInvoice)?void 0:_.currency)||"\xa3")})]})]})})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsx)(d.aR,{children:(0,a.jsx)(d.ZB,{children:"Credit Note Details"})}),(0,a.jsx)(d.Wu,{className:"space-y-4",children:(0,a.jsxs)("div",{className:"space-y-3 text-sm",children:[(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:"Credit Note Number:"}),(0,a.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:K.creditNoteNumber})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:"Issue Date:"}),(0,a.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:ea(K.issueDate)})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:"Reason:"}),(0,a.jsx)("span",{className:"font-medium text-gray-900 dark:text-white",children:K.reason})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"text-gray-600 dark:text-gray-400",children:"Status:"}),(0,a.jsxs)(o.E,{variant:er.variant,className:"flex items-center gap-1",children:[(0,a.jsx)(ei,{className:"w-3 h-3"}),er.label]})]})]})})]}),K.originalInvoice&&(0,a.jsxs)(d.Zp,{children:[(0,a.jsx)(d.aR,{children:(0,a.jsx)(d.ZB,{children:"Original Invoice"})}),(0,a.jsx)(d.Wu,{children:(0,a.jsxs)(c.$,{variant:"outline",onClick:()=>T.push("/dashboard/invoices/".concat(K.originalInvoice._id)),className:"w-full",children:[(0,a.jsx)(g.A,{className:"w-4 h-4 mr-2"}),"View Original Invoice"]})})]})]})]}),(0,a.jsxs)(d.Zp,{children:[(0,a.jsx)(d.aR,{children:(0,a.jsx)(d.ZB,{children:"Activity L
1og"})}),(0,a.jsx)(d.Wu,{children:(0,a.jsx)("div",{className:"max-h-80 overflow-y-auto space-y-3 pr-2",children:K.activityLog&&K.activityLog.length>0?K.activityLog.slice().reverse().map((e,t)=>(0,a.jsxs)("div",{className:"flex items-start gap-3 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[(0,a.jsx)("div",{className:"w-2 h-2 bg-red-500 rounded-full mt-2 flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"text-sm font-medium text-gray-900 dark:text-white capitalize",children:e.action||"Updated"}),(0,a.jsx)("p",{className:"text-xs text-gray-600 dark:text-gray-400",children:e.details}),(0,a.jsx)("p",{className:"text-xs text-gray-500 dark:text-gray-500 mt-1",children:ea(e.timestamp)})]})]},t)):(0,a.jsx)("div",{className:"text-center py-8 text-gray-500 dark:text-gray-400",children:(0,a.jsx)("p",{children:"No activity recorded yet"})})})})]}),(0,a.jsx)(C.A,{isOpen:z,onClose:()=>{G(!1),M(null)},pdfDoc:H,title:"Credit Note ".concat(null==K?void 0:K.creditNoteNumber),filename:"CreditNote_".concat(null==K?void 0:K.creditNoteNumber,"_").concat(new Date().toISOString().split("T")[0],".pdf"),onPrint:e=>{let t=window.open(e,"_blank");t&&(t.onload=()=>{t.print()})},onDownload:(e,t)=>{let s=document.createElement("a");s.href=e,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s)}})]})})}},21660:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/dashboard/credit-notes/[id]",function(){return s(9878)}])},31010:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});var a=s(14232);let r=a.forwardRef(function(e,t){let{title:s,titleId:r,...i}=e;return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":r},i),s?a.createElement("title",{id:r},s):null,a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v3.75m0-10.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.75c0 5.592 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.57-.598-3.75h-.152c-3.196 0-6.1-1.25-8.25-3.286Zm0 13.036h.008v.008H12v-.008Z"}))})},31452:(e,t,s)=>{"use strict";s.d(t,{A:()=>c});var a=s(37876);s(14232);var r=s(89099),i=s(62125),n=s(28567),l=s(31010);let c=e=>{let{title:t="Access Denied",message:s="You don't have permission to access this section.",description:c,requiredRoles:d,redirectPath:o="/dashboard",redirectText:x="Back to Dashboard",icon:h,variant:m="danger"}=e,u=(0,r.useRouter)(),{iconColor:j,icon:g}=(()=>{switch(m){case"warning":return{iconColor:"text-yellow-500",icon:h||l.A};case"info":return{iconColor:"text-blue-500",icon:h||l.A};default:return{iconColor:"text-red-500",icon:h||l.A}}})();return(0,a.jsx)(n.Zp,{children:(0,a.jsxs)(n.Wu,{className:"p-8 text-center",children:[(0,a.jsx)(g,{className:"h-16 w-16 ".concat(j," mx-auto mb-4")}),(0,a.jsx)("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white mb-2",children:t}),(0,a.jsx)("p",{className:"text-gray-600 dark:text-gray-400 mb-4",children:s}),c&&(0,a.jsx)("p",{className:"text-sm text-gray-500 dark:text-gray-500 mb-4",children:c}),d&&(0,a.jsxs)("p",{className:"text-sm text-gray-500 dark:text-gray-500 mb-6",children:["Required role: ",d]}),(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-3 justify-center",children:[(0,a.jsx)(i.$,{variant:"outline",onClick:()=>u.push(o),className:"w-full sm:w-auto",children:x}),(0,a.jsx)(i.$,{variant:"ghost",onClick:()=>u.back(),className:"w-full sm:w-auto",children:"Go Back"})]})]})})}},86419:(e,t,s)=>{"use strict";s.d(t,{A:()=>r});var a=s(14232);let r=a.forwardRef(function(e,t){let{title:s,titleId:r,...i}=e;return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:t,"aria-labelledby":r},i),s?a.createElement("title",{id:r},s):null,a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z"}))})}},e=>{e.O(0,[7725,347,2858,3,5885,1762,6167,636,6593,8792],()=>e(e.s=21660)),_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.