Skip to content

Commit 32b6579

Browse files
committed
✨ Add Event column to campaigns table and improve demo mode display
- Add Event column to campaigns performance table showing campaign goal types (Purchase, Share, Opt-in, Repeat Purchase, Registration) - Implement goal-to-label mapping in getCampaignsStats with support for real data - Update campaign stats mock data with eventType field - Display € symbol in members table when in demo mode (instead of $) - Update campaign mock data with demo-ready values
1 parent a7e87d1 commit 32b6579

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

apps/dashboard/src/context/campaigns/action/getCampaignsStats.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getBankTokenInfo } from "@/context/campaigns/action/getBankInfo";
77
import { getMyCampaignsStatsMock } from "@/context/campaigns/action/mock";
88
import { getCampaignRepository } from "@/context/campaigns/repository/CampaignRepository";
99
import { isDemoModeActive } from "@/module/common/utils/isDemoMode";
10+
import type { Goal } from "@/types/Campaign";
1011

1112
type CampaignStats = {
1213
productId: string;
@@ -33,6 +34,23 @@ type ApiResult = {
3334
}[];
3435
};
3536

37+
/**
38+
* Map campaign goal types to display labels for the Event column
39+
*/
40+
function mapGoalToEventType(goal?: Goal | ""): string {
41+
if (!goal) return "Unknown";
42+
43+
const goalMap: Record<Goal, string> = {
44+
sales: "Purchase",
45+
awareness: "Share",
46+
traffic: "Opt-in",
47+
retention: "Repeat Purchase",
48+
registration: "Registration",
49+
};
50+
51+
return goalMap[goal] || "Unknown";
52+
}
53+
3654
/**
3755
* Get the current user campaigns
3856
*/
@@ -125,6 +143,7 @@ export async function getMyCampaignsStats() {
125143
id: campaignDoc?._id?.toHexString() ?? campaign.id,
126144
bank: campaign.bank,
127145
token: token,
146+
eventType: mapGoalToEventType(campaignDoc?.type),
128147
// Raw stats
129148
openInteractions: Number(campaign.openInteractions),
130149
readInteractions: Number(campaign.readInteractions),

apps/dashboard/src/context/campaigns/action/mock.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export async function getMyCampaignsStatsMock(): Promise<
2727
id: string;
2828
bank: Address;
2929
token: Address;
30+
eventType: string;
3031
openInteractions: number;
3132
readInteractions: number;
3233
referredInteractions: number;

apps/dashboard/src/mock/campaignStats.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"id": "507f1f77bcf86cd799439011",
55
"bank": "0x1234567890123456789012345678901234567890",
66
"token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
7+
"eventType": "Purchase",
78
"openInteractions": 5200,
89
"readInteractions": 2400,
910
"referredInteractions": 1360,
@@ -24,6 +25,7 @@
2425
"id": "507f1f77bcf86cd799439012",
2526
"bank": "0x2345678901234567890123456789012345678901",
2627
"token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
28+
"eventType": "Share",
2729
"openInteractions": 105,
2830
"readInteractions": 52,
2931
"referredInteractions": 25,
@@ -44,6 +46,7 @@
4446
"id": "507f1f77bcf86cd799439014",
4547
"bank": "0x4567890123456789012345678901234567890123",
4648
"token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
49+
"eventType": "Opt-in",
4750
"openInteractions": 1500,
4851
"readInteractions": 700,
4952
"referredInteractions": 330,
@@ -55,7 +58,7 @@
5558
"sharingRate": 0.42,
5659
"ctr": 0.28,
5760
"amountSpent": 1652.0,
58-
"costPerShare": 1.40,
61+
"costPerShare": 1.4,
5962
"costPerPurchase": 5.0,
6063
"customerMeetingInteractions": 32
6164
},
@@ -64,6 +67,7 @@
6467
"id": "507f1f77bcf86cd799439015",
6568
"bank": "0x5678901234567890123456789012345678901234",
6669
"token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
70+
"eventType": "Repeat Purchase",
6771
"openInteractions": 3100,
6872
"readInteractions": 1450,
6973
"referredInteractions": 669,

apps/dashboard/src/module/campaigns/component/TableCampaignPerformance/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ export function TableCampaignPerformance() {
7575
),
7676
footer: "Total",
7777
}),
78+
columnHelper.accessor("eventType", {
79+
header: "Event",
80+
cell: ({ getValue }) => getValue(),
81+
}),
7882
columnHelper.accessor("ambassador", {
7983
header: () => (
8084
<TooltipTable

apps/dashboard/src/module/members/component/TableMembers/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import {
1919
type GetMembersParam,
2020
getProductMembers,
2121
} from "@/context/members/action/getProductMembers";
22+
import { useIsDemoMode } from "@/module/common/atoms/demoMode";
2223
import { Row } from "@/module/common/component/Row";
2324
import type { ReactTableProps } from "@/module/common/component/Table";
24-
import { useIsDemoMode } from "@/module/common/atoms/demoMode";
2525
import {
2626
addSelectedMembersAtom,
2727
removeSelectedMembersAtom,

0 commit comments

Comments
 (0)