@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
package/README.md
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
# @liiift-studio/sales-portal
|
|
2
|
+
|
|
3
|
+
Centralized sales portal dashboard package for Liiift Studio projects (Darden Studio & Positype).
|
|
4
|
+
|
|
5
|
+
## Description
|
|
6
|
+
|
|
7
|
+
This package provides a comprehensive sales dashboard for type foundries, featuring:
|
|
8
|
+
|
|
9
|
+
- 📊 Period-over-period sales comparison
|
|
10
|
+
- 📈 Interactive charts and data visualization
|
|
11
|
+
- 🗂️ DataGrid tables with sorting, filtering, and CSV export
|
|
12
|
+
- 📅 Date range selection for custom reports
|
|
13
|
+
- 💰 Stripe reconciliation checks
|
|
14
|
+
- 🎯 Top performers analysis (typefaces and designers)
|
|
15
|
+
- 📋 Detailed typeface and license type breakdowns
|
|
16
|
+
- 🔍 Summary cards with key metrics
|
|
17
|
+
|
|
18
|
+
## Liiift Add-on Features / Plugins
|
|
19
|
+
|
|
20
|
+
The Liiift platform provides a modular plugin system. Each feature can be enabled or disabled per foundry via environment variables:
|
|
21
|
+
|
|
22
|
+
| Feature | Environment Variable | Description |
|
|
23
|
+
|---------|---------------------|-------------|
|
|
24
|
+
| ✅ Sales Portal | `SALES_PORTAL_ENABLED` | Designer sales dashboard with analytics |
|
|
25
|
+
| ✅ Custom Documents | `CUSTOM_DOCUMENTS_ENABLED` | Branded invoices, receipts, license PDFs |
|
|
26
|
+
| ✅ Meta Fingerprinting | `META_FINGERPRINTING_ENABLED` | On-sale font metadata injection |
|
|
27
|
+
| ✅ Multi-Script License | `MULTI_SCRIPT_LICENSE_ENABLED` | Language/script-based licensing options |
|
|
28
|
+
| ✅ Beta/Pre-release | `BETA_PRERELEASE_ENABLED` | Early access font releases section |
|
|
29
|
+
| ✅ Bulk Font Uploader | `BULK_FONT_UPLOADER_ENABLED` | Batch font file uploads to CMS |
|
|
30
|
+
| ✅ Smart Media Pipeline | `MEDIA_PIPELINE_ENABLED` | Automated image/video optimization |
|
|
31
|
+
|
|
32
|
+
### Feature Status by Foundry
|
|
33
|
+
|
|
34
|
+
| Foundry | Sales Portal | Custom Docs | Meta FP | Multi-Script | Beta | Bulk Upload | Media Pipeline |
|
|
35
|
+
|---------|:------------:|:-----------:|:-------:|:------------:|:----:|:-----------:|:--------------:|
|
|
36
|
+
| Positype | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
37
|
+
| Darden Studio | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ |
|
|
38
|
+
| The Designers Foundry | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ |
|
|
39
|
+
| MCKL | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
|
|
40
|
+
| Sorkin Type | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install @liiift-studio/sales-portal
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Prerequisites
|
|
49
|
+
|
|
50
|
+
This package requires the following peer dependencies in your project:
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"@mui/material": "^5.10.0",
|
|
55
|
+
"@mui/x-data-grid": "^8.0.0",
|
|
56
|
+
"@mui/x-date-pickers": "^7.0.0",
|
|
57
|
+
"@mui/x-charts": "^7.0.0",
|
|
58
|
+
"react": "^18.0.0",
|
|
59
|
+
"react-dom": "^18.0.0",
|
|
60
|
+
"next": "^14.0.0",
|
|
61
|
+
"dayjs": "^1.11.0",
|
|
62
|
+
"slugify": "^1.6.0"
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Required Foundry Repository Structure
|
|
67
|
+
|
|
68
|
+
Your foundry's Next.js application **must** have the following directory structure and wrapper files to use this package. The wrapper files are thin re-exports that allow Next.js API routes to work with the centralized package.
|
|
69
|
+
|
|
70
|
+
### Complete Directory Structure
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
your-foundry-app/
|
|
74
|
+
├── .env.local # Environment variables
|
|
75
|
+
├── .npmrc # GitHub Packages authentication
|
|
76
|
+
├── package.json # Add @liiift/sales-portal dependency
|
|
77
|
+
├── pages/
|
|
78
|
+
│ ├── _app.js # Wrap with MUI providers
|
|
79
|
+
│ ├── sales-portal.js # Your sales dashboard page
|
|
80
|
+
│ └── api/
|
|
81
|
+
│ └── sales-portal/ # API wrapper directory
|
|
82
|
+
│ ├── getDesignerInfo.js # ⚠️ REQUIRED
|
|
83
|
+
│ ├── getDesigners.js # ⚠️ REQUIRED
|
|
84
|
+
│ ├── getSales.js # ⚠️ REQUIRED
|
|
85
|
+
│ ├── getSalesRange.js # ⚠️ REQUIRED
|
|
86
|
+
│ ├── getPreviousSales.js # ⚠️ REQUIRED
|
|
87
|
+
│ ├── getBalanceTransactions.js # ⚠️ REQUIRED
|
|
88
|
+
│ ├── getAnalytics.js # ⚠️ REQUIRED
|
|
89
|
+
│ └── utils/ # Utility wrappers
|
|
90
|
+
│ ├── authMiddleware.js
|
|
91
|
+
│ ├── dateUtils.js
|
|
92
|
+
│ ├── feeCalculator.js
|
|
93
|
+
│ ├── salesDataProcessing.js
|
|
94
|
+
│ ├── salesDataProcessor.js
|
|
95
|
+
│ ├── stripeFetcher.js
|
|
96
|
+
│ └── processors/
|
|
97
|
+
│ ├── invoiceProcessor.js
|
|
98
|
+
│ └── paymentProcessor.js
|
|
99
|
+
└── next.config.js # MUI transpile configuration
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Required Wrapper Files
|
|
103
|
+
|
|
104
|
+
Create each of these files **exactly** as shown:
|
|
105
|
+
|
|
106
|
+
#### API Route Wrappers (with default exports)
|
|
107
|
+
|
|
108
|
+
**`pages/api/sales-portal/getDesignerInfo.js`**
|
|
109
|
+
```javascript
|
|
110
|
+
export { default, config } from '@liiift-studio/sales-portal/api/getDesignerInfo';
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**`pages/api/sales-portal/getDesigners.js`**
|
|
114
|
+
```javascript
|
|
115
|
+
export { default, config } from '@liiift-studio/sales-portal/api/getDesigners';
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**`pages/api/sales-portal/getSales.js`**
|
|
119
|
+
```javascript
|
|
120
|
+
export { default, config } from '@liiift-studio/sales-portal/api/getSales';
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**`pages/api/sales-portal/getSalesRange.js`**
|
|
124
|
+
```javascript
|
|
125
|
+
export { default, config } from '@liiift-studio/sales-portal/api/getSalesRange';
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**`pages/api/sales-portal/getPreviousSales.js`**
|
|
129
|
+
```javascript
|
|
130
|
+
export { default, config } from '@liiift-studio/sales-portal/api/getPreviousSales';
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**`pages/api/sales-portal/getBalanceTransactions.js`**
|
|
134
|
+
```javascript
|
|
135
|
+
export { default, config } from '@liiift-studio/sales-portal/api/getBalanceTransactions';
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**`pages/api/sales-portal/getAnalytics.js`**
|
|
139
|
+
```javascript
|
|
140
|
+
export { default, config } from '@liiift-studio/sales-portal/api/getAnalytics';
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### Utility Wrappers (with named exports)
|
|
144
|
+
|
|
145
|
+
**`pages/api/sales-portal/utils/authMiddleware.js`**
|
|
146
|
+
```javascript
|
|
147
|
+
export * from '@liiift-studio/sales-portal/api/utils/authMiddleware';
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**`pages/api/sales-portal/utils/dateUtils.js`**
|
|
151
|
+
```javascript
|
|
152
|
+
export * from '@liiift-studio/sales-portal/api/utils/dateUtils';
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**`pages/api/sales-portal/utils/feeCalculator.js`**
|
|
156
|
+
```javascript
|
|
157
|
+
export * from '@liiift-studio/sales-portal/api/utils/feeCalculator';
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**`pages/api/sales-portal/utils/salesDataProcessing.js`**
|
|
161
|
+
```javascript
|
|
162
|
+
export * from '@liiift-studio/sales-portal/api/utils/salesDataProcessing';
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**`pages/api/sales-portal/utils/salesDataProcessor.js`**
|
|
166
|
+
```javascript
|
|
167
|
+
export * from '@liiift-studio/sales-portal/api/utils/salesDataProcessor';
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**`pages/api/sales-portal/utils/stripeFetcher.js`**
|
|
171
|
+
```javascript
|
|
172
|
+
export * from '@liiift-studio/sales-portal/api/utils/stripeFetcher';
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**`pages/api/sales-portal/utils/processors/invoiceProcessor.js`**
|
|
176
|
+
```javascript
|
|
177
|
+
export * from '@liiift-studio/sales-portal/api/utils/processors/invoiceProcessor';
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**`pages/api/sales-portal/utils/processors/paymentProcessor.js`**
|
|
181
|
+
```javascript
|
|
182
|
+
export * from '@liiift-studio/sales-portal/api/utils/processors/paymentProcessor';
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Quick Setup Script
|
|
186
|
+
|
|
187
|
+
To quickly create all wrapper files, you can run this bash script from your foundry app root:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
#!/bin/bash
|
|
191
|
+
# create-sales-portal-wrappers.sh
|
|
192
|
+
|
|
193
|
+
# Create directory structure
|
|
194
|
+
mkdir -p pages/api/sales-portal/utils/processors
|
|
195
|
+
|
|
196
|
+
# API route wrappers
|
|
197
|
+
echo "export { default, config } from '@liiift-studio/sales-portal/api/getDesignerInfo';" > pages/api/sales-portal/getDesignerInfo.js
|
|
198
|
+
echo "export { default, config } from '@liiift-studio/sales-portal/api/getDesigners';" > pages/api/sales-portal/getDesigners.js
|
|
199
|
+
echo "export { default, config } from '@liiift-studio/sales-portal/api/getSales';" > pages/api/sales-portal/getSales.js
|
|
200
|
+
echo "export { default, config } from '@liiift-studio/sales-portal/api/getSalesRange';" > pages/api/sales-portal/getSalesRange.js
|
|
201
|
+
echo "export { default, config } from '@liiift-studio/sales-portal/api/getPreviousSales';" > pages/api/sales-portal/getPreviousSales.js
|
|
202
|
+
echo "export { default, config } from '@liiift-studio/sales-portal/api/getBalanceTransactions';" > pages/api/sales-portal/getBalanceTransactions.js
|
|
203
|
+
echo "export { default, config } from '@liiift-studio/sales-portal/api/getAnalytics';" > pages/api/sales-portal/getAnalytics.js
|
|
204
|
+
|
|
205
|
+
# Utility wrappers
|
|
206
|
+
echo "export * from '@liiift-studio/sales-portal/api/utils/authMiddleware';" > pages/api/sales-portal/utils/authMiddleware.js
|
|
207
|
+
echo "export * from '@liiift-studio/sales-portal/api/utils/dateUtils';" > pages/api/sales-portal/utils/dateUtils.js
|
|
208
|
+
echo "export * from '@liiift-studio/sales-portal/api/utils/feeCalculator';" > pages/api/sales-portal/utils/feeCalculator.js
|
|
209
|
+
echo "export * from '@liiift-studio/sales-portal/api/utils/salesDataProcessing';" > pages/api/sales-portal/utils/salesDataProcessing.js
|
|
210
|
+
echo "export * from '@liiift-studio/sales-portal/api/utils/salesDataProcessor';" > pages/api/sales-portal/utils/salesDataProcessor.js
|
|
211
|
+
echo "export * from '@liiift-studio/sales-portal/api/utils/stripeFetcher';" > pages/api/sales-portal/utils/stripeFetcher.js
|
|
212
|
+
echo "export * from '@liiift-studio/sales-portal/api/utils/processors/invoiceProcessor';" > pages/api/sales-portal/utils/processors/invoiceProcessor.js
|
|
213
|
+
echo "export * from '@liiift-studio/sales-portal/api/utils/processors/paymentProcessor';" > pages/api/sales-portal/utils/processors/paymentProcessor.js
|
|
214
|
+
|
|
215
|
+
echo "✅ All sales-portal wrapper files created!"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Make the script executable and run it:
|
|
219
|
+
```bash
|
|
220
|
+
chmod +x create-sales-portal-wrappers.sh
|
|
221
|
+
./create-sales-portal-wrappers.sh
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Environment Variables
|
|
225
|
+
|
|
226
|
+
Create `.env.local` in your foundry app root with these required variables:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Sanity CMS Configuration
|
|
230
|
+
SANITY_STUDIO_PROJECT_ID=your_project_id
|
|
231
|
+
SANITY_STUDIO_DATASET=production
|
|
232
|
+
SANITY_STUDIO_API_VERSION=2022-04-01
|
|
233
|
+
SANITY_STUDIO_TOKEN=your_sanity_token_here
|
|
234
|
+
|
|
235
|
+
# Stripe Configuration
|
|
236
|
+
STRIPE_SECRET_KEY=your_stripe_secret_key_here
|
|
237
|
+
|
|
238
|
+
# ============================================
|
|
239
|
+
# LIIIFT ADD-ON FEATURES / PLUGINS
|
|
240
|
+
# ============================================
|
|
241
|
+
# Each feature can be enabled/disabled independently per foundry
|
|
242
|
+
|
|
243
|
+
# Sales Portal - Designer sales dashboard with analytics
|
|
244
|
+
SALES_PORTAL_ENABLED=true
|
|
245
|
+
|
|
246
|
+
# Custom Documents - Branded invoices, receipts, license PDFs
|
|
247
|
+
CUSTOM_DOCUMENTS_ENABLED=true
|
|
248
|
+
|
|
249
|
+
# Meta Fingerprinting - On-sale font metadata injection
|
|
250
|
+
META_FINGERPRINTING_ENABLED=true
|
|
251
|
+
|
|
252
|
+
# Multi-Script License Selection - Language/script-based licensing
|
|
253
|
+
MULTI_SCRIPT_LICENSE_ENABLED=true
|
|
254
|
+
|
|
255
|
+
# Beta/Pre-release Section - Early access font releases
|
|
256
|
+
BETA_PRERELEASE_ENABLED=true
|
|
257
|
+
|
|
258
|
+
# Bulk Font Uploader - Batch font file uploads to CMS
|
|
259
|
+
BULK_FONT_UPLOADER_ENABLED=true
|
|
260
|
+
|
|
261
|
+
# Smart Media Pipeline - Automated image/video optimization
|
|
262
|
+
MEDIA_PIPELINE_ENABLED=true
|
|
263
|
+
|
|
264
|
+
# Optional: NextAuth (if using)
|
|
265
|
+
NEXTAUTH_URL=https://your-domain.com
|
|
266
|
+
NEXTAUTH_SECRET=your_nextauth_secret
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### Feature Toggle
|
|
270
|
+
|
|
271
|
+
The `SALES_PORTAL_ENABLED` environment variable controls whether the sales portal is accessible:
|
|
272
|
+
|
|
273
|
+
- **`true`** (default) - Sales portal functions normally
|
|
274
|
+
- **`false`** - All API endpoints return a 503 response with `{ success: false, message: 'Sales portal is currently disabled', disabled: true }`
|
|
275
|
+
|
|
276
|
+
This is useful for:
|
|
277
|
+
- Temporarily disabling the sales portal during maintenance
|
|
278
|
+
- Enabling/disabling the feature per foundry site
|
|
279
|
+
- Quick rollback without code changes
|
|
280
|
+
|
|
281
|
+
### NPM Authentication
|
|
282
|
+
|
|
283
|
+
This package is published to npmjs.org under the `@liiift-studio` organization. No additional registry configuration is required - npm will automatically fetch from the public registry.
|
|
284
|
+
|
|
285
|
+
For private installations requiring authentication, configure your npm credentials:
|
|
286
|
+
```bash
|
|
287
|
+
npm login
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Integration Checklist
|
|
291
|
+
|
|
292
|
+
Use this checklist to verify your setup:
|
|
293
|
+
|
|
294
|
+
- [ ] ✅ Package installed: `@liiift-studio/sales-portal` in package.json
|
|
295
|
+
- [ ] ✅ All 7 API route wrappers created in `pages/api/sales-portal/`
|
|
296
|
+
- [ ] ✅ All 8 utility wrappers created in `pages/api/sales-portal/utils/`
|
|
297
|
+
- [ ] ✅ `.env.local` file created with all required environment variables
|
|
298
|
+
- [ ] ✅ `next.config.js` includes MUI transpilePackages
|
|
299
|
+
- [ ] ✅ `pages/_app.js` wrapped with MUI ThemeProvider and LocalizationProvider
|
|
300
|
+
- [ ] ✅ `pages/sales-portal.js` created with Sales component
|
|
301
|
+
- [ ] ✅ Development server starts without errors
|
|
302
|
+
- [ ] ✅ Navigate to `/sales-portal` and see login form
|
|
303
|
+
- [ ] ✅ Login with designer credentials succeeds
|
|
304
|
+
- [ ] ✅ Sales data displays correctly
|
|
305
|
+
- [ ] ✅ CSV export works
|
|
306
|
+
- [ ] ✅ PDF print works
|
|
307
|
+
|
|
308
|
+
## Setup
|
|
309
|
+
|
|
310
|
+
### 1. Configure Next.js
|
|
311
|
+
|
|
312
|
+
Add MUI X packages to transpilation in `next.config.js`:
|
|
313
|
+
|
|
314
|
+
```js
|
|
315
|
+
const nextConfig = {
|
|
316
|
+
transpilePackages: ['@mui/x-data-grid', '@mui/x-date-pickers', '@mui/x-charts'],
|
|
317
|
+
// ... rest of your config
|
|
318
|
+
};
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### 2. Add MUI Providers
|
|
322
|
+
|
|
323
|
+
Wrap your app with required providers in `pages/_app.js`:
|
|
324
|
+
|
|
325
|
+
```jsx
|
|
326
|
+
import { ThemeProvider } from '@mui/material/styles';
|
|
327
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
328
|
+
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
|
|
329
|
+
import { salesTheme } from '@liiift-studio/sales-portal';
|
|
330
|
+
|
|
331
|
+
function MyApp({ Component, pageProps }) {
|
|
332
|
+
return (
|
|
333
|
+
<ThemeProvider theme={salesTheme}>
|
|
334
|
+
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
335
|
+
<Component {...pageProps} />
|
|
336
|
+
</LocalizationProvider>
|
|
337
|
+
</ThemeProvider>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### 3. Set up API Routes
|
|
343
|
+
|
|
344
|
+
Copy the API handlers from the package to your `pages/api/sales-portal/` directory:
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
cp -R node_modules/@liiift-studio/sales-portal/api/* pages/api/sales-portal/
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Or create wrapper handlers:
|
|
351
|
+
|
|
352
|
+
```js
|
|
353
|
+
// pages/api/sales-portal/getSales.js
|
|
354
|
+
import handler from '@liiift-studio/sales-portal/api/getSales';
|
|
355
|
+
export default handler;
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
## Usage
|
|
359
|
+
|
|
360
|
+
### Basic Sales Dashboard
|
|
361
|
+
|
|
362
|
+
```jsx
|
|
363
|
+
import { Sales } from '@liiift-studio/sales-portal';
|
|
364
|
+
|
|
365
|
+
export default function SalesPortalPage() {
|
|
366
|
+
return <Sales designer={designerData} admin={isAdmin} />;
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Date Range Sales Table
|
|
371
|
+
|
|
372
|
+
```jsx
|
|
373
|
+
import { DateRangeSalesTable } from '@liiift-studio/sales-portal';
|
|
374
|
+
|
|
375
|
+
export default function ExportsPage() {
|
|
376
|
+
return (
|
|
377
|
+
<DateRangeSalesTable
|
|
378
|
+
designer={designerData}
|
|
379
|
+
admin={isAdmin}
|
|
380
|
+
loading={false}
|
|
381
|
+
updateLoadingState={(key, state) => console.log(key, state)}
|
|
382
|
+
/>
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Individual Components
|
|
388
|
+
|
|
389
|
+
```jsx
|
|
390
|
+
import {
|
|
391
|
+
SalesTable,
|
|
392
|
+
SalesChart,
|
|
393
|
+
SummaryCards,
|
|
394
|
+
TopPerformers
|
|
395
|
+
} from '@liiift-studio/sales-portal';
|
|
396
|
+
|
|
397
|
+
// Use components individually as needed
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## Exports
|
|
401
|
+
|
|
402
|
+
### Components
|
|
403
|
+
- `Sales` - Main dashboard component
|
|
404
|
+
- `SalesTable` - Table with sales data
|
|
405
|
+
- `DateRangeSalesTable` - Table for custom date ranges
|
|
406
|
+
- `SalesChart` - Charts for visualizing sales trends
|
|
407
|
+
- `SummaryCards` - Key metrics summary cards
|
|
408
|
+
- `TopPerformers` - Top performing typefaces/designers
|
|
409
|
+
- `TypefaceList` - Detailed typeface breakdown
|
|
410
|
+
- `LicenseTypeList` - License type analysis
|
|
411
|
+
- `PeriodComparison` - Period-over-period comparison
|
|
412
|
+
- `DebugValues` - Debug information display
|
|
413
|
+
- `TableRowCells`, `getCellValue` - Table cell rendering utilities
|
|
414
|
+
- `COLUMNS` - Table column definitions
|
|
415
|
+
|
|
416
|
+
### Hooks
|
|
417
|
+
- `useSalesDateQuery` - Date query management hook
|
|
418
|
+
|
|
419
|
+
### Utilities
|
|
420
|
+
- Currency formatting utilities
|
|
421
|
+
- Sales data processing functions
|
|
422
|
+
|
|
423
|
+
### Styles
|
|
424
|
+
- `salesTheme` - MUI theme configuration
|
|
425
|
+
|
|
426
|
+
### API Handlers (import separately)
|
|
427
|
+
```js
|
|
428
|
+
import getDesignerInfo from '@liiift-studio/sales-portal/api/getDesignerInfo';
|
|
429
|
+
import getDesigners from '@liiift-studio/sales-portal/api/getDesigners';
|
|
430
|
+
import getSales from '@liiift-studio/sales-portal/api/getSales';
|
|
431
|
+
import getPreviousSales from '@liiift-studio/sales-portal/api/getPreviousSales';
|
|
432
|
+
import getSalesRange from '@liiift-studio/sales-portal/api/getSalesRange';
|
|
433
|
+
import getBalanceTransactions from '@liiift-studio/sales-portal/api/getBalanceTransactions';
|
|
434
|
+
import getAnalytics from '@liiift-studio/sales-portal/api/getAnalytics';
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
## Development
|
|
438
|
+
|
|
439
|
+
To make changes to this package:
|
|
440
|
+
|
|
441
|
+
1. Clone the repository
|
|
442
|
+
2. Make your changes
|
|
443
|
+
3. Update the version: `npm version patch|minor|major`
|
|
444
|
+
4. Commit and push
|
|
445
|
+
5. GitHub Actions will automatically publish to npmjs.org
|
|
446
|
+
|
|
447
|
+
## Updating in Projects
|
|
448
|
+
|
|
449
|
+
To get the latest version in your project:
|
|
450
|
+
|
|
451
|
+
```bash
|
|
452
|
+
npm update @liiift-studio/sales-portal
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
## License
|
|
456
|
+
|
|
457
|
+
UNLICENSED
|
|
458
|
+
|
|
459
|
+
## Support
|
|
460
|
+
|
|
461
|
+
For issues or questions, contact the development team or open an issue in the repository.
|
package/SETUP.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Sales Portal Package Setup & Usage Guide
|
|
2
|
+
|
|
3
|
+
## What Was Created
|
|
4
|
+
|
|
5
|
+
A centralized npm package `@liiift/sales-portal` that contains all the sales portal code:
|
|
6
|
+
|
|
7
|
+
- **Repository**: https://github.com/Liiift-Studio/sales-portal
|
|
8
|
+
- **Package Name**: `@liiift/sales-portal`
|
|
9
|
+
- **Version**: 1.0.0
|
|
10
|
+
|
|
11
|
+
## Package Contents
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
sales-portal/
|
|
15
|
+
├── components/ # All React components
|
|
16
|
+
├── api/ # API route handlers
|
|
17
|
+
├── hooks/ # Custom React hooks
|
|
18
|
+
├── utils/ # Utility functions
|
|
19
|
+
├── styles/ # SCSS and theme files
|
|
20
|
+
├── data/ # Static data (country codes)
|
|
21
|
+
├── index.js # Main export file
|
|
22
|
+
├── package.json # Package configuration
|
|
23
|
+
└── README.md # Full documentation
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## How to Use in Projects
|
|
27
|
+
|
|
28
|
+
### First Time Setup
|
|
29
|
+
|
|
30
|
+
1. **Ensure `.npmrc` exists in your project** (already created in Positype):
|
|
31
|
+
```
|
|
32
|
+
@liiift:registry=https://npm.pkg.github.com
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
2. **Authenticate with GitHub Packages** (one-time setup):
|
|
36
|
+
```bash
|
|
37
|
+
# Create a GitHub personal access token with read:packages scope
|
|
38
|
+
# Then login to GitHub Packages
|
|
39
|
+
npm login --registry=https://npm.pkg.github.com
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
3. **Install the package**:
|
|
43
|
+
```bash
|
|
44
|
+
# For production (when published)
|
|
45
|
+
yarn add @liiift/sales-portal
|
|
46
|
+
|
|
47
|
+
# For local development (currently linked)
|
|
48
|
+
yarn link "@liiift/sales-portal"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### In Your Code
|
|
52
|
+
|
|
53
|
+
**Import components:**
|
|
54
|
+
```jsx
|
|
55
|
+
import { Sales, DateRangeSalesTable, salesTheme } from '@liiift/sales-portal';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Use in pages:**
|
|
59
|
+
```jsx
|
|
60
|
+
import { Sales, salesTheme } from '@liiift/sales-portal';
|
|
61
|
+
import { ThemeProvider } from '@mui/system';
|
|
62
|
+
|
|
63
|
+
export default function SalesPortalPage() {
|
|
64
|
+
return (
|
|
65
|
+
<ThemeProvider theme={salesTheme}>
|
|
66
|
+
<Sales designer={designerData} admin={isAdmin} />
|
|
67
|
+
</ThemeProvider>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Testing the Changes in Positype
|
|
73
|
+
|
|
74
|
+
### Current Status
|
|
75
|
+
|
|
76
|
+
✅ Package created and linked locally
|
|
77
|
+
✅ Positype updated to import from package
|
|
78
|
+
✅ `.npmrc` configured
|
|
79
|
+
⏳ Needs dev server restart for testing
|
|
80
|
+
|
|
81
|
+
### Steps to Test
|
|
82
|
+
|
|
83
|
+
1. **Restart the development server**:
|
|
84
|
+
```bash
|
|
85
|
+
cd /Users/quinn-keaveney/Desktop/GITs/positype
|
|
86
|
+
# Stop current server (Ctrl+C)
|
|
87
|
+
yarn dev
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
2. **Visit the sales portal**:
|
|
91
|
+
```
|
|
92
|
+
http://localhost:3000/sales-portal
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
3. **Expected behavior**:
|
|
96
|
+
- Login page loads correctly
|
|
97
|
+
- Components import from `@liiift/sales-portal` package
|
|
98
|
+
- All functionality works as before
|
|
99
|
+
|
|
100
|
+
## Publishing Updates
|
|
101
|
+
|
|
102
|
+
### Making Changes to the Package
|
|
103
|
+
|
|
104
|
+
1. **Make changes in the sales-portal repo**:
|
|
105
|
+
```bash
|
|
106
|
+
cd /Users/quinn-keaveney/Desktop/GITs/sales-portal
|
|
107
|
+
# Make your changes...
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
2. **Commit changes**:
|
|
111
|
+
```bash
|
|
112
|
+
git add -A
|
|
113
|
+
git commit -m "Description of changes"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
3. **Update version**:
|
|
117
|
+
```bash
|
|
118
|
+
npm version patch # for bug fixes
|
|
119
|
+
npm version minor # for new features
|
|
120
|
+
npm version major # for breaking changes
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
4. **Push and tag**:
|
|
124
|
+
```bash
|
|
125
|
+
git push
|
|
126
|
+
git push --tags
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
5. **GitHub Actions will automatically publish** the new version to GitHub Packages
|
|
130
|
+
|
|
131
|
+
### Updating Projects
|
|
132
|
+
|
|
133
|
+
When a new version is published, update in your projects:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
cd /Users/quinn-keaveney/Desktop/GITs/positype
|
|
137
|
+
yarn upgrade @liiift/sales-portal
|
|
138
|
+
|
|
139
|
+
cd /Users/quinn-keaveney/Desktop/GITs/Darden-Studio
|
|
140
|
+
yarn upgrade @liiift/sales-portal
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Manual Publishing (If Needed)
|
|
144
|
+
|
|
145
|
+
If GitHub Actions doesn't work or you need to publish manually:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
cd /Users/quinn-keaveney/Desktop/GITs/sales-portal
|
|
149
|
+
npm publish
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Note: You'll need to authenticate with a GitHub token that has `write:packages` permission.
|
|
153
|
+
|
|
154
|
+
## Migration for Darden Studio
|
|
155
|
+
|
|
156
|
+
To migrate Darden Studio to use the package:
|
|
157
|
+
|
|
158
|
+
1. **Add `.npmrc` file**:
|
|
159
|
+
```
|
|
160
|
+
@liiift:registry=https://npm.pkg.github.com
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
2. **Install the package**:
|
|
164
|
+
```bash
|
|
165
|
+
yarn add @liiift/sales-portal
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
3. **Update imports** in Darden Studio's files:
|
|
169
|
+
```jsx
|
|
170
|
+
// Before
|
|
171
|
+
import { Sales } from '../../components/sales-portal/Sales';
|
|
172
|
+
|
|
173
|
+
// After
|
|
174
|
+
import { Sales } from '@liiift/sales-portal';
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
4. **Keep API routes** in place (they're project-specific)
|
|
178
|
+
|
|
179
|
+
5. **Remove old local files**:
|
|
180
|
+
```bash
|
|
181
|
+
# Backup first!
|
|
182
|
+
rm -rf components/sales-portal
|
|
183
|
+
# Keep pages/api/sales-portal - these are needed
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Benefits
|
|
187
|
+
|
|
188
|
+
✅ **Single Source of Truth**: One codebase for both projects
|
|
189
|
+
✅ **Easy Updates**: Update package once, upgrade in both projects
|
|
190
|
+
✅ **Version Control**: Track changes with semantic versioning
|
|
191
|
+
✅ **No Code Duplication**: Maintain features in one place
|
|
192
|
+
✅ **Consistent Experience**: Same portal across all foundries
|
|
193
|
+
|
|
194
|
+
## Troubleshooting
|
|
195
|
+
|
|
196
|
+
### "Cannot find module '@liiift/sales-portal'"
|
|
197
|
+
|
|
198
|
+
**Solution**: Link the package locally or install from GitHub Packages:
|
|
199
|
+
```bash
|
|
200
|
+
cd /Users/quinn-keaveney/Desktop/GITs/sales-portal
|
|
201
|
+
yarn link
|
|
202
|
+
|
|
203
|
+
cd /Users/quinn-keaveney/Desktop/GITs/positype
|
|
204
|
+
yarn link "@liiift/sales-portal"
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Import paths not resolving
|
|
208
|
+
|
|
209
|
+
**Solution**: Check `next.config.js` has `transpilePackages`:
|
|
210
|
+
```js
|
|
211
|
+
transpilePackages: ['@mui/x-data-grid', '@mui/x-date-pickers', '@mui/x-charts']
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### MUI theme issues
|
|
215
|
+
|
|
216
|
+
**Solution**: Ensure `ThemeProvider` and `LocalizationProvider` are set up in `_app.js`
|
|
217
|
+
|
|
218
|
+
### GitHub Packages authentication
|
|
219
|
+
|
|
220
|
+
**Solution**: Create a personal access token with `read:packages` scope and run:
|
|
221
|
+
```bash
|
|
222
|
+
npm login --registry=https://npm.pkg.github.com
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Support
|
|
226
|
+
|
|
227
|
+
For issues or questions about the package:
|
|
228
|
+
- Check the main README.md in the repository
|
|
229
|
+
- Review the GitHub repository: https://github.com/Liiift-Studio/sales-portal
|
|
230
|
+
- Contact the development team
|