powr-sdk-web 2.0.1 → 2.0.3

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 CHANGED
@@ -1,137 +1,137 @@
1
- # Powr SDK Web
2
-
3
- A comprehensive React component library for building modern web applications with PowrBase integration.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install powr-sdk-web
9
- ```
10
-
11
- ## Components
12
-
13
- ### PowrLogin
14
- A customizable authentication component supporting login, registration, and toggle modes.
15
-
16
- ```jsx
17
- import { PowrLogin } from 'powr-sdk-web';
18
-
19
- <PowrLogin
20
- mode="toggle"
21
- appName="MyApp"
22
- appLogo="/logo.png"
23
- onLogin={(data) => console.log('Login successful:', data)}
24
- onRegister={(data) => console.log('Registration successful:', data)}
25
- loginApiUrl="https://api.powrbase.cloud/auth/login"
26
- registerApiUrl="https://api.powrbase.cloud/auth/register"
27
- />
28
- ```
29
-
30
- **Props:**
31
- - `mode`: 'login' | 'register' | 'toggle'
32
- - `appName`: Application name to display
33
- - `appLogo`: URL to application logo
34
- - `onLogin`: Callback function for successful login
35
- - `onRegister`: Callback function for successful registration
36
- - `loginApiUrl`: Custom login API endpoint (optional)
37
- - `registerApiUrl`: Custom registration API endpoint (optional)
38
-
39
- ### WaitlistDisplay
40
- Display waitlist entries from PowrBase Cloud API.
41
-
42
- ```jsx
43
- import { WaitlistDisplay } from 'powr-sdk-web';
44
-
45
- <WaitlistDisplay
46
- projectId="your-project-id"
47
- apiUrl="https://api.powrbase.cloud/waitlists"
48
- />
49
- ```
50
-
51
- **Props:**
52
- - `projectId`: Your project ID (required)
53
- - `apiUrl`: Custom API endpoint (optional)
54
-
55
- ### PowrFormBuilder
56
- Dynamic form builder that fetches and renders forms based on schema from PowrBase Cloud API.
57
-
58
- ```jsx
59
- import { PowrFormBuilder } from 'powr-sdk-web';
60
-
61
- <PowrFormBuilder
62
- formName="student-registration"
63
- projectId="your-project-id"
64
- theme="purple"
65
- onSubmitSuccess={(data) => console.log('Form submitted:', data)}
66
- onSubmitError={(error) => console.error('Form error:', error)}
67
- />
68
- ```
69
-
70
- **Props:**
71
- - `formName`: Name of the form to fetch (required)
72
- - `projectId`: Your project ID (required)
73
- - `apiUrl`: Custom API endpoint (optional, defaults to PowrBase Cloud)
74
- - `onSubmitSuccess`: Callback for successful form submission
75
- - `onSubmitError`: Callback for form submission errors
76
- - `className`: Additional CSS classes
77
- - `theme`: Color theme ('purple', 'blue', 'green', 'red', 'yellow', 'indigo', 'pink')
78
-
79
- **Supported Field Types:**
80
- - `email`: Email input with validation
81
- - `text`: Text input
82
- - `radio`: Radio button groups
83
- - `custom`: Special fields (e.g., QR codes)
84
- - `fileUploader`: File upload with payment proof support
85
-
86
- ### FormDisplay
87
- Display form responses from PowrBase Cloud API.
88
-
89
- ```jsx
90
- import { FormDisplay } from 'powr-sdk-web';
91
-
92
- <FormDisplay
93
- formName="student-registration"
94
- projectId="your-project-id"
95
- theme="purple"
96
- />
97
- ```
98
-
99
- **Props:**
100
- - `formName`: Name of the form to display responses for (required)
101
- - `projectId`: Your project ID (required)
102
- - `apiUrl`: Custom API endpoint (optional, defaults to PowrBase Cloud)
103
- - `className`: Additional CSS classes
104
- - `theme`: Color theme ('purple', 'blue', 'green', 'red', 'yellow', 'indigo', 'pink')
105
-
106
- ### Other Components
107
-
108
- - `PowrBaseSwiper`: Customizable image/video swiper
109
- - `PowrBaseReviews`: Review display and management
110
- - `PowrBaseUploader`: File upload component
111
- - `PowrBaseComments`: Comment system
112
- - `PowrBaseWaitlist`: Waitlist submission component
113
- - `PowrBaseActivities`: Activity feed
114
- - `PowrBaseInvoice`: Invoice management
115
- - `PowrLike`: Like/reaction system
116
- - `PowrBaseBlogs`: Blog management
117
-
118
- ## API Integration
119
-
120
- All components are designed to work with the PowrBase Cloud API by default, but can be configured to use custom endpoints.
121
-
122
- ### Default API Endpoints:
123
- - Authentication: `https://api.powrbase.cloud/auth`
124
- - Forms: `https://api.powrbase.cloud/forms`
125
- - Waitlists: `https://api.powrbase.cloud/waitlists`
126
-
127
- ## Styling
128
-
129
- Components use Tailwind CSS classes and support custom theming. The default theme is purple, but you can customize colors using the `theme` prop where available.
130
-
131
- ## TypeScript Support
132
-
133
- Full TypeScript support is included with proper type definitions for all components.
134
-
135
- ## License
136
-
1
+ # Powr SDK Web
2
+
3
+ A comprehensive React component library for building modern web applications with PowrBase integration.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install powr-sdk-web
9
+ ```
10
+
11
+ ## Components
12
+
13
+ ### PowrLogin
14
+ A customizable authentication component supporting login, registration, and toggle modes.
15
+
16
+ ```jsx
17
+ import { PowrLogin } from 'powr-sdk-web';
18
+
19
+ <PowrLogin
20
+ mode="toggle"
21
+ appName="MyApp"
22
+ appLogo="/logo.png"
23
+ onLogin={(data) => console.log('Login successful:', data)}
24
+ onRegister={(data) => console.log('Registration successful:', data)}
25
+ loginApiUrl="https://api.powrbase.cloud/auth/login"
26
+ registerApiUrl="https://api.powrbase.cloud/auth/register"
27
+ />
28
+ ```
29
+
30
+ **Props:**
31
+ - `mode`: 'login' | 'register' | 'toggle'
32
+ - `appName`: Application name to display
33
+ - `appLogo`: URL to application logo
34
+ - `onLogin`: Callback function for successful login
35
+ - `onRegister`: Callback function for successful registration
36
+ - `loginApiUrl`: Custom login API endpoint (optional)
37
+ - `registerApiUrl`: Custom registration API endpoint (optional)
38
+
39
+ ### WaitlistDisplay
40
+ Display waitlist entries from PowrBase Cloud API.
41
+
42
+ ```jsx
43
+ import { WaitlistDisplay } from 'powr-sdk-web';
44
+
45
+ <WaitlistDisplay
46
+ projectId="your-project-id"
47
+ apiUrl="https://api.powrbase.cloud/waitlists"
48
+ />
49
+ ```
50
+
51
+ **Props:**
52
+ - `projectId`: Your project ID (required)
53
+ - `apiUrl`: Custom API endpoint (optional)
54
+
55
+ ### PowrFormBuilder
56
+ Dynamic form builder that fetches and renders forms based on schema from PowrBase Cloud API.
57
+
58
+ ```jsx
59
+ import { PowrFormBuilder } from 'powr-sdk-web';
60
+
61
+ <PowrFormBuilder
62
+ formName="student-registration"
63
+ projectId="your-project-id"
64
+ theme="purple"
65
+ onSubmitSuccess={(data) => console.log('Form submitted:', data)}
66
+ onSubmitError={(error) => console.error('Form error:', error)}
67
+ />
68
+ ```
69
+
70
+ **Props:**
71
+ - `formName`: Name of the form to fetch (required)
72
+ - `projectId`: Your project ID (required)
73
+ - `apiUrl`: Custom API endpoint (optional, defaults to PowrBase Cloud)
74
+ - `onSubmitSuccess`: Callback for successful form submission
75
+ - `onSubmitError`: Callback for form submission errors
76
+ - `className`: Additional CSS classes
77
+ - `theme`: Color theme ('purple', 'blue', 'green', 'red', 'yellow', 'indigo', 'pink')
78
+
79
+ **Supported Field Types:**
80
+ - `email`: Email input with validation
81
+ - `text`: Text input
82
+ - `radio`: Radio button groups
83
+ - `custom`: Special fields (e.g., QR codes)
84
+ - `fileUploader`: File upload with payment proof support
85
+
86
+ ### FormDisplay
87
+ Display form responses from PowrBase Cloud API.
88
+
89
+ ```jsx
90
+ import { FormDisplay } from 'powr-sdk-web';
91
+
92
+ <FormDisplay
93
+ formName="student-registration"
94
+ projectId="your-project-id"
95
+ theme="purple"
96
+ />
97
+ ```
98
+
99
+ **Props:**
100
+ - `formName`: Name of the form to display responses for (required)
101
+ - `projectId`: Your project ID (required)
102
+ - `apiUrl`: Custom API endpoint (optional, defaults to PowrBase Cloud)
103
+ - `className`: Additional CSS classes
104
+ - `theme`: Color theme ('purple', 'blue', 'green', 'red', 'yellow', 'indigo', 'pink')
105
+
106
+ ### Other Components
107
+
108
+ - `PowrBaseSwiper`: Customizable image/video swiper
109
+ - `PowrBaseReviews`: Review display and management
110
+ - `PowrBaseUploader`: File upload component
111
+ - `PowrBaseComments`: Comment system
112
+ - `PowrBaseWaitlist`: Waitlist submission component
113
+ - `PowrBaseActivities`: Activity feed
114
+ - `PowrBaseInvoice`: Invoice management
115
+ - `PowrLike`: Like/reaction system
116
+ - `PowrBaseBlogs`: Blog management
117
+
118
+ ## API Integration
119
+
120
+ All components are designed to work with the PowrBase Cloud API by default, but can be configured to use custom endpoints.
121
+
122
+ ### Default API Endpoints:
123
+ - Authentication: `https://api.powrbase.cloud/auth`
124
+ - Forms: `https://api.powrbase.cloud/forms`
125
+ - Waitlists: `https://api.powrbase.cloud/waitlists`
126
+
127
+ ## Styling
128
+
129
+ Components use Tailwind CSS classes and support custom theming. The default theme is purple, but you can customize colors using the `theme` prop where available.
130
+
131
+ ## TypeScript Support
132
+
133
+ Full TypeScript support is included with proper type definitions for all components.
134
+
135
+ ## License
136
+
137
137
  MIT License
