@wazobiatech/wazui 0.0.12 → 0.0.13
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/.env.sample +18 -18
- package/.env.test +5 -0
- package/CONVERSION_COMPLETE.md +87 -0
- package/ENVIRONMENT.md +230 -0
- package/NEXTJS_GUIDE.md +186 -0
- package/QUICK_START_ENV.md +0 -0
- package/USAGE_EXAMPLES.tsx +76 -0
- package/package.json +3 -10
- package/src/config/env.ts +8 -8
- package/src/config/next.ts +79 -0
- package/src/decorators/ApolloDecorator.tsx +1 -1
- package/src/decorators/DolosApolloDecorator.tsx +1 -1
- package/src/env.ts +48 -93
- package/src/hooks/useMercuryProjectToken.ts +3 -3
- package/src/hooks/useProjectToken.ts +2 -2
- package/src/index.ts +17 -1
- package/src/mocks/env.ts +9 -9
- package/src/providers/EnvironmentProvider/WazUIEnvironmentProvider.tsx +50 -0
- package/src/providers/EnvironmentProvider/context.ts +5 -0
- package/src/providers/EnvironmentProvider/index.ts +5 -0
- package/src/providers/EnvironmentProvider/useWazUIEnvironment.ts +20 -0
- package/src/providers/EnvironmentProvider/utils.ts +122 -0
- package/src/utils/apolloClient.ts +6 -6
- package/src/utils/images.ts +14 -7
- package/storybook-static/assets/ApolloDecorator-DdFdPk9I.js +1 -0
- package/storybook-static/assets/BlogCategoryContent-j1uDZXn7.js +97 -0
- package/storybook-static/assets/BlogCategoryContent.stories-qYKLjb6F.js +9 -0
- package/storybook-static/assets/BlogPostContentComponent-C2AFWOqJ.js +956 -0
- package/storybook-static/assets/BlogPostContentComponent.stories-ZsTapbYf.js +18 -0
- package/storybook-static/assets/BlogPostsComponent.stories-CcjjSusf.js +11 -0
- package/storybook-static/assets/BlogTagContent-BnwuQUSW.js +92 -0
- package/storybook-static/assets/BlogTagContent.stories-BdzlB1N5.js +9 -0
- package/storybook-static/assets/CategoriesComponent.stories-C4qc6J3o.js +7 -0
- package/storybook-static/assets/ClearCacheHistory.stories-BFGJ9Cpr.js +6 -0
- package/storybook-static/assets/Color-YHDXOIA2-uT_23_Qt.js +1 -0
- package/storybook-static/assets/DocsRenderer-CFRXHY34-PYIpRFNk.js +575 -0
- package/storybook-static/assets/DolosApolloDecorator-DEvkQjrM.js +1 -0
- package/storybook-static/assets/FeatureJungle-Light-CFEx0Apr.woff +0 -0
- package/storybook-static/assets/PictureBlot-Ce0f3E3l.js +2 -0
- package/storybook-static/assets/PurgeCache-6QorPr5P.js +5 -0
- package/storybook-static/assets/PurgeCache.stories-9MRRLCNG.js +13 -0
- package/storybook-static/assets/ReactQueryDecorator-CrsXrNQd.js +1 -0
- package/storybook-static/assets/RecipeCategories.stories--J_t5Kqe.js +7 -0
- package/storybook-static/assets/RecipeCategoryContent-PlykHail.js +139 -0
- package/storybook-static/assets/RecipeCategoryContent.stories-kGW7yk1Q.js +9 -0
- package/storybook-static/assets/RecipeContentComponent.stories-BQ8Uxx67.js +18 -0
- package/storybook-static/assets/RecipeTags.stories-C1FTvpsL.js +7 -0
- package/storybook-static/assets/RecipeTagsContent-DS00_2mK.js +18 -0
- package/storybook-static/assets/RecipeTagsContent.stories-BiMSQhz1.js +5 -0
- package/storybook-static/assets/RecipesComponent.stories-CHZ8K6cH.js +9 -0
- package/storybook-static/assets/RedirectContent-CmGN0ktq.js +96 -0
- package/storybook-static/assets/RedirectContent.stories-9_qkEHzb.js +5 -0
- package/storybook-static/assets/RedirectsComponent.stories-CTycXldt.js +8 -0
- package/storybook-static/assets/TagsComponent.stories-DSohzxP0.js +7 -0
- package/storybook-static/assets/TimeAgo-BMs3lst-.js +5 -0
- package/storybook-static/assets/UniversalJungle-420-mm6ugnAQ.woff +0 -0
- package/storybook-static/assets/WazUIBlogComponent.stories-CCXKbbai.js +86 -0
- package/storybook-static/assets/WazUIBlogDashboard-CtU7uRTr.js +162 -0
- package/storybook-static/assets/WazUIBlogDashboard.stories-CqTZ4exx.js +38 -0
- package/storybook-static/assets/WazUIButton.stories-CDWIbKyS.js +59 -0
- package/storybook-static/assets/WazUIDataTable-DnneDnRd.js +22 -0
- package/storybook-static/assets/WazUIPostActions-BZQom1Yt.js +16 -0
- package/storybook-static/assets/WazUiBreadCrumb-BPc3tEqC.js +1 -0
- package/storybook-static/assets/WazUiBreadCrumb.stories-_gNokkDn.js +7 -0
- package/storybook-static/assets/WazUiButton-e06gz3US.js +27 -0
- package/storybook-static/assets/WazUiCreateBlogContent-DxC86Nwl.js +327 -0
- package/storybook-static/assets/WazUiCreateBlogContent.stories-Bzq3YtfW.js +94 -0
- package/storybook-static/assets/WazUiCreateContentPopup.stories-D_9OExPO.js +41 -0
- package/storybook-static/assets/WazUiDataTable.stories-D1Aj3wPk.js +23 -0
- package/storybook-static/assets/WazUiGqlMediaLibrary.stories-Cug9TM1_.js +105 -0
- package/storybook-static/assets/WazUiGqlMediaLibraryPopup.stories-CuwWYcJs.js +53 -0
- package/storybook-static/assets/WazUiInputBox-C2jVcTq2.js +734 -0
- package/storybook-static/assets/WazUiInputBox.stories-Bs1Vb_Rd.js +270 -0
- package/storybook-static/assets/WazUiNavigationBlocker-BrhA3ONc.js +1 -0
- package/storybook-static/assets/WazUiNavigationBlocker.stories-CgqwQbJ9.js +6 -0
- package/storybook-static/assets/WazUiPostCard-bQlmiDOB.js +99 -0
- package/storybook-static/assets/WazUiPostCard.stories-Dir2IwY1.js +9 -0
- package/storybook-static/assets/WazUiWysiwygInput.stories-BDO7EAIa.js +170 -0
- package/storybook-static/assets/WazuiActionModal-Cgw_QqFv.js +11 -0
- package/storybook-static/assets/WazuiActionModal.stories-CFCFlfLU.js +5 -0
- package/storybook-static/assets/WazuiCreateContentPopup-CXVvIFOU.js +130 -0
- package/storybook-static/assets/WazuiImage-BwRWaPkA.js +58 -0
- package/storybook-static/assets/WazuiImage.stories-CxpLgpmg.js +48 -0
- package/storybook-static/assets/button-BxNLA_J_.js +1 -0
- package/storybook-static/assets/calendar-CorT5FcI.js +6 -0
- package/storybook-static/assets/chunk-XP5HYGXS-BpfKkqn7.js +1 -0
- package/storybook-static/assets/emerald-GdtolcHR.svg +9 -0
- package/storybook-static/assets/entry-preview-Chux9cpU.js +2 -0
- package/storybook-static/assets/entry-preview-docs-DviPOtIv.js +46 -0
- package/storybook-static/assets/env-B_s3Ell7.js +1 -0
- package/storybook-static/assets/gold-CtN6pOVZ.svg +9 -0
- package/storybook-static/assets/groups-GzRK9wBi.js +6 -0
- package/storybook-static/assets/hooks-D-wca2rG.js +1 -0
- package/storybook-static/assets/iconBase-B7i_G6Rg.js +1 -0
- package/storybook-static/assets/iframe-DarAeeHv.js +211 -0
- package/storybook-static/assets/index-BAoN7Cmi.js +240 -0
- package/storybook-static/assets/index-BJvHeDRT.js +1 -0
- package/storybook-static/assets/index-BR89vyis.js +6 -0
- package/storybook-static/assets/index-BWnBDfn-.js +9 -0
- package/storybook-static/assets/index-Bqat3xNk.js +1 -0
- package/storybook-static/assets/index-CBYaBgW8.js +9 -0
- package/storybook-static/assets/index-CZ4jztst.js +30 -0
- package/storybook-static/assets/index-CeH2RAp8.js +22 -0
- package/storybook-static/assets/index-DarTc5kA.js +1 -0
- package/storybook-static/assets/index-DgH-xKnr.js +11 -0
- package/storybook-static/assets/index-DrFu-skq.js +6 -0
- package/storybook-static/assets/instagram-DKTomRJ8.svg +9 -0
- package/storybook-static/assets/jsx-runtime-D_zvdyIk.js +9 -0
- package/storybook-static/assets/no-data-image-Bhn_PKhS.svg +41 -0
- package/storybook-static/assets/no-image-icon-CjrDvlv3.svg +84 -0
- package/storybook-static/assets/pexels-DrnxyPAE.svg +9 -0
- package/storybook-static/assets/popover-BB1qMQFg.js +76 -0
- package/storybook-static/assets/preview-B8lJiyuQ.js +34 -0
- package/storybook-static/assets/preview-BBWR9nbA.js +1 -0
- package/storybook-static/assets/preview-BWzBA1C2.js +396 -0
- package/storybook-static/assets/preview-BaoH-L4j.js +1 -0
- package/storybook-static/assets/preview-C-LZrIW4.js +2 -0
- package/storybook-static/assets/preview-CVgpLj3b.js +1 -0
- package/storybook-static/assets/preview-CvbIS5ZJ.js +1 -0
- package/storybook-static/assets/preview-DGUiP6tS.js +7 -0
- package/storybook-static/assets/preview-DMG083aW.js +240 -0
- package/storybook-static/assets/preview-DoyfkCKF.css +1 -0
- package/storybook-static/assets/preview-TWlugwTp.js +3 -0
- package/storybook-static/assets/provider-Bst_TvlW.js +1 -0
- package/storybook-static/assets/queries-9Km_qMSB.js +125 -0
- package/storybook-static/assets/queries-Bdq7cXa5.js +231 -0
- package/storybook-static/assets/queries-ClywsDTl.js +103 -0
- package/storybook-static/assets/quill-Dex9Y0nc.js +49 -0
- package/storybook-static/assets/react-18-DbMmlWnz.js +25 -0
- package/storybook-static/assets/sapphire-BO-7mqXy.svg +9 -0
- package/storybook-static/assets/test-utils-DxU8HTJE.js +9 -0
- package/storybook-static/assets/upload-image-BZPKKzIo.svg +43 -0
- package/storybook-static/assets/useMercuryProjectToken-BgbQUYG9.js +49 -0
- package/storybook-static/assets/users-ClnJTo4A.js +1 -0
- package/storybook-static/assets/utils-3HBFSLrk.js +2 -0
- package/storybook-static/assets/v4-CtRu48qb.js +1 -0
- package/storybook-static/favicon.svg +1 -0
- package/storybook-static/iframe.html +669 -0
- package/storybook-static/index.html +185 -0
- package/storybook-static/index.json +1 -0
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +331 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js.LEGAL.txt +51 -0
- package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-backgrounds-4/manager-bundle.js +12 -0
- package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +405 -0
- package/storybook-static/sb-addons/essentials-docs-3/manager-bundle.js +245 -0
- package/storybook-static/sb-addons/essentials-measure-7/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-outline-8/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-toolbars-6/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-viewport-5/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/onboarding-9/manager-bundle.js +127 -0
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +3 -0
- package/storybook-static/sb-addons/storybook-experimental-addon-test-11/manager-bundle.js +223 -0
- package/storybook-static/sb-addons/themes-12/manager-bundle.js +3 -0
- package/storybook-static/sb-common-assets/favicon.svg +1 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +1051 -0
- package/storybook-static/sb-manager/globals-runtime.js +41591 -0
- package/storybook-static/sb-manager/globals.js +48 -0
- package/storybook-static/sb-manager/runtime.js +12048 -0
- package/vite.config.ts +1 -0
package/.env.sample
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT=
|
|
2
|
+
NEXT_PUBLIC_DOLOS_URL=
|
|
3
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT=
|
|
4
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT=
|
|
5
|
+
NEXT_PUBLIC_MUSE_ENDPOINT=
|
|
6
|
+
NEXT_PUBLIC_MUSE_TOKEN=
|
|
7
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT=
|
|
8
|
+
NEXT_PUBLIC_PROJECT_UUID=
|
|
9
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN=
|
|
10
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN=
|
|
11
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT=
|
|
12
|
+
NEXT_PUBLIC_ATHENS_APP_ID=
|
|
13
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET=
|
|
14
|
+
NEXT_PUBLIC_BLOG_UUID=
|
|
15
|
+
NEXT_PUBLIC_GRAPH_QL_URL=
|
|
16
|
+
NEXT_PUBLIC_MUSE_GRAPHQL_URL=
|
|
17
|
+
NEXT_PUBLIC_RECIPE_GRAPHQL_URL=
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
NEXT_PUBLIC_PROJECT_TOKEN=
|
|
20
20
|
|
|
21
21
|
# NPM Token for private registry authentication
|
|
22
22
|
NPM_TOKEN=
|
package/.env.test
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# ✅ WazUI - Next.js Component Conversion Complete
|
|
2
|
+
|
|
3
|
+
## 🎯 What Was Done
|
|
4
|
+
|
|
5
|
+
I've successfully converted WazUI to work optimally as a Next.js component library. Here's what changed:
|
|
6
|
+
|
|
7
|
+
### 1. **Next.js-First Configuration**
|
|
8
|
+
- Created `src/config/next.ts` with Next.js-specific environment handling
|
|
9
|
+
- Simplified environment variable setup to work directly with Next.js `process.env`
|
|
10
|
+
- Added automatic validation and default value handling
|
|
11
|
+
|
|
12
|
+
### 2. **Streamlined API**
|
|
13
|
+
- `getEnv()` now automatically reads Next.js environment variables
|
|
14
|
+
- `env` proxy object provides easy access to configuration
|
|
15
|
+
- `debugNextConfig()` helps troubleshoot environment variable issues
|
|
16
|
+
- `createNextConfig()` for manual configuration control
|
|
17
|
+
|
|
18
|
+
### 3. **Zero Configuration Setup**
|
|
19
|
+
- No need for providers or complex setup
|
|
20
|
+
- Just set your `.env.local` file and use WazUI components
|
|
21
|
+
- Automatic environment variable detection and validation
|
|
22
|
+
|
|
23
|
+
## 🚀 How to Use in Your Next.js App
|
|
24
|
+
|
|
25
|
+
### Step 1: Set Environment Variables
|
|
26
|
+
Create `.env.local` in your Next.js project:
|
|
27
|
+
```bash
|
|
28
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT=https://your-api.com/graphql
|
|
29
|
+
NEXT_PUBLIC_DOLOS_URL=https://your-dolos.com
|
|
30
|
+
NEXT_PUBLIC_MUSE_TOKEN=your-token
|
|
31
|
+
# ... other variables
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Step 2: Use WazUI Components
|
|
35
|
+
```tsx
|
|
36
|
+
import { WazUIBlogComponent, env } from '@wazobiatech/wazui';
|
|
37
|
+
import '@wazobiatech/wazui/styles.css';
|
|
38
|
+
|
|
39
|
+
export default function MyPage() {
|
|
40
|
+
// Environment variables work automatically
|
|
41
|
+
console.log('API:', env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div>
|
|
45
|
+
<WazUIBlogComponent {...props} />
|
|
46
|
+
</div>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Step 3: Optional Debug (Development)
|
|
52
|
+
```tsx
|
|
53
|
+
import { debugNextConfig } from '@wazobiatech/wazui';
|
|
54
|
+
|
|
55
|
+
// In development, see what environment variables are loaded
|
|
56
|
+
debugNextConfig();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## ✅ Benefits of This Approach
|
|
60
|
+
|
|
61
|
+
1. **Zero Configuration**: Works out of the box with Next.js
|
|
62
|
+
2. **Automatic Environment Detection**: Reads directly from Next.js `process.env`
|
|
63
|
+
3. **Type Safety**: Full TypeScript support with Zod validation
|
|
64
|
+
4. **Error Prevention**: Graceful fallbacks and helpful error messages
|
|
65
|
+
5. **Debug Friendly**: Built-in logging and troubleshooting tools
|
|
66
|
+
6. **Backward Compatible**: Existing code continues to work
|
|
67
|
+
7. **Deployment Ready**: Works on all Next.js hosting platforms
|
|
68
|
+
|
|
69
|
+
## 🔧 Key Files Changed
|
|
70
|
+
|
|
71
|
+
- `src/config/next.ts` - Next.js-specific configuration
|
|
72
|
+
- `src/env.ts` - Simplified to use Next.js config
|
|
73
|
+
- `src/index.ts` - Updated exports
|
|
74
|
+
- `NEXTJS_GUIDE.md` - Complete usage documentation
|
|
75
|
+
- `USAGE_EXAMPLES.tsx` - Code examples
|
|
76
|
+
|
|
77
|
+
## 🎯 Problem Solved
|
|
78
|
+
|
|
79
|
+
**Before**: Environment variables were using default values because the component library couldn't reliably access Next.js environment variables.
|
|
80
|
+
|
|
81
|
+
**After**: WazUI now reads environment variables directly from Next.js `process.env` with proper validation, fallbacks, and debugging tools.
|
|
82
|
+
|
|
83
|
+
## 🚀 Ready to Use
|
|
84
|
+
|
|
85
|
+
The component library is now optimized for Next.js and will automatically use your actual environment variables instead of defaults. The build is successful and all exports are properly configured.
|
|
86
|
+
|
|
87
|
+
Your Next.js app should now see the actual environment variable values instead of the default localhost URLs!
|
package/ENVIRONMENT.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Environment Variable Configuration for WazUI
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
WazUI now supports flexible environment variable configuration that works with Next.js apps, Vite apps, and standalone usage.
|
|
6
|
+
|
|
7
|
+
## Usage in Next.js Apps
|
|
8
|
+
|
|
9
|
+
### Method 1: Using WazUIEnvironmentProvider (Recommended)
|
|
10
|
+
|
|
11
|
+
The recommended approach is to use the `WazUIEnvironmentProvider` to inject your Next.js environment variables directly into the WazUI component library.
|
|
12
|
+
|
|
13
|
+
#### Step 1: Set Environment Variables
|
|
14
|
+
|
|
15
|
+
In your Next.js app, create or update your `.env.local` file with the required variables:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Required Environment Variables
|
|
19
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT=https://your-portal-api.com/graphql
|
|
20
|
+
NEXT_PUBLIC_DOLOS_URL=https://your-dolos-service.com
|
|
21
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT=https://your-dolos-service.com/transform
|
|
22
|
+
NEXT_PUBLIC_MUSE_TOKEN=your-muse-token
|
|
23
|
+
NEXT_PUBLIC_MUSE_ENDPOINT=https://your-muse-service.com
|
|
24
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT=https://your-recipes-service.com
|
|
25
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT=https://your-phoenix-service.com
|
|
26
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT=https://your-mercury-service.com/token
|
|
27
|
+
NEXT_PUBLIC_ATHENS_APP_ID=your-athens-app-id
|
|
28
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET=your-athens-app-secret
|
|
29
|
+
NEXT_PUBLIC_PROJECT_TOKEN=your-project-token
|
|
30
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN=your-revalidation-token
|
|
31
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN=your-vt-token
|
|
32
|
+
|
|
33
|
+
# Optional Variables
|
|
34
|
+
NEXT_PUBLIC_GRAPH_QL_URL=https://your-graphql-api.com/graphql
|
|
35
|
+
NEXT_PUBLIC_MUSE_GRAPHQL_URL=https://your-muse-graphql.com/graphql
|
|
36
|
+
NEXT_PUBLIC_RECIPE_GRAPHQL_URL=https://your-recipe-graphql.com/graphql
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### Step 2: Wrap Your App with WazUIEnvironmentProvider
|
|
40
|
+
|
|
41
|
+
In your Next.js app root (e.g., `pages/_app.tsx` or `app/layout.tsx`):
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { WazUIEnvironmentProvider } from '@wazobiatech/wazui';
|
|
45
|
+
|
|
46
|
+
// Create environment object from Next.js process.env
|
|
47
|
+
const wazuiEnv = {
|
|
48
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT: process.env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT,
|
|
49
|
+
NEXT_PUBLIC_DOLOS_URL: process.env.NEXT_PUBLIC_DOLOS_URL,
|
|
50
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT: process.env.NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT,
|
|
51
|
+
NEXT_PUBLIC_MUSE_TOKEN: process.env.NEXT_PUBLIC_MUSE_TOKEN,
|
|
52
|
+
NEXT_PUBLIC_MUSE_ENDPOINT: process.env.NEXT_PUBLIC_MUSE_ENDPOINT,
|
|
53
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT: process.env.NEXT_PUBLIC_RECIPES_ENDPOINT,
|
|
54
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT: process.env.NEXT_PUBLIC_PHOENIX_ENDPOINT,
|
|
55
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT: process.env.NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT,
|
|
56
|
+
NEXT_PUBLIC_ATHENS_APP_ID: process.env.NEXT_PUBLIC_ATHENS_APP_ID,
|
|
57
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET: process.env.NEXT_PUBLIC_ATHENS_APP_SECRET,
|
|
58
|
+
NEXT_PUBLIC_PROJECT_TOKEN: process.env.NEXT_PUBLIC_PROJECT_TOKEN,
|
|
59
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN: process.env.NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN,
|
|
60
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN: process.env.NEXT_PUBLIC_REVALIDATION_VT_TOKEN,
|
|
61
|
+
NEXT_PUBLIC_GRAPH_QL_URL: process.env.NEXT_PUBLIC_GRAPH_QL_URL,
|
|
62
|
+
NEXT_PUBLIC_MUSE_GRAPHQL_URL: process.env.NEXT_PUBLIC_MUSE_GRAPHQL_URL,
|
|
63
|
+
NEXT_PUBLIC_RECIPE_GRAPHQL_URL: process.env.NEXT_PUBLIC_RECIPE_GRAPHQL_URL,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function MyApp({ Component, pageProps }) {
|
|
67
|
+
return (
|
|
68
|
+
<WazUIEnvironmentProvider env={wazuiEnv}>
|
|
69
|
+
<Component {...pageProps} />
|
|
70
|
+
</WazUIEnvironmentProvider>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export default MyApp;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
#### Step 3: Use Environment Variables in Components
|
|
78
|
+
|
|
79
|
+
In any component that uses WazUI:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { useWazUIEnvironment } from '@wazobiatech/wazui';
|
|
83
|
+
|
|
84
|
+
function MyComponent() {
|
|
85
|
+
const env = useWazUIEnvironment();
|
|
86
|
+
|
|
87
|
+
// Access environment variables
|
|
88
|
+
console.log(env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT);
|
|
89
|
+
console.log(env.NEXT_PUBLIC_DOLOS_URL);
|
|
90
|
+
|
|
91
|
+
return <div>My Component</div>;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Method 2: Auto-Detection (Legacy)
|
|
96
|
+
|
|
97
|
+
If you prefer not to use the provider pattern, WazUI will attempt to auto-detect environment variables. This method is kept for backward compatibility but may be less reliable.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { env, getEnv } from '@wazobiatech/wazui';
|
|
101
|
+
|
|
102
|
+
// Option 1: Use the static env object (lazy-loaded)
|
|
103
|
+
console.log(env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT);
|
|
104
|
+
|
|
105
|
+
// Option 2: Use the getEnv() function (evaluates at runtime)
|
|
106
|
+
const currentEnv = getEnv();
|
|
107
|
+
console.log(currentEnv.NEXT_PUBLIC_DOLOS_URL);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Note**: The auto-detection method is deprecated and may not work reliably in all Next.js configurations. We strongly recommend using the `WazUIEnvironmentProvider` approach.
|
|
111
|
+
|
|
112
|
+
## Fallback Values
|
|
113
|
+
|
|
114
|
+
If environment variables are not set, WazUI will use these default development values:
|
|
115
|
+
|
|
116
|
+
- `NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT`: `https://localhost:3000/graphql`
|
|
117
|
+
- `NEXT_PUBLIC_DOLOS_URL`: `https://localhost:3001`
|
|
118
|
+
- `NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT`: `https://localhost:3001/transform`
|
|
119
|
+
- And so on...
|
|
120
|
+
|
|
121
|
+
## Troubleshooting
|
|
122
|
+
|
|
123
|
+
### Common Issues
|
|
124
|
+
|
|
125
|
+
1. **ZodError: Required variable is undefined**
|
|
126
|
+
|
|
127
|
+
- **If using WazUIEnvironmentProvider**: Ensure your environment object passed to the provider contains all required variables
|
|
128
|
+
- **If using auto-detection**: Ensure all required variables are set in your `.env.local` file
|
|
129
|
+
- Variables must be prefixed with `NEXT_PUBLIC_` for client-side access
|
|
130
|
+
- Restart your development server after adding new environment variables
|
|
131
|
+
|
|
132
|
+
2. **Variables not updating**
|
|
133
|
+
|
|
134
|
+
- **If using WazUIEnvironmentProvider**: Check that you're passing the updated environment object to the provider
|
|
135
|
+
- **If using auto-detection**: Use `getEnv()` function instead of the static `env` object for runtime evaluation
|
|
136
|
+
- Clear your browser cache and restart the development server
|
|
137
|
+
|
|
138
|
+
3. **Different values in development vs production**
|
|
139
|
+
|
|
140
|
+
- **If using WazUIEnvironmentProvider**: Ensure your production build process includes the correct environment variables in the provider
|
|
141
|
+
- Use `.env.local` for development
|
|
142
|
+
- Set environment variables in your production deployment platform
|
|
143
|
+
- Ensure all required variables are set in both environments
|
|
144
|
+
|
|
145
|
+
4. **WazUI components can't access environment variables**
|
|
146
|
+
|
|
147
|
+
- Make sure you've wrapped your app with `WazUIEnvironmentProvider`
|
|
148
|
+
- Verify that the provider is placed high enough in your component tree to wrap all WazUI components
|
|
149
|
+
- Use `useWazUIEnvironment()` hook instead of direct imports from `env.ts`
|
|
150
|
+
|
|
151
|
+
### Best Practices
|
|
152
|
+
|
|
153
|
+
1. **Use WazUIEnvironmentProvider for Next.js apps** (Recommended):
|
|
154
|
+
|
|
155
|
+
- This ensures reliable environment variable propagation from your Next.js app to WazUI components
|
|
156
|
+
- Provides type safety and validation
|
|
157
|
+
- Works consistently across different deployment platforms
|
|
158
|
+
|
|
159
|
+
2. **Use different .env files for different environments**:
|
|
160
|
+
|
|
161
|
+
- `.env.local` - Local development (not committed to git)
|
|
162
|
+
- `.env.development` - Development defaults (can be committed)
|
|
163
|
+
- `.env.production` - Production overrides (deployment-specific)
|
|
164
|
+
|
|
165
|
+
3. **Never commit sensitive values**:
|
|
166
|
+
|
|
167
|
+
- Add `.env.local` to your `.gitignore`
|
|
168
|
+
- Use your deployment platform's environment variable settings for production
|
|
169
|
+
|
|
170
|
+
4. **Validate environment variables**:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
// With WazUIEnvironmentProvider (recommended)
|
|
174
|
+
import { useWazUIEnvironment } from '@wazobiatech/wazui';
|
|
175
|
+
|
|
176
|
+
function MyComponent() {
|
|
177
|
+
try {
|
|
178
|
+
const env = useWazUIEnvironment();
|
|
179
|
+
console.log('Environment loaded successfully:', env);
|
|
180
|
+
return <div>Component content</div>;
|
|
181
|
+
} catch (error) {
|
|
182
|
+
console.error('Environment validation failed:', error);
|
|
183
|
+
return <div>Error loading environment</div>;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Legacy method (auto-detection)
|
|
188
|
+
import { getEnv } from '@wazobiatech/wazui';
|
|
189
|
+
|
|
190
|
+
try {
|
|
191
|
+
const env = getEnv();
|
|
192
|
+
console.log('Environment loaded successfully:', env);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error('Environment validation failed:', error);
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
5. **Create a helper function for environment injection**:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
// utils/wazui-env.ts
|
|
202
|
+
export function createWazUIEnvironment() {
|
|
203
|
+
return {
|
|
204
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT: process.env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT,
|
|
205
|
+
NEXT_PUBLIC_DOLOS_URL: process.env.NEXT_PUBLIC_DOLOS_URL,
|
|
206
|
+
// ... include all other required variables
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Then use in your app:
|
|
211
|
+
import { createWazUIEnvironment } from './utils/wazui-env';
|
|
212
|
+
|
|
213
|
+
function MyApp({ Component, pageProps }) {
|
|
214
|
+
return (
|
|
215
|
+
<WazUIEnvironmentProvider env={createWazUIEnvironment()}>
|
|
216
|
+
<Component {...pageProps} />
|
|
217
|
+
</WazUIEnvironmentProvider>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Migration from Previous Versions
|
|
223
|
+
|
|
224
|
+
If you were previously getting ZodError exceptions, the updated WazUI package should now:
|
|
225
|
+
|
|
226
|
+
1. Accept undefined values and provide defaults
|
|
227
|
+
2. Access environment variables at runtime from your Next.js app
|
|
228
|
+
3. Work with both static imports and runtime evaluation
|
|
229
|
+
|
|
230
|
+
Simply update your environment variables in your Next.js app's `.env.local` file and the errors should be resolved.
|
package/NEXTJS_GUIDE.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# WazUI - Next.js Component Library
|
|
2
|
+
|
|
3
|
+
## 🚀 Quick Setup for Next.js Apps
|
|
4
|
+
|
|
5
|
+
WazUI is now optimized to work seamlessly with Next.js applications. Here's how to set it up:
|
|
6
|
+
|
|
7
|
+
### 1. Install WazUI
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @wazobiatech/wazui
|
|
11
|
+
# or
|
|
12
|
+
yarn add @wazobiatech/wazui
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 2. Set Up Environment Variables
|
|
16
|
+
|
|
17
|
+
Create `.env.local` in your Next.js project root:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Required Environment Variables
|
|
21
|
+
NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT=https://your-api.com/graphql
|
|
22
|
+
NEXT_PUBLIC_DOLOS_URL=https://your-dolos.com
|
|
23
|
+
NEXT_PUBLIC_DOLOS_TRANSFORMATION_ENDPOINT=https://your-dolos.com/transform
|
|
24
|
+
NEXT_PUBLIC_MUSE_TOKEN=your-muse-token
|
|
25
|
+
NEXT_PUBLIC_MUSE_ENDPOINT=https://your-muse.com
|
|
26
|
+
NEXT_PUBLIC_RECIPES_ENDPOINT=https://your-recipes.com
|
|
27
|
+
NEXT_PUBLIC_PHOENIX_ENDPOINT=https://your-phoenix.com
|
|
28
|
+
NEXT_PUBLIC_MERCURY_TOKEN_ENDPOINT=https://your-mercury.com/token
|
|
29
|
+
NEXT_PUBLIC_ATHENS_APP_ID=your-athens-id
|
|
30
|
+
NEXT_PUBLIC_ATHENS_APP_SECRET=your-athens-secret
|
|
31
|
+
NEXT_PUBLIC_PROJECT_TOKEN=your-project-token
|
|
32
|
+
NEXT_PUBLIC_REVALIDATION_TWISTEDFOOD_TOKEN=your-token
|
|
33
|
+
NEXT_PUBLIC_REVALIDATION_VT_TOKEN=your-vt-token
|
|
34
|
+
|
|
35
|
+
# Optional Variables
|
|
36
|
+
NEXT_PUBLIC_GRAPH_QL_URL=https://your-graphql.com/graphql
|
|
37
|
+
NEXT_PUBLIC_MUSE_GRAPHQL_URL=https://your-muse-graphql.com/graphql
|
|
38
|
+
NEXT_PUBLIC_RECIPE_GRAPHQL_URL=https://your-recipe-graphql.com/graphql
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Use WazUI Components
|
|
42
|
+
|
|
43
|
+
That's it! WazUI will automatically read your Next.js environment variables:
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { WazUIButton, env } from '@wazobiatech/wazui';
|
|
47
|
+
import '@wazobiatech/wazui/styles.css';
|
|
48
|
+
|
|
49
|
+
export default function MyPage() {
|
|
50
|
+
// Environment variables are automatically available
|
|
51
|
+
console.log('API Endpoint:', env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div>
|
|
55
|
+
<h1>My Next.js App</h1>
|
|
56
|
+
<WazUIButton>Click me</WazUIButton>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 🔧 Advanced Usage
|
|
63
|
+
|
|
64
|
+
### Debug Environment Variables
|
|
65
|
+
|
|
66
|
+
In development, WazUI will automatically log environment variable status to help with debugging:
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { debugNextConfig } from '@wazobiatech/wazui';
|
|
70
|
+
|
|
71
|
+
// Call this in development to see what environment variables are loaded
|
|
72
|
+
debugNextConfig();
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Manual Configuration
|
|
76
|
+
|
|
77
|
+
If you need more control, you can create the configuration manually:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { createNextConfig } from '@wazobiatech/wazui';
|
|
81
|
+
|
|
82
|
+
const config = createNextConfig();
|
|
83
|
+
console.log('WazUI Config:', config);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Using with Provider Pattern (Advanced)
|
|
87
|
+
|
|
88
|
+
For complex scenarios, you can still use the provider pattern:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { WazUIEnvironmentProvider } from '@wazobiatech/wazui';
|
|
92
|
+
|
|
93
|
+
export default function App({ Component, pageProps }) {
|
|
94
|
+
return (
|
|
95
|
+
<WazUIEnvironmentProvider>
|
|
96
|
+
<Component {...pageProps} />
|
|
97
|
+
</WazUIEnvironmentProvider>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 📱 Component Examples
|
|
103
|
+
|
|
104
|
+
### Blog Component
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
import { WazUIBlogComponent } from '@wazobiatech/wazui';
|
|
108
|
+
|
|
109
|
+
export default function BlogPage() {
|
|
110
|
+
return (
|
|
111
|
+
<WazUIBlogComponent
|
|
112
|
+
queryConfig={{
|
|
113
|
+
fetch: {
|
|
114
|
+
query: MY_QUERY,
|
|
115
|
+
variables: { blog_uuid: 'your-blog-id' },
|
|
116
|
+
dataKey: 'posts',
|
|
117
|
+
cacheKey: 'blog-posts'
|
|
118
|
+
}
|
|
119
|
+
}}
|
|
120
|
+
columns={columns}
|
|
121
|
+
filterFields={filterFields}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Media Library
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
import { WazUiGqlMediaLibrary } from '@wazobiatech/wazui';
|
|
131
|
+
|
|
132
|
+
export default function MediaPage() {
|
|
133
|
+
return (
|
|
134
|
+
<WazUiGqlMediaLibrary
|
|
135
|
+
onImageSelect={(image) => console.log('Selected:', image)}
|
|
136
|
+
multiple={true}
|
|
137
|
+
/>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## 🛠 TypeScript Support
|
|
143
|
+
|
|
144
|
+
WazUI provides full TypeScript support:
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { NextEnv, Env } from '@wazobiatech/wazui';
|
|
148
|
+
|
|
149
|
+
// Environment variables are fully typed
|
|
150
|
+
const config: NextEnv = createNextConfig();
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## 🚨 Troubleshooting
|
|
154
|
+
|
|
155
|
+
### Environment Variables Not Working?
|
|
156
|
+
|
|
157
|
+
1. **Check your `.env.local` file** - Make sure all variables are prefixed with `NEXT_PUBLIC_`
|
|
158
|
+
2. **Restart your dev server** - Next.js requires a restart after adding new environment variables
|
|
159
|
+
3. **Enable debug logging** - Call `debugNextConfig()` to see what variables are loaded
|
|
160
|
+
4. **Check the console** - WazUI logs helpful debug information in development mode
|
|
161
|
+
|
|
162
|
+
### Default Values Showing?
|
|
163
|
+
|
|
164
|
+
If you see default values like `https://localhost:3000/graphql`, it means your environment variables aren't being read properly:
|
|
165
|
+
|
|
166
|
+
1. Verify `.env.local` is in your Next.js project root (same level as `package.json`)
|
|
167
|
+
2. Ensure all variables start with `NEXT_PUBLIC_`
|
|
168
|
+
3. Restart your development server
|
|
169
|
+
4. Check the browser console for debug information
|
|
170
|
+
|
|
171
|
+
## 🎯 Migration from Previous Versions
|
|
172
|
+
|
|
173
|
+
If you were using the old environment system:
|
|
174
|
+
|
|
175
|
+
1. **No code changes needed** - The `env` and `getEnv()` functions still work
|
|
176
|
+
2. **Optional**: Remove any custom environment providers if you were using them
|
|
177
|
+
3. **Recommended**: Use `debugNextConfig()` to verify your setup
|
|
178
|
+
|
|
179
|
+
## 🌟 Benefits
|
|
180
|
+
|
|
181
|
+
✅ **Zero Configuration** - Works out of the box with Next.js
|
|
182
|
+
✅ **Automatic Environment Detection** - Reads directly from Next.js environment variables
|
|
183
|
+
✅ **Type Safety** - Full TypeScript support with validation
|
|
184
|
+
✅ **Debug Friendly** - Built-in logging and error handling
|
|
185
|
+
✅ **Backward Compatible** - Works with existing code
|
|
186
|
+
✅ **Deployment Ready** - Works on Vercel, Netlify, and other platforms
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example: pages/_app.tsx or app/layout.tsx
|
|
3
|
+
*/
|
|
4
|
+
/*
|
|
5
|
+
import { debugNextConfig } from '@wazobiatech/wazui';
|
|
6
|
+
import '@wazobiatech/wazui/styles.css';
|
|
7
|
+
|
|
8
|
+
// Optional: Enable debug logging in development
|
|
9
|
+
if (process.env.NODE_ENV === 'development') {
|
|
10
|
+
debugNextConfig();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default function App({ Component, pageProps }: AppProps) {
|
|
14
|
+
return <Component {...pageProps} />;
|
|
15
|
+
}
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Example: pages/blog.tsx or app/blog/page.tsx
|
|
20
|
+
*/
|
|
21
|
+
/*
|
|
22
|
+
import { WazUIBlogComponent, env } from '@wazobiatech/wazui';
|
|
23
|
+
|
|
24
|
+
export default function BlogPage() {
|
|
25
|
+
// Environment variables are automatically available
|
|
26
|
+
console.log('Using API:', env.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
<h1>My Blog</h1>
|
|
31
|
+
<WazUIBlogComponent
|
|
32
|
+
queryConfig={{
|
|
33
|
+
fetch: {
|
|
34
|
+
query: YOUR_GRAPHQL_QUERY,
|
|
35
|
+
variables: { blog_uuid: 'your-blog-id' },
|
|
36
|
+
dataKey: 'posts',
|
|
37
|
+
cacheKey: 'blog-posts'
|
|
38
|
+
}
|
|
39
|
+
}}
|
|
40
|
+
columns={yourColumns}
|
|
41
|
+
filterFields={yourFilters}
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Example: Testing environment variables
|
|
50
|
+
*/
|
|
51
|
+
/*
|
|
52
|
+
import { getEnv } from '@wazobiatech/wazui';
|
|
53
|
+
|
|
54
|
+
export default function TestPage() {
|
|
55
|
+
const config = getEnv();
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div>
|
|
59
|
+
<h2>Environment Test</h2>
|
|
60
|
+
<p>Portal API: {config.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT}</p>
|
|
61
|
+
<p>Dolos URL: {config.NEXT_PUBLIC_DOLOS_URL}</p>
|
|
62
|
+
<p>Muse Token: {config.NEXT_PUBLIC_MUSE_TOKEN}</p>
|
|
63
|
+
|
|
64
|
+
{config.NEXT_PUBLIC_PORTAL_GRAPHQL_ENDPOINT === 'https://localhost:3000/graphql' ? (
|
|
65
|
+
<div style={{ color: 'red' }}>
|
|
66
|
+
⚠️ Using default values - check your .env.local file
|
|
67
|
+
</div>
|
|
68
|
+
) : (
|
|
69
|
+
<div style={{ color: 'green' }}>
|
|
70
|
+
✅ Using actual environment variables
|
|
71
|
+
</div>
|
|
72
|
+
)}
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wazobiatech/wazui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "`@repo/wazui` is a React component library that provides a set of reusable UI components, hooks, and providers for building modern web applications. It is built with TypeScript, Tailwind CSS, and integrates Shadcn UI components.",
|
|
6
6
|
"homepage": "https://bitbucket.org/wazobiatech/wazui#readme",
|
|
@@ -16,15 +16,9 @@
|
|
|
16
16
|
"type": "module",
|
|
17
17
|
"exports": {
|
|
18
18
|
"./styles.css": "./dist/styles.css",
|
|
19
|
-
".":
|
|
20
|
-
"import": "./dist/index.mjs",
|
|
21
|
-
"require": "./dist/index.js",
|
|
22
|
-
"types": "./dist/index.d.ts"
|
|
23
|
-
}
|
|
19
|
+
".": "./src/index.ts"
|
|
24
20
|
},
|
|
25
|
-
"main": "./
|
|
26
|
-
"module": "./dist/index.mjs",
|
|
27
|
-
"types": "./dist/index.d.ts",
|
|
21
|
+
"main": "./src/index.ts",
|
|
28
22
|
"scripts": {
|
|
29
23
|
"dev": "storybook dev -p 6007 --no-open",
|
|
30
24
|
"build": "node --max-old-space-size=16384 ./node_modules/.bin/vite build",
|
|
@@ -136,7 +130,6 @@
|
|
|
136
130
|
"ajv": "^8.17.1",
|
|
137
131
|
"ajv-draft-04": "^1.0.0",
|
|
138
132
|
"ajv-keywords": "^5.1.0",
|
|
139
|
-
"autoprefixer": "^10.4.23",
|
|
140
133
|
"babel-jest": "^29.7.0",
|
|
141
134
|
"eslint": "^9.21.0",
|
|
142
135
|
"eslint-plugin-jest": "^28.11.0",
|
package/src/config/env.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
3
|
const configSchema = z.object({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
NEXT_PUBLIC_API_URL: z.string(),
|
|
5
|
+
NEXT_PUBLIC_APP_TITLE: z.string(),
|
|
6
|
+
NEXT_PUBLIC_APP_DESCRIPTION: z.string(),
|
|
7
|
+
NEXT_PUBLIC_APP_URL: z.string(),
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
const config = configSchema.parse(import.meta.env);
|
|
11
11
|
|
|
12
|
-
export const apiUrl = config.
|
|
13
|
-
export const appTitle = config.
|
|
14
|
-
export const appDescription = config.
|
|
15
|
-
export const appiUrl = config.
|
|
12
|
+
export const apiUrl = config.NEXT_PUBLIC_API_URL;
|
|
13
|
+
export const appTitle = config.NEXT_PUBLIC_APP_TITLE;
|
|
14
|
+
export const appDescription = config.NEXT_PUBLIC_APP_DESCRIPTION;
|
|
15
|
+
export const appiUrl = config.NEXT_PUBLIC_APP_URL;
|