@cayuse-test/react 1.0.0
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 +346 -0
- package/dist/chunk-2K3CWMLR.js +108 -0
- package/dist/chunk-2K3CWMLR.js.map +1 -0
- package/dist/chunk-B2Z63U4D.js +10398 -0
- package/dist/chunk-B2Z63U4D.js.map +1 -0
- package/dist/chunk-EPGO6B3U.js +3 -0
- package/dist/chunk-EPGO6B3U.js.map +1 -0
- package/dist/chunk-LFWPG3ND.js +97 -0
- package/dist/chunk-LFWPG3ND.js.map +1 -0
- package/dist/chunk-M2L7SQBQ.js +205 -0
- package/dist/chunk-M2L7SQBQ.js.map +1 -0
- package/dist/chunk-MJBMK4OG.js +143 -0
- package/dist/chunk-MJBMK4OG.js.map +1 -0
- package/dist/chunk-RG4GEORO.js +194 -0
- package/dist/chunk-RG4GEORO.js.map +1 -0
- package/dist/chunk-SZMEZFAR.js +193 -0
- package/dist/chunk-SZMEZFAR.js.map +1 -0
- package/dist/chunk-TYZPOXN5.js +243 -0
- package/dist/chunk-TYZPOXN5.js.map +1 -0
- package/dist/chunk-XRUFEGUC.js +225 -0
- package/dist/chunk-XRUFEGUC.js.map +1 -0
- package/dist/components/index.d.ts +1471 -0
- package/dist/components/index.js +144 -0
- package/dist/components/index.js.map +1 -0
- package/dist/context/tenant/index.d.ts +200 -0
- package/dist/context/tenant/index.js +14 -0
- package/dist/context/tenant/index.js.map +1 -0
- package/dist/globals/constants/index.d.ts +83 -0
- package/dist/globals/constants/index.js +31 -0
- package/dist/globals/constants/index.js.map +1 -0
- package/dist/globals/css/index.d.ts +2 -0
- package/dist/globals/css/index.js +2 -0
- package/dist/globals/css/index.js.map +1 -0
- package/dist/hooks/index.d.ts +125 -0
- package/dist/hooks/index.js +30 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index-4NH7IW34.css +47 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +302 -0
- package/dist/index.js.map +1 -0
- package/dist/modal-dialog-IH5SI4CF.css +93 -0
- package/dist/services/upload-s3/index.d.ts +35 -0
- package/dist/services/upload-s3/index.js +11 -0
- package/dist/services/upload-s3/index.js.map +1 -0
- package/dist/styles-2WZORUGA.css +106 -0
- package/dist/styles-32VHTPIA.css +20 -0
- package/dist/styles-3A5DZ5R7.css +70 -0
- package/dist/styles-3PFCZALV.css +60 -0
- package/dist/styles-3SNYRDO2.css +100 -0
- package/dist/styles-4FHUBUVF.css +150 -0
- package/dist/styles-4KAVAZFG.css +5 -0
- package/dist/styles-4OFM6DY5.css +22 -0
- package/dist/styles-5OXZHQGW.css +14 -0
- package/dist/styles-6XZTUN3B.css +68 -0
- package/dist/styles-73WOPK6M.css +6 -0
- package/dist/styles-7AV26IBF.css +35 -0
- package/dist/styles-7DWK55L2.css +71 -0
- package/dist/styles-7GWPZSR2.css +222 -0
- package/dist/styles-7QBPXFSY.css +6 -0
- package/dist/styles-7T6DSZIY.css +27 -0
- package/dist/styles-AUI7W2SW.css +408 -0
- package/dist/styles-AZSHBXJQ.css +85 -0
- package/dist/styles-BTXJVGNW.css +99 -0
- package/dist/styles-BUPIQG5C.css +74 -0
- package/dist/styles-CLK36LUK.css +27 -0
- package/dist/styles-CSKYCMD4.css +123 -0
- package/dist/styles-CWCX26BQ.css +13 -0
- package/dist/styles-GAIKDZU6.css +47 -0
- package/dist/styles-GB7S5BAZ.css +36 -0
- package/dist/styles-GVPT6A2Z.css +45 -0
- package/dist/styles-IUBOTHBR.css +581 -0
- package/dist/styles-IZPTZRKW.css +78 -0
- package/dist/styles-LS2YWO5W.css +39 -0
- package/dist/styles-M5BEFS4G.css +148 -0
- package/dist/styles-MHNICXOS.css +18 -0
- package/dist/styles-P6IOJDNI.css +47 -0
- package/dist/styles-Q7XE2QVU.css +55 -0
- package/dist/styles-R7IS5IGF.css +7 -0
- package/dist/styles-RDYYTTBU.css +218 -0
- package/dist/styles-RTHIZL5W.css +48 -0
- package/dist/styles-RUY4EKZW.css +9 -0
- package/dist/styles-T5QJAAUY.css +184 -0
- package/dist/styles-VBXWGFCK.css +96 -0
- package/dist/styles-VE76CGRO.css +6 -0
- package/dist/styles-VLCZ7JYV.css +140 -0
- package/dist/styles-W5HDD3YQ.css +71 -0
- package/dist/styles-X7BJCSFV.css +86 -0
- package/dist/styles-XVRR5GIG.css +42 -0
- package/dist/styles-YBC6BJBD.css +83 -0
- package/dist/styles-YXNJHPDZ.css +74 -0
- package/dist/styles-Z276IEVM.css +264 -0
- package/dist/utils/index.d.ts +145 -0
- package/dist/utils/index.js +98 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +113 -0
- package/packages/eslint-config/README.md +69 -0
- package/packages/eslint-config/base.js +25 -0
- package/packages/eslint-config/next.js +49 -0
- package/packages/eslint-config/react-internal.js +44 -0
- package/packages/typescript-config/README.md +70 -0
- package/packages/typescript-config/base.json +21 -0
- package/packages/typescript-config/nextjs.json +12 -0
- package/packages/typescript-config/react-library.json +7 -0
package/README.md
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# @cayuse-react-2/core
|
|
2
|
+
|
|
3
|
+
A comprehensive React component library providing reusable, accessible components, hooks, and utilities for modern web applications.
|
|
4
|
+
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @cayuse-react-2/core
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @cayuse-react-2/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 🚀 Quick Start
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
// Import components, hooks, and utilities
|
|
17
|
+
import {
|
|
18
|
+
Button,
|
|
19
|
+
Input,
|
|
20
|
+
DynamicTable,
|
|
21
|
+
isValidEmail,
|
|
22
|
+
formatDate,
|
|
23
|
+
useClickOutside,
|
|
24
|
+
useDictionary,
|
|
25
|
+
} from '@cayuse-react-2/core';
|
|
26
|
+
|
|
27
|
+
function MyApp() {
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
<Button variant="primary">Click me</Button>
|
|
31
|
+
<Input label="Email" type="email" />
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Using Shared Configs
|
|
38
|
+
|
|
39
|
+
**ESLint Configuration:**
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
// eslint.config.js
|
|
43
|
+
import { config } from '@cayuse-react-2/core/eslint-config/base';
|
|
44
|
+
// or for React projects
|
|
45
|
+
import { config } from '@cayuse-react-2/core/eslint-config/react-internal';
|
|
46
|
+
// or for Next.js
|
|
47
|
+
import { config } from '@cayuse-react-2/core/eslint-config/next';
|
|
48
|
+
|
|
49
|
+
export default config;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**TypeScript Configuration:**
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"extends": "@cayuse-react-2/core/typescript-config/base.json"
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 📚 What's Included
|
|
61
|
+
|
|
62
|
+
### Components (40+)
|
|
63
|
+
|
|
64
|
+
- **Forms**: Input, Checkbox, Radio, TextArea, RichText, FileUpload, Toggle, Combobox, UserSelect
|
|
65
|
+
- **Navigation**: Breadcrumbs, NavLink, Submenu, Tabs
|
|
66
|
+
- **Layout**: Button, ButtonGroup, Divider, SectionHeader, SubHeader, BasePadding
|
|
67
|
+
- **Data Display**: DynamicTable, FormattedDate, FormattedRichText, SetView, Pagination
|
|
68
|
+
- **Modals & Dialogs**: ModalDialog, AlertDialog, ConfirmationModal, PreventLeavePageDialog
|
|
69
|
+
- **Complex Components**: TaskForm, AttachmentsForm, FormNoteAttachmentsView
|
|
70
|
+
- **Misc**: Icon, IconButton, LoadingIndicator, Popup, DateSelector, CustomDropdown
|
|
71
|
+
|
|
72
|
+
### Hooks
|
|
73
|
+
|
|
74
|
+
- `useClickOutside` - Detect clicks outside elements
|
|
75
|
+
- `useConfirmNavigation` - Confirmation dialogs for unsaved changes
|
|
76
|
+
- `useDebounceCallback` - Debounced callbacks
|
|
77
|
+
- `useDictionary` - Internationalization/translations
|
|
78
|
+
- `useFileUploader` - File uploads with Uppy integration
|
|
79
|
+
- `useModalState` - Modal state management
|
|
80
|
+
|
|
81
|
+
### Utilities
|
|
82
|
+
|
|
83
|
+
- **Auth**: Token management, authentication helpers
|
|
84
|
+
- **DOM**: DOM manipulation utilities
|
|
85
|
+
- **Forms**: Validation, form helpers
|
|
86
|
+
- **HTTP**: Request utilities and constants
|
|
87
|
+
- **Helpers**: Date formatting, ID generation, common utilities
|
|
88
|
+
- **Type Checks**: Type guard functions
|
|
89
|
+
|
|
90
|
+
### Context
|
|
91
|
+
|
|
92
|
+
- `TenantContextProvider` - Multi-tenancy support
|
|
93
|
+
|
|
94
|
+
### Globals
|
|
95
|
+
|
|
96
|
+
- **Constants**: Shared application constants
|
|
97
|
+
- **CSS**: Global styles, CSS variables, media queries, reset
|
|
98
|
+
|
|
99
|
+
### Shared Configs
|
|
100
|
+
|
|
101
|
+
- **ESLint**: `base`, `react-internal`, `next` configurations
|
|
102
|
+
- **TypeScript**: `base.json`, `react-library.json`, `nextjs.json` configurations
|
|
103
|
+
|
|
104
|
+
## 🛠️ Development
|
|
105
|
+
|
|
106
|
+
### Prerequisites
|
|
107
|
+
|
|
108
|
+
- Node.js >= 20
|
|
109
|
+
- PNPM v10.14.0
|
|
110
|
+
|
|
111
|
+
### Setup
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Clone and install
|
|
115
|
+
git clone <repository-url>
|
|
116
|
+
cd cayuse-react-components-single-repo
|
|
117
|
+
pnpm install
|
|
118
|
+
|
|
119
|
+
# Start Storybook for development
|
|
120
|
+
pnpm run storybook
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Development Commands
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
# Build the package
|
|
127
|
+
pnpm run build
|
|
128
|
+
|
|
129
|
+
# Build in watch mode
|
|
130
|
+
pnpm run dev
|
|
131
|
+
|
|
132
|
+
# Type checking
|
|
133
|
+
pnpm run check-types
|
|
134
|
+
|
|
135
|
+
# Linting
|
|
136
|
+
pnpm run lint
|
|
137
|
+
pnpm run lint:fix
|
|
138
|
+
|
|
139
|
+
# Format code
|
|
140
|
+
pnpm run format
|
|
141
|
+
|
|
142
|
+
# Run tests
|
|
143
|
+
pnpm test
|
|
144
|
+
|
|
145
|
+
# Storybook
|
|
146
|
+
pnpm run storybook
|
|
147
|
+
pnpm run build-storybook
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## 📖 Storybook
|
|
151
|
+
|
|
152
|
+
View interactive component documentation and examples:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
pnpm run storybook
|
|
156
|
+
# Opens http://localhost:6006
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Features:
|
|
160
|
+
|
|
161
|
+
- Interactive component playground
|
|
162
|
+
- Accessibility testing (a11y addon)
|
|
163
|
+
- Visual testing with Vitest integration
|
|
164
|
+
- CSS custom properties documentation
|
|
165
|
+
|
|
166
|
+
## 🚀 Publishing & Version Management
|
|
167
|
+
|
|
168
|
+
### Quick Publish Workflow
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# 1. Make changes and commit
|
|
172
|
+
git add .
|
|
173
|
+
git commit -m "feat: add new component"
|
|
174
|
+
|
|
175
|
+
# 2. Run quality checks
|
|
176
|
+
pnpm run check-types && pnpm run lint && pnpm run build
|
|
177
|
+
|
|
178
|
+
# 3. Bump version (patch/minor/major)
|
|
179
|
+
npm version patch
|
|
180
|
+
|
|
181
|
+
# 4. Push with tags
|
|
182
|
+
git push --follow-tags
|
|
183
|
+
|
|
184
|
+
# 5. Publish to npm
|
|
185
|
+
pnpm publish
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Version Types
|
|
189
|
+
|
|
190
|
+
| Change Type | Command | Example | When to Use |
|
|
191
|
+
| ------------------- | ------------------------ | --------------- | ------------------ |
|
|
192
|
+
| **Bug Fix** | `npm version patch` | 1.0.0 → 1.0.1 | Fixing bugs |
|
|
193
|
+
| **New Feature** | `npm version minor` | 1.0.0 → 1.1.0 | Adding features |
|
|
194
|
+
| **Breaking Change** | `npm version major` | 1.0.0 → 2.0.0 | Breaking changes |
|
|
195
|
+
| **Pre-release** | `npm version prerelease` | 1.0.0 → 1.0.1-0 | Alpha/beta testing |
|
|
196
|
+
|
|
197
|
+
### What `npm version` Does
|
|
198
|
+
|
|
199
|
+
1. Updates `package.json` version
|
|
200
|
+
2. Creates a git commit
|
|
201
|
+
3. Creates a git tag (e.g., `v1.0.1`)
|
|
202
|
+
|
|
203
|
+
### Publishing
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Publish as public package
|
|
207
|
+
pnpm publish --access public
|
|
208
|
+
|
|
209
|
+
# Or for beta releases
|
|
210
|
+
pnpm publish --tag beta
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Verify Publication
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Check published version
|
|
217
|
+
npm view @cayuse-react-2/core version
|
|
218
|
+
|
|
219
|
+
# See all versions
|
|
220
|
+
npm view @cayuse-react-2/core versions
|
|
221
|
+
|
|
222
|
+
# Test in another project
|
|
223
|
+
npm install @cayuse-react-2/core@latest
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## 🔒 Code Quality
|
|
227
|
+
|
|
228
|
+
### Git Hooks
|
|
229
|
+
|
|
230
|
+
Pre-commit hook automatically runs:
|
|
231
|
+
|
|
232
|
+
- **Prettier** - Formats staged files
|
|
233
|
+
- **ESLint** - Checks code quality
|
|
234
|
+
- **TypeScript** - Validates types
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Skip hooks in emergencies only
|
|
238
|
+
git commit -m "emergency fix" --no-verify
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Testing
|
|
242
|
+
|
|
243
|
+
- **Vitest** with Playwright browser testing
|
|
244
|
+
- **Storybook** integration for component testing
|
|
245
|
+
- **Accessibility** testing with a11y addon
|
|
246
|
+
|
|
247
|
+
## 🏗️ Project Structure
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
@cayuse-react-2/core/
|
|
251
|
+
├── packages/
|
|
252
|
+
│ ├── components/ # 40+ React components
|
|
253
|
+
│ ├── hooks/ # Custom React hooks
|
|
254
|
+
│ ├── utils/ # Utility functions
|
|
255
|
+
│ ├── context/tenant/ # Tenant context
|
|
256
|
+
│ ├── globals/ # Constants and CSS
|
|
257
|
+
│ ├── services/ # S3 upload service
|
|
258
|
+
│ ├── eslint-config/ # Shared ESLint configs
|
|
259
|
+
│ └── typescript-config/ # Shared TypeScript configs
|
|
260
|
+
├── dist/ # Built package (generated)
|
|
261
|
+
├── .storybook/ # Storybook configuration
|
|
262
|
+
└── package.json # Single package config
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## 🤝 Contributing
|
|
266
|
+
|
|
267
|
+
1. Create feature branch: `git checkout -b feature/new-component`
|
|
268
|
+
2. Make changes following existing patterns
|
|
269
|
+
3. Add Storybook stories for new components
|
|
270
|
+
4. Write tests as needed
|
|
271
|
+
5. Commit changes (hooks run automatically)
|
|
272
|
+
6. Create pull request
|
|
273
|
+
|
|
274
|
+
### Code Standards
|
|
275
|
+
|
|
276
|
+
- TypeScript for all code
|
|
277
|
+
- React Aria Components for accessibility
|
|
278
|
+
- CSS custom properties for styling
|
|
279
|
+
- Conventional commits recommended
|
|
280
|
+
|
|
281
|
+
## 🚨 Troubleshooting
|
|
282
|
+
|
|
283
|
+
### Build Fails
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
# Check for errors
|
|
287
|
+
pnpm run check-types
|
|
288
|
+
pnpm run lint
|
|
289
|
+
|
|
290
|
+
# Auto-fix what can be fixed
|
|
291
|
+
pnpm run lint:fix
|
|
292
|
+
pnpm run format
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### Git Hooks Prevent Commit
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Fix the reported issues
|
|
299
|
+
pnpm run check-types
|
|
300
|
+
pnpm run lint:fix
|
|
301
|
+
|
|
302
|
+
# Emergency bypass (use sparingly!)
|
|
303
|
+
git commit --no-verify -m "emergency fix"
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### npm version Fails
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
# Cause: Uncommitted changes
|
|
310
|
+
git status
|
|
311
|
+
|
|
312
|
+
# Fix: Commit changes first
|
|
313
|
+
git add .
|
|
314
|
+
git commit -m "your changes"
|
|
315
|
+
npm version patch
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Publish Fails
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
# Check if logged in
|
|
322
|
+
npm whoami
|
|
323
|
+
|
|
324
|
+
# If not logged in
|
|
325
|
+
npm login
|
|
326
|
+
|
|
327
|
+
# Ensure public access
|
|
328
|
+
pnpm publish --access public
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## 📚 Resources
|
|
332
|
+
|
|
333
|
+
- **Storybook**: [http://localhost:6006](http://localhost:6006)
|
|
334
|
+
- **React Aria**: [https://react-spectrum.adobe.com/react-aria/](https://react-spectrum.adobe.com/react-aria/)
|
|
335
|
+
- **PNPM**: [https://pnpm.io/](https://pnpm.io/)
|
|
336
|
+
|
|
337
|
+
## 📄 License
|
|
338
|
+
|
|
339
|
+
See LICENSE file for details.
|
|
340
|
+
|
|
341
|
+
---
|
|
342
|
+
|
|
343
|
+
**Package**: `@cayuse-react-2/core`
|
|
344
|
+
**Version**: 1.0.0
|
|
345
|
+
**Node**: >= 20
|
|
346
|
+
**Package Manager**: PNPM 10.14.0
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useAuth
|
|
3
|
+
} from "./chunk-XRUFEGUC.js";
|
|
4
|
+
import {
|
|
5
|
+
executeRequest
|
|
6
|
+
} from "./chunk-SZMEZFAR.js";
|
|
7
|
+
|
|
8
|
+
// packages/context/tenant/tenant-context-provider.tsx
|
|
9
|
+
import React2, { useEffect } from "react";
|
|
10
|
+
|
|
11
|
+
// packages/context/tenant/tenant-context.tsx
|
|
12
|
+
import React from "react";
|
|
13
|
+
var TenantContext = React.createContext({
|
|
14
|
+
isLoaded: false,
|
|
15
|
+
isLoading: false,
|
|
16
|
+
isError: false,
|
|
17
|
+
data: {
|
|
18
|
+
groups: [],
|
|
19
|
+
person: {},
|
|
20
|
+
tenant: {},
|
|
21
|
+
tenantProducts: [],
|
|
22
|
+
user: {}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
var useTenantContext = () => {
|
|
26
|
+
const ctx = React.useContext(TenantContext);
|
|
27
|
+
if (!ctx) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
"TenantContext is not initialized. Wrap your component with TenantContext.Provider"
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return ctx;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// packages/context/tenant/tenant-context-provider.tsx
|
|
36
|
+
import { jsx } from "react/jsx-runtime";
|
|
37
|
+
var TenantProvider = ({ children }) => {
|
|
38
|
+
const auth = useAuth();
|
|
39
|
+
const [loading, setLoading] = React2.useState({
|
|
40
|
+
isLoaded: false,
|
|
41
|
+
isLoading: false,
|
|
42
|
+
isError: false
|
|
43
|
+
});
|
|
44
|
+
const [data, setData] = React2.useState({
|
|
45
|
+
groups: [],
|
|
46
|
+
person: {},
|
|
47
|
+
tenant: {},
|
|
48
|
+
tenantProducts: [],
|
|
49
|
+
user: {}
|
|
50
|
+
});
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
let canceled = false;
|
|
53
|
+
const load = async () => {
|
|
54
|
+
setLoading({ isLoaded: false, isLoading: true, isError: false });
|
|
55
|
+
try {
|
|
56
|
+
const response = await executeRequest(
|
|
57
|
+
`/api/v2/tenant/product/user/${auth.user?.username}`
|
|
58
|
+
);
|
|
59
|
+
if (!canceled) {
|
|
60
|
+
setData(response);
|
|
61
|
+
setLoading({
|
|
62
|
+
isLoaded: true,
|
|
63
|
+
isLoading: false,
|
|
64
|
+
isError: false
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error(error);
|
|
69
|
+
global.__CAYUSE__?.notify?.(
|
|
70
|
+
error.message ?? "Something went wrong when loading user information.",
|
|
71
|
+
{ type: "error" }
|
|
72
|
+
);
|
|
73
|
+
if (!canceled) {
|
|
74
|
+
setLoading({
|
|
75
|
+
isLoaded: false,
|
|
76
|
+
isLoading: false,
|
|
77
|
+
isError: true
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
if (auth?.user && !loading.isLoaded && !loading.isError && !loading.isLoading) {
|
|
83
|
+
load();
|
|
84
|
+
}
|
|
85
|
+
return () => {
|
|
86
|
+
canceled = true;
|
|
87
|
+
};
|
|
88
|
+
}, [auth?.user]);
|
|
89
|
+
return /* @__PURE__ */ jsx(
|
|
90
|
+
TenantContext.Provider,
|
|
91
|
+
{
|
|
92
|
+
value: {
|
|
93
|
+
data,
|
|
94
|
+
isLoaded: loading.isLoaded,
|
|
95
|
+
isLoading: loading.isLoading,
|
|
96
|
+
isError: loading.isError
|
|
97
|
+
},
|
|
98
|
+
children
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
TenantContext,
|
|
105
|
+
useTenantContext,
|
|
106
|
+
TenantProvider
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=chunk-2K3CWMLR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../packages/context/tenant/tenant-context-provider.tsx","../packages/context/tenant/tenant-context.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useAuth } from '@/utils/auth';\nimport { executeRequest } from '@/utils/http';\nimport {\n\tITenantContext,\n\tTenantContext,\n\tTenantContextData,\n} from './tenant-context.js';\n\nexport const TenantProvider = ({ children }: { children: React.ReactNode }) => {\n\tconst auth = useAuth();\n\n\tconst [loading, setLoading] = React.useState({\n\t\tisLoaded: false,\n\t\tisLoading: false,\n\t\tisError: false,\n\t});\n\n\tconst [data, setData] = React.useState<TenantContextData>({\n\t\tgroups: [],\n\t\tperson: {},\n\t\ttenant: {},\n\t\ttenantProducts: [],\n\t\tuser: {},\n\t} as unknown as TenantContextData);\n\n\tuseEffect(() => {\n\t\tlet canceled = false;\n\n\t\tconst load = async () => {\n\t\t\tsetLoading({ isLoaded: false, isLoading: true, isError: false });\n\n\t\t\ttry {\n\t\t\t\tconst response = await executeRequest(\n\t\t\t\t\t`/api/v2/tenant/product/user/${auth.user?.username}`,\n\t\t\t\t);\n\t\t\t\tif (!canceled) {\n\t\t\t\t\tsetData(response);\n\t\t\t\t\tsetLoading({\n\t\t\t\t\t\tisLoaded: true,\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t\tisError: false,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t} catch (error: any) {\n\t\t\t\tconsole.error(error);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t\t(global as any).__CAYUSE__?.notify?.(\n\t\t\t\t\terror.message ?? 'Something went wrong when loading user information.',\n\t\t\t\t\t{ type: 'error' },\n\t\t\t\t);\n\t\t\t\tif (!canceled) {\n\t\t\t\t\tsetLoading({\n\t\t\t\t\t\tisLoaded: false,\n\t\t\t\t\t\tisLoading: false,\n\t\t\t\t\t\tisError: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tif (auth?.user && !loading.isLoaded && !loading.isError && !loading.isLoading) {\n\t\t\tload();\n\t\t}\n\n\t\treturn () => {\n\t\t\tcanceled = true;\n\t\t};\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [auth?.user]);\n\n\treturn (\n\t\t<TenantContext.Provider\n\t\t\tvalue={\n\t\t\t\t{\n\t\t\t\t\tdata,\n\t\t\t\t\tisLoaded: loading.isLoaded,\n\t\t\t\t\tisLoading: loading.isLoading,\n\t\t\t\t\tisError: loading.isError,\n\t\t\t\t} satisfies ITenantContext\n\t\t\t}\n\t\t>\n\t\t\t{children}\n\t\t</TenantContext.Provider>\n\t);\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport React from 'react';\n\nexport interface TenantProduct {\n\tcreateUser: string;\n\tcreateDate: string;\n\tupdateUser: string;\n\tupdateDate: string;\n\thibVersion: number;\n\tactive: boolean;\n\tbaseAccessRoles: string[];\n\tdescription: string;\n\tdisplayName: string;\n\tdisplayOrder: number;\n\timage: string;\n\tinternalName: string;\n\tisExternal: boolean;\n\tisProvisionable: boolean;\n\tisCustom: boolean;\n\tname: string;\n\tpath: string;\n\tplaceholder?: string;\n\tthumbnail: string;\n\tcustomerId: string;\n\tproductSettings: any;\n\tproductId: string;\n\tcustomerName: string;\n\ttenantProductId: string;\n\tinstanceURL?: string;\n\tappId?: string;\n\tproductBulkLoad: boolean;\n\tproductBulkDelete: boolean;\n\tproductInfoReady: boolean;\n\tproductUseSimpleFormBuilder: boolean;\n\tproductNewCoiUi: boolean;\n\ttenantProductSettings: any;\n\ttenantId: string;\n\ttenantName: string;\n\tcustomerProductId: string;\n\tlinks: any[];\n\tid: string;\n}\n\nexport interface User {\n\tactive: boolean;\n\temail: string;\n\temailVerified: boolean;\n\tfirstName: string;\n\tlastName: string;\n\tguestUser: boolean;\n\tunitName: any;\n\ttenantId: string;\n\tupdatePassword: boolean;\n\tupdateProfile: boolean;\n\tusername: string;\n\tverifyEmail: boolean;\n\tuserStatus: string;\n\tlinks: any[];\n\tid: string;\n}\n\nexport interface Person {\n\tcreateUser: string;\n\tcreateDate: string;\n\tupdateUser: string;\n\tupdateDate: string;\n\thibVersion: number;\n\tactive: boolean;\n\tfirstName: string;\n\tfullName: string;\n\tlastName: string;\n\taffiliations: Affiliation[];\n\texternalAffiliations: ExternalAffiliation[];\n\tuserAccountType: string;\n\tusername: string;\n\tmiddleName: string;\n\tcontactEmail: string;\n\tuserAccountId: string;\n\ttenantId: string;\n\tuserStatus: string;\n\tuserAccountStatus: boolean;\n\tprofileTypes: unknown[];\n\trolesCount: number;\n\tcontactId: string;\n\tpersonUserLinkId: string;\n\tprefix: string | null;\n\tsuffix: string | null;\n\tpreferredName: string | null;\n\temployeeId: string;\n\tdemographicsId: string | null;\n\texternalIdentifiersId: string | null;\n\tguestUser: boolean;\n\tuserAccountStatusName: string | null;\n\tlinks: any[];\n\tid: string;\n}\n\nexport interface Affiliation {\n\tcreateUser: string;\n\tcreateDate: string;\n\tupdateUser: string;\n\tupdateDate: string;\n\thibVersion: number;\n\tactive: boolean;\n\tcontactId: string | null;\n\tprimaryAppointment: boolean;\n\tprimaryAppointmentDisplay?: string;\n\temployeeId?: string;\n\tgovAgency: string | null;\n\tstartDate: string;\n\tendDate?: string;\n\tpersonId: string;\n\tuserId: string;\n\tperformanceSiteId: string | null;\n\ttitle: string;\n\tunitId: string;\n\tunitName: string;\n\ttenantId: string;\n\tappointmentTypeId: string;\n\teraRoleId: string | null;\n\troutingProfileId: string | null;\n\tlinks: any[];\n\tid: string;\n}\n\nexport interface ExternalAffiliation {\n\tcreateUser: string;\n\tcreateDate: string;\n\tupdateUser: string;\n\tupdateDate: string;\n\thibVersion: number;\n\tactive: boolean;\n\torganizationId: string;\n\tpersonId: string;\n\ttitle: string;\n\ttenantId: string;\n\tlinks: any[];\n\tid: string;\n}\n\nexport interface Group {\n\tuserId: string;\n\tgroupId: string;\n\ttenantId: string;\n\tunitId: string | null;\n\tgroupGroupName: string;\n\tgroupGroupDescription?: string;\n\tuserEmail: string;\n\tuserUsername: string;\n\tsubunits: boolean;\n\tactive: boolean;\n\tlinks: any[];\n}\n\nexport interface Tenant {\n\tcreateUser: string;\n\tcreateDate: string;\n\tupdateUser: string;\n\tupdateDate: string;\n\thibVersion: number;\n\tactive: boolean;\n\tbulkDelete: boolean;\n\tbulkLoad: boolean;\n\thrConnect: boolean;\n\tdataLakeEnabled: boolean;\n\tcurrentFiscalYear: number;\n\tcustomerId: string;\n\tcustomerActive: boolean;\n\tcustomerName: string;\n\tdescription: string;\n\tfiscalYearStartDay: number;\n\tfiscalYearStartMonth: number;\n\thostname: string;\n\tname: string;\n\torcidClientId: any;\n\torcidClientSecret: any;\n\tssoIdpEntityIdName: any;\n\tssoLoginType: string;\n\tssoPrimaryUserAttribute: any;\n\ttenantProductDtoList: any;\n\ttimezone: string;\n\tdemographics: any;\n\tlinks: any[];\n\tid: string;\n}\n\nexport interface TenantContextData {\n\ttenantProducts: TenantProduct[];\n\tuser: User;\n\tperson: Person;\n\tgroups: Group[];\n\ttenant: Tenant;\n}\n\nexport interface ITenantContext {\n\tisLoaded: boolean;\n\tisLoading: boolean;\n\tisError: boolean;\n\tdata: TenantContextData;\n}\n\nexport const TenantContext = React.createContext<ITenantContext>({\n\tisLoaded: false,\n\tisLoading: false,\n\tisError: false,\n\tdata: {\n\t\tgroups: [],\n\t\tperson: {},\n\t\ttenant: {},\n\t\ttenantProducts: [],\n\t\tuser: {},\n\t},\n} as unknown as ITenantContext);\n\nexport const useTenantContext = () => {\n\tconst ctx: ITenantContext = React.useContext<ITenantContext>(TenantContext);\n\n\tif (!ctx) {\n\t\tthrow new Error(\n\t\t\t'TenantContext is not initialized. Wrap your component with TenantContext.Provider',\n\t\t);\n\t}\n\n\treturn ctx;\n};\n"],"mappings":";;;;;;;;AAAA,OAAOA,UAAS,iBAAiB;;;ACCjC,OAAO,WAAW;AAwMX,IAAM,gBAAgB,MAAM,cAA8B;AAAA,EAChE,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,EACT,MAAM;AAAA,IACL,QAAQ,CAAC;AAAA,IACT,QAAQ,CAAC;AAAA,IACT,QAAQ,CAAC;AAAA,IACT,gBAAgB,CAAC;AAAA,IACjB,MAAM,CAAC;AAAA,EACR;AACD,CAA8B;AAEvB,IAAM,mBAAmB,MAAM;AACrC,QAAM,MAAsB,MAAM,WAA2B,aAAa;AAE1E,MAAI,CAAC,KAAK;AACT,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;;;ADvJE;AAhEK,IAAM,iBAAiB,CAAC,EAAE,SAAS,MAAqC;AAC9E,QAAM,OAAO,QAAQ;AAErB,QAAM,CAAC,SAAS,UAAU,IAAIC,OAAM,SAAS;AAAA,IAC5C,UAAU;AAAA,IACV,WAAW;AAAA,IACX,SAAS;AAAA,EACV,CAAC;AAED,QAAM,CAAC,MAAM,OAAO,IAAIA,OAAM,SAA4B;AAAA,IACzD,QAAQ,CAAC;AAAA,IACT,QAAQ,CAAC;AAAA,IACT,QAAQ,CAAC;AAAA,IACT,gBAAgB,CAAC;AAAA,IACjB,MAAM,CAAC;AAAA,EACR,CAAiC;AAEjC,YAAU,MAAM;AACf,QAAI,WAAW;AAEf,UAAM,OAAO,YAAY;AACxB,iBAAW,EAAE,UAAU,OAAO,WAAW,MAAM,SAAS,MAAM,CAAC;AAE/D,UAAI;AACH,cAAM,WAAW,MAAM;AAAA,UACtB,+BAA+B,KAAK,MAAM,QAAQ;AAAA,QACnD;AACA,YAAI,CAAC,UAAU;AACd,kBAAQ,QAAQ;AAChB,qBAAW;AAAA,YACV,UAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,UACV,CAAC;AAAA,QACF;AAAA,MAED,SAAS,OAAY;AACpB,gBAAQ,MAAM,KAAK;AAEnB,QAAC,OAAe,YAAY;AAAA,UAC3B,MAAM,WAAW;AAAA,UACjB,EAAE,MAAM,QAAQ;AAAA,QACjB;AACA,YAAI,CAAC,UAAU;AACd,qBAAW;AAAA,YACV,UAAU;AAAA,YACV,WAAW;AAAA,YACX,SAAS;AAAA,UACV,CAAC;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAEA,QAAI,MAAM,QAAQ,CAAC,QAAQ,YAAY,CAAC,QAAQ,WAAW,CAAC,QAAQ,WAAW;AAC9E,WAAK;AAAA,IACN;AAEA,WAAO,MAAM;AACZ,iBAAW;AAAA,IACZ;AAAA,EAED,GAAG,CAAC,MAAM,IAAI,CAAC;AAEf,SACC;AAAA,IAAC,cAAc;AAAA,IAAd;AAAA,MACA,OACC;AAAA,QACC;AAAA,QACA,UAAU,QAAQ;AAAA,QAClB,WAAW,QAAQ;AAAA,QACnB,SAAS,QAAQ;AAAA,MAClB;AAAA,MAGA;AAAA;AAAA,EACF;AAEF;","names":["React","React"]}
|