package/dist/index.js CHANGED
@@ -75,7 +75,7 @@ Object.defineProperty(exports, "PowrLogin", {
75
75
  return _auth["default"];
76
76
  }
77
77
  });
78
- Object.defineProperty(exports, "WaitlistDisplay", {
78
+ Object.defineProperty(exports, "WaitlistManagement", {
79
79
  enumerable: true,
80
80
  get: function get() {
81
81
  return _display["default"];
@@ -6,7 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports["default"] = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
9
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); }
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
15
  function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
11
16
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
12
17
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
@@ -17,10 +22,12 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
17
22
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
18
23
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
19
24
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
20
- var WaitlistDisplay = function WaitlistDisplay(_ref) {
25
+ var WaitlistManagement = function WaitlistManagement(_ref) {
21
26
  var projectId = _ref.projectId,
22
27
  _ref$apiUrl = _ref.apiUrl,
23
- apiUrl = _ref$apiUrl === void 0 ? 'https://api.powrbase.cloud/waitlists' : _ref$apiUrl;
28
+ apiUrl = _ref$apiUrl === void 0 ? 'https://api.powrbase.cloud/waitlists' : _ref$apiUrl,
29
+ onAddEntry = _ref.onAddEntry,
30
+ onRefresh = _ref.onRefresh;
24
31
  var _useState = (0, _react.useState)([]),
25
32
  _useState2 = _slicedToArray(_useState, 2),
26
33
  entries = _useState2[0],
@@ -33,197 +40,305 @@ var WaitlistDisplay = function WaitlistDisplay(_ref) {
33
40
  _useState6 = _slicedToArray(_useState5, 2),
34
41
  error = _useState6[0],
35
42
  setError = _useState6[1];
36
- (0, _react.useEffect)(function () {
37
- var fetchWaitlist = /*#__PURE__*/function () {
38
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
39
- var response, data, _t;
40
- return _regenerator().w(function (_context) {
41
- while (1) switch (_context.n) {
42
- case 0:
43
- if (projectId) {
44
- _context.n = 1;
45
- break;
46
- }
47
- setError('Project ID is required');
48
- setLoading(false);
49
- return _context.a(2);
50
- case 1:
51
- _context.p = 1;
52
- setLoading(true);
53
- setError('');
54
- _context.n = 2;
55
- return fetch("".concat(apiUrl, "?projectId=").concat(projectId), {
56
- method: 'GET',
57
- headers: {
58
- 'Content-Type': 'application/json'
59
- }
60
- });
61
- case 2:
62
- response = _context.v;
63
- if (response.ok) {
64
- _context.n = 3;
65
- break;
66
- }
67
- throw new Error('Failed to fetch waitlist');
68
- case 3:
69
- _context.n = 4;
70
- return response.json();
71
- case 4:
72
- data = _context.v;
73
- if (!data.success) {
74
- _context.n = 5;
75
- break;
43
+ var _useState7 = (0, _react.useState)(false),
44
+ _useState8 = _slicedToArray(_useState7, 2),
45
+ showAddModal = _useState8[0],
46
+ setShowAddModal = _useState8[1];
47
+ var _useState9 = (0, _react.useState)(false),
48
+ _useState0 = _slicedToArray(_useState9, 2),
49
+ isSubmitting = _useState0[0],
50
+ setIsSubmitting = _useState0[1];
51
+ var _useState1 = (0, _react.useState)({
52
+ email: ''
53
+ }),
54
+ _useState10 = _slicedToArray(_useState1, 2),
55
+ formData = _useState10[0],
56
+ setFormData = _useState10[1];
57
+ var fetchWaitlist = /*#__PURE__*/function () {
58
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
59
+ var response, data, _t;
60
+ return _regenerator().w(function (_context) {
61
+ while (1) switch (_context.n) {
62
+ case 0:
63
+ if (projectId) {
64
+ _context.n = 1;
65
+ break;
66
+ }
67
+ setError('Project ID is required');
68
+ setLoading(false);
69
+ return _context.a(2);
70
+ case 1:
71
+ _context.p = 1;
72
+ setLoading(true);
73
+ setError('');
74
+ _context.n = 2;
75
+ return fetch("".concat(apiUrl, "?projectId=").concat(projectId), {
76
+ method: 'GET',
77
+ headers: {
78
+ 'Content-Type': 'application/json'
76
79
  }
77
- setEntries(data.entries || []);
78
- _context.n = 6;
80
+ });
81
+ case 2:
82
+ response = _context.v;
83
+ if (response.ok) {
84
+ _context.n = 3;
79
85
  break;
80
- case 5:
81
- throw new Error(data.message || 'Failed to load waitlist');
82
- case 6:
83
- _context.n = 8;
86
+ }
87
+ throw new Error('Failed to fetch waitlist');
88
+ case 3:
89
+ _context.n = 4;
90
+ return response.json();
91
+ case 4:
92
+ data = _context.v;
93
+ if (!data.success) {
94
+ _context.n = 5;
84
95
  break;
85
- case 7:
86
- _context.p = 7;
87
- _t = _context.v;
88
- setError(_t.message || 'Something went wrong');
89
- console.error('Error fetching waitlist:', _t);
90
- case 8:
91
- _context.p = 8;
92
- setLoading(false);
93
- return _context.f(8);
94
- case 9:
95
- return _context.a(2);
96
- }
97
- }, _callee, null, [[1, 7, 8, 9]]);
98
- }));
99
- return function fetchWaitlist() {
100
- return _ref2.apply(this, arguments);
101
- };
102
- }();
96
+ }
97
+ setEntries(data.entries || []);
98
+ _context.n = 6;
99
+ break;
100
+ case 5:
101
+ throw new Error(data.message || 'Failed to load waitlist');
102
+ case 6:
103
+ _context.n = 8;
104
+ break;
105
+ case 7:
106
+ _context.p = 7;
107
+ _t = _context.v;
108
+ setError(_t.message || 'Something went wrong');
109
+ console.error('Error fetching waitlist:', _t);
110
+ case 8:
111
+ _context.p = 8;
112
+ setLoading(false);
113
+ return _context.f(8);
114
+ case 9:
115
+ return _context.a(2);
116
+ }
117
+ }, _callee, null, [[1, 7, 8, 9]]);
118
+ }));
119
+ return function fetchWaitlist() {
120
+ return _ref2.apply(this, arguments);
121
+ };
122
+ }();
123
+ (0, _react.useEffect)(function () {
103
124
  fetchWaitlist();
104
125
  }, [projectId, apiUrl]);
126
+ var handleInputChange = function handleInputChange(e) {
127
+ var _e$target = e.target,
128
+ name = _e$target.name,
129
+ value = _e$target.value;
130
+ setFormData(function (prev) {
131
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, name, value));
132
+ });
133
+ };
134
+ var handleSubmit = /*#__PURE__*/function () {
135
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
136
+ var response, result, _t2;
137
+ return _regenerator().w(function (_context2) {
138
+ while (1) switch (_context2.n) {
139
+ case 0:
140
+ if (formData.email) {
141
+ _context2.n = 1;
142
+ break;
143
+ }
144
+ if (onAddEntry) {
145
+ onAddEntry('error', 'Email is required');
146
+ }
147
+ return _context2.a(2);
148
+ case 1:
149
+ setIsSubmitting(true);
150
+ _context2.p = 2;
151
+ _context2.n = 3;
152
+ return fetch('https://api.powrbase.cloud/waitlist', {
153
+ method: 'POST',
154
+ headers: {
155
+ 'Content-Type': 'application/json'
156
+ },
157
+ body: JSON.stringify({
158
+ email: formData.email,
159
+ projectId: projectId
160
+ })
161
+ });
162
+ case 3:
163
+ response = _context2.v;
164
+ _context2.n = 4;
165
+ return response.json();
166
+ case 4:
167
+ result = _context2.v;
168
+ if (!result.success) {
169
+ _context2.n = 5;
170
+ break;
171
+ }
172
+ if (onAddEntry) {
173
+ onAddEntry('success', 'Entry added to waitlist successfully!');
174
+ }
175
+ setFormData({
176
+ email: ''
177
+ });
178
+ setShowAddModal(false);
179
+ fetchWaitlist(); // Refresh the list
180
+ if (onRefresh) {
181
+ onRefresh();
182
+ }
183
+ _context2.n = 6;
184
+ break;
185
+ case 5:
186
+ throw new Error(result.message || 'Failed to add entry');
187
+ case 6:
188
+ _context2.n = 8;
189
+ break;
190
+ case 7:
191
+ _context2.p = 7;
192
+ _t2 = _context2.v;
193
+ console.error('Error adding entry:', _t2);
194
+ if (onAddEntry) {
195
+ onAddEntry('error', _t2.message || 'Failed to add entry to waitlist');
196
+ }
197
+ case 8:
198
+ _context2.p = 8;
199
+ setIsSubmitting(false);
200
+ return _context2.f(8);
201
+ case 9:
202
+ return _context2.a(2);
203
+ }
204
+ }, _callee2, null, [[2, 7, 8, 9]]);
205
+ }));
206
+ return function handleSubmit() {
207
+ return _ref3.apply(this, arguments);
208
+ };
209
+ }();
105
210
  if (loading) {
106
211
  return /*#__PURE__*/_react["default"].createElement("div", {
107
- style: {
108
- display: 'flex',
109
- justifyContent: 'center',
110
- alignItems: 'center',
111
- padding: '40px',
112
- color: '#666'
113
- }
114
- }, "Loading waitlist...");
212
+ className: "flex items-center justify-center h-64"
213
+ }, /*#__PURE__*/_react["default"].createElement("div", {
214
+ className: "animate-spin h-8 w-8 border-4 border-blue-600 border-t-transparent rounded-full"
215
+ }));
115
216
  }
