1import{r as p,j as e,p as w,a as m,ag as k,b as S,ae as f,ah as L,V as $,O as P,aQ as D,a9 as E,h as C,aw as N,q as T,c as W,ap as b}from"./index-Bk9gjvYU.js";import{u as M,L as B}from"./FeatureGating.styled-DR8H0ZTQ.js";import{W as A,u as O}from"./WorkspaceDataContext-CEJni88Z.js";import{a as R}from"./useTableManagement-CUBc54yh.js";import{u as q,a as F}from"./useInfiniteCoupons--K-K9b9Z.js";import{u as z}from"./useWebsiteShopify-CcItBCDT.js";import{D as c}from"./DataTable-CJdSrEAa.js";import{I as G}from"./IntegrationIcon-yoNO39PQ.js";import{S as U}from"./PlusIcon-DSejfHV8.js";import{S as H}from"./useUpdateDiscountCodeListMutation-nqHG8GNh.js";import{S as Q}from"./SearchInput-yD90E6OE.js";import{W as V}from"./WebsiteAlertBanner-Bhe8YIkt.js";import{P as Y,H as J,a as K,b as X,c as Z,A as ee,C as se,d as te}from"./Integrations.styled-O3Ddi85e.js";import"./UpdateCouponListModal-Dei4NEj-.js";import{u as oe}from"./useObserverIntersecting-LNqlJT5s.js";import"./NotFound-DquEvZuQ.js";import"./Forbidden-Dw2uWe_Q.js";import"./RefreshIcon-R01ibdFD.js";import"./index-kv441vZO.js";import"./message-KTbSURPj.js";import"./List-D65eLfX-.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new Error().stack;o&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[o]="791f091d-8851-456f-a0a9-37a99d0a95b4",s._sentryDebugIdIdentifier="sentry-dbid-791f091d-8851-456f-a0a9-37a99d0a95b4")}catch{}})();const ae=({callback:s})=>{const o=p.useRef(null);return oe(o,s),e.jsx("div",{className:"next-page-observer",ref:o})},ne=T(W).attrs({href:"https://support.wisepops.com/en/articles/13395935-upload-unique-discount-codes",target:"_blank"})` 2 margin-left: var(--space-xs); 3`,ie=D(ne),re=({workspace:s,website:o,row:t,onExport:a,isExporting:l})=>{const i=m();return e.jsxs(c.ActionsMenu,{children:[e.jsx(b,{disabled:l,label:i.formatMessage({id:"coupons.table.action.export",description:"Export action in coupons table",defaultMessage:"Export coupon list"}),onClick:a}),e.jsx(b,{label:i.formatMessage({id:"coupons.table.action.edit",description:"Edit action in coupons table",defaultMessage:"Edit"}),params:{workspace:s,website:o,listId:String(t.id)}
3,to:"/workspaces/$workspace/websites/$website/integrations/coupons/$listId/edit"}),e.jsx(b,{label:i.formatMessage({id:"coupons.table.action.delete",description:"Delete action in coupons table",defaultMessage:"Delete"}),params:{workspace:s,website:o,listId:String(t.id)},to:"/workspaces/$workspace/websites/$website/integrations/coupons/$listId/delete"})]})},ce=({row:s})=>{const o=m(),{createToast:t}=E(),{workspace:a,website:l}=k({from:"/_nav/workspaces/$workspace/websites/$website/integrations/coupons"}),[,i]=M(w.CsvDiscountCodes),{mutate:d,isPending:u}=F({id:+s.id},{onSuccess:()=>{t("default",o.formatMessage({id:"coupons.export.success",description:"Coupon list export success message",defaultMessage:"We have sent you an email containing the exported file"}))},onError:n=>{const r=n.message??o.formatMessage({id:"coupons.export.error",description:"Coupon list export error message",defaultMessage:"An error occurred while exporting the data"});t("error",r)}}),h=p.useCallback(()=>{i()&&d()},[d,i]),g=p.useMemo(()=>{const n=new Date(s.created_at).toISOString().split("T");if(!n[0])return"-";const r=n[1]?.split(".")[0];return r?`${n[0]} ${r}`:n[0]},[s.created_at]);return e.jsxs(e.Fragment,{children:[e.jsx(c.Cell.Label,{wrap:!0,children:e.jsx(te,{children:e.jsx(C.Bold,{children:s.name})})}),e.jsx(c.Cell.Label,{children:g}),e.jsxs(c.Cell.Label,{children:[s.total_code_count-s.used_code_count,"/",s.total_code_count]}),e.jsx(c.Cell.Label,{children:s.low_stock_threshold}),e.jsxs(c.Cell.Buttons,{children:[e.jsx(N,{hint:e.jsx(C.Bold,{children:o.formatMessage({id:"coupons.table.upload_button",description:"Upload button in coupons table",defaultMessage:"Upload new coupons in the list"})}),kind:"left",children:e.jsx(f,{icon:e.jsx(H,{}),kind:"tertiary",onClick:i,params:{workspace:a,website:l,listId:String(s.id)}
3,size:"small",to:"/workspaces/$workspace/websites/$website/integrations/coupons/$listId/upload"})}),e.jsx(re,{isExporting:u,onExport:h,row:s,website:l,workspace:a})]})]})},le=()=>{const s=m(),{handleSearchChange:o,handleSearchClear:t,value:a}=R();return e.jsx(c.Toolbar,{buttons:e.jsx(Q,{name:"search",onChange:o,onClear:t,placeholder:s.formatMessage({id:"coupons.table.search.placeholder",description:"Placeholder for Coupons table's search input",defaultMessage:"Search by Name"}),size:"small",value:a})})},pe=()=>{const[s,o]=M(w.CsvDiscountCodes),t=m(),{workspace:a,website:l}=k({from:"/_nav/workspaces/$workspace/websites/$website/integrations/coupons"}),d=S({from:"/_nav/workspaces/$workspace/websites/$website/integrations/coupons"}).search,{website:{id:u}}=O(),{data:h}=z({id:u}),{data:g,isFetching:n,isFetchingNextPage:r,fetchNextPage:x,hasNextPage:j}=q({search:d,websiteId:u}),v=p.useMemo(()=>({campaign_name:{name:t.formatMessage({id:"coupons.table.name",description:"Coupons page - name column",defaultMessage:"Name"})},creation_date:{name:t.formatMessage({id:"coupons.table.creation_date",description:"Coupons page - creation date column",defaultMessage:"Creation date"})},available:{name:t.formatMessage({id:"coupons.table.available",description:"Coupons page - available column",defaultMessage:"Available/Total"})},low_stock_threshold:{name:t.formatMessage({id:"coupons.table.threshold",description:"Coupons page - low stock threshold column",defaultMessage:"Email alert threshold"}),info:t.formatMessage({id:"coupons.table.threshold.hint",description:"Low stock threshold hint",defaultMessage:"You'll get notified by email when{br}available codes run below this level"},{br:e.jsx("br",{})})},action:{name:" ",style:{width:"240px"}}}),[t]),y=p.useMemo(()=>g?.pages.flatMap(({items:_})=>_)??[],[g]),I=p.useCallback(()=>{r||x()},[r,x]);return e.jsxs(Y,{title:t.formatMessage({description:"Coupons page website title",id:"page.title.coupons",defaultMessage:"Coupons - Wisepops"}),children:[e.jsxs(f,{kind:"ghost",params:{workspace:a,website:l}
3,size:"small",to:"/workspaces/$workspace/websites/$website/integrations",children:[e.jsx(L,{height:16,width:16}),t.formatMessage({description:"Coupons page back button label",id:"coupons.back",defaultMessage:"Integrations"})]}),e.jsxs(J,{children:[e.jsxs(K,{children:[e.jsx(X,{children:t.formatMessage({id:"coupons.header",description:"Coupons page header",defaultMessage:"Coupons"})}),e.jsxs(Z,{children:[e.jsx("span",{children:t.formatMessage({id:"coupons.subtitle",description:"Coupons page subtitle",defaultMessage:"Upload and manage unique discount codes to use in your Wisepops campaigns. <Link>Read more</Link>"},{Link:ie})}),h?.uses_shopify?e.jsx($,{inline:!0,kind:"info",children:t.formatMessage({id:"coupons.subtitle.shopify",description:"Coupons page subtitle - shopify note",defaultMessage:"Shopify unique discount codes are available directly in the builder."})}):null]})]}),e.jsx(f,{kind:"secondary",onClick:o,params:{workspace:a,website:l},prefix:e.jsx(U,{height:"20",width:"20"}),size:"small",to:"/workspaces/$workspace/websites/$website/integrations/coupons/add",children:e.jsxs(ee,{children:[t.formatMessage({id:"coupons.table.create_list",description:"Create new coupon list button",defaultMessage:"Create new list"}),s?null:e.jsx(B,{})]})})]}),e.jsx(V,{}),e.jsx(se,{columns:v,data:y,dataRowComponent:ce,footer:j?e.jsx(ae,{callback:I}):void 0,loading:!!n&&!r,noResults:e.jsx(c.NoResults,{image:G,text:d?t.formatMessage({id:"coupons.search.empty",description:"No results in coupons table",defaultMessage:"Nope! No coupon list match that criteria"}):t.formatMessage({id:"coupons.empty",description:"No results in coupons table",defaultMessage:"No coupon list created yet"})}),toolbar:e.jsx(le,{})}),e.jsx(P,{})]})},De=()=>e.jsx(A,{children:e.jsx(pe,{})});export{De as component};
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.