PageSourceSearch

https://upkept.io/assets/CouponDiscounts-Dg65zTJr.js

js upkept.io collected 2026-10-05 08:16:15 UTC 12,106 bytes, 47 lines download raw bytes

1import{c as q,r as y,x as h,j as e,C as n,b as p,d as j,e as a,A as c,I as l,B as F,H as b,D as m}from"./index-PoezL6ES.js";import{T as O,a as U,b as g,c as N}from"./tabs-DmcbQoIZ.js";import{F as L}from"./funnel-DCNLFK8-.js";import{D as E}from"./dollar-sign-C-KZLvuf.js";import{U as k}from"./users-f5hxXrUI.js";import{G as f}from"./gift-D1RGfOdz.js";import{T as M}from"./trending-up-CsAsBg5E.js";import"./index-Clfhxc8F.js";import"./index-BDbsAqtD.js";/**
2 * @license lucide-react v0.564.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const P=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],_=q("calendar-days",P),X=`
7  query DiscountAnalytics($filters: DiscountAnalyticsFilters) {
8    discountAnalytics(filters: $filters) {
9      totalDiscountsGiven
10      numberOfRedemptions
11      averageDiscountAmount
12      totalRevenueImpact
13    }
14  }
15`,$=`
16  query PromotionCodeStats($filters: DiscountAnalyticsFilters) {
17    promotionCodeStats(filters: $filters) {
18      promotionCodeId
19      couponId
20      customerEnteredCode
21      redemptionCount
22      totalDiscountAmount
23      averageDiscountAmount
24      totalOriginalAmount
25      firstUsed
26      lastUsed
27    }
28  }
29`,G=`
30  query DiscountRedemptions($filters: DiscountAnalyticsFilters) {
31    discountRedemptions(filters: $filters) {
32      id
33      paymentId
34      invoiceId
35      orderNumber
36      customerName
37      promotionCodeId
38      couponId
39      customerEnteredCode
40      discountAmountCents
41      originalAmountCents
42      finalAmountCents
43      discountPercentage
44      createdAt
45    }
46  }
47`,o=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(t/100),C=t=>new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),H=t=>new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});function ee(){const[t,v]=y.useState({}),[D,A]=y.useState("overview"),{data:d,isLoading:I}=h({queryKey:["discountAnalytics",t],queryFn:async()=>(await(await fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({query:X,variables:{filters:t}})})).json()).data.discountAnalytics}),{data:u,isLoading:w}=h({queryKey:["promotionCodeStats",t],queryFn:async()=>(await(await fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({query:$,variables:{filters:t}})})).json()).data.promotionCodeStats}),{data:x,isLoading:T}=h({queryKey:["discountRedemptions",t],queryFn:async()=>(await(await fetch("/graphql",{method:"POST",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({query:G,variables:{filters:t}})})).json()).data.discountRedemptions}),i=(s,r)=>{v(R=>({...R,[s]:r||void 0}))},S=()=>{v({})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:"Coupon & Discounts"}),e.jsx("p",{className:"text-muted-foreground",children:"Track promotional code usage and discount analytics"})]})}),e.jsxs(n,{children:[e.jsx(p,{children:e.jsxs(j,{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-5 w-5"}),"Filters"]})}),e.jsxs(a,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"startDate",children:"Start Date"}),e.jsx(l,{id:"startDate",type:"date",value:t.startDate||"",onChange:s=>i("startDate",s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"endDate",children:"End Date"}
47),e.jsx(l,{id:"endDate",type:"date",value:t.endDate||"",onChange:s=>i("endDate",s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"promotionCode",children:"Customer-Entered Code"}),e.jsx(l,{id:"promotionCode",placeholder:"Enter customer code (e.g., testcode1)",value:t.promotionCodeId||"",onChange:s=>i("promotionCodeId",s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{htmlFor:"couponId",children:"Coupon ID"}),e.jsx(l,{id:"couponId",placeholder:"Enter coupon ID",value:t.couponId||"",onChange:s=>i("couponId",s.target.value)})]})]}),e.jsx("div",{className:"flex gap-2 mt-4",children:e.jsx(F,{variant:"outline",onClick:S,children:"Clear Filters"})})]})]}),e.jsxs(O,{value:D,onValueChange:A,className:"space-y-4",children:[e.jsxs(U,{children:[e.jsx(g,{value:"overview",children:"Overview"}),e.jsx(g,{value:"codes",children:"Promotion Codes"}),e.jsx(g,{value:"redemptions",children:"Redemptions"})]}),e.jsx(N,{value:"overview",className:"space-y-4",children:I?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[...Array(4)].map((s,r)=>e.jsx(n,{children:e.jsx(a,{className:"p-6",children:e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-8 bg-gray-200 rounded w-1/2"})]})})},r))}):d?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(n,{children:e.jsx(a,{className:"p-6",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"mr-3",children:e.jsx(E,{className:"h-8 w-8 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Discounts Given"}),e.jsx("p",{className:"text-2xl font-bold",children:o(d.totalDiscountsGiven)})]})]})})}),e.jsx(n,{children:e.jsx(a,{className:"p-6",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"mr-3",children:e.jsx(k,{className:"h-8 w-8 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Number of Redemptions"}),e.jsx("p",{className:"text-2xl font-bold",children:d.numberOfRedemptions.toLocaleString()})]})]})})}),e.jsx(n,{children:e.jsx(a,{className:"p-6",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"mr-3",children:e.jsx(f,{className:"h-8 w-8 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Average Discount"}),e.jsx("p",{className:"text-2xl font-bold",children:o(d.averageDiscountAmount)})]})]})})}),e.jsx(n,{children:e.jsx(a,{className:"p-6",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"mr-3",children:e.jsx(M,{className:"h-8 w-8 text-orange-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Total Revenue Impact"}),e.jsx("p",{className:"text-2xl font-bold",children:o(d.totalRevenueImpact)})]})]})})})]}),d.numberOfRedemptions===0&&e.jsx(n,{children:e.jsxs(a,{className:"p-8 text-center",children:[e.jsx(f,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No discount data found"}),e.jsx("p",{className:"text-muted-foreground",children:"No promotional codes have been used yet, or none match your current filters."})]})})]}):null}),e.jsx(N,{value:"codes",className:"space-y-4",children:w?e.jsx(n,{children:e.jsx(a,{className:"p-6",children:e.jsx("div",{className:"animate-pulse space-y-4",children:[...Array(3)].map((s,r)=>e.jsx("div",{className:"h-16 bg-gray-200 rounded"},r))})})}):u&&u.length>0?e.jsxs(n,{children:[e.jsxs(p,{children:[e.jsx(j,{children:"Promotion Code Performance"}),e.jsx(b,{children:"Performance metrics for all promotion codes"})]}),e.jsx(a,{children:e.jsx("div",{className:"space-y-4",children:u.map(s=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{variant:"outline",className:"font-mono text-base",children:s.customerEnteredCode||s.promotionCodeId}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Coupon: ",s.couponId]})]}),e.jsxs(m,{variant:"secondary",children:[s.redemptionCount," redemptions"]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Total Discount:"}),e.jsx("p",{className:"font-semibold",children:o(s.totalDiscountAmount)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Average Discount:"}),e.jsx("p",{className:"font-semibold",children:o(s.averageDiscountAmount)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"First Used:"}),e.jsx("p",{className:"font-semibold",children:C(s.firstUsed)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Last Used:"}),e.jsx("p",{className:"font-semibold",children:C(s.lastUsed)})]})]})]},s.promotionCodeId))})})]}):e.jsx(n,{children:e.jsxs(a,{className:"p-8 text-center",children:[e.jsx(f,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No promotion codes found"}),e.jsx("p",{className:"text-muted-foreground",children:"No promotion codes have been used yet, or none match your current filters."})]})})}),e.jsx(N,{value:"redemptions",className:"space-y-4",children:T?e.jsx(n,{children:e.jsx(a,{className:"p-6",children:e.jsx("div",{className:"animate-pulse space-y-4",children:[...Array(5)].map((s,r)=>e.jsx("div",{className:"h-20 bg-gray-200 rounded"},r))})})}):x&&x.length>0?e.jsxs(n,{children:[e.jsxs(p,{children:[e.jsx(j,{children:"Recent Redemptions"}),e.jsx(b,{children:"Individual discount redemptions with customer details"})]}),e.jsx(a,{children:e.jsx("div",{className:"space-y-4",children:x.map(s=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{variant:"outline",className:"font-mono",children:s.orderNumber}),e.jsx("span",{className:"font-medium",children:s.customerName})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(m,{variant:"secondary",children:s.customerEnteredCode||s.promotionCodeId}),e.jsx("span",{className:"text-sm text-muted-foreground",children:H(s.createdAt)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Original Amount:"}),e.jsx("p",{className:"font-semibold",children:o(s.originalAmountCents)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Discount:"}),e.jsxs("p",{className:"font-semibold text-green-600",children:["-",o(s.discountAmountCents)," (",s.discountPercentage,"%)"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Final Amount:"}),e.jsx("p",{className:"font-semibold",children:o(s.finalAmountCents)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Payment ID:"}),e.jsxs("p",{className:"font-semibold",children:["#",s.paymentId]})]})]})]},s.id))})})]}):e.jsx(n,{children:e.jsxs(a,{className:"p-8 text-center",children:[e.jsx(_,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No redemptions foun
47d"}),e.jsx("p",{className:"text-muted-foreground",children:"No discount redemptions found for your current filters."})]})})})]})]})}export{ee 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.