116
217
  if (error) {
117
218
  return /*#__PURE__*/_react["default"].createElement("div", {
118
- style: {
119
- padding: '20px',
120
- color: '#e74c3c',
121
- textAlign: 'center',
122
- background: '#fdf2f2',
123
- borderRadius: '8px',
124
- border: '1px solid #fecaca'
125
- }
126
- }, error);
219
+ className: "text-center py-8 text-red-500"
220
+ }, /*#__PURE__*/_react["default"].createElement("p", null, error));
127
221
  }
128
- if (entries.length === 0) {
222
+ if (!projectId) {
129
223
  return /*#__PURE__*/_react["default"].createElement("div", {
130
- style: {
131
- padding: '40px',
132
- textAlign: 'center',
133
- color: '#666',
134
- background: '#f9fafb',
135
- borderRadius: '8px'
136
- }
137
- }, /*#__PURE__*/_react["default"].createElement("h3", {
138
- style: {
139
- marginBottom: '12px',
140
- color: '#374151'
141
- }
142
- }, "No Waitlist Entries"), /*#__PURE__*/_react["default"].createElement("p", null, "No one has joined the waitlist yet."));
224
+ className: "flex items-center justify-center h-64"
225
+ }, /*#__PURE__*/_react["default"].createElement("div", {
226
+ className: "text-center"
227
+ }, /*#__PURE__*/_react["default"].createElement("p", {
228
+ className: "text-gray-500"
229
+ }, "No project selected"), /*#__PURE__*/_react["default"].createElement("p", {
230
+ className: "text-sm text-gray-400"
231
+ }, "Please select a project to view waitlist")));
143
232
  }
