import{aq as l,ar as h,b as t,aw as u,j as a,B as i,q as r,a6 as x,S as p,a0 as o}from"./index-ktJf6c6X.js";import{e as m}from"./CrmPolicyApi-Cs-QWZcm.js";import{f as c,S as y,M as s}from"./targetUtils-DSjmN8-P.js";const f=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"),b=l(h.jsx("path",{d:"m12.36 6 .4 2H18v6h-3.36l-.4-2H7V6zM14 4H5v17h2v-7h5.6l.4 2h7V6h-5.6z"}),"FlagOutlined"),M=({embedded:v})=>{const{data:e,isLoading:g}=m(),n=(()=>{if(g)return t(u,{});if(!(e!=null&&e.hasTarget))return a(o,{variant:"outlined",sx:{p:4,textAlign:"center"},children:[t(b,{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 d=e.status==="ACHIEVED";return a(o,{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:[d&&t(f,{sx:{color:"#10b981"}}),a(r,{variant:"h6",fontWeight:700,children:["Target Period: ",c(e.periodStart)," → ",c(e.periodEnd)]})]}),t(y,{status:e.status})]}),d&&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(x,{sx:{my:2}}),a(p,{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})]}),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{M as default};
