1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[83],{41899:function(t,e,r){"use strict";var n=r(95318);e.Z=void 0;var i=n(r(64938)),o=r(85893),s=(0,i.default)((0,o.jsx)("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"}),"ContentCopy");e.Z=s},77957:function(t,e,r){"use strict";var n=r(95318);e.Z=void 0;var i=n(r(64938)),o=r(85893),s=(0,i.default)((0,o.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"}),"Edit");e.Z=s},64459:function(t,e,r){"use strict";var n=r(95318);e.Z=void 0;var i=n(r(64938)),o=r(85893),s=(0,i.default)((0,o.jsx)("path",{d:"M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z"}),"Reply");e.Z=s},66818:function(t,e,r){"use strict";var n=r(95318);e.Z=void 0;var i=n(r(64938)),o=r(85893),s=(0,i.default)((0,o.jsx)("path",{d:"M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z"}),"Save");e.Z=s},26307:function(t,e,r){"use strict";var n=r(95318);e.Z=void 0;var i=n(r(64938)),o=r(85893),s=(0,i.default)((0,o.jsx)("path",{d:"M2.01 21 23 12 2.01 3 2 10l15 2-15 2z"}),"Send");e.Z=s},69368:function(t,e,r){"use strict";r.d(e,{Z:function(){return F}});var n=r(63366),i=r(87462),o=r(67294),s=r(27192),a=r(41796),l=r(21964),d=r(82066),u=r(85893),c=(0,d.Z)((0,u.jsx)("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"}),"CheckBoxOutlineBlank"),h=(0,d.Z)((0,u.jsx)("path",{d:"M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-9 14l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"}),"CheckBox"),p=(0,d.Z)((0,u.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-2 10H7v-2h10v2z"}),"IndeterminateCheckBox"),f=r(98216),m=r(33616),v=r(90948),x=r(28979);function g(t){return(0,x.Z)("MuiCheckbox",t)}var b=(0,r(76087).Z)("MuiCheckbox",["root","checked","disabled","indeterminate","colorPrimary","colorSecondary"]);const _=["checkedIcon","color","icon","indeterminate","indeterminateIcon","inputProps","size"],y=(0,v.ZP)(l.Z,{shouldForwardProp:t=>(0,v.FO)(t)||"classes"===t,name:"MuiCheckbox",slot:"Root",overridesResolver:(t,e)=>{const{ownerState:r}=t;return[e.root,r.indeterminate&&e.indeterminate,"default"!==r.color&&e[`color${(0,f.Z)(r.color)}`]]}})((({theme:t,ownerState:e})=>(0,i.Z)({color:t.palette.text.secondary},!e.disableRipple&&{"&:hover":{backgroundColor:(0,a.Fq)("default"===e.color?t.palette.action.active:t.palette[e.color].main,t.palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:"transparent"}}},"default"!==e.color&&{[`&.${b.checked}, &.${b.indeterminate}`]:{color:t.palette[e.color].main},[`&.${b.disabled}`]:{color:t.palette.action.disabled}}))),Z=(0,u.jsx)(h,{}),j=(0,u.jsx)(c,{}),S=(0,u.jsx)(p,{});var F=o.forwardRef((function(t,e){var r,a;const l=(0,m.Z)({props:t,name:"MuiCheckbox"}),{checkedIcon:d=Z,color:c="primary",icon:h=j,indeterminate:p=!1,indeterminateIcon:v=S,inputProps:x,size:b="medium"}=l,F=(0,n.Z)(l,_),C=p?v:h,$=p?v:d,z=(0,i.Z)({},l,{color:c,indeterminate:p,size:b}),D=(t=>{const{classes:e,indeterminate:r,color:n}=t,o={root:["root",r&&"indeterminate",`color${(0,f.Z)(n)}`]},a=(0,s.Z)(o,g,e);return(0,i.Z)({},e,a)})(z);return(0,u.jsx)(y,(0,i.Z)({type:"checkbox",inputProps:(0,i.Z)({"data-indeterminate":p},x),icon:o.cloneElement(C,{fontSize:null!=(r=C.props.fontSize)?r:b}),checkedIcon:o.cloneElement($,{fontSize:null!=(a=$.props.fontSize)?a:b}),ownerState:z,ref:e},F,{classes:D}))}))},27484:function(t){t.exports=function(){"use strict";var t=1e3,e=6e4,r=36e5,n="millisecond",i="second",o="minute",s="hour",a="day",l="week",d="month",u="quarter",c="year",h="date",p="Invalid Date",f=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},x=function(t,e,r){var n=String(t);return!n||n.length>=e?t:""+Array(e+1-n.length).join(r)+t},g={s:x,z:function(t){var e=-t.utcOffset(),r=Math.abs(e),n=Math.floor(r/60),i=r%60;return(e<=0?"+":"-")+x(n,2,"0")+":"+x(i,2,"0")},m:function t(e,r){if(e.date()<r.date())return-t(r,e);var n=12*(r.year()-e.year())+(r.month()-e.month()),i=e.clone().add(n,d),o=r-i<0,s=e.clone().add(n+(o?-1:1),d);return+(-(n+(r-i)/(o?i-s:s-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:d,y:c,w:l,d:a,D:h,h:s,m:o,s:i,ms:n,Q:u}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},b="en",_={};_[b]=v;var y=function(t){return t instanceof F},Z=function t(e,r,n){var i;if(!e)return b;if("string"==typeof e){var o=e.toLowerCase();_[o]&&(i=o),r&&(_[o]=r,i=o);var s=e.split("-");if(!i&&s.length>1)return t(s[0])}else{var a=e.name;_[a]=e,i=a}return!n&&i&&(b=i),i||!n&&b},j=function(t,e){if(y(t))return t.clone();var r="object"==typeof e?e:{};return r.date=t,r.args=arguments,new F(r)}
vendor: 4,461 bytes, line 1
1,S=g;S.l=Z,S.i=y,S.w=function(t,e){return j(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var F=function(){function v(t){this.$L=Z(t.locale,null,!0),this.parse(t)}var x=v.prototype;return x.parse=function(t){this.$d=function(t){var e=t.date,r=t.utc;if(null===e)return new Date(NaN);if(S.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var n=e.match(f);if(n){var i=n[2]-1||0,o=(n[7]||"0").substring(0,3);return r?new Date(Date.UTC(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,o)):new Date(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,o)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},x.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},x.$utils=function(){return S},x.isValid=function(){return!(this.$d.toString()===p)},x.isSame=function(t,e){var r=j(t);return this.startOf(e)<=r&&r<=this.endOf(e)},x.isAfter=function(t,e){return j(t)<this.startOf(e)},x.isBefore=function(t,e){return this.endOf(e)<j(t)},x.$g=function(t,e,r){return S.u(t)?this[e]:this.set(r,t)},x.unix=function(){return Math.floor(this.valueOf()/1e3)},x.valueOf=function(){return this.$d.getTime()},x.startOf=function(t,e){var r=this,n=!!S.u(e)||e,u=S.p(t),p=function(t,e){var i=S.w(r.$u?Date.UTC(r.$y,e,t):new Date(r.$y,e,t),r);return n?i:i.endOf(a)},f=function(t,e){return S.w(r.toDate()[t].apply(r.toDate("s"),(n?[0,0,0,0]:[23,59,59,999]).slice(e)),r)},m=this.$W,v=this.$M,x=this.$D,g="set"+(this.$u?"UTC":"");switch(u){case c:return n?p(1,0):p(31,11);case d:return n?p(1,v):p(0,v+1);case l:var b=this.$locale().weekStart||0,_=(m<b?m+7:m)-b;return p(n?x-_:x+(6-_),v);case a:case h:return f(g+"Hours",0);case s:return f(g+"Minutes",1);case o:return f(g+"Seconds",2);case i:return f(g+"Milliseconds",3);default:return this.clone()}},x.endOf=function(t){return this.startOf(t,!1)},x.$set=function(t,e){var r,l=S.p(t),u="set"+(this.$u?"UTC":""),p=(r={},r[a]=u+"Date",r[h]=u+"Date",r[d]=u+"Month",r[c]=u+"FullYear",r[s]=u+"Hours",r[o]=u+"Minutes",r[i]=u+"Seconds",r[n]=u+"Milliseconds",r)[l],f=l===a?this.$D+(e-this.$W):e;if(l===d||l===c){var m=this.clone().set(h,1);m.$d[p](f),m.init(),this.$d=m.set(h,Math.min(this.$D,m.daysInMonth())).$d}else p&&this.$d[p](f);return this.init(),this},x.set=function(t,e){return this.clone().$set(t,e)},x.get=function(t){return this[S.p(t)]()},x.add=function(n,u){var h,p=this;n=Number(n);var f=S.p(u),m=function(t){var e=j(p);return S.w(e.date(e.date()+Math.round(t*n)),p)};if(f===d)return this.set(d,this.$M+n);if(f===c)return this.set(c,this.$y+n);if(f===a)return m(1);if(f===l)return m(7);var v=(h={},h[o]=e,h[s]=r,h[i]=t,h)[f]||1,x=this.$d.getTime()+n*v;return S.w(x,this)},x.subtract=function(t,e){return this.add(-1*t,e)},x.format=function(t){var e=this,r=this.$locale();if(!this.isValid())return r.invalidDate||p;var n=t||"YYYY-MM-DDTHH:mm:ssZ",i=S.z(this),o=this.$H,s=this.$m,a=this.$M,l=r.weekdays,d=r.months,u=function(t,r,i,o){return t&&(t[r]||t(e,n))||i[r].slice(0,o)},c=function(t){return S.s(o%12||12,t,"0")},h=r.meridiem||function(t,e,r){var n=t<12?"AM":"PM";return r?n.toLowerCase():n},f={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:S.s(a+1,2,"0"),MMM:u(r.monthsShort,a,d,3),MMMM:u(d,a),D:this.$D,DD:S.s(this.$D,2,"0"),d:String(this.$W),dd:u(r.weekdaysMin,this.$W,l,2),ddd:u(r.weekdaysShort,this.$W,l,3),dddd:l[this.$W],H:String(o),HH:S.s(o,2,"0"),h:c(1),hh:c(2),a:h(o,s,!0),A:h(o,s,!1),m:String(s),mm:S.s(s,2,"0"),s:String(this.$s),ss:S.s(this.$s,2,"0"),SSS:S.s(this.$ms,3,"0"),Z:i};return n.replace(m,(function(t,e){return e||f[t]||i.replace(":","")}))},x.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},x.diff=function(n,h,p){var f,m=S.p(h),v=j(n),x=(v.utcOffset()-this.utcOffset())*e,g=this-v,b=S.m(this,v);return b=(f={},f[c]=b/12,f[d]=b,f[u]=b/3,f[l]=(g-x)/6048e5,f[a]=(g-x)/864e5,f[s]=g/r,f[o]=g/e,f[i]=g/t,f)[m]||g,p?b:S.a(b)},x.daysInMonth=function(){return this.endOf(d).$D},x.$locale=function(){return _[this.$L]},x.locale=function(t,e){if(!t)return this.$L;var r=this.clone(),n=Z(t,e,!0);return n&&(r.$L=n),r},x.clone=function(){return S.w(this.$d,this)},x.toDate=function(){return new Date(this.valueOf())},x.toJSON=function(){return this.isValid()?this.toISOString():null},x.toISOString=function(){return this.$d.toISOString()},x.toString=function(){return this.$d.toUTCString()},v}
1(),C=F.prototype;return j.prototype=C,[["$ms",n],["$s",i],["$m",o],["$H",s],["$W",a],["$M",d],["$y",c],["$D",h]].forEach((function(t){C[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),j.extend=function(t,e){return t.$i||(t(e,F,j),t.$i=!0),j},j.locale=Z,j.isDayjs=y,j.unix=function(t){return j(1e3*t)},j.en=_[b],j.Ls=_,j.p={},j}()},46658:function(t,e,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/phibro/commercial-politics/rebate/[program-id]/target",function(){return r(8779)}])},8779:function(t,e,r){"use strict";r.r(e),r.d(e,{__N_SSP:function(){return et},default:function(){return rt}});var n=r(47568),i=r(26042),o=r(69396),s=r(828),a=r(29815),l=r(10092),d=r(85893),u=r(43584),c=r(87357),h=function(t){var e=t.title,r=t.type;return(0,d.jsx)(c.Z,{sx:{px:"2rem",py:"0.5rem",borderRadius:"1rem",boxShadow:"0px 4px 4px 0px rgba(0,0,0, 0.25)",background:{PENDING_SEND:"#F0F0F0",SUCCESS:"#6db33f",PENDING_APPROVAL:"#F8C300",REVIEW:"#E40000"}[r],fontSize:"0.875rem"},children:e})},p=r(41505),f=r(81347),m=r(80612),v=r(23966),x=r(17649),g=r(41899),b=r(72882),_=r(7906),y=r(53184),Z=r(53816),j=r(98102),S=r(295),F=r(83321),C=r(13970),$=r(75363),z=r(89467),D=r(67445),M=r(62714),w=r(11163),k=function(t){var e,r=t.isUpdate,n=t.months,s=t.target,a=t.setTarget,l=t.isClient,u=(0,v.aC)().user,h=(0,M.$G)("ViewGoalPlans").t,p=(0,w.useRouter)(),f=(0,D.A)(n),m=null===s||void 0===s?void 0:s.products.reduce((function(t,e){var r,n,a=t.findIndex((function(t){return t.product_id===e.product_id}));-1===a?t.push({product_id:e.product_id,product_name:e.product_name,rebateValue:null!==(n=null===(r=null===s||void 0===s?void 0:s.productsRebate.find((function(t){return t.product_id===e.product_id})))||void 0===r?void 0:r.value)&&void 0!==n?n:0,months:[{first_day_of_month:e.first_day_of_month,target:e.target}]}):t[a]=(0,o.Z)((0,i.Z)({},t[a]),{months:t[a].months.concat({first_day_of_month:e.first_day_of_month,target:e.target})});return t}),[]),x=function(t,e){a((function(r){return(0,o.Z)((0,i.Z)({},r),{productsRebate:r.productsRebate.map((function(r){return r.product_id===t?(0,o.Z)((0,i.Z)({},r),{value:e}):r}))})}))},k=function(){var t=m[0].rebateValue;m.forEach((function(e){x(e.product_id,t)}))};return(0,d.jsx)(c.Z,{sx:{width:"100%"},children:(0,d.jsx)(c.Z,{pt:3,pr:4,children:(0,d.jsx)(b.Z,{sx:{width:"100%",maxHeight:"calc(100vh - 16.75rem - 52px)",pb:2},children:(0,d.jsxs)(_.Z,{size:"small",children:[(0,d.jsx)(y.Z,{sx:{position:"sticky",top:0,zIndex:10},children:(0,d.jsxs)(Z.Z,{children:[(0,d.jsx)(j.Z,{sx:{bgcolor:"#FFFFFF",minWidth:l?"16rem":"12rem",align:"center",py:2,borderRight:l?"0.5px solid #F0F0F0":void 0,borderBottom:"0.5px solid #F0F0F0",fontSize:"0.875rem",fontWeight:"bold"},children:h("Products")}),!l&&(0,d.jsx)(j.Z,{align:"center",sx:{bgcolor:"#FFFFFF",minWidth:"7.5rem",py:2,pr:4,borderRight:"0.5px solid #F0F0F0",borderBottom:"0.5px solid #F0F0F0"},children:(0,d.jsx)(c.Z,{sx:{backgroundColor:"#e5e5e5",borderRadius:1,fontSize:"0.75rem"},children:h("Rebate")})}),n.map((function(t,e){return(0,d.jsx)(j.Z,{align:"center",sx:{bgcolor:"#FFFFFF",minWidth:"5rem",py:2,px:1,borderBottom:"0.5px solid #F0F0F0"},children:(0,d.jsx)(c.Z,{sx:{backgroundColor:"#e5e5e5",borderRadius:1,fontSize:"0.75rem"},children:(0,z.V)(new Date(t).toLocaleString(p.locale,{timeZone:"Universal",month:"short",year:"2-digit"}).replace(". de ","/").replace(" ","/"))})},e)})),["1st quarter","2nd quarter","3rd quarter","4th quarter","yearly"].map((function(t,e){return(0,d.jsx)(j.Z,{align:"center",sx:{bgcolor:"#FFFFFF",minWidth:"6rem",py:2,px:1,borderLeft:0===e?"1px solid #F0F0F0":"",borderBottom:"0.5px solid #F0F0F0"},children:(0,d.jsx)(c.Z,{sx:{backgroundColor:"primary.main",color:"secondary.contrastText",borderRadius:1,fontSize:"0.75rem"},children:h(t)})},e)}))]})}),(0,d.jsx)(S.Z,{children:null===m||void 0===m?void 0:m.map((function(t,n){return(0,d.jsxs)(Z.Z,{children:[(0,d.jsx)(j.Z,{sx:{fontSize:"0.75rem",borderRight:l?"0.5px solid #F0F0F0":"0.5px solid transparent",borderTop:"0.5px solid transparent",borderLeft:"0.5px solid transparent",borderBottom:"0.5px solid #F0F0F0",py:2},children:t.product_name}),!l&&(0,d.jsxs)(j.Z,{sx:{fontSize:"0.75rem",borderRight:"0.5px solid #F0F0F0",borderBottom:"0.5px solid #F0F0F0",minWidth:"7.5rem",py:1,pr:4,pl:0!==n?"1.7rem":0,display:"flex",alignItems:"center"},align:"center",children:[0===n&&(0,d.jsx)(F.Z,{onClick:k,disabled:"Pendente Comercial"!==(null===s||void 0===s?void 0:s.status)||(null===s||void 0===s?void 0:s.comercial_user_id
1)!==(null===u||void 0===u?void 0:u.id),size:"small",sx:{borderRadius:1,px:1.5,py:.75,mr:.5,minWidth:"1.5rem",maxWidth:"1.5rem"},children:(0,d.jsx)(g.Z,{})}),(0,d.jsx)(C.ZP,{disabled:"Pendente Comercial"!==(null===s||void 0===s?void 0:s.status)||(null===s||void 0===s?void 0:s.comercial_user_id)!==(null===u||void 0===u?void 0:u.id),sx:{border:"1px solid #707070",borderRadius:1,height:"1.5rem",fontSize:"0.75rem",px:1.5,display:"flex"},fullWidth:!0,value:t.rebateValue.toLocaleString(p.locale,{minimumFractionDigits:0,maximumFractionDigits:0}),onChange:function(e){var r=e.target.value.replace(/[^\d]/g,"")||"0";x(t.product_id,Number(r))}})]}),t.months.map((function(e){return(0,d.jsx)(j.Z,{sx:{fontSize:"0.75rem",borderBottom:"0.5px solid #F0F0F0",minWidth:"5rem",py:1,px:1},align:"center",children:(0,d.jsx)(C.ZP,{disabled:!r||"Aprovado"===(null===s||void 0===s?void 0:s.justification)&&$.phibroQuarter[(0,D.G)(new Date(e.first_day_of_month))]<=$.phibroQuarter[(0,D.G)(new Date)],sx:{border:"1px solid #707070",borderRadius:1,height:"1.5rem",fontSize:"0.75rem",px:1.5,display:"flex"},value:e.target.toLocaleString(p.locale,{minimumFractionDigits:0,maximumFractionDigits:0}),onChange:function(r){var n=r.target.value.replace(/[^\d]/g,"")||"0";!function(t,e,r){a((function(n){return(0,o.Z)((0,i.Z)({},n),{products:n.products.map((function(n){return n.product_id===t&&n.first_day_of_month===e?(0,o.Z)((0,i.Z)({},n),{target:r}):n}))})}))}(t.product_id,e.first_day_of_month,Number(n))}})},e.first_day_of_month)})),f.map((function(r,n){return(0,d.jsx)(j.Z,{align:"center",sx:function(t){return{minWidth:"6rem",py:2,color:t.palette.primary.main,fontWeight:"700",borderBottom:"0.5px solid #F0F0F0",borderLeft:0===n?"1px solid #F0F0F0":"",fontSize:"0.75rem"}},children:(0,d.jsx)(c.Z,{border:"1px solid transparent",borderRadius:1,children:r.months.reduce((function(r,n){var i;return r+(null!==(e=null===(i=t.months.find((function(t){return t.first_day_of_month===n})))||void 0===i?void 0:i.target)&&void 0!==e?e:0)}),0).toLocaleString(p.locale,{minimumFractionDigits:0,maximumFractionDigits:0})})},r.quarter)})),(0,d.jsx)(j.Z,{align:"center",sx:function(t){return{minWidth:"6rem",py:2,color:t.palette.primary.main,fontWeight:"700",borderBottom:"0.5px solid #F0F0F0",fontSize:"0.75rem"}},children:(0,d.jsx)(c.Z,{border:"1px solid transparent",borderRadius:1,children:t.months.reduce((function(t,e){return t+e.target}),0).toLocaleString(p.locale,{minimumFractionDigits:0,maximumFractionDigits:0})})})]},t.product_id)}))})]})})})})},P=r(27036),R=r(77957),W=r(17397),E=r(64459),T=r(66818),O=r(42761),L=r(26307),I=r(2734),N=r(27948),V=r(98456),H=r(94054),B=r(15861),A=r(18360),U=r(18972),Y=r(21023),G=r(46901),q=r(68061),J=r(50480),Q=r(36872),X=r(50135),K=r(67294),tt={"Pendente Envio":{type:"PENDING_SEND",title:"pendingShipping"},"Pendente Comercial":{type:"PENDING_APPROVAL",title:"commercialPending"},"Pendente Diretoria":{type:"PENDING_APPROVAL",title:"pendingBoard"},Aprovado:{type:"SUCCESS",title:"approved"},Revisar:{type:"REVIEW",title:"review"}},et=!0,rt=function(t){var e,r,g,b,_=t.programId,y=(0,M.$G)("GoalPlans").t,Z=(0,I.Z)(),j=(0,v.aC)().user,S=(0,K.useState)(),C=S[0],$=S[1],z=(0,K.useState)(),D=z[0],w=z[1],et=(0,K.useState)(),rt=et[0],nt=et[1],it=(0,K.useState)([]),ot=it[0],st=it[1],at=(0,K.useState)(""),lt=at[0],dt=at[1],ut=(0,K.useState)(""),ct=ut[0],ht=ut[1],pt=(0,K.useState)(""),ft=pt[0],mt=pt[1],vt=(0,K.useState)([]),xt=vt[0],gt=vt[1],bt=(0,K.useState)(!1),_t=bt[0],yt=bt[1],Zt=(0,K.useState)([]),jt=Zt[0],St=Zt[1],Ft=(0,K.useState)(!1),Ct=Ft[0],$t=Ft[1],zt=(0,K.useState)(!1),Dt=zt[0],Mt=zt[1],wt=(0,K.useState)(!1),kt=wt[0],Pt=wt[1],Rt=(0,K.useState)(""),Wt=Rt[0],Et=Rt[1],Tt=(0,K.useState)(""),Ot=Tt[0],Lt=Tt[1],It=null!==(g=null===(r=ot.find((function(t){var e;return(null===(e=t.profile_id)||void 0===e?void 0:e.toString())===lt})))||void 0===r?void 0:r.clients)&&void 0!==g?g:[],Nt=String(null===j||void 0===j?void 0:j.id)===ct,Vt="5"===lt,Ht=xt.reduce((function(t,r){return(e=t).concat.apply(e,(0,a.Z)(r.products))}),[]),Bt=tt[null!==(b=null===D||void 0===D?void 0:D.status)&&void 0!==b?b:"Pendente Envio"],At=function(){var t=(0,n.Z)((function(){return(0,l.__generator)(this,(function(t){return ht(""),dt(""),mt(""),Jt(),[2]}))}
1));return function(){return t.apply(this,arguments)}}(),Ut=function(){var t=(0,n.Z)((function(){return(0,l.__generator)(this,(function(t){switch(t.label){case 0:if(!D)return[3,5];$("save"),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,(0,u.MS)({user_id:D.user_id,program_id:_,products:(0,a.Z)(D.products).concat((0,a.Z)((null===rt||void 0===rt?void 0:rt.products.filter((function(t){return!D.products.find((function(e){return e.product_id===t.product_id}))})))||[])).filter((function(t){return t.target}))})];case 2:return t.sent(),Yt(),[3,5];case 3:return t.sent(),[3,5];case 4:return $(void 0),[7];case 5:return[2]}}))}));return function(){return t.apply(this,arguments)}}(),Yt=function(){var t=(0,n.Z)((function(){var t,e,r,n,s,a;return(0,l.__generator)(this,(function(l){switch(l.label){case 0:$("search"),l.label=1;case 1:return l.trys.push([1,3,4,5]),[4,(0,u.U9)({user_id:Number(ct)})];case 2:return e=l.sent()||{control_id:0,status:"Pendente Envio",user_id:Number(ct),products:[],productsRebate:[]},n=(0,o.Z)((0,i.Z)({},e),{products:Ht.reduce((function(t,r){return jt.forEach((function(n){var s,a,l=null!==(a=null===(s=e.products.find((function(t){return t.product_id===r.product_id&&t.first_day_of_month===n})))||void 0===s?void 0:s.target)&&void 0!==a?a:0;t.push((0,o.Z)((0,i.Z)({},r),{target:l,first_day_of_month:n}))})),t}),[]),productsRebate:Ht.map((function(t){var n;return{product_id:t.product_id,value:null!==(r=null===(n=e.productsRebate.find((function(e){return e.product_id===t.product_id})))||void 0===n?void 0:n.value)&&void 0!==r?r:0}}))}),s=null===(t=xt.find((function(t){return t.cluster_id.toString()===ft})))||void 0===t?void 0:t.products,nt(n),w((0,o.Z)((0,i.Z)({},n),{products:(s?n.products.filter((function(t){return s.find((function(e){return e.product_id===t.product_id}))})):n.products).filter((function(t){return Number(ct)===(null===j||void 0===j?void 0:j.id)||!!n.products.find((function(e){return e.product_id===t.product_id&&e.target}))})),productsRebate:s?n.productsRebate.filter((function(t){return s.find((function(e){return e.product_id===t.product_id}))})):n.productsRebate})),[3,5];case 3:return a=l.sent(),console.log(a),[3,5];case 4:return $(void 0),[7];case 5:return[2]}}
1))}));return function(){return t.apply(this,arguments)}}();(0,K.useEffect)((function(){j&&(0,n.Z)((function(){var t,e,r,n,i,o;return(0,l.__generator)(this,(function(a){switch(a.label){case 0:$("select"),a.label=1;case 1:return a.trys.push([1,3,4,5]),[4,Promise.all([(0,u.E1)(_),(0,u.SY)(),(0,u.ZL)()])];case 2:return t=s.Z.apply(void 0,[a.sent(),3]),e=t[0],r=t[1],n=t[2],St(function(t,e){for(var r=new Date(t),n=new Date(e),i=[],o=new Date(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate()),s=new Date(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()),a=new Date(o);a<=s;){var l=a.getFullYear(),d=("0"+(a.getMonth()+1)).slice(-2),u="".concat(l,"-").concat(d,"-").concat("01");i.push(u),a.setMonth(a.getMonth()+1)}return i}(null!==(i=null===e||void 0===e?void 0:e.start_date)&&void 0!==i?i:"",null!==(o=null===e||void 0===e?void 0:e.end_date)&&void 0!==o?o:"")),gt(r),st(n),1===n.length&&(dt(String(n[0].profile_id)),1===n[0].clients.length&&ht(String(n[0].clients[0].id))),[3,5];case 3:return a.sent(),[3,5];case 4:return $(void 0),[7];case 5:return[2]}}
1))}))()}),[j]);var Gt=function(){var t=(0,n.Z)((function(){return(0,l.__generator)(this,(function(t){switch(t.label){case 0:$t(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,(0,u.Bc)({control_id:null===D||void 0===D?void 0:D.control_id,data:{status:"Aprovado",productsRebate:(null===j||void 0===j?void 0:j.id)===(null===D||void 0===D?void 0:D.comercial_user_id)?null===D||void 0===D?void 0:D.productsRebate:void 0}})];case 2:return t.sent(),Yt(),[3,5];case 3:return t.sent(),[3,5];case 4:return $t(!1),[7];case 5:return[2]}}))}));return function(){return t.apply(this,arguments)}}(),qt=function(){var t=(0,n.Z)((function(){return(0,l.__generator)(this,(function(t){switch(t.label){case 0:Mt(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,(0,u.Bc)({control_id:null===D||void 0===D?void 0:D.control_id,data:{status:"Devolvido",justification:Wt,returnStatus:Ot}})];case 2:return t.sent(),Yt(),Et(""),Pt(!1),[3,5];case 3:return t.sent(),[3,5];case 4:return Mt(!1),[7];case 5:return[2]}}))}));return function(){return t.apply(this,arguments)}}(),Jt=function(){w(void 0),nt(void 0)};return(0,d.jsx)(m.Z,{display:"block",children:(0,d.jsxs)(c.Z,{sx:{position:"relative",flexGrow:1,display:"flex",flexFlow:"column"},children:[(0,d.jsxs)(N.Z,{sx:{flexGrow:0,flexBasis:"auto"},children:[(0,d.jsx)(f.Z,{title:y("Goals Plan"),icon:x.Z}),(0,d.jsxs)(c.Z,{display:"flex",gap:6,mt:2,alignItems:"select"===C?"center":"flex-end",mr:4,mb:1,children:["select"===C?(0,d.jsx)(V.Z,{size:14,sx:{}}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(H.Z,{size:"small",sx:{mr:2,minWidth:150},children:[(0,d.jsx)(B.Z,{variant:"body2",ml:1,gutterBottom:!0,children:y("channel")}),(0,d.jsx)(A.Z,{color:"primary",sx:{color:"grey.800",backgroundColor:"#fff",borderRadius:1,fontSize:"0.875rem","&.Mui-disabled":{backgroundColor:"grey.400"}},displayEmpty:!0,renderValue:function(t){var e;return t?ot&&(null===(e=ot.find((function(t){return t.profile_id.toString()===lt})))||void 0===e?void 0:e.profile_name):(0,d.jsx)(d.Fragment,{children:y("select")})},size:"small",SelectDisplayProps:{style:{padding:Z.spacing(.5,1.5),maxWidth:120}},MenuProps:{sx:{maxHeight:"60%"}},fullWidth:!0,disabled:!ot.length,value:lt,onChange:function(t){dt(t.target.value),ht(""),Jt()},children:ot.map((function(t){return(0,d.jsx)(U.Z,{value:String(t.profile_id),sx:function(t){return{"&.Mui-selected":{backgroundColor:t.palette.primary.main,color:t.palette.getContrastText(t.palette.primary.main),"&:hover":{backgroundColor:t.palette.secondary.main,color:t.palette.getContrastText(t.palette.secondary.main)}},"&:hover":{backgroundColor:t.palette.highlight.main,color:t.palette.getContrastText(t.palette.highlight.main)}}},children:t.profile_name},t.profile_id)}))})]}),(0,d.jsxs)(H.Z,{size:"small",sx:{mr:2,minWidth:150},children:[(0,d.jsx)(B.Z,{variant:"body2",ml:1,gutterBottom:!0,children:y("client")}),(0,d.jsx)(A.Z,{color:"primary",sx:{color:"grey.800",backgroundColor:"#fff",borderRadius:1,fontSize:"0.875rem","&.Mui-disabled":{backgroundColor:"grey.400"}},displayEmpty:!0,renderValue:function(t){var e;return t?null===(e=null===It||void 0===It?void 0:It.find((function(t){var e;return(null===(e=t.id)||void 0===e?void 0:e.toString())===ct})))||void 0===e?void 0:e.name:(0,d.jsx)(d.Fragment,{children:y("select")})},size:"small",SelectDisplayProps:{style:{padding:Z.spacing(.5,1.5),maxWidth:120}},MenuProps:{sx:{maxHeight:"60%"}},fullWidth:!0,disabled:!It.length,value:ct,onChange:function(t){ht(t.target.value)},children:It.map((function(t){return(0,d.jsx)(U.Z,{value:String(t.id),sx:function(t){return{"&.Mui-selected":{backgroundColor:t.palette.primary.main,color:t.palette.getContrastText(t.palette.primary.main),"&:hover":{backgroundColor:t.palette.secondary.main,color:t.palette.getContrastText(t.palette.secondary.main)}},"&:hover":{backgroundColor:t.palette.highlight.main,color:t.palette.getContrastText(t.palette.highlight.main)}}},children:t.name},t.id)}))})]}),Nt&&(0,d.jsxs)(H.Z,{size:"small",sx:{mr:2,minWidth:150},children:[(0,d.jsx)(B.Z,{variant:"body2",ml:1,gutterBottom:!0,children:y("Product Cluster")}),(0,d.jsx)(A.Z,{color:"primary",sx:{color:"grey.800",backgroundColor:"#fff",borderRadius:1,fontSize:"0.875rem","&.Mui-disabled":{backgroundColor:"grey.400"}},displayEmpty:!0,renderValue:function(t){var e;return t?xt&&(null===(e=xt.find((function(t){return t.cluster_id.toString()===ft})))||void 0===e?void 0:e.cluster_name):(0,d.jsx)(d.Fragment,{children:y("select")})},size:"medium",SelectDisplayProps:{style:{padding:Z.spacing(.5,1.5),maxWidth:120}},MenuProps:{sx:{maxHeight:"60%"}}
1,fullWidth:!0,disabled:!xt.length,value:ft,onChange:function(t){mt(t.target.value)},children:xt.map((function(t){return(0,d.jsx)(U.Z,{value:String(t.cluster_id),sx:function(t){return{"&.Mui-selected":{backgroundColor:t.palette.primary.main,color:t.palette.getContrastText(t.palette.primary.main),"&:hover":{backgroundColor:t.palette.secondary.main,color:t.palette.getContrastText(t.palette.secondary.main)}},"&:hover":{backgroundColor:t.palette.highlight.main,color:t.palette.getContrastText(t.palette.highlight.main)}}},children:t.cluster_name},t.cluster_id)}))})]})]}),(0,d.jsxs)(c.Z,{display:"flex",children:[(0,d.jsx)(Y.Z,{title:y("Clear filters"),children:(0,d.jsx)("span",{children:(0,d.jsx)(F.Z,{color:"highlight",variant:"contained",size:"small",sx:{borderRadius:"50%",p:.75,minWidth:"min-content"},onClick:function(){return At()},children:(0,d.jsx)(W.Z,{fontSize:"small"})})})}),(0,d.jsx)(Y.Z,{title:y("Search"),children:(0,d.jsx)("span",{children:(0,d.jsxs)(F.Z,{color:"highlight",variant:"contained",size:"small",sx:{borderRadius:"50%",p:.75,minWidth:"min-content",ml:2},disabled:"search"===C||!ct,onClick:Yt,children:[(0,d.jsx)(O.Z,{fontSize:"small"}),"search"===C&&(0,d.jsx)(V.Z,{size:14,sx:{position:"absolute",top:"25%",left:"25%"}})]})})})]})]})]}),(0,d.jsxs)(c.Z,{sx:{display:"flex",flexDirection:"column",gap:2},children:[!!D&&(0,d.jsx)(G.Z,{severity:"error",elevation:1,variant:"standard",sx:{maxWidth:"25rem",py:0,fontSize:"0.75rem",alignSelf:"end"},children:y(Nt?Vt?"Preencha os campos com os valores de SELL OUT.":"Preencha os campos com os valores de SELL IN.":"Informe o percentual de REBATE individualmente ou utilize a op\xe7\xe3o Copiar para replicar os valores.")}),!!D&&(0,d.jsxs)(c.Z,{sx:{display:"flex",alignItems:"center",justifyContent:"end",px:6},children:[(0,d.jsxs)(c.Z,{sx:{display:"flex",gap:3,alignItems:"center",fontSize:"0.875rem"},children:[y("status")," ",(0,d.jsx)(h,{type:Bt.type,title:y(Bt.title)})]}),Nt&&!!D&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(Y.Z,{title:y("edit"),children:(0,d.jsx)("span",{children:(0,d.jsx)(F.Z,{disabled:_t||"Pendente Envio"!==D.status&&"Aprovado"!==D.status,color:"highlight",variant:"contained",size:"small",sx:{borderRadius:"50%",p:1,minWidth:"min-content",ml:2},onClick:function(){yt(!0)},children:(0,d.jsx)(R.Z,{fontSize:"small"})})})}),(0,d.jsx)(Y.Z,{title:y("save"),children:(0,d.jsx)("span",{children:(0,d.jsxs)(F.Z,{color:"highlight",variant:"contained",size:"small",sx:{borderRadius:"50%",p:1,minWidth:"min-content",ml:2},disabled:"save"===C||!_t||"Pendente Envio"!==D.status&&"Aprovado"!==D.status,onClick:function(){Ut(),yt(!1)},children:[(0,d.jsx)(T.Z,{fontSize:"small"}),"save"===C&&(0,d.jsx)(V.Z,{size:14,sx:{position:"absolute",top:"25%",left:"25%"}})]})})}),(0,d.jsx)(Y.Z,{title:y("send"),children:(0,d.jsx)("span",{children:(0,d.jsxs)(F.Z,{color:"highlight",variant:"contained",size:"small",sx:{borderRadius:"50%",p:1,minWidth:"min-content",ml:2},disabled:!D.control_id||"Pendente Envio"!==D.status||Ct,onClick:Gt,children:[(0,d.jsx)(L.Z,{fontSize:"small"}),Ct&&(0,d.jsx)(V.Z,{size:14,sx:{position:"absolute",top:"25%",left:"25%"}})]})})})]}),!Nt&&!!lt&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(Y.Z,{title:y("giveBack"),children:(0,d.jsx)("span",{children:(0,d.jsx)(F.Z,{color:"warning",variant:"contained",size:"small",sx:{borderRadius:"50%",p:1,minWidth:"min-content",ml:2},disabled:D.comercial_user_id===(null===j||void 0===j?void 0:j.id)&&"Pendente Comercial"!==D.status||D.director_user_id===(null===j||void 0===j?void 0:j.id)&&"Pendente Diretoria"!==D.status,onClick:function(){return Pt(!0)},children:(0,d.jsx)(E.Z,{fontSize:"small"})})})}),(0,d.jsx)(Y.Z,{title:y("approve"),children:(0,d.jsx)("span",{children:(0,d.jsxs)(F.Z,{color:"highlight",variant:"contained",size:"small",sx:{borderRadius:"50%",p:1,minWidth:"min-content",ml:2},disabled:D.comercial_user_id===(null===j||void 0===j?void 0:j.id)&&"Pendente Comercial"!==D.status||D.director_user_id===(null===j||void 0===j?void 0:j.id)&&"Pendente Diretoria"!==D.status||Ct,onClick:Gt,children:[(0,d.jsx)(P.Z,{fontSize:"small"}),Ct&&(0,d.jsx)(V.Z,{size:14,sx:{position:"absolute",top:"25%",left:"25%"}})]})})})]})]})]}),(0,d.jsxs)(p.Z,{title:"Devolver aprova\xe7\xe3o de metas",open:kt,setOpen:Pt,PaperProps:{width:"40%",maxWidth:"600px",minWidth:"400px"},BoxProps:{display:"flex",flexDirection:"column",pt:3},children:[(null===j||void 0===j?void 0:j.id)===(null===D||void 0===D?void 0:D.director_user_id
1)&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(B.Z,{mb:2,children:"Para quem voc\xea deseja devolver o lan\xe7amento?"}),(0,d.jsx)(H.Z,{fullWidth:!0,children:(0,d.jsxs)(q.Z,{row:!0,onChange:function(t,e){return Lt(e)},value:Ot,sx:{justifyContent:"space-between",display:"flex",mb:2},children:[(0,d.jsx)(J.Z,{value:"Cliente",control:(0,d.jsx)(Q.Z,{}),label:"Cliente (necess\xe1rio corrigir valores das Metas)"}),(0,d.jsx)(J.Z,{value:"Comercial",control:(0,d.jsx)(Q.Z,{}),label:"Comercial (necess\xe1rio corrigir valores de Rebate)"})]})})]}),(0,d.jsx)(B.Z,{mb:2,children:"Informe uma justificativa"}),(0,d.jsx)(X.Z,{sx:{m:0,p:0,backgroundColor:"#fff"},placeholder:"Justificativa",variant:"outlined",margin:"normal",size:"small",type:"text",name:"title",hiddenLabel:!0,fullWidth:!0,autoFocus:!0,required:!0,multiline:!0,rows:4,value:Wt,onChange:function(t){return Et(t.target.value)}}),(0,d.jsx)(B.Z,{variant:"body2",mt:2,mb:4,children:"Ao devolver a aprova\xe7\xe3o de metas, informe uma justificativa orientando o respons\xe1vel sobre o motivo de ter sido devolvido."}),(0,d.jsxs)(F.Z,{color:"warning",variant:"contained",size:"small",sx:{alignSelf:"end",borderRadius:2,px:4},disabled:Dt||Wt.length<=2,onClick:qt,children:["Devolver",Dt&&(0,d.jsx)(V.Z,{size:14,sx:{position:"absolute",top:"25%",left:"45%"}})]})]}),(0,d.jsx)(c.Z,{mt:2,mx:-3,px:2,sx:{display:"flex",flexFlow:"column",flexGrow:1,flexBasis:"auto",bgcolor:"white"},children:D&&(0,d.jsx)(k,{isUpdate:_t,months:jt,target:D,setTarget:w,isClient:Nt})})]})})}}},function(t){t.O(0,[251,3970,8360,1664,210,3795,2055,2244,3725,135,7419,612,1988,5363,9774,2888,179],(function(){return e=46658,t(t.s=e);var e}));var e=t.O();_N_E=e}]);
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.