1import{a7 as me,c as se,cC as he,cD as G,bg as H,j as e,A as _,aG as xe,a8 as L,E as fe,bY as re,cE as ge,B as W,aZ as u,o as A,b$ as R,Y as K,T as J,M as F,b as O,O as P,al as be,S as X,am as Y,cF as je,be as Ce,aI as Q,a9 as p,cG as z,I as ae,K as oe,bn as pe,as as ve,bc as le,b1 as de,b2 as ee,cH as Me,cI as w,az as De,cx as Se,bk as U,bl as q,bm as N,b5 as $,Z as ye,cJ as Ee,l as Ie,c2 as Te,cK as _e,cL as Ae,cM as ke,P as Fe}from"./index-C0j1_6-p.js";import{H as We}from"./Header-C5_ygwd9.js";import{C as Re}from"./ColoredLabel-BoaZzI6b.js";import{g as te,P as ne}from"./PriceFromat-D9fM9JHi.js";import{a as we,D as qe}from"./DataGrid-CUfiO2CX.js";import{C as ce}from"./CampaignsAutocomplete-CYGH1IUk.js";import{F as Ne}from"./FilesDropzoneButton-DVnEwN2r.js";import{D as Oe}from"./FileCopy-Gy1jdisU.js";import{D as Le}from"./DatePicker-CwJY7OnF.js";import"./index-DxOCYmLd.js";import"./Tabs-BzbU2f7N.js";import"./LastPage-CNids9YC.js";import"./TableCell-B2Hnx-yf.js";import"./debugUtils-ByMxgS5z.js";import"./HelperToolTip-BkDI-sYL.js";import"./Download-D-jRR4Ew.js";function ue({value:r,field:a,labelKey:d,intl:o,minDate:l,minDateMessage:j,onDatePickerChange:g,helperText:E,includeTime:C=!1,isStartDate:v=!1,isEndDate:D=!1,error:i,required:s=!1,hideInputLabel:h=!1,size:m,slotProps:x,...k}){const c=se(M=>{var t,n,S;return(S=(n=(t=M.account)==null?void 0:t.user)==null?void 0:n.personalization)==null?void 0:S.timeFormat}),I=he(c,!C),f=r?G(H(r),v,D):null,b=h||!d?void 0:o.formatMessage({id:d}),T={...x,field:{clearable:!0,helperText:i||E,error:!!i,required:!!s,...m?{size:m}:{},...x==null?void 0:x.field},textField:{fullWidth:!0,...m?{size:m}:{},label:b,...x==null?void 0:x.textField}},y={...k,sx:{width:"100%",...k.sx},slotProps:T,label:b,format:I,value:f,minDate:l?H(l):null};return C?e.jsx(Oe,{...y,onChange:M=>{G(M,v,D),g(M)}}):e.jsx(Le,{...y,onChange:M=>{g(G(M,v,D))}})}ue.propTypes={value:_.any,intl:_.any,field:_.string,labelKey:_.string,minDate:_.any,minDateMessage:_.string,onDatePickerChange:_.func,hideInputLabel:_.bool,size:_.string};const Ge=me(ue),Pe=P().shape({orderId:X().nullable().trim().required("Order ID is required"),campaign:P().nullable().required("Campaign is required"),orderDate:P().nullable().required("Order Date is required"),amount:Y().typeError("Amount must be a number").required("Amount is required"),estimatedAffiliateCommission:Y().typeError("Estimated commission must be a number").required("Estimated commission is required"),comment:X().nullable(),invoice:be().required("Invoice file is required").test("fileExists","Invoice file is required",r=>!!r)});function Ue({onSuccess:r=()=>{}}){var h,m,x,k,c,I;const{enqueueSnackbar:a}=xe(),d=L(),{additionalCurrencies:o,currency:l}=se(fe),j=[l==null?void 0:l.code,...o.map(f=>f.code)||[]],{register:g,handleSubmit:E,control:C,watch:v,reset:D,formState:{errors:i}}=re({resolver:ge(Pe),defaultValues:{orderId:null,campaign:null,orderDate:null,amount:null,estimatedAffiliateCommission:null,comment:null,sub1:null,sub2:null,sub3:null,invoice:null}}),s=f=>{je({...f,orderDate:Ce(f.orderDate)},f.invoice).then(()=>{Q(a,d,!0),r()}).catch(()=>{Q(a,d,!1)})};return e.jsx(W,{component:"form",onSubmit:E(s),sx:{maxWidth:600,minWidth:300},children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{item:!0,xs:12,children:e.jsx(A,{fullWidth:!0,label:"Order ID",...g("orderId"),error:!!i.orderId,helperText:(h=i.orderId)==null?void 0:h.message})}),e.jsx(u,{item:!0,xs:12,children:e.jsx(R,{name:"orderDate",control:C,render:({field:f})=>{var b;return e.jsx(Ge,{includeTime:!0,labelKey:"order_date",value:f.value,onDatePickerChange:f.onChange,error:!!i.orderDate,helperText:(b=i.orderDate)==null?void 0:b.message,...f})}})}),e.jsx(u,{item:!0,xs:12,children:e.jsx(ce,{name:"campaign",control:C,errorMessage:(m=i.campaign)==null?void 0:m.message})}),e.jsx(u,{item:!0,xs:6,children:e.jsx(R,{name:"amount",control:C,render:({field:f})=>{var b,T,y,M;return e.jsx(A,{fullWidth:!0,label:"Amount",type:"number",...f,InputProps:{endAdornment:e.jsx(K,{position:"end",children:(y=te(j.includes((b=v("campaign"))==null?void 0:b.subLabel)?(T=v("campaign"))==null?void 0:T.subLabel:l==null?void 0:l.code))==null?void 0:y.symbol})},inputProps:{step:"0.1"},error:!!i.amount,helperText:(M=i.amount)==null?void 0:M.message})}})}),e.jsx(u,{item:!0,xs:6,children:e.jsx(R,{name:"estimatedAffiliate
1Commission",control:C,render:({field:f})=>{var b,T,y,M;return e.jsx(A,{fullWidth:!0,label:"Estimated Affiliate Commission",type:"number",...f,InputProps:{endAdornment:e.jsx(K,{position:"end",children:(y=te(j.includes((b=v("campaign"))==null?void 0:b.subLabel)?(T=v("campaign"))==null?void 0:T.subLabel:l==null?void 0:l.code))==null?void 0:y.symbol})},inputProps:{step:"0.1"},error:!!i.estimatedAffiliateCommission,helperText:(M=i.estimatedAffiliateCommission)==null?void 0:M.message})}})}),e.jsx(u,{item:!0,xs:4,children:e.jsx(A,{fullWidth:!0,label:"Sub 1",...g("sub1"),error:!!i.sub1,helperText:(x=i.sub1)==null?void 0:x.message})}),e.jsx(u,{item:!0,xs:4,children:e.jsx(A,{fullWidth:!0,label:"Sub 2",...g("sub2"),error:!!i.sub2,helperText:(k=i.sub2)==null?void 0:k.message})}),e.jsx(u,{item:!0,xs:4,children:e.jsx(A,{fullWidth:!0,label:"Sub 3",...g("sub3"),error:!!i.sub3,helperText:(c=i.sub3)==null?void 0:c.message})}),e.jsx(u,{item:!0,xs:12,children:e.jsx(R,{name:"invoice",control:C,render:({field:f})=>e.jsxs(W,{display:"flex",gap:2,flexDirection:"column",children:[e.jsxs(W,{display:"flex",gap:2,children:[e.jsxs(J,{color:"textPrimary",alignSelf:"center",children:[e.jsx(F,{id:"invoice"}),":"]}),e.jsx(Ne,{multiple:!1,uploadFiles:b=>f.onChange((b==null?void 0:b[0])||null)})]}),i.invoice&&e.jsx(J,{color:"error",variant:"caption",sx:{ml:1},children:i.invoice.message})]})})}),e.jsx(u,{item:!0,xs:12,children:e.jsx(A,{fullWidth:!0,label:"Comment",multiline:!0,rows:3,...g("comment"),error:!!i.comment,helperText:(I=i.comment)==null?void 0:I.message})}),e.jsx(u,{item:!0,xs:12,children:e.jsx(O,{type:"submit",variant:"contained",fullWidth:!0,children:e.jsx(F,{id:"save"})})})]})})}function $e(r){return r.toLowerCase()}var ze=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],Ve=/[^A-Z0-9]+/gi;function Ze(r,a){a===void 0&&(a={});for(var d=a.splitRegexp,o=d===void 0?ze:d,l=a.stripRegexp,j=l===void 0?Ve:l,g=a.transform,E=g===void 0?$e:g,C=a.delimiter,v=C===void 0?" ":C,D=ie(ie(r,o,"$1\0$2"),j,"\0"),i=0,s=D.length;D.charAt(i)==="\0";)i++;for(;D.charAt(s-1)==="\0";)s--;return D.slice(i,s).split("\0").map(E).join(v)}function ie(r,a,d){return a instanceof RegExp?r.replace(a,d):a.reduce(function(o,l){return o.replace(l,d)},r)}var V=function(){return V=Object.assign||function(a){for(var d,o=1,l=arguments.length;o<l;o++){d=arguments[o];for(var j in d)Object.prototype.hasOwnProperty.call(d,j)&&(a[j]=d[j])}return a},V.apply(this,arguments)};function Be(r){return r.charAt(0).toUpperCase()+r.substr(1)}function He(r){return Be(r.toLowerCase())}function Ke(r,a){return a===void 0&&(a={}),Ze(r,V({delimiter:" ",transform:He},a))}function Je({onSubmitFilters:r=()=>{}}){const{handleSubmit:a,control:d,watch:o,setValue:l,reset:j}=re({defaultValues:{query:"",status:null,orderDateStart:null,orderDateEnd:null,creationDateStart:null,creationDateEnd:null,campaigns:[]}}),g=L(),E=s=>{const h={...s,orderDateStart:w(s.orderDateStart),orderDateEnd:w(s.orderDateEnd),creationDateStart:w(s.creationDateStart),creationDateEnd:w(s.creationDateEnd),campaigns:Me(s.campaigns)};console.log(h),r(h)},C=(s,h,m)=>{const x=s();l(h,x==null?void 0:x[0]),l(m,x==null?void 0:x[1])},v=s=>{C(s,"orderDateStart","orderDateEnd")},D=s=>{C(s,"creationDateStart","creationDateEnd")},i=p.useMemo(()=>Object.values(z).map(s=>({label:Ke(s.key),value:s.key.toUpperCase()})),[]);return e.jsx(ae,{children:e.jsx("form",{onSubmit:a(E),children:e.jsx(oe,{sx:{p:2},children:e.jsxs(u,{container:!0,spacing:2,children:[e.jsx(u,{item:!0,xl:12/5,md:4,xs:6,children:e.jsx(pe,{control:d,placeholder:g.formatMessage({id:"order_id"}),width:"100%"})}),e.jsx(u,{item:!0,xl:12/5,md:4,xs:6,children:e.jsx(R,{name:"status",control:d,render:({field:s})=>e.jsx(ve,{options:i,getOptionLabel:h=>h.label,isOptionEqualToValue:(h,m)=>h.value===(m==null?void 0:m.value),value:i.find(h=>h.value===s.value)||null,onChange:(h,m)=>s.onChange((m==null?void 0:m.value)||null),renderInput:h=>e.jsx(A,{...h,label:g.formatMessage({id:"status"})})})})}),e.jsx(le,{scope:de.AFFILIATE_CAMPAIGN.value,children:e.jsx(u,{item:!0,xl:12/5,md:4,xs:6,children:e.jsx(ce,{multiple:!0,name:"campaigns",control:d})})}),e.jsx(u,{item:!0,xl:12/5,xs:6,children:e.jsx(ee,{wide:!0,value:[o("orderDateStart"),o("orderDateEnd")],label:g.formatMessage({id:"order_date"}),setValue:v})}),e.jsx(u,{item:!0,xl:12/5,xs:6,children:e.jsx(ee,{wide:!0,value:[o("creationDateStart"),o("creationDateEnd")],label:g.formatMessage({id:"creation_date"}),setValue:D})}),e.jsx(u,{item:!0,xs:12,children:e.jsxs(W,{display:"flex",width:"100%",gap:2,justifyContent:"flex-end",children:[e.jsx(O,{variant:"outlined",color:"primary",onClick:()=>j(),children:e.jsx(F,{id:"clear_filters"})}),e.jsx(O,{type:"submit",color:"primary",variant:"contained",children:e.jsx(F,{id:"filter",defaultMessage:"Filter"})})]})})]})})})})}function Xe(r,a){const[d,o]=p.useState(!1),[l,j]=p.useState(!0),[g,E]=p.useState([]),[C,v]=p.useState(null),[D,i]=p.useState(0),[s,h]=p.useState({page:0,pageSize:10}),[m,x]=p.useState([{sort:"desc",field:"requestCreationDate"}]),k=De(),c=L(),I=t=>{j(!0),Ae(s,m,t??C).then(n=>{E((n==null?void 0:n.content)??[]),i((n==null?void 0:n.totalElements)??0)}).finally(()=>{j(!1),t&&v(t)})},f=()=>{o(!0)},b=()=>{o(!1)},T=()=>{I(),b()},y=t=>{k({title:e.jsx(F,{id:"confirmation"}
1),showCancel:!0,customApproveText:"ok",message:e.jsx(F,{id:"are_you_sure_you_want_to_resolve"})}).then(n=>n&&ke(t).then(()=>{I()}))};p.useImperativeHandle(a,()=>({handleCreationModalOpen:()=>f})),p.useEffect(()=>{I()},[s,m]);const M=p.useMemo(()=>[{field:"orderId",headerName:c.formatMessage({id:"order_id"}),flex:1,minWidth:200},{field:"status",headerName:c.formatMessage({id:"status"}),minWidth:150,renderCell:t=>{var n,S,Z;return e.jsxs(W,{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",gap:2,children:[e.jsx(Re,{color:(n=Se[t==null?void 0:t.value])==null?void 0:n.color,children:c.formatMessage({id:(S=t==null?void 0:t.value)==null?void 0:S.toLowerCase()})}),(t==null?void 0:t.value)===z.DECLINED.key.toUpperCase()&&e.jsx(U,{sx:{cursor:"help"},title:(Z=t==null?void 0:t.row)==null?void 0:Z.adminResponse,children:e.jsx(q,{icon:N.actions.chatHelp})}),(t==null?void 0:t.value)===z.APPROVED.key.toUpperCase()&&e.jsx(U,{sx:{cursor:"pointer"},title:c.formatMessage({id:"linked_conversion"}),children:e.jsx(q,{onClick:()=>{var B;return window.open(`/app/affiliate/statistics/conversions?missingConversionId=${(B=t==null?void 0:t.row)==null?void 0:B.id}`,"_blank")},icon:N.actions.openInNewTab})})]})}},{field:"amount",headerName:c.formatMessage({id:"amount"}),minWidth:80,renderCell:t=>{var n,S;return e.jsx(ne,{value:(t==null?void 0:t.value)??0,currency:(S=(n=t.row)==null?void 0:n.currency)==null?void 0:S.code})}},{field:"estimatedAffiliateCommission",headerName:c.formatMessage({id:"estimated_commission"}),minWidth:80,renderCell:t=>{var n,S;return e.jsx(ne,{value:(t==null?void 0:t.value)??0,currency:(S=(n=t.row)==null?void 0:n.currency)==null?void 0:S.code})}},{field:"orderDate",headerName:c.formatMessage({id:"order_date"}),minWidth:200,valueGetter:t=>$(t==null?void 0:t.value)},{field:"requestCreationDate",headerName:c.formatMessage({id:"creation_date"}),minWidth:200,valueGetter:t=>$(t==null?void 0:t.value)},{field:"requestProcessDate",headerName:c.formatMessage({id:"proccessed_date"}),minWidth:200,valueGetter:t=>t!=null&&t.value?$(t==null?void 0:t.value):null},{field:"campaign",headerName:c.formatMessage({id:"campaign"}),minWidth:200,valueGetter:t=>{var n;return(n=t==null?void 0:t.value)==null?void 0:n.label}},{field:"comment",headerName:c.formatMessage({id:"comment"}),minWidth:100,sortable:!1},{field:"sub1",headerName:c.formatMessage({id:"sub1"}),minWidth:100},{field:"sub2",headerName:c.formatMessage({id:"sub2"}),minWidth:100},{field:"sub3",headerName:c.formatMessage({id:"sub3"}),minWidth:100},{field:"attachedInvoice",headerName:c.formatMessage({id:"invoice"}),minWidth:80,renderCell:t=>(t==null?void 0:t.value)&&e.jsx(U,{title:"Download",children:e.jsx(ye,{onClick:()=>{var n;return Ee(`${Ie.attachmentActions.downloadDoc((n=t==null?void 0:t.value)==null?void 0:n.id)}`)},edge:"end",size:"large",children:e.jsx(q,{icon:N.actions.download})})})},{field:"actions",type:"actions",headerName:c.formatMessage({id:"actions"}),width:100,getActions:({id:t,row:n})=>[e.jsx(we,{id:n==null?void 0:n.id,icon:e.jsx(q,{icon:N.actions.check}),label:c.formatMessage({id:"mark_as_resolved"}),onClick:()=>y(n==null?void 0:n.id),showInMenu:!0})]}],[c]);return e.jsxs(e.Fragment,{children:[e.jsx(Je,{onSubmitFilters:I}),e.jsx("br",{}),e.jsx(ae,{children:e.jsx(oe,{sx:{p:1},children:e.jsx(qe,{rows:g,columns:M,pagination:!0,paginationModel:s,paginationMode:"server",onPaginationModelChange:h,sortModel:m,onSortModelChange:x,sortingMode:"server",getRowId:t=>t==null?void 0:t.id,rowCount:D,loading:l})})}),e.jsx(Te,{open:d,onClose:b,children:e.jsx(W,{sx:_e,children:e.jsx(Ue,{onSuccess:T})})})]})}const Ye=p.forwardRef(Xe);function ft(){const[r,a]=p.useState(!1),d=L(),o=p.useRef();p.useEffect(()=>{o.current&&a(!0)},[o]);const l=p.useCallback(()=>{var j;return e.jsx(O,{loading:!r,onClick:(j=o==null?void 0:o.current)==null?void 0:j.handleCreationModalOpen(),variant:"contained",children:e.jsx(F,{id:"create"})})},[o,r]);return e.jsx(le,{scope:de.MISSING_CONVERSIONS.value,children:e.jsx(Fe,{title:d.formatMessage({id:"missing_conversions"}),children:e.jsxs(u,{container:!0,spacing:3,children:[e.jsx(u,{item:!0,xs:12,children:e.jsx(We,{title:"missing_conversions",subComponent:l,breadcrumbs:[{title:"dashboard",link:"/"},{title:"reports",link:""}]})}),e.jsx(u,{item:!0,xs:12,children:e.jsx(Ye,{ref:o})})]})})})}export{ft 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.