import{p,_ as w}from"./AppLayout.vue_vue_type_script_setup_true_lang-C-UlPCqH.js";import{d as B,o as d,a as l,b as o,e as a,h as D,w as m,f as t,l as h,i as u,t as r,g as k,q as b,j as f,F as N,D as S}from"./app-D9-EssCM.js";import{A as $}from"./arrow-left-CdAVEsab.js";import{S as E}from"./square-pen-CvugRQ9Y.js";import{T as A}from"./trash-2-Dis-KatR.js";import{T}from"./triangle-alert-CHfwYE_1.js";import"./index-CcjNLu6f.js";import"./index-CMWG4mbA.js";import"./useForwardExpose-MNmriUeS.js";import"./VisuallyHidden-DG35s1YI.js";import"./RovingFocusGroup-Diffidi3.js";import"./useArrowNavigation-C6Y-ieo6.js";import"./x-DwmBYYXD.js";import"./_plugin-vue_export-helper-DmjF0He4.js";const C={class:"p-4"},V={class:"mb-6 flex items-center justify-between"},F={class:"flex items-center gap-2"},q={class:"mx-auto max-w-4xl"},L={class:"mb-6"},P={class:"text-2xl font-bold text-gray-900"},j={class:"text-gray-600"},M={class:"space-y-6"},z={class:"rounded-lg border bg-white p-6"},I={class:"grid gap-6 md:grid-cols-2"},Q={class:"mt-1 text-lg text-gray-900"},R={class:"mt-1 text-lg text-gray-900"},U={class:"mt-1 text-lg text-gray-900"},G={class:"mt-1 text-lg text-gray-900"},H={class:"mt-1 flex items-center gap-2"},J={class:"text-lg text-gray-900"},K={class:"mt-1"},O={key:1,class:"inline-flex items-center rounded-full px-3 py-1 text-sm font-medium bg-gray-100 text-gray-800"},W={key:0,class:"mt-6"},X={class:"mt-1 text-gray-900 whitespace-pre-wrap bg-gray-50 p-4 rounded-md"},ut=B({__name:"Show",props:{product:{},batch:{}},setup(g){const e=g;function n(i){return i?new Date(i)<new Date:!1}function c(i,s=30){if(!i)return!1;const _=new Date(i),v=new Date,x=Math.ceil((_.getTime()-v.getTime())/(1e3*60*60*24));return x>0&&x<=s}function y(){confirm("Are you sure you want to delete this batch?")&&S.delete(`/products/${e.product.id}/batches/${e.batch.id}`)}return(i,s)=>(d(),l(N,null,[o(a(D),{title:`Batch ${e.batch.batch_number} - ${e.product.name}`},null,8,["title"]),o(w,{breadcrumbs:[{title:"Products",href:a(p).index().url},{title:e.product.name,href:a(p).show(e.product.id).url},{title:"Batches",href:`/products/${e.product.id}/batches`},{title:e.batch.batch_number,href:"#"}]},{default:m(()=>[t("div",C,[t("div",V,[o(a(h),{href:`/products/${e.product.id}/batches`,class:"flex items-center gap-2 text-gray-600 hover:text-gray-900"},{default:m(()=>[o(a($),{class:"h-4 w-4"}),s[0]||(s[0]=u(" Back to Batches ",-1))]),_:1},8,["href"]),t("div",F,[o(a(h),{href:`/products/${e.product.id}/batches/${e.batch.id}/edit`,class:"flex items-center gap-2 rounded-md border border-gray-300 px-4 py-2 text-gray-700 hover:bg-gray-50"},{default:m(()=>[o(a(E),{class:"h-4 w-4"}),s[1]||(s[1]=u(" Edit ",-1))]),_:1},8,["href"]),t("button",{onClick:y,class:"flex items-center gap-2 rounded-md border border-red-300 px-4 py-2 text-red-700 hover:bg-red-50"},[o(a(A),{class:"h-4 w-4"}),s[2]||(s[2]=u(" Delete ",-1))])])]),t("div",q,[t("div",L,[t("h1",P,"Batch: "+r(e.batch.batch_number),1),t("p",j,"Product: "+r(e.product.name),1)]),t("div",M,[t("div",z,[s[10]||(s[10]=t("h2",{class:"mb-4 text-lg font-semibold text-gray-900"},"Batch Information",-1)),t("div",I,[t("div",null,[s[3]||(s[3]=t("div",{class:"text-sm font-medium text-gray-500"},"Batch Number",-1)),t("div",Q,r(e.batch.batch_number),1)]),t("div",null,[s[4]||(s[4]=t("div",{class:"text-sm font-medium text-gray-500"},"Quantity",-1)),t("div",R,r(e.batch.quantity),1)]),t("div",null,[s[5]||(s[5]=t("div",{class:"text-sm font-medium text-gray-500"},"Unit Cost",-1)),t("div",U,r(e.batch.unit_cost?"R"+parseFloat(e.batch.unit_cost.toString()).toFixed(2):"N/A"),1)]),t("div",null,[s[6]||(s[6]=t("div",{class:"text-sm font-medium text-gray-500"},"Manufacture Date",-1)),t("div",G,r(e.batch.manufacture_date?new Date(e.batch.manufacture_date).toLocaleDateString():"N/A"),1)]),t("div",null,[s[7]||(s[7]=t("div",{class:"text-sm font-medium text-gray-500"},"Expiry Date",-1)),t("div",H,[t("div",J,r(e.batch.expiry_date?new Date(e.batch.expiry_date).toLocaleDateString():"N/A"),1),e.batch.expiry_date&&(n(e.batch.expiry_date)||c(e.batch.expiry_date))?(d(),k(a(T),{key:0,class:b(["h-5 w-5",n(e.batch.expiry_date)?"text-red-500":"text-yellow-500"])},null,8,["class"])):f("",!0)])]),t("div",null,[s[8]||(s[8]=t("div",{class:"text-sm font-medium text-gray-500"},"Status",-1)),t("div",K,[e.batch.expiry_date?(d(),l("span",{key:0,class:b(["inline-flex items-center rounded-full px-3 py-1 text-sm font-medium",n(e.batch.expiry_date)?"bg-red-100 text-red-800":c(e.batch.expiry_date)?"bg-yellow-100 text-yellow-800":"bg-green-100 text-green-800"])},r(n(e.batch.expiry_date)?"Expired":c(e.batch.expiry_date)?"Expiring Soon":"Valid"),3)):(d(),l("span",O," No Expiry "))])])]),e.batch.notes?(d(),l("div",W,[s[9]||(s[9]=t("div",{class:"text-sm font-medium text-gray-500"},"Notes",-1)),t("div",X,r(e.batch.notes),1)])):f("",!0)])])])])]),_:1},8,["breadcrumbs"])],64))}});export{ut as default};
