-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
442 lines (397 loc) · 10.3 KB
/
Copy pathtypes.ts
File metadata and controls
442 lines (397 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
// User Authentication
export interface User {
id: string;
email: string; // Made non-optional
name?: string;
isSuperAdmin?: boolean;
isActive?: boolean; // Adicionado para status da conta
createdAt?: string; // Added for tracking user creation date
}
// For authService internal use, not exposed to UI directly usually
export interface UserWithPassword extends User {
passwordHash: string; // In a real backend, this would be a hash
isActive: boolean; // Garante que UserWithPassword sempre tenha isActive
}
export interface AuthResponse {
token: string;
user: User;
}
export interface DecodedToken {
userId: string;
email: string;
name?: string;
isSuperAdmin?: boolean;
isActive?: boolean; // Adicionado para status da conta
iat: number;
exp: number;
}
// Product related new types
export interface Coupon {
id: string;
code: string;
description?: string; // Optional description for admin
discountType: 'percentage' | 'fixed'; // Fixed is in cents
discountValue: number;
isActive: boolean;
isAutomatic: boolean; // If true, applies automatically if no other coupon is used
minPurchaseValueInCents?: number; // Optional: Minimum purchase value to apply coupon
uses?: number; // How many times it has been used
maxUses?: number; // Optional: Maximum number of uses
expiresAt?: string; // Optional: ISO date string
appliesToProductId?: string; // For product-specific coupons, null/undefined for general
}
export interface OrderBumpOffer {
productId: string; // ID of the product being offered as a bump
customPriceInCents?: number; // Optional custom price for the bump
name: string; // Denormalized for easy display
description: string; // Denormalized
imageUrl?: string; // Denormalized
}
export interface UpsellOffer {
productId: string; // ID of the product being offered as an upsell
customPriceInCents?: number; // Optional custom price for the upsell
name: string; // Denormalized
description: string; // Denormalized
imageUrl?: string; // Denormalized
}
// Product
export interface ProductCheckoutCustomization {
primaryColor?: string;
logoUrl?: string;
videoUrl?: string;
salesCopy?: string; // Will store HTML
testimonials?: { author: string; text: string }[];
guaranteeBadges?: { id: string; imageUrl: string; altText: string }[];
countdownTimer?: {
enabled: boolean;
durationMinutes?: number; // Duração em minutos
messageBefore?: string;
messageAfter?: string; // Message to show when timer expires
backgroundColor?: string;
textColor?: string;
};
}
export type Json =
| string
| number
| boolean
| null
| { [key: string]: Json | undefined }
| Json[];
export interface Product {
id: string;
platformUserId: string;
slug?: string;
name: string;
description: string;
priceInCents: number;
imageUrl?: string;
checkoutCustomization: ProductCheckoutCustomization;
deliveryUrl?: string;
totalSales?: number;
clicks?: number;
checkoutViews?: number;
conversionRate?: number;
abandonmentRate?: number;
orderBump?: OrderBumpOffer;
upsell?: UpsellOffer;
coupons?: Coupon[];
}
// Sale
export enum PaymentStatus {
WAITING_PAYMENT = 'waiting_payment',
PAID = 'paid',
CANCELLED = 'cancelled',
EXPIRED = 'expired',
FAILED = 'failed',
}
export enum PaymentMethod {
PIX = 'pix',
CREDIT_CARD = 'credit_card',
BOLETO = 'boleto',
}
export interface SaleProductItem {
productId: string;
name: string;
quantity: number;
priceInCents: number;
originalPriceInCents: number;
isOrderBump?: boolean;
isUpsell?: boolean;
deliveryUrl?: string;
slug?: string; // Added slug
}
export interface Sale {
id: string;
platformUserId: string;
pushInPayTransactionId: string;
upsellPushInPayTransactionId?: string;
orderIdUrmify?: string;
products: SaleProductItem[];
customer: {
name: string;
email: string;
ip?: string;
whatsapp: string;
};
paymentMethod: PaymentMethod;
status: PaymentStatus;
upsellStatus?: PaymentStatus;
totalAmountInCents: number;
upsellAmountInCents?: number;
originalAmountBeforeDiscountInCents: number;
discountAppliedInCents?: number;
couponCodeUsed?: string;
createdAt: string;
paidAt?: string;
trackingParameters?: Record<string, string>;
commission?: {
totalPriceInCents: number;
gatewayFeeInCents: number;
userCommissionInCents: number;
currency: string;
};
platformCommissionInCents?: number;
}
export interface SaleTransaction {
id: string;
platformUserId: string;
valueInCents: number;
originalValueBeforeDiscountInCents: number;
couponCodeUsed?: string;
discountAppliedToTransactionInCents?: number;
qrCode?: string;
qrCodeBase64?: string;
status: PaymentStatus;
attempts: number;
createdAt: string;
paidAt?: string;
webhookUrl: string;
customerName: string;
customerEmail: string;
customerWhatsapp: string;
products: SaleProductItem[];
trackingParameters?: Record<string, string>;
isUpsellTransaction?: boolean;
originalSaleId?: string;
}
// Customer
export enum FunnelStage {
LEAD = 'lead',
PROSPECT = 'prospect',
CUSTOMER = 'customer',
}
export interface Customer {
id: string;
platformUserId: string;
name: string;
email: string;
whatsapp: string;
productsPurchased: string[];
funnelStage: FunnelStage;
firstPurchaseDate: string;
lastPurchaseDate: string;
totalOrders: number;
totalSpentInCents: number;
saleIds: string[];
}
// Abandoned Cart
export enum AbandonedCartStatus {
NOT_CONTACTED = 'not_contacted',
EMAIL_SENT = 'email_sent',
RECOVERED = 'recovered',
IGNORED = 'ignored',
}
export interface AbandonedCart {
id: string;
platformUserId: string;
customerName: string;
customerEmail: string;
customerWhatsapp: string;
productId: string;
productName: string;
potentialValueInCents: number;
date: string;
lastInteractionAt: string;
status: AbandonedCartStatus;
trackingParameters?: Record<string, string>;
}
// Finances
export interface FinancialSummary {
balance: number;
pending: number;
availableForWithdrawal: number;
}
export interface Transaction {
id: string;
date: string;
description: string;
amount: number; // in cents
type: 'credit' | 'debit';
}
// Integrations
export type PixelType = 'Facebook Pixel' | 'Google Ads' | 'GTM' | 'TikTok Pixel';
export interface PixelIntegration {
id: string;
type: PixelType; // Changed from 'name' to 'type'
settings: Record<string, string>;
enabled: boolean;
}
export interface AppSettings {
customDomain?: string;
checkoutIdentity: {
logoUrl?: string;
faviconUrl?: string;
brandColor?: string;
};
smtpSettings?: {
host: string;
port: number;
user: string;
pass: string;
};
apiTokens: {
pushinPay: string;
utmify: string;
pushinPayEnabled: boolean;
utmifyEnabled: boolean;
};
pixelIntegrations?: PixelIntegration[];
}
export interface PlatformSettings {
id: 'global';
platformCommissionPercentage: number;
platformFixedFeeInCents: number;
platformAccountIdPushInPay: string;
}
export interface AuditLogEntry {
id: string;
timestamp: string;
actorUserId: string;
actorEmail: string;
actionType: string;
targetEntityType?: string;
targetEntityId?: string;
description: string;
details?: Record<string, any>;
}
// For dashboard metric cards
export interface MetricData {
title: string;
value: string | number;
change?: string;
icon: React.ElementType;
bgColorClass: string;
textColorClass: string;
}
export interface DashboardData {
totalRevenue: number;
numberOfSales: number;
averageTicket: number;
newCustomers: number;
salesTrend: { periodLabel: string; amount: number }[];
topSellingProducts?: { id: string; name: string; quantitySold: number; revenueGenerated: number; }[];
}
// PushInPay API Types
export interface PushInPayPixRequest {
value: number;
originalValueBeforeDiscount: number;
webhook_url: string;
customerName: string;
customerEmail: string;
customerWhatsapp: string;
products: SaleProductItem[];
trackingParameters?: Record<string, string>;
couponCodeUsed?: string;
discountAppliedInCents?: number;
isUpsellTransaction?: boolean;
originalSaleId?: string;
}
export interface PushInPayPixResponseData {
id: string;
qr_code: string;
qr_code_base64: string;
status: string; // Corrected: Was PaymentStatus, API returns string
value: number;
}
export interface PushInPayPixResponse {
data?: PushInPayPixResponseData;
success: boolean;
message?: string;
}
export interface PushInPayTransactionStatusData {
id: string;
status: string; // Corrected: Was PaymentStatus, API returns string
value: number;
paid_at?: string;
}
export interface PushInPayTransactionStatusResponse {
data?: PushInPayTransactionStatusData;
success: boolean;
message?: string;
}
// UTMify API Types
export interface UtmifyCustomer {
name: string;
email: string;
whatsapp: string;
ip?: string;
phone?: string | null;
document?: string | null;
country?: string;
}
export interface UtmifyProduct {
id: string;
name: string;
quantity: number;
priceInCents: number;
planId: string | null;
planName: string | null;
isUpsell?: boolean;
slug?: string; // Added slug
}
export interface UtmifyCommission {
totalPriceInCents: number;
gatewayFeeInCents: number;
userCommissionInCents: number;
currency: string;
}
export interface UtmifyOrderPayload {
orderId: string;
platform: string;
paymentMethod: "pix" | "credit_card" | "boleto";
status: PaymentStatus;
createdAt: string;
customer: UtmifyCustomer;
products: UtmifyProduct[];
trackingParameters?: Record<string, string | null>;
commission?: UtmifyCommission;
approvedDate?: string | null;
refundedAt?: string | null;
isTest?: boolean;
couponCodeUsed?: string;
discountAppliedInCents?: number;
originalAmountBeforeDiscountInCents?: number;
isUpsellTransaction?: boolean;
originalSaleId?: string;
}
export interface UtmifyResponse {
success: boolean;
message?: string;
data?: any;
}
// For navigation items
export interface NavItemConfig {
name: string;
href: string;
icon: React.ElementType;
soon?: boolean;
}
// API Client related types
export interface ApiError {
message: string;
status?: number;
}
export interface ApiErrorResponse {
error: ApiError;
}