bettertend/frontend/dist/assets/RequestDetailView-BkDwCZ7I.js

2 lines
16 KiB
JavaScript

import{r as c,c as P,s as te,o as se,i as B,w as i,v as re,g as l,b as e,d as u,a,j as d,t as o,e as n,F as h,k as m,n as x,aR as E,ae as oe,aU as le,l as ae}from"./index-BUdRbiwj.js";import{u as ie,a as de,f as ne,R as ue,c as me}from"./useRequestManagement-aHkLwKaS.js";import{F as ve,a as ce}from"./FPPageHeader-CTG2L28r.js";import{F as k}from"./FPCard-qHzcEQAE.js";import{F as xe}from"./FPModal-DWGF1LV8.js";import{F as b}from"./FPBadge-BKY5dPnL.js";import{F as ge}from"./FPTabs-R71V25QN.js";const pe={class:"px-6 py-8"},ye={key:0,class:"flex items-center justify-center h-64"},fe={key:1,class:"text-center py-12"},ke={class:"text-gray-600 mb-6"},be={key:2,class:"space-y-8"},we={class:"grid grid-cols-1 md:grid-cols-4 gap-6"},_e={class:"flex items-center"},he={class:"flex-shrink-0"},qe={class:"ml-4"},Re={class:"text-2xl font-bold text-gray-900"},Be={class:"flex items-center"},Ce={class:"flex-shrink-0"},De={class:"ml-4"},Te={class:"text-2xl font-bold text-gray-900"},Ae={class:"flex items-center"},Se={class:"ml-4"},je={class:"text-lg font-semibold text-gray-900"},Fe={class:"flex items-center"},Ne={class:"ml-4"},Oe={key:0,class:"text-xs text-red-500"},Le={key:0,class:"space-y-6"},Me={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},Pe={class:"space-y-2"},Ee={class:"text-sm font-medium text-gray-900"},Ve={class:"text-sm font-medium text-gray-900"},ze={class:"space-y-2"},Ue={class:"flex items-center space-x-2"},$e={class:"text-sm font-medium text-gray-900"},Ie={key:0},He={class:"flex items-center space-x-2"},We={class:"text-sm font-medium text-gray-900"},Je={key:1},Qe={class:"text-sm font-medium text-gray-900"},Ye={key:2},Ke={class:"text-sm font-medium text-gray-900"},Ge={class:"text-sm text-gray-700 leading-relaxed"},Xe={key:0,class:"bg-orange-50 border border-orange-200 rounded-lg p-4"},Ze={class:"text-sm text-orange-700"},et={key:1,class:"bg-blue-50 border border-blue-200 rounded-lg p-4"},tt={class:"text-sm text-blue-700"},st={key:1,class:"space-y-6"},rt={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},ot={class:"space-y-3"},lt={class:"text-sm font-medium text-gray-900"},at={key:0},it={key:0,class:"text-xs text-red-500 ml-2"},dt={key:1},nt={class:"text-sm font-medium text-gray-900"},ut={class:"text-sm font-medium text-gray-900"},mt={key:0},vt={class:"space-y-3"},ct={key:0},xt={class:"text-sm font-medium text-gray-900"},gt={key:1},pt={class:"text-sm font-medium text-gray-900"},yt={class:"border-t pt-6"},ft={class:"space-y-4"},kt={class:"flex items-start space-x-3"},bt={class:"text-xs text-gray-500"},wt={key:0,class:"flex items-start space-x-3"},_t={class:"text-xs text-gray-500"},ht={key:2,class:"space-y-6"},qt={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},Rt={class:"space-y-3"},Bt={class:"text-sm font-medium text-gray-900"},Ct={class:"text-sm font-medium text-gray-900"},Dt={class:"flex items-center justify-center"},Tt={class:"space-y-4"},Pt={__name:"RequestDetailView",setup(At){const V=te(),C=re(),z=ie(),{approveRequest:U}=de(),{showNotification:D}=ae(),q=c(!1),w=c(null),s=c(null),g=c("basic"),p=c(!1),R=c(!1),y=c(""),$=P(()=>parseInt(V.params.id)),I=P(()=>{var t;const r=[{key:"basic",label:"Basic Information",icon:"info"},{key:"timeline",label:"Timeline",icon:"clock"}];return(t=s.value)!=null&&t.workOrder&&r.push({key:"workorder",label:"Work Order",icon:"clipboard"}),r}),T=async()=>{try{q.value=!0,w.value=null;const r=await z.fetchRequestById($.value);s.value=r}catch(r){w.value=r.message||"Failed to load request details"}finally{q.value=!1}},H=()=>{C.push(`/requests?edit=${s.value.id}`)},W=()=>{p.value=!0},J=async()=>{try{R.value=!0,await U(s.value.id,{comments:y.value.trim()}),D({type:"success",title:"Success",message:"Request approved successfully"}),p.value=!1,y.value="",await T()}catch(r){D({type:"error",title:"Error",message:r.message||"Failed to approve request"})}finally{R.value=!1}},Q=()=>{p.value=!1,y.value=""},Y=()=>{var r;(r=s.value)!=null&&r.workOrder&&C.push(`/work-orders/${s.value.workOrder.id}`)},A=r=>ne[r]||r,S=r=>ue[r]||r,j=r=>me[r]||r,F=r=>r?new Date(r).toLocaleDateString():null,f=r=>r?new Date(r).toLocaleString():"Not set",_=r=>r?new Date(r)<new Date:!1,N=r=>r?`${r.firstName} ${r.lastName}`:"Unknown",K=r=>r?`${r.firstName} ${r.lastName}`:"Unassigned",O=r=>({pending:"warning",under_review:"primary",approved:"success",rejected:"error",in_progress:"primary",completed:"success",cancelled:"secondary"})[r]||"secondary",L=r=>({low:"secondary",medium:"primary",high:"warning",critical:"error",emergency:"error"})[r]||"secondary",G=r=>({pending:"bg-yellow-100",under_review:"bg-blue-100",approved:"bg-green-100",rejected:"bg-red-100",in_progress:"bg-purple-100",completed:"bg-green-200",cancelled:"bg-gray-100"})[r]||"bg-gray-100",X=r=>({pending:"text-yellow-600",under_review:"text-blue-600",approved:"text-green-600",rejected:"text-red-600",in_progress:"text-purple-600",completed:"text-green-700",cancelled:"text-gray-600"})[r]||"text-gray-600",Z=r=>({low:"bg-green-100",medium:"bg-blue-100",high:"bg-orange-100",critical:"bg-red-100",emergency:"bg-red-200"})[r]||"bg-gray-100",ee=r=>({low:"text-green-600",medium:"text-blue-600",high:"text-orange-600",critical:"text-red-600",emergency:"text-red-700"})[r]||"text-gray-600";return se(()=>{T()}),(r,t)=>(l(),B(ve,null,{header:i(()=>{var v,M;return[u(ce,{title:((v=s.value)==null?void 0:v.title)||"Request Details",description:s.value?`Request #${s.value.customId||s.value.id}`:"Loading request details...",breadcrumbs:[{text:"Requests",to:"/requests"},{text:((M=s.value)==null?void 0:M.title)||"Details",to:null}]},{actions:i(()=>[s.value?(l(),B(n(h),{key:0,variant:"outline",size:"sm",onClick:H},{default:i(()=>t[4]||(t[4]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})],-1),m(" Edit Request ",-1)])),_:1,__:[4]})):d("",!0),s.value&&["pending","under_review"].includes(s.value.status)?(l(),B(n(h),{key:1,variant:"primary",size:"sm",onClick:W},{default:i(()=>t[5]||(t[5]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})],-1),m(" Approve Request ",-1)])),_:1,__:[5]})):d("",!0)]),_:1},8,["title","description","breadcrumbs"])]}),default:i(()=>[e("div",pe,[q.value?(l(),a("div",ye,t[6]||(t[6]=[e("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600"},null,-1)]))):w.value?(l(),a("div",fe,[t[8]||(t[8]=e("svg",{class:"w-16 h-16 mx-auto text-gray-300 mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})],-1)),t[9]||(t[9]=e("h3",{class:"text-lg font-medium text-gray-900 mb-2"},"Failed to load request",-1)),e("p",ke,o(w.value),1),u(n(h),{variant:"outline",onClick:t[0]||(t[0]=v=>r.$router.push("/requests"))},{default:i(()=>t[7]||(t[7]=[m(" Back to Requests ",-1)])),_:1,__:[7]})])):s.value?(l(),a("div",be,[e("div",we,[u(n(k),null,{default:i(()=>[e("div",_e,[e("div",he,[e("div",{class:x(["w-8 h-8 rounded-lg flex items-center justify-center",G(s.value.status)])},[(l(),a("svg",{class:x(["w-5 h-5",X(s.value.status)]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},t[10]||(t[10]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"},null,-1)]),2))],2)]),e("div",qe,[t[11]||(t[11]=e("div",{class:"text-sm font-medium text-gray-500"},"Status",-1)),e("div",Re,[u(n(b),{variant:O(s.value.status)},{default:i(()=>[m(o(A(s.value.status)),1)]),_:1},8,["variant"])])])])]),_:1}),u(n(k),null,{default:i(()=>[e("div",Be,[e("div",Ce,[e("div",{class:x(["w-8 h-8 rounded-lg flex items-center justify-center",Z(s.value.priority)])},[(l(),a("svg",{class:x(["w-5 h-5",ee(s.value.priority)]),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},t[12]||(t[12]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.854-.833-2.598 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"},null,-1)]),2))],2)]),e("div",De,[t[13]||(t[13]=e("div",{class:"text-sm font-medium text-gray-500"},"Priority",-1)),e("div",Te,[u(n(b),{variant:L(s.value.priority)},{default:i(()=>[m(o(S(s.value.priority)),1)]),_:1},8,["variant"])])])])]),_:1}),u(n(k),null,{default:i(()=>[e("div",Ae,[t[15]||(t[15]=e("div",{class:"flex-shrink-0"},[e("div",{class:"w-8 h-8 rounded-lg bg-blue-100 flex items-center justify-center"},[e("svg",{class:"w-5 h-5 text-blue-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"})])])],-1)),e("div",Se,[t[14]||(t[14]=e("div",{class:"text-sm font-medium text-gray-500"},"Type",-1)),e("div",je,o(j(s.value.type)),1)])])]),_:1}),u(n(k),null,{default:i(()=>[e("div",Fe,[t[17]||(t[17]=e("div",{class:"flex-shrink-0"},[e("div",{class:"w-8 h-8 rounded-lg bg-purple-100 flex items-center justify-center"},[e("svg",{class:"w-5 h-5 text-purple-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})])])],-1)),e("div",Ne,[t[16]||(t[16]=e("div",{class:"text-sm font-medium text-gray-500"},"Required Date",-1)),e("div",{class:x(["text-lg font-semibold text-gray-900",_(s.value.requiredDate)?"text-red-600":""])},o(F(s.value.requiredDate)||"Not set"),3),_(s.value.requiredDate)?(l(),a("div",Oe," Overdue ")):d("",!0)])])]),_:1})]),u(n(k),null,{default:i(()=>[u(n(ge),{modelValue:g.value,"onUpdate:modelValue":t[1]||(t[1]=v=>g.value=v),tabs:I.value},{default:i(()=>[g.value==="basic"?(l(),a("div",Le,[e("div",Me,[e("div",null,[t[22]||(t[22]=e("h4",{class:"text-sm font-medium text-gray-900 mb-2"},"Request Information",-1)),e("dl",Pe,[e("div",null,[t[18]||(t[18]=e("dt",{class:"text-sm text-gray-500"},"Title",-1)),e("dd",Ee,o(s.value.title),1)]),e("div",null,[t[19]||(t[19]=e("dt",{class:"text-sm text-gray-500"},"Type",-1)),e("dd",Ve,o(j(s.value.type)),1)]),e("div",null,[t[20]||(t[20]=e("dt",{class:"text-sm text-gray-500"},"Priority",-1)),e("dd",null,[u(n(b),{variant:L(s.value.priority)},{default:i(()=>[m(o(S(s.value.priority)),1)]),_:1},8,["variant"])])]),e("div",null,[t[21]||(t[21]=e("dt",{class:"text-sm text-gray-500"},"Status",-1)),e("dd",null,[u(n(b),{variant:O(s.value.status)},{default:i(()=>[m(o(A(s.value.status)),1)]),_:1},8,["variant"])])])])]),e("div",null,[t[27]||(t[27]=e("h4",{class:"text-sm font-medium text-gray-900 mb-2"},"Assignment & Location",-1)),e("dl",ze,[e("div",null,[t[23]||(t[23]=e("dt",{class:"text-sm text-gray-500"},"Requested By",-1)),e("dd",Ue,[u(n(E),{user:s.value.requestedBy,size:"sm"},null,8,["user"]),e("span",$e,o(N(s.value.requestedBy)),1)])]),s.value.assignedTo?(l(),a("div",Ie,[t[24]||(t[24]=e("dt",{class:"text-sm text-gray-500"},"Assigned To",-1)),e("dd",He,[u(n(E),{user:s.value.assignedTo,size:"sm"},null,8,["user"]),e("span",We,o(K(s.value.assignedTo)),1)])])):d("",!0),s.value.assetName?(l(),a("div",Je,[t[25]||(t[25]=e("dt",{class:"text-sm text-gray-500"},"Asset",-1)),e("dd",Qe,o(s.value.assetName),1)])):d("",!0),s.value.locationName?(l(),a("div",Ye,[t[26]||(t[26]=e("dt",{class:"text-sm text-gray-500"},"Location",-1)),e("dd",Ke,o(s.value.locationName),1)])):d("",!0)])])]),e("div",null,[t[28]||(t[28]=e("h4",{class:"text-sm font-medium text-gray-900 mb-2"},"Description",-1)),e("p",Ge,o(s.value.description),1)]),s.value.urgencyReason?(l(),a("div",Xe,[t[29]||(t[29]=e("h4",{class:"text-sm font-medium text-orange-800 mb-2"},"Urgency Reason",-1)),e("p",Ze,o(s.value.urgencyReason),1)])):d("",!0),s.value.businessJustification?(l(),a("div",et,[t[30]||(t[30]=e("h4",{class:"text-sm font-medium text-blue-800 mb-2"},"Business Justification",-1)),e("p",tt,o(s.value.businessJustification),1)])):d("",!0)])):d("",!0),g.value==="timeline"?(l(),a("div",st,[e("div",rt,[e("div",null,[t[35]||(t[35]=e("h4",{class:"text-sm font-medium text-gray-900 mb-4"},"Key Dates",-1)),e("dl",ot,[e("div",null,[t[31]||(t[31]=e("dt",{class:"text-sm text-gray-500"},"Created",-1)),e("dd",lt,o(f(s.value.createdAt)),1)]),s.value.requiredDate?(l(),a("div",at,[t[32]||(t[32]=e("dt",{class:"text-sm text-gray-500"},"Required Date",-1)),e("dd",{class:x(["text-sm font-medium",_(s.value.requiredDate)?"text-red-600":"text-gray-900"])},[m(o(F(s.value.requiredDate))+" ",1),_(s.value.requiredDate)?(l(),a("span",it,"(Overdue)")):d("",!0)],2)])):d("",!0),s.value.approvedDate?(l(),a("div",dt,[t[33]||(t[33]=e("dt",{class:"text-sm text-gray-500"},"Approved",-1)),e("dd",nt,o(f(s.value.approvedDate)),1)])):d("",!0),e("div",null,[t[34]||(t[34]=e("dt",{class:"text-sm text-gray-500"},"Last Updated",-1)),e("dd",ut,o(f(s.value.updatedAt)),1)])])]),s.value.estimatedHours||s.value.estimatedCost?(l(),a("div",mt,[t[38]||(t[38]=e("h4",{class:"text-sm font-medium text-gray-900 mb-4"},"Estimates",-1)),e("dl",vt,[s.value.estimatedHours?(l(),a("div",ct,[t[36]||(t[36]=e("dt",{class:"text-sm text-gray-500"},"Estimated Hours",-1)),e("dd",xt,o(s.value.estimatedHours)+" hours",1)])):d("",!0),s.value.estimatedCost?(l(),a("div",gt,[t[37]||(t[37]=e("dt",{class:"text-sm text-gray-500"},"Estimated Cost",-1)),e("dd",pt,"$"+o(s.value.estimatedCost.toFixed(2)),1)])):d("",!0)])])):d("",!0)]),e("div",yt,[t[43]||(t[43]=e("h4",{class:"text-sm font-medium text-gray-900 mb-4"},"Activity Timeline",-1)),e("div",ft,[e("div",kt,[t[40]||(t[40]=e("div",{class:"flex-shrink-0 w-2 h-2 rounded-full bg-blue-600 mt-2"},null,-1)),e("div",null,[t[39]||(t[39]=e("p",{class:"text-sm font-medium text-gray-900"},"Request created",-1)),e("p",bt,o(f(s.value.createdAt))+" by "+o(N(s.value.requestedBy)),1)])]),s.value.approvedDate?(l(),a("div",wt,[t[42]||(t[42]=e("div",{class:"flex-shrink-0 w-2 h-2 rounded-full bg-green-600 mt-2"},null,-1)),e("div",null,[t[41]||(t[41]=e("p",{class:"text-sm font-medium text-gray-900"},"Request approved",-1)),e("p",_t,o(f(s.value.approvedDate)),1)])])):d("",!0)])])])):d("",!0),g.value==="workorder"&&s.value.workOrder?(l(),a("div",ht,[t[49]||(t[49]=e("div",{class:"bg-green-50 border border-green-200 rounded-lg p-4"},[e("div",{class:"flex items-center"},[e("svg",{class:"w-5 h-5 text-green-600 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})]),e("span",{class:"text-sm font-medium text-green-800"},"Work Order Created")])],-1)),e("div",qt,[e("div",null,[t[47]||(t[47]=e("h4",{class:"text-sm font-medium text-gray-900 mb-4"},"Work Order Details",-1)),e("dl",Rt,[e("div",null,[t[44]||(t[44]=e("dt",{class:"text-sm text-gray-500"},"Work Order ID",-1)),e("dd",Bt,o(s.value.workOrder.id),1)]),e("div",null,[t[45]||(t[45]=e("dt",{class:"text-sm text-gray-500"},"Title",-1)),e("dd",Ct,o(s.value.workOrder.title),1)]),e("div",null,[t[46]||(t[46]=e("dt",{class:"text-sm text-gray-500"},"Status",-1)),e("dd",null,[u(n(b),{variant:"primary"},{default:i(()=>[m(o(s.value.workOrder.status),1)]),_:1})])])])]),e("div",Dt,[u(n(h),{variant:"primary",onClick:Y},{default:i(()=>t[48]||(t[48]=[e("svg",{class:"w-4 h-4 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})],-1),m(" View Work Order ",-1)])),_:1,__:[48]})])])])):d("",!0)]),_:1},8,["modelValue","tabs"])]),_:1})])):d("",!0)]),u(n(xe),{modelValue:p.value,"onUpdate:modelValue":t[3]||(t[3]=v=>p.value=v),title:"Approve Request",onConfirm:J,onCancel:Q,"confirm-text":"Approve",loading:R.value},{default:i(()=>[e("div",Tt,[t[51]||(t[51]=e("p",null,"Are you sure you want to approve this request? This will create a new work order.",-1)),e("div",null,[t[50]||(t[50]=e("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Approval Comments (Optional)",-1)),oe(e("textarea",{"onUpdate:modelValue":t[2]||(t[2]=v=>y.value=v),class:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-primary-500 focus:border-primary-500",placeholder:"Add any comments about the approval...",rows:"3"},null,512),[[le,y.value]])])])]),_:1},8,["modelValue","loading"])]),_:1}))}};export{Pt as default};