umwd-components 0.1.233 → 0.1.235

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.
Files changed (43) hide show
  1. package/dist/cjs/components/FleetSection.js +11 -2
  2. package/dist/cjs/components/PageBuilder.js +135 -0
  3. package/dist/cjs/components/PersonaliaSection.js +13 -4
  4. package/dist/cjs/components/PictureBarSection.js +11 -2
  5. package/dist/cjs/components/TextImageSection.js +2 -15
  6. package/dist/cjs/components/dashboard/SideNav.js +28 -3
  7. package/dist/cjs/components/page-builder/PBTextImageSection.js +150 -0
  8. package/dist/cjs/data/actions/pagebuilder-actions.js +197 -0
  9. package/dist/cjs/data/services/pagebuilder-service.js +32 -0
  10. package/dist/cjs/index.js +2 -0
  11. package/dist/esm/components/FleetSection.js +11 -2
  12. package/dist/esm/components/PageBuilder.js +131 -0
  13. package/dist/esm/components/PersonaliaSection.js +13 -4
  14. package/dist/esm/components/PictureBarSection.js +11 -2
  15. package/dist/esm/components/TextImageSection.js +2 -15
  16. package/dist/esm/components/dashboard/SideNav.js +28 -3
  17. package/dist/esm/components/page-builder/PBTextImageSection.js +148 -0
  18. package/dist/esm/data/actions/pagebuilder-actions.js +195 -0
  19. package/dist/esm/data/services/pagebuilder-service.js +30 -0
  20. package/dist/esm/index.js +1 -0
  21. package/package.json +1 -1
  22. package/src/components/FleetSection.tsx +6 -6
  23. package/src/components/PageBuilder.tsx +91 -0
  24. package/src/components/PageV2.tsx +49 -0
  25. package/src/components/PersonaliaSection.tsx +8 -8
  26. package/src/components/PictureBarSection.tsx +7 -6
  27. package/src/components/TextImageSection.tsx +5 -104
  28. package/src/components/dashboard/SideNav.tsx +51 -14
  29. package/src/components/page-builder/ColumnsSection.tsx +88 -0
  30. package/src/components/page-builder/FeaturesSection.tsx +141 -0
  31. package/src/components/page-builder/FleetSection.tsx +223 -0
  32. package/src/components/page-builder/HeroSection.tsx +148 -0
  33. package/src/components/page-builder/IconSection.tsx +74 -0
  34. package/src/components/page-builder/LogoBarSection.tsx +110 -0
  35. package/src/components/page-builder/PBTextImageSection.tsx +189 -0
  36. package/src/components/page-builder/PersonaliaSection.tsx +382 -0
  37. package/src/components/page-builder/PictureBarSection.tsx +84 -0
  38. package/src/data/actions/pagebuilder-actions.ts +196 -0
  39. package/src/data/services/pagebuilder-service.ts +30 -0
  40. package/src/index.js +1 -0
  41. package/src/stories/Page.stories.js +30 -18
  42. package/src/stories/PageBuilder.stories.js +356 -0
  43. package/src/stories/SideNav.stories.js +10 -0
@@ -13,6 +13,15 @@ var RadarIcon = require('@mui/icons-material/Radar');
13
13
  var SpeedIcon = require('@mui/icons-material/Speed');
14
14
  var HeightIcon = require('@mui/icons-material/Height');
15
15
 
