1import{b as o,e as g,j as s,w as a,aR as H,g as b,k as q,h as p,v as M,F as $,aB as J,f as n,V as D,ai as Z,t as I,y as v,aW as x,at as ee,I as U,a6 as E,a1 as te,M as O,ab as ae,ao as se,m as le,bl as ne,s as oe,p as re,aw as ue,aI as ie,a7 as de,L as me,q as pe,N as j,l as ce,c as T,r as f,ae as ge,d as L,Q as fe,u as ve,o as ye}from"./index-DUWew8AW.js";import{_ as _e,B as z}from"./ApprovalsTooltip-HDmRxrXU.js";import{R as he}from"./ReportingResource-DVqEy9lw.js";import{_ as be}from"./ClientLink-iPZtHPmn.js";const Ie={class:"w-full"},Be={key:1,class:"flex justify-center md:flex-row space-x-1"},Fe={class:"pr-0"},Ve={key:0,class:"flex justify-end space-x-3 p-6"},Re={class:"w-1/2"},ke={class:"py-6"},xe={__name:"BudgetInsightsClientViewTable",props:{report:{type:Array,required:!0},loading:{type:Boolean,default:!1},budgetIncreaseApprovals:{type:Array,required:!0},reportDate:{type:String,required:!0}},emits:["fetch"],setup(w,{emit:V}){const y=w,R=V,{showErrorNotification:k,showSuccessNotification:C}=ve(),{requiredTextRule:B}=ge(),A=[{title:"Client Name",key:"name"},{title:"Total Budget Recommendation Increase",key:"totalBudgetRecommendationIncrease",align:"center",width:250},{title:"Search Budget Recommendation Increase",key:"searchBudgetRecommendationIncrease",align:"center",width:250},{title:"PMAX/VLA Budget Recommendation Increase",key:"pmaxBudgetRecommendationIncrease",align:"center",width:250},{title:"Status",key:"status",sortable:!1,align:"center"},{title:"",key:"actions",sortable:!1,align:"end"}],N=["One Time (This Month Only)","On Going Change","Custom Time Frame"],_=f(!1),u=f(null),i=f([]),d=f(!1),c=f(!1),F=T(()=>fe.getters["authorization/currentUser"]),K=T(()=>L().format("YYYY-MM-DD"));function W(m){var P;let e=0,t=0,l=0;m.campaigns.forEach(h=>{h.type==="sem"?t+=h.missed_budget_opportunity:h.type==="pmax"&&(l+=h.missed_budget_opportunity),e+=h.missed_budget_opportunity});const r=y.budgetIncreaseApprovals.find(h=>h.clientId===m.id);return{...m,totalBudgetRecommendationIncrease:e,searchBudgetRecommendationIncrease:t,pmaxBudgetRecommendationIncrease:l,taskId:r?r.taskId:null,amounts:r?r.amounts:[],approvalDate:(r==null?void 0:r.createdAt)||null,approvedBy:((P=r==null?void 0:r.user)==null?void 0:P.fullName)||"N/A",completedAt:(r==null?void 0:r.completedAt)||null,changeTimeFrame:(r==null?void 0:r.changeTimeFrame)||{timeFrame:null,dateRange:[]}}}const G=T(()=>y.report.map(m=>W(m))),S=T(()=>i.value.reduce((m,e)=>m+parseFloat(e.updated_budget_opportunity||0),0));function Q(m){u.value=m,i.value=m.campaigns.map(e=>({...e,actual_missed_budget_opportunity:parseFloat(e.missed_budget_opportunity).toFixed(2),updated_budget_opportunity:null})),d.value=!0}function Y(){d.value=!1,u.value=null,i.value=[]}async function X(){const m=i.value.filter(l=>parseFloat(l.updated_budget_opportunity)>0).map(l=>({campaignId:l.campaign_id,campaignName:l.campaign_name,campaignType:l.type,opportunity:parseFloat(l.missed_budget_opportunity).toFixed(2),increase:parseFloat(l.updated_budget_opportunity).toFixed(2),leadOpportunity:l.missed_conversion_opportunity})),e={timeFrame:u.value.changeTimeFrame.timeFrame,dateRange:u.value.changeTimeFrame.timeFrame==="Custom Time Frame"?u.value.changeTimeFrame.dateRange:null},t={clientId:u.value.id,userId:F.value.id,userName:F.value.fullName,userEmail:F.value.email,amounts:m,month:y.reportDate,changeTimeFrame:e};Y(),_.value=!0,await z.createBudgetIncreaseApproval(t).then(()=>{R("fetch"),C("Budget increase request has been successfully submitted.")}).catch(()=>{k()}).finally(()=>{_.value=!1})}return(m,e)=>(o(),g("div",Ie,[s(ee,{loading:w.loading,class:"w-full elevation-1",items:G.value,headers:A,"items-per-page":-1,"hide-default-footer":!0,"item-value":"id","expand-strategy":"single","no-data-text":"No automotive clients..."},{"item.name":a(({item:t})=>[(o(),b(be,{client:t,key:`client-${t.id}`},null,8,["client"]))]),"item.totalBudgetRecommendationIncrease":a(({item:t})=>[p(I(v(x)(t.totalBudgetRecommendationIncrease)),1)]),"item.searchBudgetRecommendationIncrease":a(({item:t})=>[p(I(v(x)(t.searchBudgetRecommendationIncrease)),1)]),"item.pmaxBudgetRecommendationIncrease":a(({item:t})=>[p(I(v(x)(t.pmaxBudgetRecommendationIncrease)),1)]),"item.status":a(({item:t})=>[t.taskId?(o(),g($,{key:0},[t.completedAt?(o(),b(J,{key:0,location:"bottom"},{activator:a(({props:l})=>[s(D,Z(l,{color:"success"}),{default:a(()=>[...e[6]||(e[6]=[p("fas fa-check-circle",-1)])]),_:1},16)]),default:a(()=>[e[7]||(e[7]=n("span",null,"Request has been processed",-1))]),_:1})):(o(),g("div",Be,[s(D,{start:"",color:"warning"},{default:a(()=>[...e[8]||(e[8]=[p("fas fa-hourglass-half",-1)])]),_:1}),e[9]||(e[9]=n("span",{class:"text-gray-600"},"Request In Progress",-1))]))],64)):(o(),g($,{key:1},[t.totalBudgetRecommendationIncrease>0?(o(),b(D,{key:0,color:"grey"},{default:a(()=>[...e[10]||(e[10]=[p(" fas fa-circle-check ",-1)])]),_:1})):(o(),b(D,{key:1,color:"grey"},{default:a(()=>[...e[11]||(e[11]=[p("fas fa-minus",-1)])]),_:1}))],64))]),"item.actions":a(({item:t})=>[s(H,null,{default:a(()=>[t.taskId?(o(),b(_e,{key:0,direction:"left",amounts:t.amounts,"approval-date":t.approvalDate,"approved-by":t.approvedBy,changeTimeFrame:t.changeTimeFrame},null,8,["amounts","approval-date","approved-by","changeTimeFrame"])):t.totalBudgetRecommendationIncrease>0?(o(),b(q,{key:1,size:"small",variant:"outlined",color:"primary",onClick:l=>Q(t)},{default:a(()=>[...e[12]||(e[12]=[p(" Approve ",-1)])]),_:1},8,["onClick"])):M("",!0)]),_:2},1024)]),_:1},8,["loading","items"]),s(j,{modelValue:d.value,"onUpdate:modelValue":e[4]||(e[4]=t=>d.value=t),persistent:"",onKeydown:pe(Y,["esc"]),"max-width":"1200",width:"95%",
1scrollable:""},{default:a(()=>[s(U,null,{default:a(()=>[s(E,null,{default:a(()=>[...e[13]||(e[13]=[p("Enter Budget Increase For Each Campaign",-1)])]),_:1}),s(te),s(O,{class:"h-full max-h-[100vh-300px]"},{default:a(()=>[s(ae,{ref:"form",modelValue:c.value,"onUpdate:modelValue":e[3]||(e[3]=t=>c.value=t)},{default:a(()=>[s(se,{class:"elevation-1"},{default:a(()=>[e[14]||(e[14]=n("thead",null,[n("tr",null,[n("th",{class:"bg-gray-200"},"Campaign Name"),n("th",{class:"bg-gray-200"},"Recommended Budget Increases"),n("th",{class:"bg-gray-200"},"Conversion Increase Opportunity"),n("th",{class:"bg-gray-200"},"Approved Budget Increase")])],-1)),n("tbody",null,[(o(!0),g($,null,le(i.value,t=>(o(),g("tr",{key:t.campaign_id},[n("td",null,I(t.campaign_name),1),n("td",null,I(v(x)(t.actual_missed_budget_opportunity)),1),n("td",null,I(v(ne)(t.missed_conversion_opportunity)),1),n("td",Fe,[s(oe,{prefix:"$",modelValue:t.updated_budget_opportunity,"onUpdate:modelValue":l=>t.updated_budget_opportunity=l,"hide-details":"auto",type:"number",variant:"filled",label:"Increase Amount",rules:[l=>l<=Number(t.actual_missed_budget_opportunity)||"Cannot exceed the recommended increase"],onWheel:e[0]||(e[0]=re(()=>{},["prevent","stop"]))},null,8,["modelValue","onUpdate:modelValue","rules"])])]))),128))])]),_:1}),u.value?(o(),g("div",Ve,[n("div",Re,[s(ue,{variant:"filled",rules:v(B),required:"",label:"Time Frame For Budget Increase",modelValue:u.value.changeTimeFrame.timeFrame,"onUpdate:modelValue":e[1]||(e[1]=t=>u.value.changeTimeFrame.timeFrame=t),items:N},null,8,["rules","modelValue"]),u.value.changeTimeFrame.timeFrame==="Custom Time Frame"?(o(),b(ie,{key:0,menu:"",range:"","auto-commit":"",value:u.value.changeTimeFrame.dateRange,"display-format":"MM/DD/YYYY",min:K.value,label:"Select Date Range",variant:"filled",rules:v(B),required:"",onInput:e[2]||(e[2]=t=>u.value.changeTimeFrame.dateRange=t)},null,8,["value","min","rules"])):M("",!0)])])):M("",!0)]),_:1},8,["modelValue"])]),_:1}),s(de,{class:"flex items-center justify-end"},{default:a(()=>[n("span",null,"Total Budget Increase: "+I(v(x)(S.value)),1),s(me),s(q,{color:"error",variant:"text",onClick:Y},{default:a(()=>[...e[15]||(e[15]=[p("Cancel",-1)])]),_:1}),s(q,{color:"primary",disabled:!c.value||S.value===0,onClick:X},{default:a(()=>[...e[16]||(e[16]=[p(" Submit ",-1)])]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]),s(j,{modelValue:_.value,"onUpdate:modelValue":e[5]||(e[5]=t=>_.value=t),"max-width":"540",width:"95%",persistent:""},{default:a(()=>[s(U,null,{default:a(()=>[s(E,null,{default:a(()=>[...e[17]||(e[17]=[p("Completing Your Request",-1)])]),_:1}),s(O,null,{default:a(()=>[n("div",ke,[s(ce,{indeterminate:"",color:"primary"}),e[18]||(e[18]=n("span",{class:"pl-6"},"Please wait while your request is being processed...",-1))])]),_:1})]),_:1})]),_:1},8,["modelValue"])]))}},Te={class:"px-6 pt-6"},we={key:0,class:"mb-6 bg-red-700 text-white p-3 font-bold rounded-sm animate-pulse text-lg uppercase"},Ce={key:1},qe={__name:"DashboardBudgetInsightsClientView",props:["myClients"],setup(w){const V=w,y=f(!0),R=f(!1),k=f([]),C=f([]),B=f(L().subtract(1,"month").startOf("month").format("YYYY-MM")),A=T(()=>{var d;const i=V.myClients.map(c=>c.id);return((d=k.value)==null?void 0:d.filter(c=>{var F;return i.includes(c.id)&&((F=c.industry)==null?void 0:F.includes("Automotive"))}))||[]});async function N(i){k.value=[],V.myClients.length>0&&await he.getSEMBudgetRecommendationReport(B.value,i,V.myClients.map(d=>d.id)).then(d=>{k.value=d.data})}async function _(){await z.getAllBudgetIncreaseApprovals({month:B.value}).then(i=>{C.value=i.data})}async function u(i=!1,d=!1){y.value=!0,R.value=!1;const c=i||d;await Promise.all([N(c),_()]).catch(()=>{R.value=!0}).finally(()=>{y.value=!1})}return ye(()=>{u()}),(i,d)=>(o(),g("div",Te,[R.value?(o(),g("div",we," There was an error while getting the data. Please refresh this page and try again! ")):(o(),g("div",Ce,[s(xe,{report:A.value,budgetIncreaseApprovals:C.value,loading:y.value,onFetch:_,"report-date":B.value},null,8,["report","budgetIncreaseApprovals","loading","report-date"])]))]))}};export{qe 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.