144
233
  return /*#__PURE__*/_react["default"].createElement("div", {
145
- style: {
146
- maxWidth: '800px',
147
- margin: '0 auto',
148
- background: '#fff',
149
- borderRadius: '12px',
150
- boxShadow: '0 2px 12px rgba(0,0,0,0.07)',
151
- overflow: 'hidden'
152
- }
234
+ className: "space-y-6"
153
235
  }, /*#__PURE__*/_react["default"].createElement("div", {
154
- style: {
155
- padding: '24px',
156
- borderBottom: '1px solid #e5e7eb',
157
- background: '#f9fafb'
158
- }
159
- }, /*#__PURE__*/_react["default"].createElement("h2", {
160
- style: {
161
- margin: 0,
162
- fontSize: '20px',
163
- fontWeight: '600',
164
- color: '#111827'
165
- }
166
- }, "Waitlist Entries (", entries.length, ")"), /*#__PURE__*/_react["default"].createElement("p", {
167
- style: {
168
- margin: '8px 0 0 0',
169
- color: '#6b7280',
170
- fontSize: '14px'
171
- }
172
- }, "People who have joined your waitlist")), /*#__PURE__*/_react["default"].createElement("div", {
173
- style: {
174
- maxHeight: '400px',
175
- overflowY: 'auto'
176
- }
177
- }, entries.map(function (entry, index) {
178
- return /*#__PURE__*/_react["default"].createElement("div", {
179
- key: entry._id || index,
180
- style: {
181
- padding: '16px 24px',
182
- borderBottom: '1px solid #f3f4f6',
183
- display: 'flex',
184
- justifyContent: 'space-between',
185
- alignItems: 'center',
186
- background: index % 2 === 0 ? '#fff' : '#fafafa'
187
- }
188
- }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
189
- style: {
190
- fontWeight: '500',
191
- color: '#111827',
192
- marginBottom: '4px'
193
- }
194
- }, entry.email), /*#__PURE__*/_react["default"].createElement("div", {
195
- style: {
196
- fontSize: '12px',
197
- color: '#6b7280'
198
- }
199
- }, "Joined ", new Date(entry.createdAt).toLocaleDateString('en-US', {
200
- year: 'numeric',
201
- month: 'short',
202
- day: 'numeric',
203
- hour: '2-digit',
204
- minute: '2-digit'
205
- }))), /*#__PURE__*/_react["default"].createElement("div", {
206
- style: {
207
- fontSize: '12px',
208
- color: '#6b7280',
209
- background: '#f3f4f6',
210
- padding: '4px 8px',
211
- borderRadius: '4px'
212
- }
213
- }, "#", index + 1));
214
- })), entries.length > 0 && /*#__PURE__*/_react["default"].createElement("div", {
215
- style: {
216
- padding: '16px 24px',
217
- background: '#f9fafb',
218
- borderTop: '1px solid #e5e7eb',
219
- textAlign: 'center'
220
- }
236
+ className: "flex items-center justify-between"
237
+ }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("h1", {
238
+ className: "text-2xl font-bold text-gray-900"
239
+ }, "Waitlist Management"), /*#__PURE__*/_react["default"].createElement("p", {
240
+ className: "text-gray-600 mt-1"
241
+ }, "Manage your waitlist entries and approvals")), /*#__PURE__*/_react["default"].createElement("button", {
242
+ onClick: function onClick() {
243
+ return setShowAddModal(true);
244
+ },
245
+ className: "bg-orange-600 hover:bg-orange-700 text-white px-4 py-2 rounded-lg flex items-center gap-2"
246
+ }, /*#__PURE__*/_react["default"].createElement("svg", {
247
+ className: "h-4 w-4",
248
+ fill: "none",
249
+ stroke: "currentColor",
250
+ viewBox: "0 0 24 24"
251
+ }, /*#__PURE__*/_react["default"].createElement("path", {
252
+ strokeLinecap: "round",
253
+ strokeLinejoin: "round",
254
+ strokeWidth: 2,
255
+ d: "M12 4v16m8-8H4"
256
+ })), "Add Entry")), /*#__PURE__*/_react["default"].createElement("div", {
257
+ className: "grid grid-cols-1 md:grid-cols-1 gap-4"
258
+ }, /*#__PURE__*/_react["default"].createElement("div", {
259
+ className: "bg-white rounded-lg shadow p-4"
260
+ }, /*#__PURE__*/_react["default"].createElement("div", {
261
+ className: "flex items-center"
262
+ }, /*#__PURE__*/_react["default"].createElement("div", {
263
+ className: "h-8 w-8 text-blue-600"
264
+ }, /*#__PURE__*/_react["default"].createElement("svg", {
265
+ fill: "currentColor",
266
+ viewBox: "0 0 20 20"
267
+ }, /*#__PURE__*/_react["default"].createElement("path", {
268
+ d: "M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3z"
269
+ }))), /*#__PURE__*/_react["default"].createElement("div", {
270
+ className: "ml-3"
221
271
  }, /*#__PURE__*/_react["default"].createElement("p", {
222
- style: {
223
- margin: 0,
224
- fontSize: '14px',
225
- color: '#6b7280'
226
- }
227
- }, "Total entries: ", entries.length)));
272
+ className: "text-sm font-medium text-gray-600"
273
+ }, "Total Waitlist Entries"), /*#__PURE__*/_react["default"].createElement("p", {
274
+ className: "text-2xl font-bold text-gray-900"
275
+ }, entries.length))))), /*#__PURE__*/_react["default"].createElement("div", {
276
+ className: "bg-white rounded-lg shadow"
277
+ }, /*#__PURE__*/_react["default"].createElement("div", {
278
+ className: "px-6 py-4 border-b border-gray-200"
279
+ }, /*#__PURE__*/_react["default"].createElement("h3", {
280
+ className: "text-lg font-semibold text-gray-900"
281
+ }, "Waitlist Entries")), /*#__PURE__*/_react["default"].createElement("div", {
282
+ className: "p-6"
283
+ }, entries.length === 0 ? /*#__PURE__*/_react["default"].createElement("div", {
284
+ className: "text-center py-8 text-gray-500"
285
+ }, /*#__PURE__*/_react["default"].createElement("div", {
286
+ className: "h-12 w-12 mx-auto mb-4 text-gray-300"
287
+ }, /*#__PURE__*/_react["default"].createElement("svg", {
288
+ fill: "currentColor",
289
+ viewBox: "0 0 20 20"
290
+ }, /*#__PURE__*/_react["default"].createElement("path", {
291
+ d: "M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3z"
292
+ }))), /*#__PURE__*/_react["default"].createElement("p", null, "No waitlist entries yet"), /*#__PURE__*/_react["default"].createElement("p", {
293
+ className: "text-sm"
294
+ }, "Add your first entry to get started")) : /*#__PURE__*/_react["default"].createElement("div", {
295
+ className: "space-y-4"
296
+ }, entries.map(function (entry) {
297
+ return /*#__PURE__*/_react["default"].createElement("div", {
298
+ key: entry._id,
299
+ className: "flex items-center justify-between p-4 border rounded-lg hover:bg-gray-50"
300
+ }, /*#__PURE__*/_react["default"].createElement("div", {
301
+ className: "flex-1"
302
+ }, /*#__PURE__*/_react["default"].createElement("div", {
303
+ className: "flex items-center space-x-3"
304
+ }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("p", {
305
+ className: "text-sm font-medium text-gray-900"
306
+ }, entry.email), /*#__PURE__*/_react["default"].createElement("p", {
307
+ className: "text-xs text-gray-400"
308
+ }, "Added: ", new Date(entry.createdAt).toLocaleDateString())))));
309
+ })))), showAddModal && /*#__PURE__*/_react["default"].createElement("div", {
310
+ className: "fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50"
311
+ }, /*#__PURE__*/_react["default"].createElement("div", {
312
+ className: "bg-white rounded-2xl shadow-xl p-8 w-full max-w-lg"
313
+ }, /*#__PURE__*/_react["default"].createElement("h2", {
314
+ className: "text-xl font-bold text-gray-800 mb-6"
315
+ }, "Add Waitlist Entry"), /*#__PURE__*/_react["default"].createElement("div", {
316
+ className: "space-y-4"
317
+ }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("label", {
318
+ htmlFor: "email",
319
+ className: "block text-sm font-medium text-gray-700 mb-1"
320
+ }, "Email *"), /*#__PURE__*/_react["default"].createElement("input", {
321
+ id: "email",
322
+ name: "email",
323
+ type: "email",
324
+ value: formData.email,
325
+ onChange: handleInputChange,
326
+ placeholder: "Enter email address",
327
+ required: true,
328
+ className: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
329
+ }))), /*#__PURE__*/_react["default"].createElement("div", {
330
+ className: "flex justify-end gap-4 mt-6"
331
+ }, /*#__PURE__*/_react["default"].createElement("button", {
332
+ onClick: function onClick() {
333
+ return setShowAddModal(false);
334
+ },
335
+ className: "bg-gray-300 text-gray-700 hover:bg-gray-400 px-4 py-2 rounded-md"
336
+ }, "Cancel"), /*#__PURE__*/_react["default"].createElement("button", {
337
+ onClick: handleSubmit,
338
+ disabled: isSubmitting,
339
+ className: "bg-orange-600 text-white hover:bg-orange-700 px-4 py-2 rounded-md disabled:opacity-50"
340
+ }, isSubmitting ? /*#__PURE__*/_react["default"].createElement("div", {
341
+ className: "animate-spin h-5 w-5 mx-auto border-2 border-white border-t-transparent rounded-full"
342
+ }) : 'Add Entry')))));
228
343
  };
