PageSourceSearch

https://e-commerce.admoji.com/_next/static/chunks/pages/campaigns/edit-campaign-aeb9c7bd99f8114d.js

js admoji.com collected 2026-10-06 19:59:40 UTC 66,453 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5726],{41030:function(e,t,l){(window.__NEXT_P=window.__NEXT_P||[]).push(["/campaigns/edit-campaign",function(){return l(14505)}])},14505:function(e,t,l){"use strict";l.r(t),l.d(t,{default:function(){return eH}});var a=l(97458),s=l(52983),i=l(39648),r=l.n(i),n=l(75413),o=l(72371),c=l(99456),u=l(43314),d=l(14912),m=l(93747),p=l(25132),h=l(39837),g=l(44557),v=l(9682),f=l(71884),x=l(69413),j=l(494),b=l(9344),y=l(36972),S=l(54676),C=l(28460),k=l(55253),D=l(36469),w=l(35683),z=l(84703),P=e=>{var t,l,s;let{isEdit:i}=e,{control:r,setValue:o,formState:{errors:c}}=(0,S.Gc)(),{query:d}=(0,n.useRouter)(),{data:m}=p.f.useGetCampaignAffiliates(Number(d.id)),g=(0,k.MW)(null==m?void 0:m.Affiliates);return(0,a.jsx)(u.K,{children:(0,a.jsxs)(w.M,{cols:1,spacing:16,children:[!i&&(0,a.jsx)(h.zE,{searchable:!1,name:"AffiliateID",label:"Affiliate",placeholder:"Choose",data:g,setValue:o,control:r,error:null===(t=c.AffiliateID)||void 0===t?void 0:t.message}),(0,a.jsx)(h.hZ,{name:"Step1Comm",label:"Step1 Commission",placeholder:"Value",control:r,error:null===(l=c.Step1Comm)||void 0===l?void 0:l.message,icon:z.Z}),(0,a.jsx)(h.hZ,{name:"Step2Comm",label:"Step2 Commission",placeholder:"Value",control:r,error:null===(s=c.Step2Comm)||void 0===s?void 0:s.message,icon:z.Z})]})})},E=l(4601),I=l(44048);let R=(e,t)=>{let l=null==t?void 0:t.find(t=>t.id===e);return l?l.name:null},A=(e,t)=>{var l;return null!==(l=null==t?void 0:t.find(t=>t.id===e))&&void 0!==l?l:null},N=e=>{let{onDelete:t,onEdit:l}=e;return[{id:"name",accessorKey:"name",header:()=>(0,a.jsx)(h.Nq,{label:"Name"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),isTitle:!0}),filterFn:k.bm.fuzzyFilter},{id:"Step1Comm",accessorKey:"Step1Comm",header:()=>(0,a.jsx)(h.Nq,{label:"Step1 Commission"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"currency"}),filterFn:k.bm.fuzzyFilter},{id:"Step2Comm",accessorKey:"Step2Comm",header:()=>(0,a.jsx)(h.Nq,{label:"Step2 Commission"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"currency"}),filterFn:k.bm.fuzzyFilter},{id:"DateEnteredUtc",accessorKey:"DateEnteredUtc",header:()=>(0,a.jsx)(h.Nq,{label:"Active"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"date"}),filterFn:k.bm.fuzzyFilter},{id:"Action",accessorKey:"Action",header:()=>(0,a.jsx)(h.Nq,{label:"Actions"}),enableSorting:!1,cell:e=>{let{row:s}=e;return(0,a.jsx)(h.pj,{value:null,children:(0,a.jsxs)(m.Z,{gap:8,w:"100%",wrap:"nowrap",children:[(0,a.jsx)(h.ps,{icon:(0,a.jsx)(E.Z,{}),onClick:l,payload:s.original.id}),(0,a.jsx)(h.ps,{icon:(0,a.jsx)(I.Z,{}),onClick:t,payload:s.original.id})]})})}}]};var T=()=>{var e;let[t,l]=(0,s.useState)(""),[i,r]=(0,s.useState)([]),[o,c]=(0,s.useState)({type:null}),[d]=(0,j.c)(t,500),g=(0,s.useRef)(null),{isDarkTheme:v}=(0,C.e5)(),{query:w}=(0,n.useRouter)(),z=Number(w.id),E=(e,t)=>c({type:e,id:t}),{data:I,isFetching:T}=p.f.useGetAffiliates(z),{mutate:M,isPending:F}=p.f.useCreateAffiliate(z),{mutate:Z,isPending:_}=p.f.useUpdateAffiliate(z),{mutate:U}=p.f.useDeleteAffiliate(z),q=(0,S.cI)({resolver:(0,b.F)(D.qZU),mode:"onChange",defaultValues:{SiteID:z}}),V=N({onDelete:e=>{k.Q_.confirmAction({title:"Delete Affiliate",description:"You will not be able to revert this! Are you sure?",onConfirm:()=>{U(e,{onSuccess:()=>{k.Z0.handleSuccessResponse("Affiliate deleted successfully")},onError:e=>(0,k.S3)(e)})}})},onEdit:e=>{let t=A(e,null==I?void 0:I.Affiliates);t&&(["Step1Comm","Step2Comm"].forEach(e=>{q.setValue(e,t[e].toString())}),q.setValue("AffiliateID",t.id.toString()),E("edit",e))}}),K=()=>{E(null),q.reset()},G=(0,s.useMemo)(()=>R(o.id,null==I?void 0:I.Affiliates),[o.id,null==I?void 0:I.Affiliates]);return(0,a.jsxs)(S.RV,{...q,children:[(0,a.jsxs)(u.K,{gap:24,h:"100%",children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:v?"gray.1":"gray.10",tt:"capitalize",children:"Affiliates"}),(0,a.jsxs)(m.Z,{gap:12,children:[(0,a.jsx)(h.f$,{search:t,setSearch:l}),(0,a.jsx)(x.z,{variant:"subtle",size:"sm",onClick:()=>{E("add"),q.reset()},leftSection:(0,a.jsx)(y.Z,{width:24,height:24}),children:"New"})]})]}),(0,a.jsx)(h.iA,{data:k.bm.transformTableDates((null==I?void 0:I.Affiliates)||[],["DateEnteredUtc"]),columns:V,sorting:i,onSortingChange:r,globalFilter:d,setGlobalFilter:l,dataCount:null==I?void 0:null===(e=I.Aff
1iliates)||void 0===e?void 0:e.length,horizontalSpacing:"xs",verticalSpacing:"12px",striped:"even",withRowBorders:!0,ref:g,isLoading:T})]}),o.type&&(0,a.jsx)(h.Cp,{opened:!0,onClose:K,title:"add"===o.type?"Add Affiliate":"Edit Affiliate ".concat(G),children:(0,a.jsxs)("form",{onSubmit:q.handleSubmit(e=>{let t="add"===o.type;(t?M:Z)(e,{onSuccess:()=>{k.Z0.handleSuccessResponse("Affiliate ".concat(t?"created":"updated"," successfully")),E(null),q.reset()},onError:e=>(0,k.S3)(e)})}),children:[(0,a.jsx)(P,{isEdit:"edit"===o.type}),(0,a.jsxs)(m.Z,{w:"100%",mt:18,gap:8,justify:"flex-end",wrap:"nowrap",children:[(0,a.jsx)(x.z,{variant:"outline",onClick:K,children:"Close"}),(0,a.jsx)(x.z,{type:"submit",loading:F||_,children:"Save"})]})]})})]})},M=l(48981),F=l(74014),Z=e=>{var t;let{processingFilterOptions:l}=e,{control:i,setValue:r,watch:n,formState:{errors:o}}=(0,S.Gc)(),c=n("BlockPrepaid");return(0,s.useEffect)(()=>{c!==F.WyZ.ProcessingFilter&&r("PrepaidSiteID",null)},[c,r]),(0,a.jsxs)(u.K,{w:"60%",maw:1e3,children:[(0,a.jsx)(h.us,{labelPosition:"right",name:"BlockTest",label:"Block Test Cards",control:i}),(0,a.jsx)(h.us,{labelPosition:"right",name:"BlockDebit",label:"Block Debit Cards",control:i}),(0,a.jsx)(h.us,{labelPosition:"right",name:"BlockMasterCard",label:"Block Master Cards",control:i}),(0,a.jsx)(h.ez,{name:"BlockPrepaid",control:i,label:"Block Prepaids",children:(0,a.jsxs)(m.Z,{wrap:"nowrap",gap:18,children:[(0,a.jsx)(M.Y,{value:F.WyZ.Yes,label:"Yes"}),(0,a.jsx)(M.Y,{value:F.WyZ.ProcessingFilter,label:"Processing Filter"}),(0,a.jsx)(M.Y,{value:F.WyZ.No,label:"No"})]})}),"processingFilter"===c&&(0,a.jsx)(h.zE,{name:"PrepaidSiteID",label:"Processing Filter",searchable:!1,placeholder:"Choose",data:l,setValue:r,control:i,error:null===(t=o.PrepaidSiteID)||void 0===t?void 0:t.message})]})};let _=e=>!0===e?F.WyZ.Yes:null===e?F.WyZ.ProcessingFilter:F.WyZ.No;var U=()=>{let{isDarkTheme:e}=(0,C.e5)(),{query:t}=(0,n.useRouter)(),{data:l}=p.f.useCommonSiteList(),{data:i,isLoading:r}=p.f.useGetBinManagement(Number(t.id)),{mutate:d}=p.f.useUpdateBinManagement(Number(t.id)),h=(0,S.cI)({resolver:(0,b.F)(D.xb4),mode:"onChange"});(0,s.useEffect)(()=>{var e;if(!i)return;let{Result:l}=i;Object.entries({SiteID:Number(t.id),BlockDebit:l.BlockDebit,BlockMasterCard:l.BlockMasterCard,BlockTest:l.BlockTest,BlockPrepaid:_(l.BlockPrepaid),PrepaidSiteID:null===(e=l.PrepaidSiteID)||void 0===e?void 0:e.toString()}).forEach(e=>{let[t,l]=e;return h.setValue(t,l)})},[i,h]);let g=(0,k.MW)(null==l?void 0:l.Sites,{showId:!0});return r?(0,a.jsx)(o.M,{h:"30vh",children:(0,a.jsx)(c.a,{})}):(0,a.jsx)(S.RV,{...h,children:(0,a.jsxs)(u.K,{component:"form",gap:24,h:"100%",onSubmit:h.handleSubmit(e=>{d(e,{onSuccess:()=>{k.Z0.handleSuccessResponse("Campaign bin management updated successfully")},onError:e=>(0,k.S3)(e)})}),children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:e?"gray.1":"gray.10",tt:"capitalize",children:"BIN Management"}),(0,a.jsx)(x.z,{type:"submit",variant:"light",children:"Save"})]}),(0,a.jsx)(Z,{processingFilterOptions:g})]})})},q=l(87044),V=l(31294),K=l(58758),G=()=>{var e,t,l,i,r,o,c,d,g,f,j,b,y,C;let{query:D}=(0,n.useRouter)(),{control:w,setValue:P,watch:E,clearErrors:I,formState:{errors:R}}=(0,S.Gc)(),{data:A}=K.U.useGetProducts(Number(D.id)),{data:N,isFetching:T,refetch:Z}=p.f.useGenerateCode(),_=(0,k.MW)((null==A?void 0:A.Products)||[]),U=E("DiscountType");return(0,s.useEffect)(()=>{N&&(P("Code",N.Result.Code),I("Code"))},[N]),(0,a.jsxs)(u.K,{w:"70%",maw:1e3,children:[(0,a.jsx)(h.HS,{name:"Code",label:(0,a.jsxs)(m.Z,{justify:"space-between",w:"100%",children:[(0,a.jsx)(q.x,{children:"Coupon Code"}),(0,a.jsx)(x.z,{variant:"subtle",onClick:()=>{Z()},loading:T,children:"Generate Code"})]}),placeholder:"Coupon Code",control:w,error:null===(e=R.Code)||void 0===e?void 0:e.message}),(0,a.jsx)(h.zE,{name:"DiscountType",label:"Discount Type",placeholder:"Choose",searchable:!1,data:v.mwc,setValue:P,control:w,error:null===(t=R.DiscountType)||void 0===t?void 0:t.message}),(0,a.jsx)(h.zE,{name:"ChargeID",label:"Product",labelTooltip:"Leave blank to apply to the whole order",placeholder:"Choose",searchable:!1,data:_,setValue:P,control:w,error:null===(l=R.ChargeID)||void 0===l?void 0:l.message}),E("ChargeID")&&(0,a.jsx)(h.us,{control:w,name:"IsRecurring",label:"Recurring Coupon",labelPosition:"right",tooltip:"Recurring coupons will be disabled for whole orders. Please select a product if you want to use recurring coupons"}),(0,a.jsx)(h.hZ,{name:"Discount",label:"Discount",placeholder:"Value",control:w,type:"number",error:null===(i=R.Discount)||void 0===i?void 0:i.message,icon:U===v.mwc[0].value?V.Z:z.Z}),E("IsRecurring")&&E("ChargeID")&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.hZ,{name:"RecurringDiscount",label:"Recurring Discount",placeholder:"Value",control:w,error:null===(r=R.RecurringDiscount)||void 0===r?void 0:r.message,icon:U===v.mwc[0].value?V.Z:z.Z}),(0,a.jsx)(h.HS,{label:"Max Cycles (optional)",name:"MaxCycles",control:w,error:null===(o=R.MaxCycles)||void 0===o?void 0:o.message})]}),(0,a.jsx)(h.wM,{name:"StartDateUtc",label:"Start Date",allowDeselect:!0,maxDate:void 0,placeholder:"Choose a date",control:w,error:null===(c=R.StartDateUtc)||void 0===c?void 0:c.message}),(0,a.jsx)(h.qZ,{name:"StartTime",label:"Start Time",placeholder:"HH:MM",control:w,error:null===(d=R.StartTime)||void 0===d?void 0:d.message}),(0,a.jsx)(h.us,{control:w,name:"IsEndDate",label:"Set End Date",labelPosition:"right"}),E("IsEndDate")&&(0,a.jsxs)(u.K,{children:[(0,a.jsx)(h.wM,{name:"EndDateUtc",label:"End Date",allowDeselect:!0,maxDate:void 0,placeholder:"Choose a date",control:w,error:null===(g=R.EndDateUtc)||void 0===g?void 0:g.message}),(0,a.jsx)(h.qZ,{name:"EndTime",label:"End Time",placeholder:"HH:MM",control:w,error:null===(f=R.EndTime)||void 0===f?void 0:f.message})]}),(0,a.jsx)(h.ez,{name:"MinRequirementsType",control:w,label:"Minimum requirements",children:(0,a.jsxs)(m.Z,{wrap:"nowrap",gap:18,children:[(0,a.jsx)(M.Y,{value:F.cHn.NONE,label:"No"}),(0,a.jsx)(M.Y,{value:F.cHn.AMOUNT,label:"Minimum purchase amount"}),(0,a.jsx)(M.Y,{value:F.cHn.ITEMS_COUNT,label:"Minimum quantity of items"})]})}),E("MinRequirementsType")===F.cHn.AMOUNT&&(0,a.jsx)(h.hZ,{label:"",name:"MinAmount",placeholder:"Value",control:w,error:null===(j=R.MinAmount)||void 0===j?void 0:j.message,icon:z.Z}),E("MinRequirementsType")===F.cHn.ITEMS_COUNT&&(0,a.jsx)(h.HS,{label:"",placeholder:"Enter minimum quantity",name:"MinItemsCount",control:w,error:null===(b=R.MinItemsCount)||void 0===b?void 0:b.message}),(0,a.jsx)(h.us,{control:w,name:"WithTotalUsageLimit",label:"Limit number of times this discount can be used in total",labelPosition:"right",error:null===(y=R.WithTotalUsageLimit)||void 0===y?void 0:y.message}),E("WithTotalUsageLimit")&&(0,a.jsx)(h.HS,{label:"",name:"TotalUsageLimit",control:w,error:null===(C=R.TotalUsageLimit)||void 0===C?void 0:C.message}),(0,a.jsx)(h.us,{control:w,name:"IsOnePerCustomer",label:"Limit to one use per customer",labelPosition:"right"})]})};let L=e=>({SiteID:e,DiscountType:v.mwc[0].value,MinRequirementsType:F.cHn.NONE,IsOnePerCustomer:!1,IsRecurring:!1,ChargeID:null,StartDateUtc:null,IsFlat:!1});var O=e=>{let{onCancel:t,id:l}=e,{isDarkTheme:i}=(0,C.e5)(),{query:r}=(0,n.useRouter)(),o=(0,S.cI)({resolver:(0,b.F)(D.dJL),mode:"onChange",defaultValues:L(Number(r.id))}),{data:c}=p.f.useGetCoupon(Number(r.id),l),{mutate:d}=l?p.f.useUpdateCoupon(Number(r.id)):p.f.useCreateCoupon(Number(r.id));return(0,s.useEffect)(()=>
1{if(l&&c){var e,t,a,s,i,r,n;Object.entries({Code:c.Result.Code,CouponType:c.Result.CouponType,ChargeID:null!==(n=null===(e=c.Result.ChargeID)||void 0===e?void 0:e.toString())&&void 0!==n?n:null,IsRecurring:c.Result.IsRecurring,DiscountType:c.Result.IsFlat?v.mwc[1].value:v.mwc[0].value,Discount:c.Result.Discount.toString(),RecurringDiscount:null===(t=c.Result.RecurringDiscount)||void 0===t?void 0:t.toString(),IsFlat:c.Result.IsFlat,IsOnePerCustomer:c.Result.IsOnePerCustomer,TotalUsageLimit:null===(a=c.Result.TotalUsageLimit)||void 0===a?void 0:a.toString(),MaxCycles:null===(s=c.Result.MaxCycles)||void 0===s?void 0:s.toString(),StartDateUtc:c.Result.StartDateUtc?new Date(1e3*c.Result.StartDateUtc):null,EndDateUtc:c.Result.EndDateUtc?new Date(1e3*c.Result.EndDateUtc):null,IsEndDate:!!c.Result.EndDateUtc,MinRequirementsType:c.Result.MinRequirementsType,MinItemsCount:c.Result.MinRequirementsType===F.cHn.ITEMS_COUNT?null===(i=c.Result.MinRequirements)||void 0===i?void 0:i.toString():null,MinAmount:c.Result.MinRequirementsType===F.cHn.AMOUNT?null===(r=c.Result.MinRequirements)||void 0===r?void 0:r.toString():null,WithTotalUsageLimit:!!c.Result.TotalUsageLimit}).forEach(e=>{let[t,l]=e;o.setValue(t,l)})}l||o.setValue("Code","")},[l,c,o]),(0,a.jsx)(S.RV,{...o,children:(0,a.jsxs)(u.K,{component:"form",h:"100%",onSubmit:o.handleSubmit(e=>{d(l?{...e,CouponID:l}:e,{onSuccess:()=>{k.Z0.handleSuccessResponse(l?"Coupon updated successfully":"Coupon created successfully",t)},onError:e=>(0,k.S3)(e)})}),children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:i?"gray.1":"gray.10",children:l?"Edit Coupon":"Add Coupon"}),(0,a.jsxs)(m.Z,{children:[(0,a.jsx)(x.z,{variant:"subtle",onClick:t,children:"Back"}),(0,a.jsx)(x.z,{variant:"light",type:"submit",children:"Save"})]})]}),(0,a.jsx)(G,{})]})})},H=l(7257),W=(0,l(23390).Z)("outline","power","IconPower",[["path",{d:"M7 6a7.75 7.75 0 1 0 10 0",key:"svg-0"}],["path",{d:"M12 4l0 8",key:"svg-1"}]]);let B=e=>{let{onDelete:t,onDeactivate:l,onActivate:s,onEdit:i}=e;return[{id:"Code",accessorKey:"Code",header:()=>(0,a.jsx)(h.Nq,{label:"Code"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),isTitle:!0}),filterFn:k.bm.fuzzyFilter},{id:"Discount",accessorKey:"Discount",header:()=>(0,a.jsx)(h.Nq,{label:"Discount"}),cell:e=>{let{row:t}=e,l=t.original.IsFlat?t.original.Discount:t.original.Discount/100,s=t.original.IsFlat?"currency":"percent";return(0,a.jsx)(h.pj,{value:l,format:s})},filterFn:k.bm.fuzzyFilter},{id:"Product",accessorKey:"Product",header:()=>(0,a.jsx)(h.Nq,{label:"Product"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue()}),filterFn:k.bm.fuzzyFilter},{id:"IsActive",accessorKey:"IsActive",header:()=>(0,a.jsx)(h.Nq,{label:"Status"}),cell:e=>(0,a.jsx)(h.pj,{value:null,format:"string",children:(0,a.jsx)(h.OE,{status:Number(e.getValue())})}),filterFn:k.bm.fuzzyFilter},{id:"Action",accessorKey:"Action",header:()=>(0,a.jsx)(h.Nq,{label:"Actions"}),enableSorting:!1,cell:e=>{let{row:r}=e;return(0,a.jsx)(h.pj,{value:null,children:(0,a.jsxs)(m.Z,{gap:8,w:"100%",wrap:"nowrap",children:[(0,a.jsx)(h.ps,{icon:(0,a.jsx)(E.Z,{}),onClick:i,payload:r.original.id}),(0,a.jsx)(h.ps,{icon:(0,a.jsx)(I.Z,{}),onClick:t,payload:r.original.id}),(0,a.jsx)(h.ps,{icon:(0,a.jsx)(W,{}),onClick:r.original.IsActive?l:s,payload:r.original.id})]})})}}]};var $=e=>{let{onAddCoupon:t,onEditCoupon:l}=e,[i,r]=(0,s.useState)(!1),[o,c]=(0,s.useState)(""),[d,g]=(0,s.useState)([]),[v]=(0,j.c)(o,500),{query:b}=(0,n.useRouter)(),S=(0,s.useRef)(null),{isDarkTheme:D}=(0,C.e5)(),{data:w,isFetching:z}=p.f.useGetCoupons(Number(b.id)),{mutate:P}=p.f.useEnableCoupons(Number(b.id)),{mutate:E}=p.f.useDeleteCoupon(Number(b.id)),{mutate:I}=p.f.useToggleCouponStatus(Number(b.id));(0,s.useEffect)(()=>{r((null==w?void 0:w.Result.IsEnableCoupons)||!1)},[w]);let R=B({onDelete:e=>{k.Q_.confirmAction({title:"Delete Coupon",description:"Deleting coupons will remove them from all active recurrings. Are you sure?",onConfirm:()=>{E(e,{onSuccess:()=>{k.Z0.handleSuccessResponse("Coupon deleted successfully")},onError:e=>(0,k.S3)(e)})}})},onDeactivate:e=>{k.Q_.confirmAction({title:"Deactivate Coupon",description:"Deactivating coupons will remove them from all active recurrings. Are you sure?",confirmationText:"Yes, Deactivate",onConfirm:()=>{I(e,{onSuccess:()=>{k.Z0.handleSuccessResponse("Coupon deactivated successfully")},onError:e=>(0,k.S3)(e)})}})},onActivate:e=>{k.Q_.confirmAction({title:"Activate Coupon",description:"Activating coupons will add them to all active recurrings. Are you sure?",confirmationText:"Yes, Activate",onConfirm:()=>{I(e,{onSuccess:()=>{k.Z0.handleSuccessResponse("Coupon activated successfully")},onError:e=>(0,k.S3)(e)})}})},onEdit:e=>{l(e)}});return(0,a.jsxs)(u.K,{gap:24,h:"100%",children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:D?"gray.1":"gray.10",children:"Coupons"}),(0,a.jsxs)(m.Z,{gap:12,children:[(0,a.jsx)(h.f$,{search:o,setSearch:c}),(0,a.jsx)(x.z,{variant:"subtle",size:"sm",onClick:t,leftSection:(0,a.jsx)(y.Z,{width:24,height:24}),children:"New"})]})]}),(0,a.jsx)(H.r,{label:"Enable Coupons",checked:i,onChange:e=>{r(e.currentTarget.checked),P()}}),(0,a.jsx)(h.iA,{data:(null==w?void 0:w.Result.Coupons)||[],columns:R,sorting:d,onSortingChange:g,globalFilter:v,setGlobalFilter:c,dataCount:null==w?void 0:w.Result.Coupons.length,horizontalSpacing:"xs",verticalSpacing:"12px",striped:"even",withRowBorders:!0,ref:S,isLoading:z})]})},Y=()=>
1{let[e,t]=(0,s.useState)(!1),[l,i]=(0,s.useState)(void 0);return e?(0,a.jsx)(O,{onCancel:()=>t(!1),id:l}):(0,a.jsx)($,{onAddCoupon:()=>{i(void 0),t(!0)},onEditCoupon:e=>{i(e),t(!0)}})},X=l(75438),Q=l(70326),J=l(61782),ee=l(98220),et=l(51391);let el=(e,t)=>{let l=new Map(t.map(e=>[e.TypeID,e.TypeName]));return e.map(e=>({...e,TypeName:l.get(e.TypeID)||"Unknown"}))},ea=(e,t)=>[{id:"select",accessorKey:"select",header:()=>(0,a.jsx)(h.Nq,{label:"Assign"}),enableSorting:!1,cell:l=>{let{row:s}=l,i=s.original.EventID,r=!!e[i];return(0,a.jsx)(h.pj,{value:null,format:"string",children:(0,a.jsx)(m.Z,{gap:8,w:"100%",wrap:"nowrap",justify:"center",children:(0,a.jsx)(et.X,{checked:r,onChange:()=>t(e=>({...e,[i]:!e[i]}))})})})}},{id:"EventName",accessorKey:"EventName",header:()=>(0,a.jsx)(h.Nq,{label:"Name"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue()}),filterFn:k.bm.fuzzyFilter},{id:"TypeName",accessorKey:"TypeName",header:()=>(0,a.jsx)(h.Nq,{label:"Type"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue()}),filterFn:k.bm.fuzzyFilter}],es=e=>Object.entries(e).filter(e=>{let[,t]=e;return t}).map(e=>{let[t]=e;return+t});var ei=l(43784),er=l.n(ei),en=()=>{let e=(0,s.useRef)(null),[t,l]=(0,s.useState)(1),[i,r]=(0,s.useState)(50),{query:o}=(0,n.useRouter)(),[c,d]=(0,s.useState)({}),[g,f]=(0,s.useState)([]),[j,b]=(0,s.useState)(null),{data:y,isFetching:S}=p.f.useGetEmailAutoresponders(Number(o.id)),{mutate:C,isPending:D}=p.f.useUpdateEmailAutoresponders(Number(o.id)),w=el((null==y?void 0:y.Result.ClientEvents)||[],(null==y?void 0:y.Result.TemplateTypes)||[]),z=(0,s.useMemo)(()=>j?w.filter(e=>e.TypeID===Number(j)):w,[w,j]),P=(0,k.MW)(null==y?void 0:y.Result.TemplateTypes,{valueKey:"TypeID",labelKey:"TypeName"}),E=(0,s.useMemo)(()=>ea(c,d),[c,d]),I=(0,s.useMemo)(()=>z.slice((t-1)*i,t*i),[t,z,i]);(0,s.useEffect)(()=>{0===I.length&&l(t>1?t-1:t)},[I.length]);let R=()=>{d({}),b(null),X.qk.close(v.WhL)};return(0,a.jsxs)(u.K,{py:8,children:[(0,a.jsx)(Q.n,{mah:450,offsetScrollbars:"y",scrollbarSize:6,styles:{viewport:{paddingRight:12}},children:(0,a.jsxs)(u.K,{gap:12,children:[(0,a.jsx)(J.P,{ml:"auto",data:P,label:"Template Type",placeholder:"Choose",value:j,onChange:b,checkIconPosition:"right",nothingFoundMessage:"No template found",classNames:er()}),(0,a.jsx)(h.iA,{data:I||[],columns:E,sorting:g,onSortingChange:f,rowSelection:c,dataCount:z.length,horizontalSpacing:"xs",verticalSpacing:"12px",striped:"even",isLoading:S,manualPagination:!0,page:t,perPage:i,onPageChange:e=>l(e.page),onPerPageChange:e=>r(e),ref:e})]})}),(0,a.jsxs)(m.Z,{gap:8,justify:"flex-end",children:[(0,a.jsx)(x.z,{variant:"outline",onClick:R,children:"Close"}),(0,a.jsx)(x.z,{loading:D,onClick:()=>{let e=es(c);if(!e.length){(0,ee.c0)({message:"Please select at least one event",color:"red",icon:(0,a.jsx)(h.sh,{type:F.k$E.ERROR})});return}C({SiteID:Number(o.id),EventIDs:e},{onSuccess:()=>{k.Z0.handleSuccessResponse("Email autoresponders updated successfully",R)},onError:e=>(0,k.S3)(e)})},children:"Save"})]})]})},eo=l(67221);let ec=e=>{let{onDelete:t}=e;return[{id:"EventName",accessorKey:"EventName",header:()=>(0,a.jsx)(h.Nq,{label:"Event"}),cell:e=>{let{row:t}=e,l="".concat(window.location.origin).concat(g.h3.EditEmailEvent,"/?id=").concat(t.original.EventID);return(0,a.jsx)(h.pj,{value:null,format:"string",children:(0,a.jsxs)(u.K,{gap:8,children:[(0,a.jsx)(h.rU,{size:"sm",type:"url",target:"_blank",href:l,children:t.original.EventName}),(0,a.jsxs)(q.x,{size:"sm",c:"light-dark(var(--mantine-color-gray-6), var(--mantine-color-gray-4))",children:[t.original.TemplateName," (",t.original.EventTypeName,")"]})]})})},filterFn:k.bm.fuzzyFilter},{id:"SmtpServer",accessorKey:"SmtpServer",header:()=>(0,a.jsx)(h.Nq,{label:"SMTP"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"string"}),filterFn:k.bm.fuzzyFilter},{id:"IsActive",accessorKey:"IsActive",header:()=>(0,a.jsx)(h.Nq,{label:"Active"}),cell:e=>(0,a.jsx)(h.pj,{value:null,format:"string",children:(0,a.jsx)(h.OE,{status:Number(e.getValue())})}),filterFn:k.bm.fuzzyFilter},{id:"Products",accessorKey:"Products",header:()=>(0,a.jsx)(h.Nq,{label:"Products"}),cell:e=>{let{row:t}=e,l=t.original.Products||[];return(0,a.jsx)(h.pj,{value:null,format:"string",children:l.length>0?(0,a.jsx)(Q.n,{mah:350,type:"hover",offsetScrollbars:!0,children:(0,a.jsx)(m.Z,{gap:8,children:l.map(e=>(0,a.jsx)(eo.C,{h:30,children:(0,a.jsxs)(q.x,{fz:"sm",children:[e.Name," (ID: ",e.ProductID,")"]})},e.ProductID))})}):(0,a.jsx)(q.x,{size:"sm",c:"red.6",fw:500,children:"No products assigned"})})},filterFn:k.bm.fuzzyFilter},{id:"Action",accessorKey:"Action",header:()=>(0,a.jsx)(h.Nq,{label:"Actions"}),enableSorting:!1,cell:e=>{let{row:l}=e;return(0,a.jsx)(h.pj,{value:null,children:(0,a.jsx)(h.ps,{icon:(0,a.jsx)(I.Z,{}),onClick:t,payload:l.original.EventID})})}}]};var eu=()=>{var e;
1let[t,l]=(0,s.useState)(""),[i,r]=(0,s.useState)([]),[o]=(0,j.c)(t,500),{query:c}=(0,n.useRouter)(),d=(0,s.useRef)(null),{isDarkTheme:g}=(0,C.e5)(),{data:b,isFetching:S}=p.f.useGetEmailAutoresponders(Number(c.id)),{mutate:D}=p.f.useUnassignEmailAutoresponder(Number(c.id)),w=ec({onDelete:e=>{k.Q_.confirmAction({title:"Delete Email Autoresponder",description:"You will not be able to revert this! Are you sure?",onConfirm:()=>{D({SiteID:Number(c.id),EventID:e})}})}});return(0,a.jsxs)(u.K,{gap:24,h:"100%",children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:g?"gray.1":"gray.10",tt:"capitalize",children:"Email Autoresponders"}),(0,a.jsxs)(m.Z,{gap:12,children:[(0,a.jsx)(h.f$,{search:t,setSearch:l}),(0,a.jsx)(x.z,{variant:"subtle",size:"sm",onClick:()=>{X.qk.open({title:"Select Event",modalId:v.WhL,children:(0,a.jsx)(en,{}),styles:{content:{width:"960px"}}})},leftSection:(0,a.jsx)(y.Z,{width:24,height:24}),children:"New"})]})]}),(0,a.jsx)(h.iA,{data:(null==b?void 0:b.Result.SiteEvents)||[],columns:w,sorting:i,onSortingChange:r,globalFilter:o,setGlobalFilter:l,dataCount:null==b?void 0:null===(e=b.Result.SiteEvents)||void 0===e?void 0:e.length,horizontalSpacing:"xs",verticalSpacing:"12px",striped:"even",withRowBorders:!0,ref:d,isLoading:S})]})},ed=l(48701),em=l(54354);let ep=()=>[{id:"EventID",accessorKey:"EventID",header:()=>(0,a.jsx)(h.Nq,{label:"Event ID"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"number"}),filterFn:k.bm.fuzzyFilter},{id:"EventName",accessorKey:"EventName",header:()=>(0,a.jsx)(h.Nq,{label:"Event Name"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"string"}),filterFn:k.bm.fuzzyFilter},{id:"EventTypeName",accessorKey:"EventTypeName",header:()=>(0,a.jsx)(h.Nq,{label:"Event Type"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"string"}),filterFn:k.bm.fuzzyFilter},{id:"SmtpServer",accessorKey:"SmtpServer",header:()=>(0,a.jsx)(h.Nq,{label:"SMTP Server"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"string"}),filterFn:k.bm.fuzzyFilter},{id:"TemplateName",accessorKey:"TemplateName",header:()=>(0,a.jsx)(h.Nq,{label:"Template Name"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"string"}),filterFn:k.bm.fuzzyFilter},{id:"IsActive",accessorKey:"IsActive",header:()=>(0,a.jsx)(h.Nq,{label:"Active"}),cell:e=>(0,a.jsx)(h.pj,{value:null,format:"string",children:(0,a.jsx)(h.OE,{status:Number(e.getValue())})}),filterFn:k.bm.fuzzyFilter}];var eh=()=>{let[e,t]=(0,s.useState)(""),[l,i]=(0,s.useState)([]),[r]=(0,j.c)(e,500),{query:o}=(0,n.useRouter)(),{isDarkTheme:c}=(0,C.e5)(),d=(0,s.useRef)(null),{data:g,isFetching:v}=p.f.useGetEmailAutoresponders(Number(o.id)),x=(0,s.useMemo)(()=>{var e;return(null==g?void 0:null===(e=g.Result)||void 0===e?void 0:e.SiteEvents)||[]},[g]),b=(0,s.useMemo)(()=>x.filter(e=>!e.Products||0===e.Products.length),[x]),y=(0,s.useMemo)(()=>ep(),[]);return(0,a.jsxs)(u.K,{gap:24,h:"100%",children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:c?"gray.1":"gray.10",tt:"capitalize",children:"Events"}),(0,a.jsx)(m.Z,{gap:12,children:(0,a.jsx)(h.f$,{search:e,setSearch:t})})]}),b.length>0&&(0,a.jsx)(ed.b,{icon:(0,a.jsx)(em.Z,{}),color:"yellow",variant:"light",children:(0,a.jsxs)(u.K,{gap:4,children:[(0,a.jsx)(q.x,{size:"sm",fw:500,children:"Events Without Products"}),(0,a.jsxs)(q.x,{size:"sm",children:[b.length," ",1===b.length?"event has":"events have"," no products assigned. Email autoresponders will not work for"," ",1===b.length?"this event":"these events"," without products. Assign products to events in the Email Autoresponders tab."]})]})}),(0,a.jsx)(h.iA,{data:x,columns:y,sorting:l,onSortingChange:i,globalFilter:r,setGlobalFilter:t,dataCount:x.length,horizontalSpacing:"xs",verticalSpacing:"12px",striped:"even",withRowBorders:!0,ref:d,isLoading:v})]})},eg=l(3885),ev=l(57095),ef=e=>{let{paymentTypeList:t}=e,{control:l,setValue:s,formState:{errors:i}}=(0,S.Gc)(),r=(0,ev.kV)(t);return(0,a.jsx)(u.K,{gap:"xl",children:(0,a.jsx)(eg.r,{gutter:"md",children:r.map(e=>{var t;let{name:r,label:n,options:o}=e;return(0,a.jsx)(eg.r.Col,{span:{base:12,sm:6,md:4,lg:3},children:(0,a.jsx)(h.zE,{name:r,label:n,placeholder:o.length>0?"Select processor...":"No processors available",searchable:!0,data:o,setValue:s,
1control:l,error:null===(t=i[r])||void 0===t?void 0:t.message})},r)})})})},ex=()=>{let{isDarkTheme:e}=(0,C.e5)(),t=(0,S.cI)({resolver:(0,b.F)(D.X1X),mode:"onChange"}),{query:l}=(0,n.useRouter)(),{data:i,isLoading:r}=p.f.useGetPaymentType(Number(l.id)),{mutate:d}=p.f.useUpdateCampaignPaymentType(Number(l.id));return((0,s.useEffect)(()=>{i&&Object.entries(i.Result.Site).forEach(e=>{let[l,a]=e;(l.endsWith("ProcessorID")||"SiteID"===l)&&t.setValue(l,a?a.toString():null)})},[i]),r)?(0,a.jsx)(o.M,{h:"30vh",children:(0,a.jsx)(c.a,{})}):(0,a.jsx)(S.RV,{...t,children:(0,a.jsxs)(u.K,{component:"form",h:"100%",onSubmit:t.handleSubmit(e=>{d(e,{onSuccess:()=>{k.Z0.handleSuccessResponse("Campaign processors updated successfully")},onError:e=>(0,k.S3)(e)})}),children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:e?"gray.1":"gray.10",tt:"capitalize",children:"Processors"}),(0,a.jsx)(x.z,{type:"submit",variant:"light",children:"Save"})]}),(0,a.jsx)(ef,{paymentTypeList:null==i?void 0:i.Result})]})})};let ej=[{label:"All Status Events",value:"all"},{label:"Success",value:"1"},{label:"Declined",value:"2"},{label:"Error",value:"4"},{label:"Pending",value:"8"},{label:"Cancelled",value:"16"},{label:"Chargeback",value:"32"},{label:"Partial",value:"64"}],eb=[{label:"Customer ID",value:"customer_id"},{label:"Customer First Name",value:"customer_first_name"},{label:"Customer Last Name",value:"customer_last_name"},{label:"Customer Email",value:"customer_email"},{label:"Customer Phone",value:"customer_phone"},{label:"Customer Address",value:"customer_address"},{label:"Customer Address 2",value:"customer_address2"},{label:"Customer City",value:"customer_city"},{label:"Customer State",value:"customer_state"},{label:"Customer Zip",value:"customer_zip"},{label:"Customer Country",value:"customer_country"},{label:"Order ID",value:"order_id"},{label:"Order Total",value:"order_total"},{label:"Transaction ID",value:"transaction_id"},{label:"Products",value:"products"},{label:"Status",value:"status"},{label:"Click ID",value:"click_id"},{label:"Affiliate ID",value:"affiliate_id"},{label:"Sub Affiliate ID",value:"sub_affiliate_id"},{label:"Sub Affiliate ID 2",value:"sub_affiliate_id2"},{label:"Sub Affiliate ID 3",value:"sub_affiliate_id3"},{label:"Sub Affiliate ID 4",value:"sub_affiliate_id4"},{label:"Sub Affiliate ID 5",value:"sub_affiliate_id5"},{label:"Commission",value:"commission"},{label:"Commission Type",value:"commission_type"},{label:"Campaign ID",value:"campaign_id"},{label:"Campaign Name",value:"campaign_name"},{label:"Timestamp",value:"timestamp"}],ey=[{label:"CPA (Fixed Amount)",value:"0"},{label:"CPC (Percentage)",value:"1"}];var eS=e=>{var t,l,i,r,o;let{onSave:d,isSaveLoading:p=!1}=e,{query:g}=(0,n.useRouter)(),f=g.id,j=(0,S.cI)({resolver:(0,b.F)(D.ysk),mode:"onChange",defaultValues:{AffiliateID:"",PostbackUrl:"",TriggerStatuses:[],CommissionType:"0",CommissionAmount:0,SiteID:f||"",PayloadOptions:[],PayloadLocation:!1,TokenMappingRows:[]}}),{control:y,setValue:k,handleSubmit:w,formState:{errors:z}}=j,{fields:P,append:E,remove:I}=(0,S.Dq)({control:y,name:"TokenMappingRows"}),R=(0,S.qo)({control:y,name:"PostbackUrl"}),A=(0,S.qo)({control:y,name:"CommissionType"}),N=(0,S.qo)({control:y,name:"TokenMappingRows"}),{isDarkTheme:T}=(0,C.e5)(),{data:M,isFetching:Z}=K.U.useGetSitePostbackConfig(f,{enabled:!!f}),_=K.U.useSavePostbackConfig(f),U=K.U.useTestPostbackUrl(f);(0,s.useEffect)(()=>{if((null==M?void 0:M.Good)&&f){if(M.Result){var e;let t=M.Result;k("AffiliateID",(null===(e=t.AffiliateID)||void 0===e?void 0:e.toString())||""),k("PostbackUrl",t.PostbackUrl||""),k("TriggerStatuses",t.TriggerStatuses?t.TriggerStatuses.map(String).map(e=>"63"===e||"127"===e?"all":e):["1"]),k("CommissionType",t.CommissionType?"1":"0"),k("CommissionAmount",t.CommissionAmount||0),k("SiteID",f),k("PayloadOptions",t.PayloadOptions||["click_id"]),k("PayloadLocation",!t.PayloadLocation),k("TokenMappingRows",t.TokenMappings?Object.entries(t.TokenMappings).map(e=>{let[t,l]=e;return{key:t,token:l}}):[])}else k("AffiliateID",""),k("PostbackUrl",""),k("TriggerStatuses",["all"]),k("CommissionType","0"),k("CommissionAmount",0),k("SiteID",f),k("PayloadOptions",[]),k("PayloadLocation",!1),k("TokenMappingRows",[])}},[M,k,f]),(0,s.useEffect)(()=>{f&&k("SiteID",f)},[f,k]),(0,s.useEffect)(()=>{k("CommissionAmount",0)},[A,k]);let V=async()=>{var e,t,l,s;if(!R){(0,ee.c0)({title:"Error",message:"Please enter a postback URL first",color:"red",icon:(0,a.jsx)(h.sh,{type:F.k$E.ERROR})});return}if(!f){(0,ee.c0)({title:"Error",message:"Site ID is required",color:"red",icon:(0,a.jsx)(h.sh,{type:F.k$E.ERROR})});return}try{let t=j.getValues(),l=null!==(e=t.TokenMappingRows)&&void 0!==e?e:[],s=Object.fromEntries(l.filter(e=>e.key.trim()&&e.token.trim()).map(e=>{let{key:t,token:l}=e;return[t,l]})),i={PostbackUrl:R,TestStatus:"Success",PayloadLocation:!t.PayloadLocation,PayloadOptions:t.PayloadOptions,TokenMappings:Object.keys(s).length>0?s:null},r=await U.mutateAsync(i);r.Good&&r.Result.Success?(0,ee.c0)({title:"Success",message:r.Result.message,color:"green",icon:(0,a.jsx)(h.sh,{type:F.k$E.SUCCESS})}):(0,ee.c0)({title:"Test Failed",message:r.Result.message,color:"orange",icon:(0,a.jsx)(h.sh,{type:F.k$E.WARNING})})}catch(e){(0,ee.c0)({title:"Error",message:(null===(s=e.response)||void 0===s?void 0:null===(l=s.data)||void 0===l?void 0:null===(t=l.Result)||void 0===t?void 0:t.message)||"Failed to test postback URL",color:"red",icon:(0,a.jsx)(h.sh,{type:F.k$E.ERROR})})}},G=async e=>{var t,l,s,i;if(!f){(0,ee.c0)({title:"Error",message:"Site ID is required",color:"red",icon:(0,a.jsx)(h.sh,{type:F.k$E.ERROR})});return}let r=Object.fromEntries((null!==(t=e.TokenMappingRows)&&void 0!==t?t:[]).filter(e=>e.key.trim()&&e.token.trim()).map(e=>{let{key:t,token:l}=e;return[t,l]}
1)),n={...e,TriggerStatuses:e.TriggerStatuses.includes("all")?["127"]:e.TriggerStatuses,PayloadLocation:!e.PayloadLocation,TokenMappings:Object.keys(r).length>0?r:null,TokenMappingRows:void 0};try{let t=await _.mutateAsync(n);(null==t?void 0:t.Good)?((0,ee.c0)({title:"Success",message:"Postback configuration saved successfully",color:"green",icon:(0,a.jsx)(h.sh,{type:F.k$E.SUCCESS})}),d&&d(e)):(0,ee.c0)({title:"Error",message:(null==t?void 0:t.ErrorMessage)||"Failed to save postback configuration",color:"red",icon:(0,a.jsx)(h.sh,{type:F.k$E.ERROR})})}catch(e){(0,ee.c0)({title:"Error",message:(null===(i=e.response)||void 0===i?void 0:null===(s=i.data)||void 0===s?void 0:null===(l=s.Result)||void 0===l?void 0:l.message)||"Failed to save postback configuration",color:"red",icon:(0,a.jsx)(h.sh,{type:F.k$E.ERROR})})}};return(0,a.jsxs)(u.K,{gap:24,children:[(0,a.jsx)(q.x,{fw:500,c:T?"gray.4":"gray.6",children:"Server-to-server postbacks automatically notify your affiliate network when orders change status. Your network will provide you with a postback endpoint URL—enter it below along with which status events should trigger notifications. This enables real-time conversion tracking and commission settlement."}),(0,a.jsxs)("form",{onSubmit:w(G),children:[(0,a.jsxs)(u.K,{gap:16,children:[Z&&(0,a.jsxs)(m.Z,{justify:"center",children:[(0,a.jsx)(c.a,{size:"sm"}),(0,a.jsx)(q.x,{size:"sm",c:"dimmed",children:"Loading postback configuration..."})]}),!Z&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(u.K,{gap:8,children:[(0,a.jsx)(q.x,{fz:"md",fw:500,c:T?"gray.0":"gray.10",children:"Token Mappings"}),(0,a.jsx)(q.x,{size:"xs",c:"dimmed",children:"Define parameter names for your postback. Click a chip below the URL field to insert it as a query parameter."}),P.map((e,t)=>(0,a.jsxs)(m.Z,{gap:8,align:"flex-end",children:[(0,a.jsx)(h.HS,{name:"TokenMappingRows.".concat(t,".key"),control:y,label:0===t?"Custom Key":void 0,placeholder:"e.g. cid",style:{flex:1}}),(0,a.jsx)(h.zE,{name:"TokenMappingRows.".concat(t,".token"),control:y,setValue:k,label:0===t?"Token":void 0,placeholder:"Select token",data:eb,style:{flex:1}}),(0,a.jsx)(x.z,{variant:"subtle",color:"red",size:"compact-sm",type:"button",mb:2,onClick:()=>I(t),children:"\xd7"})]},e.id)),(0,a.jsx)(x.z,{variant:"outline",size:"xs",type:"button",onClick:()=>E({key:"",token:""}),style:{alignSelf:"flex-start"},children:"+ Add Token Mapping"})]}),(0,a.jsxs)(u.K,{gap:4,children:[(0,a.jsxs)(m.Z,{gap:12,align:"end",children:[(0,a.jsx)(h.HS,{name:"PostbackUrl",control:y,label:"Postback URL",placeholder:"https://network.com/conversions/postback",error:null===(t=z.PostbackUrl)||void 0===t?void 0:t.message,style:{flex:1},required:!0}),(0,a.jsx)(x.z,{variant:"outline",color:"gray",type:"button",onClick:V,loading:U.isPending,disabled:!R,children:"Test"})]}),N&&N.some(e=>e.key&&e.token)&&(0,a.jsx)(m.Z,{gap:6,mt:4,children:N.filter(e=>e.key&&e.token).map(e=>(0,a.jsx)(eo.C,{variant:"outline",color:"gray",tt:"none",style:{cursor:"pointer"},onClick:()=>{let t="".concat(e.key,"={").concat(e.token,"}"),l=(null==R?void 0:R.includes("?"))?"&":"?";k("PostbackUrl","".concat(null!=R?R:"").concat(l).concat(t))},children:e.key},"".concat(e.key,"-").concat(e.token)))}),(0,a.jsxs)(q.x,{size:"xs",c:"dimmed",children:["Tip: use ","{token}"," placeholders directly in the URL — e.g. ?cid=","{click_id}","&val=","{commission}",". Those params won't be appended twice."]})]}),(0,a.jsx)(h.a_,{control:y,name:"TriggerStatuses",label:"Status Triggers",placeholder:"Select status events that trigger postbacks",data:ej,error:null===(l=z.TriggerStatuses)||void 0===l?void 0:l.message}),(0,a.jsxs)(m.Z,{gap:12,align:"end",children:[(0,a.jsx)(h.zE,{control:y,setValue:k,name:"CommissionType",label:"Commission Type",placeholder:"Select commission type",data:ey,error:null===(i=z.CommissionType)||void 0===i?void 0:i.message,style:{flex:1}}),(0,a.jsx)(h.HS,{name:"CommissionAmount",control:y,label:"1"===A?"CPC (Percentage)":"CPA (Fixed Amount)",placeholder:"1"===A?"Enter percentage":"Enter fixed amount",error:null===(r=z.CommissionAmount)||void 0===r?void 0:r.message,style:{flex:1},leftSection:"1"===A?"%":"$",type:"number",step:"any"})]}),(0,a.jsx)(h.a_,{control:y,name:"PayloadOptions",label:"Available Postback Tokens",placeholder:"Select tokens to include in postback data",data:eb,error:null===(o=z.PayloadOptions)||void 0===o?void 0:o.message}),(0,a.jsx)(h.us,{control:y,name:"PayloadLocation",label:"Send Payload in Request Body",tooltip:"When enabled, payload will be sent in the request body as JSON. When disabled, payload will be sent as URL query parameters."})]})]}),!Z&&(0,a.jsx)(m.Z,{justify:"flex-end",mt:"md",children:(0,a.jsx)(x.z,{type:"submit",loading:_.isPending||p,color:"pink",size:"md",children:"Save Postback Configuration"})})]}),(0,a.jsx)(q.x,{fz:"lg",fw:500,c:T?"gray.1":"gray.10",children:"Implementation Requirements"}),(0,a.jsx)(q.x,{fw:500,c:T?"gray.4":"gray.6",children:"In order for postbacks to work, your backend must store the affiliate's click ID when the customer lands on your site. This click ID is passed back in the postback so the affiliate network can match conversions to their clicks."}),(0,a.jsx)(q.x,{fw:500,c:T?"gray.4":"gray.6",children:'You must capture the click ID from the URL parameter and pass it to the Add Customer API call. The click ID variable should be labeled "ClickID" in your API requests.'}),(0,a.jsxs)(u.K,{gap:0,children:["Please refer to the API Add Customer call/example:",(0,a.jsxs)(h.rU,{type:"url",href:"".concat(v.aWR,"/#add-customer"),target:"_blank",children:[v.aWR,"/#add-customer"]})]})]})},eC=()=>{let{isDarkTheme:e}=(0,C.e5)();return(0,a.jsxs)(u.K,{h:"100%",children:[(0,a.jsx)(f.D,{fz:"xl",c:e?"gray.1":"gray.10",tt:"capitalize",children:"Postback Configuration"}),(0,a.jsx)(q.x,{fw:500,c:e?"gray.4":"gray.6",children:"Configure server-to-server postbacks to automatically notify your affiliate network when orders change status."}),(0,a.jsx)(eS,{})]})},ek=l(94525),eD=l(84633),ew=l(70014),ez=l(56821),eP=l(25043);let eE=e=>[{id:"ProductId",accessorKey:"ProductId",header:()=>(0,a.jsx)(h.Nq,{label:"Product ID"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"string"}),filterFn:k.bm.fuzzyFilter},{id:"Name",accessorKey:"Name",header:()=>(0,a.jsx)(h.Nq,{label:"Name"}),cell:e=>{let t=e.row.original.ProductId;return(0,a.jsx)(h.pj,{value:null,children:(0,a.jsx)(h.rU,{type:"router",size:"sm",href:g.h3.EditProduct.replace("[id]",t.toString()),children:e.getValue()})})},filterFn:k.bm.fuzzyFilter},{id:"ProductGroup",accessorKey:"ProductGroup",header:()=>(0,a.jsx)(h.Nq,{label:"Product Group"}),cell:()=>(0,a.jsx)(h.pj,{value:e||"N/A",format:"string"}),filterFn:k.bm.fuzzyFilter},{id:"Type",accessorKey:"Type",header:()=>(0,a.jsx)(h.Nq,{label:"Type"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue()}),filterFn:k.bm.fuzzyFilter},{id:"Amount",accessorKey:"Amount",header:()=>(0,a.jsx)(h.Nq,{label:"Amount"}),cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"currency"}),filterFn:k.bm.fuzzyFilter},{id:"isActive",accessorKey:"isActive",header:()=>(0,a.jsx)(h.Nq,{label:"Status"}),cell:e=>{let t=e.getValue();return(0,a.jsx)(h.pj,{value:null,format:"string",children:(0,a.jsx)(h.OE,{status:Number(t),label:t?"Active":"Inactive"})})},filterFn:k.bm.fuzzyFilter}];var eI=l(78116),eR=l.n(eI),eA=e=>{let{title:t,opened:l,close:i,productId:r}=e,{isDarkTheme:n}
1=(0,C.e5)(),o=(0,s.useRef)(null),[c,d]=(0,s.useState)(""),[g]=(0,j.c)(c,500),[f,b]=(0,s.useState)([]),[y,S]=(0,s.useState)({}),{data:D,isFetching:w}=p.f.useGetGroupCharges(r),z=s.useMemo(()=>eE(t),[t]),P=k.pz.getActionButtons({download:()=>{var e;let t=((null===(e=o.current)||void 0===e?void 0:e.getAllFormattedDataToCSV())||[]).map(e=>e.filter(e=>"Action"!==e.columnId).map(e=>"isActive"===e.columnId?!0===e.rawValue?"Active":"Inactive":"Amount"===e.columnId?k.Ko.formatUSDCurrency(Number(e.rawValue)):e.formattedValue)),l=[k.bm.getTableHeaders(z),t.map(e=>e.map(e=>k.Ko.formatToQuotedString(e))).join("\n")].join("\n");k.mx.downloadCSV(l,v.dMH.product_campaigns)}});return(0,a.jsx)(ew.u,{opened:l,centered:!0,onClose:i,title:t,zIndex:211,closeButtonProps:{icon:(0,a.jsx)(eP.Z,{width:24,height:24})},overlayProps:{zIndex:210},classNames:{header:eR().modalHeader,close:eR().modalClose,title:eR().modalTitle,body:eR().modalBody,content:eR().modalContent},children:(0,a.jsxs)(u.K,{gap:18,children:[(0,a.jsxs)(m.Z,{gap:12,justify:"flex-end",children:[(0,a.jsx)(h.f$,{search:c,setSearch:d}),(0,a.jsx)(m.Z,{gap:12,children:P.map(e=>{let{ariaLabel:t,icon:l,handler:s}
1=e;return(0,a.jsx)(ez.A,{size:24,onClick:s,"aria-label":t,radius:"xl",variant:"transparent",color:n?"pink.4":"pink.3",className:eR().actionIcon,children:l},t)})})]}),(0,a.jsx)(h.iA,{data:(null==D?void 0:D.Charges)||[],columns:z,sorting:f,onSortingChange:b,expanded:y,setExpanded:S,globalFilter:g,setGlobalFilter:d,dataCount:null==D?void 0:D.Charges.length,horizontalSpacing:"xs",verticalSpacing:"12px",striped:"even",ref:o,isLoading:w}),(0,a.jsx)(m.Z,{justify:"flex-end",children:(0,a.jsx)(x.z,{variant:"outline",onClick:i,children:"Close"})})]})})};let eN=(e,t,l,s,i)=>[{id:"select",header:()=>(0,a.jsx)(h.Nq,{label:"Select"}),enableSorting:!1,enableColumnFilter:!1,size:80,minSize:80,maxSize:80,cell:e=>{let{row:s}=e,i=Number(s.original.id),r=!!t[i];return(0,a.jsx)(m.Z,{gap:8,w:"100%",wrap:"nowrap",justify:"center",children:(0,a.jsx)(et.X,{checked:r,onChange:e=>{e.stopPropagation(),l({id:i,checked:!r})}})})}},{id:"id",accessorKey:"id",header:()=>(0,a.jsx)(h.Nq,{label:"Product Group ID"}),size:150,minSize:120,maxSize:180,cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"string"}),filterFn:k.bm.fuzzyFilter},{id:"name",accessorKey:"name",header:()=>(0,a.jsx)(h.Nq,{label:"Product Group"}),size:250,minSize:200,cell:e=>(0,a.jsx)(h.pj,{value:e.getValue(),format:"string"}),filterFn:k.bm.fuzzyFilter},{id:"products",accessorKey:"products",header:()=>(0,a.jsx)(h.Nq,{label:"Products"}),size:120,minSize:100,maxSize:150,cell:e=>{var t,l;let{row:s}=e,r=null==i?void 0:i.get(Number(s.original.id)),n=null!==(t=null==r?void 0:r.active)&&void 0!==t?t:0,o=null!==(l=null==r?void 0:r.inactive)&&void 0!==l?l:0;return(0,a.jsx)(h.pj,{value:"".concat(n," active / ").concat(o," inactive"),format:"string"})},filterFn:k.bm.fuzzyFilter},{id:"variants",accessorKey:"variants",header:()=>(0,a.jsx)(h.Nq,{label:"Variants"}),size:120,minSize:100,maxSize:150,cell:e=>{var t;let{row:l}=e,i=null!==(t=null==s?void 0:s.get(Number(l.id)))&&void 0!==t?t:0;return(0,a.jsx)(h.pj,{value:i,format:"string"})},filterFn:k.bm.fuzzyFilter},{id:"action",accessorKey:"action",header:()=>(0,a.jsx)(h.Nq,{label:"Actions"}),enableSorting:!1,size:120,minSize:120,maxSize:120,cell:t=>{let l=t.row.original;return(0,a.jsx)(h.pj,{value:"View Details",format:"string",clickAction:{modal:!0},onClick:()=>e({title:"Products",keyId:l.id})})},filterFn:k.bm.fuzzyFilter}],eT=[{value:"all",label:"All"},{value:"selected",label:"Selected"},{value:"unselected",label:"Unselected"}];var eM=()=>{let[e,t]=(0,s.useState)(""),[l,i]=(0,s.useState)([]),[r,o]=(0,s.use
1State)({}),[c,d]=(0,s.useState)(null),[g]=(0,j.c)(e,500),[v,y]=(0,s.useState)(eT[1].value),[w,z]=(0,s.useState)(),{query:P}=(0,n.useRouter)(),{isDarkTheme:E}=(0,C.e5)(),[I,{open:R,close:A}]=(0,ek.q)(!1),N=(0,s.useRef)(null),{data:T,isFetching:M}=p.f.useGetProductGroups(),{data:F}=p.f.useGetGroups(Number(P.id)),{data:Z}=eD.F.useProductsList(),{mutate:_}=p.f.useUpdateProductGroups(Number(P.id)),U=(0,s.useMemo)(()=>{var e;return new Set((null==F?void 0:null===(e=F.Result)||void 0===e?void 0:e.map(e=>e.id))||[])},[F]),q=(0,S.cI)({resolver:(0,b.F)(D.$HI),mode:"onChange"});(0,s.useEffect)(()=>{if(null==T?void 0:T.ProductGroups){let e=T.ProductGroups.filter(e=>U.has(Number(e.id))).map(e=>Number(e.id));o(e.reduce((e,t)=>({...e,[t]:!0}),{})),q.setValue("SiteID",Number(P.id)),q.setValue("SiteProductGroups",e)}},[T,U]);let V=e=>{var t;let{title:l,keyId:a}=e,s=null==T?void 0:null===(t=T.ProductGroups)||void 0===t?void 0:t.find(e=>e.id===a);z(Number(a)),d((null==s?void 0:s.name)||l),R()},K=e=>{let{id:t,checked:l}=e;o(e=>{let a={...e};return l?a[t]=!0:delete a[t],q.setValue("SiteProductGroups",Object.keys(a).map(Number)),a})},G=(0,s.useMemo)(()=>{var e;let t=new Map;return null==Z||null===(e=Z.Result)||void 0===e||e.forEach(e=>{var l;let a=(null===(l=e.Products)||void 0===l?void 0:l.reduce((e,t)=>e+(t.VariantCount||0),0))||0;t.set(e.ID,a)}),t},[Z]),L=(0,s.useMemo)(()=>{var e;let t=new Map;return null==Z||null===(e=Z.Result)||void 0===e||e.forEach(e=>{var l,a;t.set(e.ID,{active:null!==(l=e.ActiveProductCount)&&void 0!==l?l:0,inactive:null!==(a=e.InactiveProductCount)&&void 0!==a?a:0})}),t},[Z]),O=(0,s.useMemo)(()=>eN(V,r,K,G,L),[r,E,G,L]),H=(0,s.useMemo)(()=>{let e=(null==T?void 0:T.ProductGroups)||[];return"selected"===v?e.filter(e=>r[Number(e.id)]):"unselected"===v?e.filter(e=>!r[Number(e.id)]):e},[T,r,v]);return(0,a.jsx)(S.RV,{...q,children:(0,a.jsxs)(u.K,{component:"form",gap:24,h:"100%",onSubmit:q.handleSubmit(e=>{_(e,{onSuccess:()=>k.Z0.handleSuccessResponse("Product groups updated successfully"),onError:e=>(0,k.S3)(e)})}),children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:E?"gray.1":"gray.10",tt:"capitalize",children:"Products"}),(0,a.jsxs)(m.Z,{gap:12,children:[(0,a.jsx)(h.f$,{search:e,setSearch:t}),(0,a.jsx)(x.z,{type:"submit",variant:"light",children:"Save"})]})]}),(0,a.jsx)(h.Dx,{value:v,onChange:y,tabsData:eT,withBottomBorder:!0}),(0,a.jsx)(h.iA,{data:H,columns:O,sorting:l,onSortingChange:i,globalFilter:g,setGlobalFilter:t,dataCount:H.length,horizontalSpacing:"xs",verticalSpacing:"12px",rowSelection:r,striped:"even",withRowBorders:!0,ref:N,isLoading:M,layout:"fixed"}),(0,a.jsx)(eA,{title:c,opened:I,close:A,productId:w})]})})},eF=()=>{var e,t,l,s;let{control:i,setValue:r,formState:{errors:n}}=(0,S.Gc)();return(0,a.jsxs)(u.K,{w:"60%",maw:1e3,children:[(0,a.jsx)(h.HS,{name:"Name",label:"Name",placeholder:"Name",control:i,error:null===(e=n.Name)||void 0===e?void 0:e.message}),(0,a.jsx)(h.HS,{name:"CampaignID",label:"External Reference ID",placeholder:"Reference ID",control:i,error:null===(t=n.CampaignID)||void 0===t?void 0:t.message}),(0,a.jsx)(h.HS,{name:"DomainUrl",label:"Domain URL",placeholder:"https://example.com",control:i,error:null===(l=n.DomainUrl)||void 0===l?void 0:l.message}),(0,a.jsx)(h.zE,{name:"OfferType",label:"Offer Type",placeholder:"Choose",searchable:!1,data:v.Nb8,setValue:r,control:i,error:null===(s=n.OfferType)||void 0===s?void 0:s.message}),(0,a.jsx)(h.us,{name:"IsActive",label:"Active",control:i})]})},eZ=e=>{let{campaign:t}=e,{isDarkTheme:l}=(0,C.e5)(),{query:i}=(0,n.useRouter)(),r=(0,S.cI)({resolver:(0,b.F)(D.Ppe),mode:"onChange"}),{mutate:o,isPending:c}=p.f.useUpdateCampaignSettings(Number(i.id)),{handleSubmit:d,setValue:h}=r;return(0,s.useEffect)(()=>{t&&Object.entries(t).forEach(e=>{let[t,l]=e;h(t,l)})},[t,h]),(0,a.jsx)(S.RV,{...r,children:(0,a.jsxs)(u.K,{component:"form",h:"100%",onSubmit:d(e=>{o(e,{onSuccess:()=>k.Z0.handleSuccessResponse("Campaign updated successfully"),onError:e=>(0,k.S3)(e)})}),children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:l?"gray.1":"gray.10",tt:"capitalize",children:"Settings"}),(0,a.jsx)(x.z,{type:"submit",variant:"light",loading:c,children:"Save"})]}),(0,a.jsx)(eF,{})]})})},e_=l(55226),eU=l(57507),eq=l(17866),eV=l(58202),eK=l(80537),eG=()=>{var e,t,l,s,i,r;let{isDarkTheme:o}=(0,C.e5)(),{colors:c}=(0,eV.rZ)(),{query:d}=(0,n.useRouter)(),{watch:g,control:v,getValues:f,formState:{errors:j},setError:b,setValue:y}=(0,S.Gc)(),D=g("AuthType"),w="DevDashboard"===D,{mutate:z,isPending:P}
1=p.f.useValidateShopifyCart(Number(d.id)),E=g("IsValidateCredentials");return(0,a.jsxs)(u.K,{w:"60%",maw:1e3,children:[(0,a.jsx)(h.HS,{required:!0,name:"DomainUrl",label:"Shopify URL",placeholder:"https://example.com",control:v,error:null===(e=j.DomainUrl)||void 0===e?void 0:e.message}),w?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.HS,{required:!0,name:"ClientId",label:"Client ID",placeholder:"Client ID",control:v,error:null===(l=j.ClientId)||void 0===l?void 0:l.message}),(0,a.jsx)(h.HS,{required:!0,name:"ClientSecret",label:"Client Secret",placeholder:"Client Secret",control:v,error:null===(s=j.ClientSecret)||void 0===s?void 0:s.message})]}):(0,a.jsx)(h.HS,{required:!0,name:"PrivateAppPassword",label:"Admin API Access Token",placeholder:"Admin API Access Token",control:v,error:null===(t=j.PrivateAppPassword)||void 0===t?void 0:t.message}),(0,a.jsxs)(u.K,{gap:12,align:"start",children:[(0,a.jsxs)(m.Z,{gap:4,children:[(0,a.jsx)(q.x,{fz:"md",fw:500,c:o?"gray.1":"gray.9",children:"Validate Credentials"}),(0,a.jsx)(q.x,{c:c.red[7],children:"*"})]}),E?(0,a.jsxs)(m.Z,{gap:4,children:[(0,a.jsx)(eK.Z,{color:o?c.green[4]:c.green[6]}),(0,a.jsx)(q.x,{fz:"md",fw:500,c:o?c.green[4]:c.green[6],children:"Success"})]}):(0,a.jsxs)(u.K,{gap:4,align:"start",children:[(0,a.jsx)(x.z,{variant:"light",loading:P,size:"sm",onClick:()=>{let e=f("DomainUrl"),t=f("PrivateAppPassword"),l=f("ClientId"),a=f("ClientSecret");e||b("DomainUrl",{message:"Domain URL is required"}),w||t||b("PrivateAppPassword",{message:"Admin API Access Token is required"}),w&&!l&&b("ClientId",{message:"Client ID is required"}),w&&!a&&b("ClientSecret",{message:"Client Secret is required"}),e&&(w||t)&&(!w||l&&a)&&z({domainUrl:e,privateAppPassword:t,authType:D,clientId:l,clientSecret:a},{onSuccess:()=>{k.Z0.handleSuccessResponse("Shopify cart validated successfully",()=>y("IsValidateCredentials",!0))},onError:e=>{(0,k.S3)(e)}})},children:"Validate"}),(0,a.jsx)(q.x,{fz:12,c:c.red[7],children:null===(i=j.IsValidateCredentials)||void 0===i?void 0:i.message})]})]}),!w&&(0,a.jsx)(h.HS,{required:!0,name:"WebhookVerificationKey",label:"Application Secret",placeholder:"Application Secret",control:v,error:null===(r=j.WebhookVerificationKey)||void 0===r?void 0:r.message})]})},eL=()=>{let{isDarkTheme:e}=(0,C.e5)(),{query:t}=(0,n.useRouter)(),l=Number(t.id),i=(0,S.cI)({resolver:(0,b.F)(D.H$q),mode:"onChange",defaultValues:{SiteID:l,AuthType:"DevDashboard"}}),{data:r,isFetching:d}=p.f.useGetCampaignShopifyCart(l),h=null==r?void 0:r.Result.DomainUrl,g=null==r?void 0:r.Result;(0,s.useEffect)(()=>{(null==g?void 0:g.Existed)&&i.reset({SiteID:l,AuthType:g.AuthType||"DevDashboard",DomainUrl:g.DomainUrl||"",ClientId:g.ClientId||"",ClientSecret:g.ClientSecret||"",PrivateAppPassword:g.PrivateAppPassword||"",WebhookVerificationKey:g.WebhookVerificationKey||"",IsValidateCredentials:!0})},[g]);let{mutate:j,isPending:y}=p.f.useEditCampaignShopifyCart(l),{mutate:w,isPending:z}=p.f.useDeleteCampaignShopifyCart(l),{mutate:P,isPending:E}=p.f.useSyncShopifyProducts(l);return d?(0,a.jsx)(o.M,{h:"30vh",children:(0,a.jsx)(c.a,{})}):(0,a.jsx)(S.RV,{...i,children:(0,a.jsxs)(u.K,{component:"form",h:"100%",onSubmit:i.handleSubmit(e=>{j(e,{onSuccess:()=>{k.Z0.handleSuccessResponse("Shopify cart created successfully",i.reset)},onError:e=>(0,k.S3)(e)})}),children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:e?"gray.1":"gray.10",tt:"capitalize",children:"Shopify Cart Integration"}),(0,a.jsxs)(m.Z,{children:[(0,a.jsx)(x.z,{type:"submit",variant:"light",loading:y,children:"Save"}),h&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.z,{variant:"light",leftSection:(0,a.jsx)(eU.Z,{size:16}),onClick:()=>{P(void 0,{onSuccess:e=>{let t=e.Data;t?k.Z0.handleSuccessResponse("Synced ".concat(t.TotalProductsSynced," products (").concat(t.ProductsCreated," new, ").concat(t.ProductsUpdated," updated)")):k.Z0.handleSuccessResponse("Products synced successfully")},onError:e=>(0,k.S3)(e)})},loading:E,children:"Sync Products"}),(0,a.jsx)(x.z,{variant:"light",onClick:()=>{w(l,{onSuccess:()=>{k.Z0.handleSuccessResponse("Shopify cart deleted successfully")},onError:e=>(0,k.S3)(e)})},loading:z,children:"Delete"})]})]})]}),(0,a.jsxs)(m.Z,{gap:"md",children:[(0,a.jsx)(e_.e,{href:v.Rp0,target:"_blank",size:"sm",c:"dimmed",children:(0,a.jsxs)(m.Z,{gap:4,children:[(0,a.jsx)(eq.Z,{size:14}),(0,a.jsx)(q.x,{size:"sm",children:"Documentation"})]})}),(0,a.jsx)(e_.e,{href:v.rJg,target:"_blank",size:"sm",c:"dimmed",children:(0,a.jsxs)(m.Z,{gap:4,children:[(0,a.jsx)(eq.Z,{size:14}),(0,a.jsx)(q.x,{size:"sm",children:"API Credentials Setup"})]})})]}),(0,a.jsx)(eG,{})]})})},eO=()=>{let{isDarkTheme:e}=(0,C.e5)(),{query:t}=(0,n.useRouter)(),l=Number(t.id),{data:s,isFetching:i}=p.f.useGetCampaignWhop(l),{mutate:r,isPending:d}=p.f.useEditCampaignWhop(l),{mutate:h,isPending:g}=p.f.useDeleteCampaignWhop(l),{mutate:v,isPending:j}=p.f.useSyncWhopProducts(l),b=null==s?void 0:s.Result,y=!!(null==b?void 0:b.ProcessorID),S=!!(null==b?void 0:b.Existed);return i?(0,a.jsx)(o.M,{h:"30vh",children:(0,a.jsx)(c.a,{})}):(0,a.jsxs)(u.K,{h:"100%",children:[(0,a.jsxs)(m.Z,{justify:"space-between",children:[(0,a.jsx)(f.D,{fz:"xl",c:e?"gray.1":"gray.10",tt:"capitalize",children:"Whop Integration"}),(0,a.jsx)(m.Z,{children:S?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.z,{variant:"light",leftSection:(0,a.jsx)(eU.Z,{size:16}),onClick:()=>{v(void 0,{onSuccess:e=>{let t=e.Data;t?k.Z0.handleSuccessResponse("Synced ".concat(t.TotalProductsSynced," products (").concat(t.ProductsCreated," new, ").concat(t.ProductsUpdated," updated)")):k.Z0.handleSuccessResponse("Product sync started")},onError:e=>(0,k.S3)(e)})},loading:j,children:"Sync Products"}),(0,a.jsx)(x.z,{variant:"light",color:"red",onClick:()=>{h(l,{onSuccess:()=>{k.Z0.handleSuccessResponse("Whop integration removed from this campaign")},onError:e=>(0,k.S3)(e)})},loading:g,children:"Disable"})]}):(0,a.jsx)(x.z,{variant:"light",onClick:()=>{r(void 0,{onSuccess:()=>{k.Z0.handleSuccessResponse("Whop is enabled. Synced products and their orders are now visible on this campaign.")},onError:e=>(0,k.S3)(e)})},loading:d,disabled:!y,children:"Enable"})})]}),(0,a.jsx)(q.x,{size:"sm",c:e?"gray.4":"gray.6",maw:720,children:"Whop credentials live on the campaign processor. Enabling the integration maps the synced Whop product group to this campaign so orders and products show up here."}),!y&&(0,a.jsx)(ed.b,{icon:(0,a.jsx)(em.Z,{size:16}),title:"Whop processor required",color:"yellow",variant:"light",children:"Assign a Whop processor on the Processors tab first, then enable the integration here."}),y&&(0,a.jsxs)(u.K,{gap:6,maw:720,children:[(0,a.jsxs)(q.x,{size:"sm",children:[(0,a.jsxs)(q.x,{span:!0,fw:500,children:["Processor:"," "]}),(null==b?void 0:b.ProcessorName)||(null==b?void 0:b.ProcessorID),(null==b?void 0:b.IsTest)?" (sandbox)":""]}),(null==b?void 0:b.CompanyId)&&(0,a.jsxs)(q.x,{size:"sm",children:[(0,a.jsxs)(q.x,{span:!0,fw:500,children:["Company ID:"," "]}),b.CompanyId]}),S&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(q.x,{size:"sm",children:[(0,a.jsxs)(q.x,{span:!0,fw:500,children:["Product group:"," "]}),(null==b?void 0:b.ProductGroupName)||(null==b?void 0:b.ProductGroupID)]}),(null==b?void 0:b.LastSyncUtc)&&(0,a.jsxs)(q.x,{size:"sm",children:[(0,a.jsxs)(q.x,{span:!0,fw:500,children:["Last sync:"," "]}),b.LastSyncUtc]})]})]})]})},eH=()=>
1{let[e,t]=(0,s.useState)(ev.MH[0].value),{query:l,push:i}=(0,n.useRouter)(),{data:f,isLoading:x}=p.f.useGetCRMCampaignSettings(Number(l.id));return x?(0,a.jsx)(o.M,{h:"30vh",children:(0,a.jsx)(c.a,{})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r(),{children:(0,a.jsx)("title",{children:"Edit Campaign"})}),(0,a.jsx)(u.K,{p:40,pt:17,w:"100%",align:"center",children:(0,a.jsxs)(u.K,{h:"100%",w:"100%",maw:v.Mpv,gap:32,children:[(0,a.jsx)(h.uL,{path:g.h3.EditCampaign,name:null==f?void 0:f.Result.Name}),(0,a.jsx)(d.m,{h:"100%",p:0,defaultValue:e,orientation:"vertical",onChange:t,bg:"transparent",w:"100%",children:(0,a.jsxs)(m.Z,{w:"100%",gap:20,wrap:"nowrap",align:"flex-start",children:[(0,a.jsx)(h.Am,{tabs:ev.MH,onBack:()=>i(g.h3.Campaigns)}),(0,a.jsx)(d.m.Panel,{value:e||ev.MH[0].value,h:"100%",children:(()=>{switch(e){case ev.MH[1].value:return(0,a.jsx)(ex,{});case ev.MH[2].value:return(0,a.jsx)(U,{});case ev.MH[3].value:return(0,a.jsx)(eM,{});case ev.MH[4].value:return(0,a.jsx)(eh,{});case ev.MH[5].value:return(0,a.jsx)(eu,{});case ev.MH[6].value:return(0,a.jsx)(Y,{});case ev.MH[7].value:return(0,a.jsx)(T,{});case ev.MH[8].value:return(0,a.jsx)(eC,{});case ev.MH[9].value:return(0,a.jsx)(eL,{});case ev.MH[10].value:return(0,a.jsx)(eO,{});default:return(0,a.jsx)(eZ,{campaign:null==f?void 0:f.Result})}})()})]})})]})})]})}},57095:function(e,t,l){"use strict";l.d(t,{MH:function(){return D},Sz:function(){return k},gh:function(){return C},kV:function(){return w}});var a=l(97458),s=l(93747),i=l(4601),r=l(40953),n=l(44048),o=l(32674),c=l(43902),u=l(31129),d=l(48616),m=l(23390),p=(0,m.Z)("outline","calendar-event","IconCalendarEvent",[["path",{d:"M4 5m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M16 3l0 4",key:"svg-1"}],["path",{d:"M8 3l0 4",key:"svg-2"}],["path",{d:"M4 11l16 0",key:"svg-3"}],["path",{d:"M8 15h2v2h-2z",key:"svg-4"}]]),h=(0,m.Z)("outline","mail","IconMail",[["path",{d:"M3 7a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10z",key:"svg-0"}],["path",{d:"M3 7l9 6l9 -6",key:"svg-1"}]]),g=l(96397),v=l(85350),f=(0,m.Z)("outline","webhook","IconWebhook",[["path",{d:"M4.876 13.61a4 4 0 1 0 6.124 3.39h6",key:"svg-0"}],["path",{d:"M15.066 20.502a4 4 0 1 0 1.934 -7.502c-.706 0 -1.424 .179 -2 .5l-3 -5.5",key:"svg-1"}],["path",{d:"M16 8a4 4 0 1 0 -8 0c0 1.506 .77 2.818 2 3.5l-3 5.5",key:"svg-2"}]]),x=(0,m.Z)("outline","shopping-cart","IconShoppingCart",[["path",{d:"M6 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-0"}],["path",{d:"M17 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M17 17h-11v-14h-2",key:"svg-2"}],["path",{d:"M6 5l14 1l-1 7h-13",key:"svg-3"}]]),j=(0,m.Z)("outline","package","IconPackage",[["path",{d:"M12 3l8 4.5l0 9l-8 4.5l-8 -4.5l0 -9l8 -4.5",key:"svg-0"}],["path",{d:"M12 12l8 -4.5",key:"svg-1"}],["path",{d:"M12 12l0 9",key:"svg-2"}],["path",{d:"M12 12l-8 -4.5",key:"svg-3"}],["path",{d:"M16 5.25l-8 4.5",key:"svg-4"}]]),b=l(39837),y=l(55253),S=l(9682);let C=e=>{let{onDelete:t,onEdit:l,onDuplicate:o}=e;return[{id:"SiteID",accessorKey:"SiteID",header:()=>(0,a.jsx)(b.Nq,{label:"Campaign ID"}),cell:e=>(0,a.jsx)(b.pj,{value:e.getValue(),isTitle:!0}),filterFn:y.bm.fuzzyFilter},{id:"name",accessorKey:"Name",header:()=>(0,a.jsx)(b.Nq,{label:"Name"}),cell:e=>(0,a.jsx)(b.pj,{value:e.getValue()}),filterFn:y.bm.fuzzyFilter},{id:"DateEntered",accessorKey:"DateEntered",header:()=>(0,a.jsx)(b.Nq,{label:"Created"}),cell:e=>(0,a.jsx)(b.pj,{value:e.getValue(),format:"date"}),filterFn:y.bm.fuzzyFilter},{id:"DateModified",accessorKey:"DateModified",header:()=>(0,a.jsx)(b.Nq,{label:"Updated"}),cell:e=>(0,a.jsx)(b.pj,{value:e.getValue(),format:"date"}),filterFn:y.bm.fuzzyFilter},{id:"LastTRXUtc",accessorKey:"LastTRXUtc",header:()=>(0,a.jsx)(b.Nq,{label:"Last TRX"}),cell:e=>(0,a.jsx)(b.pj,{value:e.getValue(),format:"date"}),filterFn:y.bm.fuzzyFilter},{id:"IsActive",accessorKey:"IsActive",header:()=>(0,a.jsx)(b.Nq,{label:"Active"}),cell:e=>(0,a.jsx)(b.pj,{value:null,format:"string",children:(0,a.jsx)(b.OE,{status:Number(e.getValue())})}),filterFn:y.bm.fuzzyFilter},{id:"Action",accessorKey:"Action",header:()=>(0,a.jsx)(b.Nq,{label:"Actions"}),enableSorting:!1,cell:e=>{let{row:c}=e;return(0,a.jsx)(b.pj,{value:null,children:(0,a.jsxs)(s.Z,{gap:8,w:"100%",wrap:"nowrap",children:[(0,a.jsx)(b.ps,{icon:(0,a.jsx)(i.Z,{}),onClick:l,payload:c.original.SiteID,tooltipProps:{label:"Edit",position:"top"}}),(0,a.jsx)(b.ps,{icon:(0,a.jsx)(r.Z,{}),onClick:o,payload:c.original.SiteID,tooltipProps:{label:"Duplicate",position:"top"}}),(0,a.jsx)(b.ps,{icon:(0,a.jsx)(n.Z,{}),onClick:t,payload:c.original.SiteID,tooltipProps:{label:"Delete",position:"top"}})]})})}}]},k=(e,t)=>{let l=null==t?void 0:t.find(t=>t.SiteID===e);return l?l.Name:null},D=[{icon:(0,a.jsx)(o.Z,{width:20,height:20}),label:"Settings",value:"settings"},{icon:(0,a.jsx)(c.Z,{width:20,height:20}),label:"Processors",value:"processors"},{icon:(0,a.jsx)(u.Z,{width:20,height:20}),label:"Bin Management",value:"binManagement"},{icon:(0,a.jsx)(d.Z,{width:20,height:20}),label:"Products",value:"products"},{icon:(0,a.jsx)(p,{width:20,height:20}),label:"Events",value:"events"},{icon:(0,a.jsx)(h,{width:20,height:20}),label:"Email Autoresponders",value:"emailAutoresponders"},{icon:(0,a.jsx)(g.Z,{width:20,height:20}),label:"Coupons",value:"coupons"},{icon:(0,a.jsx)(v.Z,{width:20,height:20}),label:"Affiliates",value:"affiliates"},{icon:(0,a.jsx)(f,{width:20,height:20}),label:"Postback Configuration",value:"postbackConfiguration"},{icon:(0,a.jsx)(x,{width:20,height:20}),label:"Shopify Cart Integration",value:"shopifyCartIntegration"},{icon:(0,a.jsx)(j,{width:20,height:20}),label:"Whop Integration",value:"whopIntegration"}],w=e=>S.nMR.map(t=>{let{key:l,name:a,label:s}=t,i=null==e?void 0:e[l];return{name:a,label:s,options:Array.isArray(i)&&i.every(e=>e&&"number"==typeof e.id&&"string"==typeof e.name)?i.map(e=>({value:e.id.toString(),label:e.name})):[]}})},78116:function(e){e.exports={modalHeader:"ProductsDetailsModal_modalHeader__KYeY8",modalClose:"ProductsDetailsModal_modalClose__7aU_y",modalTitle:"ProductsDetailsModal_modalTitle__4K9VD",modalBody:"ProductsDetailsModal_modalBody__T6bux",modalContent:"ProductsDetailsModal_modalContent__w97Xp",closeButton:"ProductsDetailsModal_closeButton__CFUhW",saveButton:"ProductsDetailsModal_saveButton__OT_iP"}},43784:function(e){e.exports={root:"SelectEventModal_root__Yi9YW",input:"SelectEventModal_input__cyiDH",option:"SelectEventModal_option__O62lo"}},3885:function(e,t,l){"use strict";l.d(t,{r:function(){return R}});var a=l(52983),s=l(1385),i=l(91809),r=l(96656),n=l(67587),o=l(11469),c=l(97601);let[u,d]=(0,l(62404).R)("Grid component was not found in tree");var m=l(78364),p=l(3407),h=l(625),g=l(16822),v=l(56130),f=l(58202),x=l(26584);let j=(e,t)=>"content"===e?"auto":"auto"===e?"0rem":e?`${100/(t/e)}%`:void 0,b=(e,t,l)=>l||"auto"===e?"100%":"content"===e?"unset":j(e,t),y=(e,t)=>{if(e)return"auto"===e||t?"1":"auto"},S=(e,t)=>0===e?"0":e?`${100/(t/e)}%`:void 0;function C({span:e,order:t,offset:l,selector:s}){let i=(0,f.rZ)(),r=d(),n=void 0===(0,v.v)(e)?12:(0,v.v)(e),o=(0,h.L)({"--col-order":v.v(t)?.toString(),"--col-flex-grow":y(n,r.grow),"--col-flex-basis":j(n,r.columns),"--col-width":"content"===n?"auto":void 0,"--col-max-width":b(n,r.columns,r.grow),"--col-offset":S((0,v.v)(l),r.columns)}),c=(0,p.X)(i.breakpoints).reduce((a,s)=>(a[s]||(a[s]={}),"object"==typeof t&&void 0!==t[s]&&(a[s]["--col-order"]=t[s]?.toString()),"object"==typeof e&&void 0!==e[s]&&(a[s]["--col-flex-grow"]=y(e[s],r.grow),a[s]["--col-flex-basis"]=j(e[s],r.columns),a[s]["--col-width"]="content"===e[s]?"auto":void 0,a[s]["--col-max-width"]=b(e[s],r.columns,r.grow)),"object"==typeof l&&void 0!==l[s]&&(a[s]["--col-offset"]=S(l[s],r.columns)),a),{}),u=(0,g.I)((0,p.X)(c),i).filter(e=>(0,p.X)(c[e.value]).length>0).map(e=>({query:`(min-width: ${i.breakpoints[e.value]})`,styles:c[e.value]}));return a.createElement(x.f,{styles:o,media:u,selector:s})}var k={root:"m-410352e9",inner:"m-dee7bd2f",col:"m-96bdd299"};let D={span:12},w=(0,c.d)((e,t)=>{let{classNames:l,className:s,style:r,styles:c,vars:u,span:p,order:h,offset:g,...v}=(0,i.w)("GridCol",D,e),f=d(),x=(0,n.m)();return a.createElement(a.Fragment,null,a.createElement(C,{selector:`.${x}`,span:p,order:h,offset:g}),a.createElement(o.x,{ref:t,...f.getStyles("col",{className:(0,m.Z)(s,x),style:r,classNames:l,styles:c}),...v}))});w.classes=k,w.displayName="@mantine/core/GridCol";var z=l(86731);function P({gutter:e,selector:t}){let l=(0,f.rZ)(),s=(0,h.L)({"--grid-gutter":(0,z.bG)((0,v.v)(e))}),i=(0,p.X)(l.breakpoints).reduce((t,l)=>(t[l]||(t[l]={}
1),"object"==typeof e&&void 0!==e[l]&&(t[l]["--grid-gutter"]=(0,z.bG)(e[l])),t),{}),r=(0,g.I)((0,p.X)(i),l).filter(e=>(0,p.X)(i[e.value]).length>0).map(e=>({query:`(min-width: ${l.breakpoints[e.value]})`,styles:i[e.value]}));return a.createElement(x.f,{styles:s,media:r,selector:t})}let E={gutter:"md",grow:!1,columns:12},I=(0,s.Z)((e,{justify:t,align:l,overflow:a})=>({root:{"--grid-justify":t,"--grid-align":l,"--grid-overflow":a}})),R=(0,c.d)((e,t)=>{let l=(0,i.w)("Grid",E,e),{classNames:s,className:c,style:d,styles:m,unstyled:p,vars:h,grow:g,gutter:v,columns:f,align:x,justify:j,children:b,...y}=l,S=(0,r.y)({name:"Grid",classes:k,props:l,className:c,style:d,classNames:s,styles:m,unstyled:p,vars:h,varsResolver:I}),C=(0,n.m)();return a.createElement(u,{value:{getStyles:S,grow:g,columns:f}},a.createElement(P,{selector:`.${C}`,...l}),a.createElement(o.x,{ref:t,...S("root",{className:C}),...y},a.createElement("div",{...S("inner")},b)))});R.classes=k,R.displayName="@mantine/core/Grid",R.Col=w},54354:function(e,t,l){"use strict";l.d(t,{Z:function(){return a}});var a=(0,l(23390).Z)("outline","alert-circle","IconAlertCircle",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 8v4",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]])},17866:function(e,t,l){"use strict";l.d(t,{Z:function(){return a}});var a=(0,l(23390).Z)("outline","external-link","IconExternalLink",[["path",{d:"M12 6h-6a2 2 0 0 0 -2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-6",key:"svg-0"}],["path",{d:"M11 13l9 -9",key:"svg-1"}],["path",{d:"M15 4h5v5",key:"svg-2"}]])},31294:function(e,t,l){"use strict";l.d(t,{Z:function(){return a}});var a=(0,l(23390).Z)("outline","percentage","IconPercentage",[["path",{d:"M17 17m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M7 7m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-1"}],["path",{d:"M6 18l12 -12",key:"svg-2"}]])},85350:function(e,t,l){"use strict";l.d(t,{Z:function(){return a}});var a=(0,l(23390).Z)("outline","sitemap","IconSitemap",[["path",{d:"M3 15m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z",key:"svg-0"}],["path",{d:"M15 15m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z",key:"svg-1"}],["path",{d:"M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z",key:"svg-2"}],["path",{d:"M6 15v-1a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v1",key:"svg-3"}],["path",{d:"M12 9l0 3",key:"svg-4"}]])}},function(e){e.O(0,[2888,9774,179],function(){return e(e.s=41030)}),_N_E=e.O()}]);

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.