@liiift-studio/sales-portal 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +461 -0
- package/SETUP.md +230 -0
- package/api/getAnalytics.d.ts +38 -0
- package/api/getAnalytics.js +346 -0
- package/api/getBalanceTransactions.d.ts +29 -0
- package/api/getBalanceTransactions.js +125 -0
- package/api/getDesignerInfo.d.ts +37 -0
- package/api/getDesignerInfo.js +98 -0
- package/api/getDesigners.d.ts +28 -0
- package/api/getDesigners.js +63 -0
- package/api/getPreviousSales.d.ts +23 -0
- package/api/getPreviousSales.js +82 -0
- package/api/getSales.d.ts +29 -0
- package/api/getSales.js +50 -0
- package/api/getSalesRange.d.ts +23 -0
- package/api/getSalesRange.js +58 -0
- package/api/utils/authMiddleware.js +84 -0
- package/api/utils/dateUtils.js +69 -0
- package/api/utils/feeCalculator.js +148 -0
- package/api/utils/processors/invoiceProcessor.js +337 -0
- package/api/utils/processors/paymentProcessor.js +462 -0
- package/api/utils/salesDataProcessing.js +596 -0
- package/api/utils/salesDataProcessor.js +224 -0
- package/api/utils/stripeFetcher.js +248 -0
- package/components/DateRangeSalesTable.js +1072 -0
- package/components/DebugValues.js +48 -0
- package/components/LicenseTypeList.js +193 -0
- package/components/LoginForm.js +219 -0
- package/components/PeriodComparison.js +501 -0
- package/components/Sales.js +773 -0
- package/components/SalesChart.js +307 -0
- package/components/SalesPortalPage.js +147 -0
- package/components/SalesTable.js +677 -0
- package/components/SummaryCards.js +345 -0
- package/components/TopPerformers.js +331 -0
- package/components/TypefaceList.js +154 -0
- package/components/table-columns.js +70 -0
- package/components/table-row-cells.js +295 -0
- package/data/countryCode.json +318 -0
- package/hooks/useSalesDateQuery.d.ts +20 -0
- package/hooks/useSalesDateQuery.js +71 -0
- package/index.d.ts +172 -0
- package/index.js +33 -0
- package/package.json +87 -0
- package/styles/sales-portal.module.scss +383 -0
- package/styles/sales-portal.theme.d.ts +5 -0
- package/styles/sales-portal.theme.js +799 -0
- package/utils/currencyUtils.d.ts +20 -0
- package/utils/currencyUtils.js +79 -0
- package/utils/salesDataProcessing.d.ts +44 -0
- package/utils/salesDataProcessing.js +596 -0
- package/utils/useSalesDateQuery.js +71 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Type definitions for currency utility functions
|
|
2
|
+
|
|
3
|
+
export function formatCurrency(
|
|
4
|
+
amount: number,
|
|
5
|
+
currencyCode?: string,
|
|
6
|
+
locale?: string
|
|
7
|
+
): string;
|
|
8
|
+
|
|
9
|
+
export function parseCurrency(
|
|
10
|
+
formattedAmount: string,
|
|
11
|
+
currencyCode?: string
|
|
12
|
+
): number;
|
|
13
|
+
|
|
14
|
+
export function getCurrencySymbol(currencyCode: string): string;
|
|
15
|
+
|
|
16
|
+
export function convertCurrency(
|
|
17
|
+
amount: number,
|
|
18
|
+
fromCurrency: string,
|
|
19
|
+
toCurrency: string
|
|
20
|
+
): number;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Currency formatting utility functions
|
|
3
|
+
* All sales data from API is in cents, these utilities help with proper formatting
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Format currency value in USD
|
|
8
|
+
* @param {number} value - Value in dollars to format as currency
|
|
9
|
+
* @param {Object} options - Formatting options
|
|
10
|
+
* @param {number} options.minimumFractionDigits - Minimum fraction digits (default: 2)
|
|
11
|
+
* @param {number} options.maximumFractionDigits - Maximum fraction digits (default: 2)
|
|
12
|
+
* @returns {string} Formatted currency string
|
|
13
|
+
*/
|
|
14
|
+
export const formatCurrency = (
|
|
15
|
+
value,
|
|
16
|
+
{ minimumFractionDigits = 2, maximumFractionDigits = 2 } = {}
|
|
17
|
+
) => {
|
|
18
|
+
return new Intl.NumberFormat('en-US', {
|
|
19
|
+
style: 'currency',
|
|
20
|
+
currency: 'USD',
|
|
21
|
+
minimumFractionDigits,
|
|
22
|
+
maximumFractionDigits,
|
|
23
|
+
}).format(value);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Convert cents to dollars
|
|
28
|
+
* @param {number} cents - Value in cents
|
|
29
|
+
* @returns {number} Value in dollars
|
|
30
|
+
*/
|
|
31
|
+
export const centsToDollars = (cents) => {
|
|
32
|
+
if (typeof cents !== 'number') {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
return cents / 100;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Format cents as currency
|
|
40
|
+
* @param {number} cents - Value in cents
|
|
41
|
+
* @param {Object} options - Formatting options
|
|
42
|
+
* @returns {string} Formatted currency string
|
|
43
|
+
*/
|
|
44
|
+
export const formatCentsAsCurrency = (cents, options = {}) => {
|
|
45
|
+
return formatCurrency(centsToDollars(cents), options);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Calculate percentage change between two values
|
|
50
|
+
* @param {number} current - Current value
|
|
51
|
+
* @param {number} previous - Previous value
|
|
52
|
+
* @returns {number|null} Percentage change or null if previous is zero
|
|
53
|
+
*/
|
|
54
|
+
export const calculatePercentageChange = (current, previous) => {
|
|
55
|
+
if (!previous || previous === 0) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return ((current - previous) / previous) * 100;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Format percentage value
|
|
63
|
+
* @param {number} value - Percentage value
|
|
64
|
+
* @param {Object} options - Formatting options
|
|
65
|
+
* @param {number} options.decimals - Number of decimal places (default: 1)
|
|
66
|
+
* @param {boolean} options.showPlusSign - Whether to show plus sign for positive values (default: true)
|
|
67
|
+
* @returns {string} Formatted percentage string
|
|
68
|
+
*/
|
|
69
|
+
export const formatPercentage = (
|
|
70
|
+
value,
|
|
71
|
+
{ decimals = 1, showPlusSign = true } = {}
|
|
72
|
+
) => {
|
|
73
|
+
if (value === null || value === undefined) {
|
|
74
|
+
return '';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const sign = value > 0 && showPlusSign ? '+' : '';
|
|
78
|
+
return `${sign}${value.toFixed(decimals)}%`;
|
|
79
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Type definitions for sales data processing utilities
|
|
2
|
+
|
|
3
|
+
export interface SalesData {
|
|
4
|
+
id: string;
|
|
5
|
+
date: string;
|
|
6
|
+
customer?: string;
|
|
7
|
+
amount: number;
|
|
8
|
+
typeface: string;
|
|
9
|
+
licenseType: string;
|
|
10
|
+
country?: string;
|
|
11
|
+
currency?: string;
|
|
12
|
+
discount?: number;
|
|
13
|
+
refund?: number;
|
|
14
|
+
invoice_id?: string;
|
|
15
|
+
metadata?: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SummaryData {
|
|
19
|
+
totalRevenue: number;
|
|
20
|
+
orderCount: number;
|
|
21
|
+
averageOrderValue: number;
|
|
22
|
+
refundAmount?: number;
|
|
23
|
+
discountAmount?: number;
|
|
24
|
+
netRevenue?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function processSalesData(rawData: any[]): SalesData[];
|
|
28
|
+
|
|
29
|
+
export function aggregateSalesData(data: SalesData[]): SummaryData;
|
|
30
|
+
|
|
31
|
+
export function filterSalesByDateRange(
|
|
32
|
+
data: SalesData[],
|
|
33
|
+
startDate: string,
|
|
34
|
+
endDate: string
|
|
35
|
+
): SalesData[];
|
|
36
|
+
|
|
37
|
+
export function groupSalesByTypeface(data: SalesData[]): Record<string, SalesData[]>;
|
|
38
|
+
|
|
39
|
+
export function groupSalesByLicenseType(data: SalesData[]): Record<string, SalesData[]>;
|
|
40
|
+
|
|
41
|
+
export function calculateRevenueByPeriod(
|
|
42
|
+
data: SalesData[],
|
|
43
|
+
period: 'daily' | 'weekly' | 'monthly'
|
|
44
|
+
): any[];
|