import{an as l,ao as h,b as t,at as m,j as a,q as r,a0 as d,B as i,a2 as p,S as x}from"./index-DlNZgIG9.js";import{f as y}from"./CrmPolicyApi-DkVQ8G4z.js";import{u as f}from"./useOrderPolicy-B_iHUtLc.js";import{f as c,S as b,M as s}from"./targetUtils-BNkxeFvE.js";const T=l(h.jsx("path",{d:"M19 5h-2V3H7v2H5c-1.1 0-2 .9-2 2v1c0 2.55 1.92 4.63 4.39 4.94.63 1.5 1.98 2.63 3.61 2.96V19H7v2h10v-2h-4v-3.1c1.63-.33 2.98-1.46 3.61-2.96C19.08 12.63 21 10.55 21 8V7c0-1.1-.9-2-2-2M5 8V7h2v3.82C5.84 10.4 5 9.3 5 8m7 6c-1.65 0-3-1.35-3-3V5h6v6c0 1.65-1.35 3-3 3m7-6c0 1.3-.84 2.4-2 2.82V7h2z"}),"EmojiEventsOutlined"),C=l(h.jsx("path",{d:"m12.36 6 .4 2H18v6h-3.36l-.4-2H7V6zM14 4H5v17h2v-7h5.6l.4 2h7V6h-5.6z"}),"FlagOutlined"),S=({embedded:v})=>{const{data:e,isLoading:g}=y(),{salesTargetRevenueLabel:u}=f(),n=(()=>{if(g)return t(m,{});if(!(e!=null&&e.hasTarget))return a(d,{variant:"outlined",sx:{p:4,textAlign:"center"},children:[t(C,{sx:{fontSize:40,color:"text.disabled"}}),t(r,{color:"text.secondary",sx:{mt:1},children:"No active target assigned for today. Your manager will assign one for the current period."})]});const o=e.status==="ACHIEVED";return a(d,{variant:"outlined",sx:{p:{xs:2,md:3}},children:[a(i,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:1},children:[a(i,{sx:{display:"flex",alignItems:"center",gap:1},children:[o&&t(T,{sx:{color:"#10b981"}}),a(r,{variant:"h6",fontWeight:700,children:["Target Period: ",c(e.periodStart)," → ",c(e.periodEnd)]})]}),t(b,{status:e.status})]}),o&&t(r,{variant:"body2",color:"success.main",sx:{mt:.5},children:"🎉 Target achieved! Keep going — extra records count as over-achievement until the period closes."}),t(p,{sx:{my:2}}),a(x,{spacing:1.5,children:[t(s,{label:"Leads Created",achieved:e.leadsCreatedAchieved,target:e.leadsCreatedTarget}),t(s,{label:"Leads Converted",achieved:e.leadsConvertedAchieved,target:e.leadsConvertedTarget}),t(s,{label:"Orders",achieved:e.ordersAchieved,target:e.orderTarget}),t(s,{label:"Product Quantity",achieved:e.productQtyAchieved,target:e.productQtyTarget}),t(s,{label:"Revenue",achieved:e.revenueAchieved,target:e.revenueTarget,money:!0,hint:u})]}),e.remarks&&a(r,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:2,fontStyle:"italic"},children:["Manager’s note: “",e.remarks,"”"]})]})})();return v?t(i,{children:n}):a(i,{sx:{p:{xs:1.5,md:3},width:"100%",maxWidth:800,mx:"auto"},children:[t(r,{variant:"h5",fontWeight:700,sx:{mb:2},children:"My Target"}),n]})};export{S as default};
