PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.21
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.21
1.4.21 1.4.20 1.4.19 1.4.18 1.4.17 1.4.16 1.4.15 1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 All 184 releases
disco / backend / views / components / Analytics / components / campaigns / CampaignsTable.jsx

CampaignsTable.jsx in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.4.21, at backend/views/components/Analytics/components/campaigns/CampaignsTable.jsx

116 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import useIsPro from '@/lib/useIsPro';
2 import { truncate } from '@/lib/utils';
3 import { __ } from '@wordpress/i18n';
4 import { Link } from 'react-router';
5 import DataTable from '../ui-blocks/DataTable';
6 import IntentBadge from './IntentBadge';
7 import StatusBadge from './StatusBadge';
8
9 const COLUMNS = [
10 { key: 'name', label: 'Name' },
11 { key: 'intent', label: 'Intent' },
12 { key: 'revenue', label: 'Revenue', sortable: true },
13 { key: 'dateRange', label: 'Date Range' },
14 { key: 'orders', label: 'Orders', sortable: true },
15 { key: 'customers', label: 'Customers', sortable: true },
16 { key: 'status', label: 'Status' },
17 ];
18
19 const renderRow = (campaign) => (
20 <tr
21 key={campaign.id}
22 className="disco:border-b disco:border-[#f3f4f6] disco:last:border-0 disco:hover:bg-[#f9fafb] disco:cursor-pointer disco:transition-colors"
23 >
24 <td className="disco:px-4 disco:py-3">
25 <span className="disco:flex disco:items-center disco:gap-2">
26 <span
27 className="disco:size-1.75 disco:rounded-xs disco:shrink-0"
28 style={{
29 backgroundColor: campaign.dotColor,
30 }}
31 />
32 <Link
33 to={`/campaigns-reports/${campaign.id}`}
34 className="disco:font-medium! disco:text-gray-900! disco:hover:text-primary! disco:focus:text-primary!"
35 >
36 {truncate(campaign.name, 30)}
37 </Link>
38 </span>
39 </td>
40 <td className="disco:px-4 disco:py-3">
41 <IntentBadge intent={campaign.intent} />
42 </td>
43 <td className="disco:px-4 disco:py-3 disco:font-medium disco:text-[#374151]">
44 {campaign.revenue}
45 </td>
46 <td className="disco:px-4 disco:py-3 disco:text-[#6b7280]">
47 {campaign.dateRange}
48 </td>
49 <td className="disco:px-4 disco:py-3 disco:text-[#374151]">
50 {campaign.orders}
51 </td>
52 <td className="disco:px-4 disco:py-3 disco:text-[#374151]">
53 {campaign.customers}
54 </td>
55 <td className="disco:px-4 disco:py-3">
56 <StatusBadge status={campaign.status} />
57 </td>
58 </tr>
59 );
60
61 const CampaignsTable = ({
62 campaigns = [],
63 isLoading = false,
64 search = '',
65 onSearchChange,
66 sortKey = 'spent',
67 sortDir = 'desc',
68 onSort,
69 page = 1,
70 totalPages = 1,
71 total = 0,
72 onPageChange,
73 }) => {
74 const isPro = useIsPro();
75
76 return (
77 <DataTable
78 columns={COLUMNS}
79 data={campaigns}
80 renderRow={renderRow}
81 title="Recent Campaigns"
82 total={total}
83 searchPlaceholder="Search campaigns..."
84 search={search}
85 onSearchChange={onSearchChange}
86 sortKey={sortKey}
87 sortDir={sortDir}
88 onSort={onSort}
89 page={page}
90 totalPages={totalPages}
91 onPageChange={onPageChange}
92 isLoading={isLoading}
93 locked={!isPro}
94 lockOverlay={{
95 size: 'lg',
96 label: __('Upgrade to pro', 'disco'),
97 titleClassName:
98 'disco:max-w-md disco:text-base disco:font-normal disco:text-[#111827] disco:leading-snug',
99 title: (
100 <>
101 <strong className="disco:font-semibold">
102 {__('Upgrade to Disco Pro', 'disco')}
103 </strong>{' '}
104 {__(
105 'to unlock your complete campaign data — including real revenue per campaign, discount ROI, and full trend history.',
106 'disco'
107 )}
108 </>
109 ),
110 }}
111 />
112 );
113 };
114
115 export default CampaignsTable;
116