229
- var _default = exports["default"] = WaitlistDisplay;
344
+ var _default = exports["default"] = WaitlistManagement;
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
- {
2
- "name": "powr-sdk-web",
3
- "version": "2.0.1",
4
- "main": "dist/index.js",
5
-
6
- "scripts": {
7
- "build": "babel src -d dist --copy-files",
8
- "prepublishOnly": "npm run build"
9
- },
10
- "keywords": [
11
- "react",
12
- "component",
13
- "npm",
14
- "file-upload",
15
- "powrbase",
16
- "comments"
17
- ],
18
- "author": "Lawazia Tech",
19
- "license": "MIT",
20
- "repository": {
21
- "type": "git",
22
- "url": "https://github.com/lawaziatech/react-byto.git"
23
- },
24
- "peerDependencies": {
25
- "react": "*",
26
- "react-dom": "*"
27
- },
28
- "dependencies": {
29
- "react-hook-form": "^7.58.0",
30
- "axios": "^1.7.7"
31
- },
32
- "devDependencies": {
33
- "@babel/cli": "^7.24.1",
34
- "@babel/core": "^7.24.4",
35
- "@babel/preset-env": "^7.24.4",
36
- "@babel/preset-react": "^7.24.1",
37
- "prop-types": "^15.8.1"
38
- }
39
- }
1
+ {
2
+ "name": "powr-sdk-web",
3
+ "version": "2.0.3",
4
+ "main": "dist/index.js",
5
+
6
+ "scripts": {
7
+ "build": "babel src -d dist --copy-files",
8
+ "prepublishOnly": "npm run build"
9
+ },
10
+ "keywords": [
11
+ "react",
12
+ "component",
13
+ "npm",
14
+ "file-upload",
15
+ "powrbase",
16
+ "comments"
17
+ ],
18
+ "author": "Lawazia Tech",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/lawaziatech/react-byto.git"
23
+ },
24
+ "peerDependencies": {
25
+ "react": "*",
26
+ "react-dom": "*"
27
+ },
28
+ "dependencies": {
29
+ "react-hook-form": "^7.58.0",
30
+ "axios": "^1.7.7"
31
+ },
32
+ "devDependencies": {
33
+ "@babel/cli": "^7.24.1",
34
+ "@babel/core": "^7.24.4",
35
+ "@babel/preset-env": "^7.24.4",
36
+ "@babel/preset-react": "^7.24.1",
37
+ "prop-types": "^15.8.1"
38
+ }
39
+ }