16
+ /* interface ImageProps {
17
+ id: number;
18
+ url: string;
19
+ alternativeText: string;
20
+ style: React.CSSProperties;
21
+ width: number;
22
+ height: number;
23
+ } */
24
+
16
25
  function FleetSection(_ref) {
17
26
  let {
18
27
  data
@@ -79,8 +88,8 @@ function FleetSection(_ref) {
79
88
  variant: "outlined"
80
89
  }, airplane.floorplan !== null && /*#__PURE__*/React.createElement(StrapiImage.StrapiImage, {
81
90
  id: (_airplane$floorplan$i = airplane.floorplan.id) === null || _airplane$floorplan$i === void 0 ? void 0 : _airplane$floorplan$i.toString(),
82
- src: airplane.floorplan.url,
83
- alt: airplane.floorplan.alternativeText,
91
+ url: airplane.floorplan.url,
92
+ alternativeText: airplane.floorplan.alternativeText,
84
93
  width: airplane.floorplan.width,
85
94
  height: airplane.floorplan.height,
86
95
  style: {
@@ -0,0 +1,135 @@
1
+ /*
2
+ * UMWD-Components
3
+ * @copyright Jelle Paulus
4
+ * @license MIT
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ Object.defineProperty(exports, '__esModule', { value: true });
10
+
11
+ var React = require('react');
12
+ var material = require('@mui/material');
13
+ var PBTextImageSection = require('./page-builder/PBTextImageSection.js');
14
+ var HeroSection = require('./HeroSection.js');
15
+ var FeaturesSection = require('./FeaturesSection.js');
16
+ var FleetSection = require('./FleetSection.js');
17
+ var IconSection = require('./IconSection.js');
18
+ var ColumnsSection = require('./ColumnsSection.js');
19
+ var ContactForm = require('./ContactForm.js');
20
+ var PersonaliaSection = require('./PersonaliaSection.js');
21
+ var PictureBarSection = require('./PictureBarSection.js');
22
+ var LogoBarSection = require('./LogoBarSection.js');
23
+ var reactDom = require('react-dom');
24
+ var pagebuilderActions = require('../data/actions/pagebuilder-actions.js');
25
+
26
+ const INITIAL_STATE = {
27
+ zodErrors: null,
28
+ strapiErrors: null,
29
+ data: null,
30
+ message: null
31
+ };
32
+ function blockRenderer(block) {
33
+ switch (block.__component) {
34
+ case "layout.hero-section":
35
+ return /*#__PURE__*/React.createElement(HeroSection.HeroSection, {
36
+ key: block.id,
37
+ data: block
38
+ });
39
+ case "layout.features-section":
40
+ return /*#__PURE__*/React.createElement(FeaturesSection.FeatureSection, {
41
+ key: block.id,
42
+ data: block
43
+ });
44
+ case "layout.contact-section":
45
+ return /*#__PURE__*/React.createElement(ContactForm.default, {
46
+ key: block.id,
47
+ data: block
48
+ });
49
+ case "layout.text-image-section":
50
+ return /*#__PURE__*/React.createElement(PBTextImageSection.PBTextImageSection, {
51
+ key: block.id,
52
+ data: block
53
+ });
54
+ case "layout.icon-section":
55
+ return /*#__PURE__*/React.createElement(IconSection.IconSection, {
56
+ key: block.id,
57
+ data: block
58
+ });
59
+ case "layout.fleet-section":
60
+ return /*#__PURE__*/React.createElement(FleetSection.FleetSection, {
61
+ key: block.id,
62
+ data: block
63
+ });
64
+ case "layout.columns-section":
65
+ return /*#__PURE__*/React.createElement(ColumnsSection.ColumnsSection, {
66
+ key: block.id,
67
+ data: block
68
+ });
69
+ case "layout.personalia-section":
70
+ return /*#__PURE__*/React.createElement(PersonaliaSection.PersonaliaSection, {
71
+ key: block.id,
72
+ data: block
73
+ });
74
+ case "layout.picture-bar-section":
75
+ return /*#__PURE__*/React.createElement(PictureBarSection.PictureBarSection, {
76
+ key: block.id,
77
+ data: block
78
+ });
79
+ case "layout.logo-bar-section":
80
+ return /*#__PURE__*/React.createElement(LogoBarSection.LogoBarSection, {
81
+ key: block.id,
82
+ data: block
83
+ });
84
+ default:
85
+ return null;
86
+ }
87
+ }
88
+ function PageBuilder(_ref) {
89
+ let {
90
+ data
91
+ } = _ref;
92
+ const {
93
+ title,
94
+ description,
95
+ blocks,
96
+ sx
97
+ } = data;
98
+ if (!blocks) {
99
+ return /*#__PURE__*/React.createElement("p", null, "No sections found");
100
+ }
101
+ const [formState, formAction] = reactDom.useFormState(pagebuilderActions.updatePageAction, INITIAL_STATE);
102
+ return /*#__PURE__*/React.createElement(material.Box, {
103
+ sx: {
104
+ ...sx
105
+ }
106
+ }, /*#__PURE__*/React.createElement("form", {
107
+ action: formAction
108
+ }, /*#__PURE__*/React.createElement(material.Box, {
109
+ sx: {
110
+ width: "100%",
111
+ backgroundColor: "primary.dark",
112
+ p: 2
113
+ }
114
+ }, /*#__PURE__*/React.createElement(material.Button, {
115
+ variant: "contained",
116
+ color: "primary"
117
+ }, "Save")), /*#__PURE__*/React.createElement(material.Stack, {
118
+ spacing: 2,
119
+ sx: {
120
+ p: 2
121
+ }
122
+ }, /*#__PURE__*/React.createElement(material.TextField, {
123
+ id: "title",
124
+ name: "title",
125
+ value: title,
126
+ label: "title"
127
+ }), /*#__PURE__*/React.createElement(material.TextField, {
128
+ id: "description",
129
+ name: "description",
130
+ value: description,
131
+ label: "description"
132
+ })), blocks.map(blockRenderer)));
133
+ }
134
+
135
+ exports.default = PageBuilder;
@@ -14,6 +14,15 @@ var iconsMaterial = require('@mui/icons-material');
14
14
  var BlockRendererClient = require('./BlockRendererClient.js');
15
15
  var MuiLink = require('./MuiLink.js');
16
16
 
17
+ /* interface ImageProps {
18
+ id: string; // because the next Image ultimately requires a string
19
+ url: string;
20
+ alternativeText: string;
21
+ style: React.CSSProperties;
22
+ width: number;
23
+ height: number;
24
+ } */
25
+
17
26
  function needsShortening(data, maxLength) {
18
27
  let totalLength = 0;
19
28
  for (const paragraph of data) {
@@ -111,8 +120,8 @@ function PartnerDialog(_ref) {
111
120
  alignItems: "stretch"
112
121
  }, ((_partner$photo = partner.photo) === null || _partner$photo === void 0 ? void 0 : _partner$photo.url) && /*#__PURE__*/React.createElement(StrapiImage.StrapiImage, {
113
122
  id: partner.photo.id,
114
- src: partner.photo.url,
115
- alt: partner.photo.alternativeText,
123
+ url: partner.photo.url,
124
+ alternativeText: partner.photo.alternativeText,
116
125
  width: 200,
117
126
  height: 200,
118
127
  style: {
@@ -217,8 +226,8 @@ function Partner(partner, index) {
217
226
  alignItems: "stretch"
218
227
  }, ((_partner$photo2 = partner.photo) === null || _partner$photo2 === void 0 ? void 0 : _partner$photo2.url) && /*#__PURE__*/React.createElement(StrapiImage.StrapiImage, {
219
228
  id: partner.photo.id,
220
- src: partner.photo.url,
221
- alt: partner.photo.alternativeText,
229
+ url: partner.photo.url,
230
+ alternativeText: partner.photo.alternativeText,
222
231
  width: 200,
223
232
  height: 200,
224
233
  style: {
@@ -12,6 +12,15 @@ var material = require('@mui/material');
12
12
  var StrapiImage = require('./StrapiImage.js');
13
13
  var utils = require('../lib/utils.js');
14
14
 
15
+ /* interface ImageProps {
16
+ id: number;
17
+ url: string;
18
+ alternativeText: string;
19
+ style: React.CSSProperties;
20
+ width: number;
21
+ height: number;
22
+ } */
23
+
15
24
  function PictureBarSection(_ref) {
16
25
  let {
17
26
  data
@@ -56,8 +65,8 @@ function PictureBarSection(_ref) {
56
65
  }
57
66
  }, /*#__PURE__*/React.createElement(StrapiImage.StrapiImage, {
58
67
  id: picture.id.toString(),
59
- src: picture.url,
60
- alt: picture.alternativeText,
68
+ url: picture.url,
69
+ alternativeText: picture.alternativeText,
61
70
  width: picture.width,
62
71
  height: picture.height,
63
72
  style: {
@@ -61,10 +61,10 @@ function StickyImage(_ref) {
61
61
  }
62
62
  }, /*#__PURE__*/React.createElement(StrapiImage.StrapiImage, {
63
63
  id: "image".concat(image.url),
64
- alt: image.alternativeText,
64
+ alternativeText: image.alternativeText,
65
65
  height: image.height,
66
66
  width: image.width,
67
- src: image.url,
67
+ url: image.url,
68
68
  style: {
69
69
  width: "100%",
70
70
  height: "auto",
@@ -76,19 +76,6 @@ function StickyImage(_ref) {
76
76
  }
77
77
  }));
78
78
  }
79
-
80
- /*
81
- TODO intregrate this interface into StrapiImage.tsx
82
-
83
- interface ImageProps {
84
- id: number;
85
- url: string;
86
- alternativeText: string;
87
- style: React.CSSProperties;
88
- width: number;
89
- height: number;
90
- } */
91
-
92
79
  function TextImageSection(_ref2) {
93
80
  let {
94
81
  data
@@ -182,7 +182,13 @@ function SideNav(_ref) {
182
182
  }
183
183
  }, /*#__PURE__*/React__namespace.createElement(material.IconButton, {
184
184
  onClick: handleDrawerClose
185
- }, theme.direction === "rtl" ? /*#__PURE__*/React__namespace.createElement(iconsMaterial.ChevronRight, null) : /*#__PURE__*/React__namespace.createElement(iconsMaterial.ChevronLeft, null))), /*#__PURE__*/React__namespace.createElement(material.Divider, null), sections.map((section, index) => /*#__PURE__*/React__namespace.createElement(Link, {
185
+ }, theme.direction === "rtl" ? /*#__PURE__*/React__namespace.createElement(iconsMaterial.ChevronRight, null) : /*#__PURE__*/React__namespace.createElement(iconsMaterial.ChevronLeft, null))), /*#__PURE__*/React__namespace.createElement(material.Divider, null), sections.map((section, index) => /*#__PURE__*/React__namespace.createElement(material.Box, {
186
+ sx: {
187
+ display: "flex",
188
+ flexDirection: "column",
189
+ alignItems: "flex-start"
190
+ }
191
+ }, /*#__PURE__*/React__namespace.createElement(Link, {
186
192
  key: index,
187
193
  href: section.link,
188
194
  passHref: true
@@ -194,11 +200,30 @@ function SideNav(_ref) {
194
200
  p: 1,
195
201
  cursor: "pointer"
196
202
  }
197
- }, section.icon, open && /*#__PURE__*/React__namespace.createElement(material.Typography, {
203
+ }, section.icon, !open && section.subSections && /*#__PURE__*/React__namespace.createElement(material.Typography, null, "..."), open && /*#__PURE__*/React__namespace.createElement(material.Typography, {
198
204
  sx: {
199
205
  pl: 2
200
206
  }
201
- }, section.title))))), /*#__PURE__*/React__namespace.createElement(material.Box, {
207
+ }, section.title))), section.subSections && open && section.subSections.map((subSection, index) => {
208
+ return /*#__PURE__*/React__namespace.createElement(Link, {
209
+ key: index,
210
+ href: subSection.link,
211
+ passHref: true
212
+ }, /*#__PURE__*/React__namespace.createElement(material.Box, {
213
+ sx: {
214
+ display: "flex",
215
+ alignItems: "center",
216
+ justifyContent: "center",
217
+ p: 1,
218
+ cursor: "pointer"
219
+ }
220
+ }, /*#__PURE__*/React__namespace.createElement(material.Typography, {
221
+ variant: "body2",
222
+ sx: {
223
+ pl: 4
224
+ }
225
+ }, subSection.title)));
226
+ })))), /*#__PURE__*/React__namespace.createElement(material.Box, {
202
227
  component: "main",
203
228
  sx: {
204
229
  flexGrow: 1,
@@ -0,0 +1,150 @@
1
+ "use client";
2
+ /*
3
+ * UMWD-Components
4
+ * @copyright Jelle Paulus
5
+ * @license MIT
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var React = require('react');
11
+ var material = require('@mui/material');
12
+ var StrapiImage = require('../StrapiImage.js');
13
+ var utils = require('../../lib/utils.js');
14
+
15
+ function StickyImage(_ref) {
16
+ let {
17
+ image
18
+ } = _ref;
19
+ const theme = material.useTheme();
20
+ const imageSrc = image.url;
21
+ if (imageSrc === undefined) {
22
+ return null;
23
+ }
24
+ const [offsetY, setOffsetY] = React.useState(0);
25
+ const handleScroll = () => {
26
+ const offset = 160;
27
+ const imageDivID = "image-container".concat(image.url);
28
+ const imageDiv = document.getElementById(imageDivID);
29
+ const imageID = "image".concat(image.url);
30
+ const imageElement = document.getElementById(imageID);
31
+ if (imageDiv === null || imageElement === null) {
32
+ return;
33
+ }
34
+ const imageDivRect = imageDiv.getBoundingClientRect();
35
+ const imageRect = imageElement.getBoundingClientRect();
36
+ if (imageRect.height >= imageDivRect.height) {
37
+ return;
38
+ }
39
+ const imageAtBottomOffset = imageDivRect.height - imageRect.height;
40
+ if (imageDivRect.y <= offset && -imageDivRect.y <= imageDivRect.height - imageRect.height - offset) {
41
+ setOffsetY(-imageDivRect.y + offset);
42
+ } else if (imageDivRect.y > 0) {
43
+ setOffsetY(0);
44
+ } else {
45
+ setOffsetY(imageAtBottomOffset);
46
+ }
47
+ };
48
+ React.useEffect(() => {
49
+ window.addEventListener("scroll", handleScroll);
50
+ return () => window.removeEventListener("scroll", handleScroll);
51
+ }, []); // Empty dependency array to run effect only once
52
+
53
+ return /*#__PURE__*/React.createElement(material.Box, {
54
+ id: "image-container".concat(image.url),
55
+ sx: {
56
+ height: "100%",
57
+ position: "relative"
58
+ }
59
+ }, /*#__PURE__*/React.createElement(StrapiImage.StrapiImage, {
60
+ id: "image".concat(image.url),
61
+ alternativeText: image.alternativeText,
62
+ height: image.height,
63
+ width: image.width,
64
+ url: image.url,
65
+ style: {
66
+ width: "100%",
67
+ height: "auto",
68
+ display: "block",
69
+ position: "relative",
70
+ top: offsetY,
71
+ borderRadius: 4,
72
+ border: "1px solid ".concat(theme.palette.secondary.main)
73
+ }
74
+ }));
75
+ }
76
+ function PBTextImageSection(_ref2) {
77
+ let {
78
+ data
79
+ } = _ref2;
80
+ const {
81
+ title,
82
+ text,
83
+ image,
84
+ reverse = false,
85
+ maxWidth,
86
+ sx = {},
87
+ glass = false,
88
+ anchor = ""
89
+ } = data;
90
+
91
+ /* TODO Text_content should deal with linebreaks,
92
+ reading up upon mui-markdown docs is advised */
93
+
94
+ /* TODO Replace with blocks */
95
+
96
+ const theme = material.useTheme();
97
+ return /*#__PURE__*/React.createElement(material.Container, {
98
+ maxWidth: maxWidth ? maxWidth : "lg",
99
+ sx: {
100
+ my: 1,
101
+ ...sx
102
+ },
103
+ id: anchor
104
+ }, title && /*#__PURE__*/React.createElement(material.Typography, {
105
+ variant: "h1",
106
+ textAlign: "center",
107
+ sx: {
108
+ pb: 2
109
+ }
110
+ }, title), /*#__PURE__*/React.createElement(material.Grid, {
111
+ container: true,
112
+ spacing: 2,
113
+ direction: reverse ? "row-reverse" : "row"
114
+ }, /*#__PURE__*/React.createElement(material.Grid, {
115
+ item: true,
116
+ xs: 12,
117
+ md: (image === null || image === void 0 ? void 0 : image.url) !== undefined ? 8 : 12
118
+ }, /*#__PURE__*/React.createElement(material.Paper, {
119
+ sx: {
120
+ p: 2,
121
+ backdropFilter: "blur(3px)",
122
+ backgroundColor: utils.setOpacity(theme.palette.background.paper, glass ? 0.1 : 1),
123
+ border: glass ? "1px solid rgba(255, 255, 255, 0.15)" : "none"
124
+ }
125
+ }, text !== null && text !== undefined && /*#__PURE__*/React.createElement(material.Box, {
126
+ sx: {
127
+ height: "100%",
128
+ overflow: "hidden",
129
+ display: "flex",
130
+ alignItems: "center",
131
+ justifyContent: "flex-start"
132
+ }
133
+ }, /*#__PURE__*/React.createElement(material.TextField, {
134
+ multiline: true,
135
+ placeholder: text,
136
+ value: text,
137
+ onChange: e => console.log(e.target.value),
138
+ sx: {
139
+ width: "100%"
140
+ }
141
+ })))), (image === null || image === void 0 ? void 0 : image.url) !== undefined && /*#__PURE__*/React.createElement(material.Grid, {
142
+ item: true,
143
+ xs: 12,
144
+ md: 4
145
+ }, /*#__PURE__*/React.createElement(StickyImage, {
146
+ image: image
147
+ }))));
148
+ }
149
+
150
+ exports.PBTextImageSection = PBTextImageSection;
@@ -0,0 +1,197 @@
1
+ "use server";
2
+ /*
3
+ * UMWD-Components
4
+ * @copyright Jelle Paulus
5
+ * @license MIT
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var zod = require('zod');
11
+ var pagebuilderService = require('../services/pagebuilder-service.js');
12
+
13
+ var _process$env$HOST;
14
+ ({
15
+ maxAge: 60 * 60 * 24 * 7,
16
+ // 1 week
17
+ path: "/",
18
+ domain: (_process$env$HOST = process.env.HOST) !== null && _process$env$HOST !== void 0 ? _process$env$HOST : "localhost",
19
+ httpOnly: true,
20
+ secure: process.env.NODE_ENV === "production"
21
+ });
22
+ const schemaUpdate = zod.z.object({
23
+ id: zod.z.string(),
24
+ title: zod.z.string().min(3).max(100, {
25
+ message: "Title must be between 3 and 100 characters"
26
+ }),
27
+ description: zod.z.string().min(3).max(200, {
28
+ message: "Description must be between 3 and 200 characters"
29
+ })
30
+ /* blocks: z.array(
31
+ z.object({
32
+ id: z.string(),
33
+ type: z.string(),
34
+ data: z.object({
35
+ text: z.string().min(3).max(200, {
36
+ message: "Text must be between 3 and 200 characters",
37
+ }),
38
+ }),
39
+ })
40
+ ), */
41
+ });
42
+ async function updatePageAction(prevState, FormData) {
43
+ const validatedFields = schemaUpdate.safeParse({
44
+ id: FormData.get("id"),
45
+ title: FormData.get("title"),
46
+ description: FormData.get("description")
47
+ // blocks: FormData.get("blocks"),
48
+ });
49
+ if (!validatedFields.success) {
50
+ return {
51
+ ...prevState,
52
+ zodErrors: validatedFields.error.flatten().fieldErrors,
53
+ strapiErrors: null,
54
+ message: "Missing Fields. Failed to Update Page."
55
+ };
56
+ }
57
+ const responseData = await pagebuilderService.updatePageService(validatedFields.data);
58
+ if (!responseData) {
59
+ return {
60
+ ...prevState,
61
+ strapiErrors: null,
62
+ zodErrors: null,
63
+ message: "Ops! Something went wrong. Please try again."
64
+ };
65
+ }
66
+ if (responseData.error) {
67
+ return {
68
+ ...prevState,
69
+ strapiErrors: responseData.error,
70
+ zodErrors: null,
71
+ message: "Failed to Update Page."
72
+ };
73
+ }
74
+ return {
75
+ ...prevState,
76
+ strapiErrors: null,
77
+ zodErrors: null,
78
+ message: "Page Updated Successfully."
79
+ };
80
+ }
81
+
82
+ /* const schemaRegister = z.object({
83
+ username: z.string().min(3).max(20, {
84
+ message: "Username must be between 3 and 20 characters",
85
+ }),
86
+ password: z.string().min(6).max(100, {
87
+ message: "Password must be between 6 and 100 characters",
88
+ }),
89
+ email: z.string().email({
90
+ message: "Please enter a valid email address",
91
+ }),
92
+ });
93
+
94
+ export async function registerUserAction(prevState: any, formData: FormData) {
95
+ const validatedFields = schemaRegister.safeParse({
96
+ username: formData.get("username"),
97
+ password: formData.get("password"),
98
+ email: formData.get("email"),
99
+ });
100
+
101
+ if (!validatedFields.success) {
102
+ return {
103
+ ...prevState,
104
+ zodErrors: validatedFields.error.flatten().fieldErrors,
105
+ strapiErrors: null,
106
+ message: "Missing Fields. Failed to Register.",
107
+ };
108
+ }
109
+
110
+ const responseData = await registerUserService(validatedFields.data);
111
+
112
+ if (!responseData) {
113
+ return {
114
+ ...prevState,
115
+ strapiErrors: null,
116
+ zodErrors: null,
117
+ message: "Ops! Something went wrong. Please try again.",
118
+ };
119
+ }
120
+
121
+ if (responseData.error) {
122
+ return {
123
+ ...prevState,
124
+ strapiErrors: responseData.error,
125
+ zodErrors: null,
126
+ message: "Failed to Register.",
127
+ };
128
+ }
129
+
130
+ cookies().set("jwt", responseData.jwt, config);
131
+ redirect("/dashboard");
132
+ }
133
+
134
+ const schemaLogin = z.object({
135
+ identifier: z
136
+ .string()
137
+ .min(3, {
138
+ message: "Identifier must have at least 3 or more characters",
139
+ })
140
+ .max(20, {
141
+ message: "Please enter a valid username or email address",
142
+ }),
143
+ password: z
144
+ .string()
145
+ .min(6, {
146
+ message: "Password must have at least 6 or more characters",
147
+ })
148
+ .max(100, {
149
+ message: "Password must be between 6 and 100 characters",
150
+ }),
151
+ });
152
+
153
+ export async function loginUserAction(prevState: any, formData: FormData) {
154
+ const validatedFields = schemaLogin.safeParse({
155
+ identifier: formData.get("identifier"),
156
+ password: formData.get("password"),
157
+ });
158
+
159
+ if (!validatedFields.success) {
160
+ return {
161
+ ...prevState,
162
+ zodErrors: validatedFields.error.flatten().fieldErrors,
163
+ message: "Missing Fields. Failed to Login.",
164
+ };
165
+ }
166
+
167
+ const responseData = await loginUserService(validatedFields.data);
168
+
169
+ if (!responseData) {
170
+ return {
171
+ ...prevState,
172
+ strapiErrors: responseData.error,
173
+ zodErrors: null,
174
+ message: "Ops! Something went wrong. Please try again.",
175
+ };
176
+ }
177
+
178
+ if (responseData.error) {
179
+ return {
180
+ ...prevState,
181
+ strapiErrors: responseData.error,
182
+ zodErrors: null,
183
+ message: "Failed to Login.",
184
+ };
185
+ }
186
+
187
+ cookies().set("jwt", responseData.jwt, config);
188
+
189
+ redirect("/dashboard");
190
+ }
191
+
192
+ export async function logoutAction() {
193
+ cookies().set("jwt", "", { ...config, maxAge: 0 });
194
+ redirect("/");
195
+ } */
196
+
197
+ exports.updatePageAction = updatePageAction;
@@ -0,0 +1,32 @@
1
+ /*
2
+ * UMWD-Components
3
+ * @copyright Jelle Paulus
4
+ * @license MIT
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ var utils = require('../../lib/utils.js');
10
+
11
+ const baseUrl = utils.getStrapiURL();
12
+ async function updatePageService(pageData) {
13
+ const url = new URL("/api/pages/".concat(pageData.id), baseUrl);
14
+ try {
15
+ const response = await fetch(url, {
16
+ method: "POST",
17
+ headers: {
18
+ "Content-Type": "application/json"
19
+ // Add the jwt bearer token here
20
+ },
21
+ body: JSON.stringify({
22
+ ...pageData
23
+ }),
24
+ cache: "no-cache"
25
+ });
26
+ return response.json();
27
+ } catch (error) {
28
+ console.error("Page Builder Error:", error);
29
+ }
30
+ }
31
+
32
+ exports.updatePageService = updatePageService;
package/dist/cjs/index.js CHANGED
@@ -23,6 +23,7 @@ var RegisterForm = require('./components/forms/RegisterForm.js');
23
23
  var SigninForm = require('./components/forms/SigninForm.js');
24
24
  var SideNav = require('./components/dashboard/SideNav.js');
25
25
  var LogoutButton = require('./components/LogoutButton.js');
26
+ var PageBuilder = require('./components/PageBuilder.js');
26
27
 
27
28
 
28
29
 
@@ -43,3 +44,4 @@ exports.RegisterForm = RegisterForm.default;
43
44
  exports.SigninForm = SigninForm.default;
44
45
  exports.SideNav = SideNav.default;
45
46
  exports.LogoutButton = LogoutButton.default;
47
+ exports.PageBuilder = PageBuilder.default;