umwd-components 0.1.310 → 0.1.312
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/dist/src/components/common/Address.js +1 -1
- package/dist/src/components/e-commerce/customer/CustomerProfileDisplay.js +1 -1
- package/dist/src/components/e-commerce/customer/DenseCustomerProfileDisplay.js +1 -1
- package/dist/src/components/layout/SideNav.js +1 -1
- package/dist/src/data/actions/profile-actions.js +1 -1
- package/dist/src/data/loaders.js +2 -1
- package/dist/src/data/services/pagebuilder-service.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/common/Address.d.ts +1 -5
- package/dist/types/components/e-commerce/customer/BusinessCredentials.d.ts +1 -6
- package/dist/types/components/public-information/PublicInformationForm.d.ts +5 -0
- package/dist/types/data/actions/pagebuilder-actions.d.ts +6 -6
- package/dist/types/data/actions/public-information/updatePublicInformationAction.d.ts +1 -0
- package/dist/types/data/loaders/public-information/getPublicInformation.d.ts +1 -0
- package/dist/types/types/AddressProps.d.ts +5 -1
- package/dist/types/types/e-commerce/BusinessCredentialsProps.d.ts +5 -0
- package/dist/types/types/public-information/types.d.ts +20 -0
- package/package.json +1 -1
- package/src/components/common/Address.tsx +6 -8
- package/src/components/e-commerce/customer/BusinessCredentials.tsx +3 -6
- package/src/components/e-commerce/customer/CustomerProfileDisplay.tsx +6 -9
- package/src/components/e-commerce/customer/DenseCustomerProfileDisplay.tsx +6 -5
- package/src/components/layout/SideNav.tsx +1 -1
- package/src/components/public-information/PublicInformationForm.tsx +175 -0
- package/src/data/actions/profile-actions.ts +1 -1
- package/src/data/actions/public-information/updatePublicInformationAction.ts +51 -0
- package/src/data/loaders/public-information/getPublicInformation.ts +23 -0
- package/src/data/loaders.ts +8 -6
- package/src/data/services/pagebuilder-service.ts +1 -1
- package/src/types/AddressProps.tsx +7 -1
- package/src/types/e-commerce/BusinessCredentialsProps.tsx +6 -0
- package/src/types/public-information/types.tsx +22 -0
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { AddressProps } from "@/types/AddressProps";
|
|
2
2
|
import React from "react";
|
|
3
|
-
|
|
4
|
-
data?: AddressProps;
|
|
5
|
-
componentName: string;
|
|
6
|
-
componentReference: string;
|
|
7
|
-
}
|
|
3
|
+
import { AddressFieldsProps } from "@/types/AddressProps";
|
|
8
4
|
export default function Address({ data }: {
|
|
9
5
|
readonly data: AddressProps;
|
|
10
6
|
}): React.JSX.Element;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { BusinessCredentialsProps } from "../../../types/e-commerce/BusinessCredentialsProps";
|
|
2
|
+
import { BusinessCredentialsFieldsProps } from "../../../types/e-commerce/BusinessCredentialsProps";
|
|
2
3
|
import React from "react";
|
|
3
4
|
export default function BusinessCredentials({ data, }: {
|
|
4
5
|
readonly data: BusinessCredentialsProps;
|
|
5
6
|
}): React.JSX.Element;
|
|
6
|
-
interface BusinessCredentialsFieldsProps {
|
|
7
|
-
data: BusinessCredentialsProps;
|
|
8
|
-
componentName: string;
|
|
9
|
-
componentReference: string;
|
|
10
|
-
}
|
|
11
7
|
export declare function BusinessCredentialsFields({ data, componentName, componentReference, }: BusinessCredentialsFieldsProps): React.JSX.Element;
|
|
12
|
-
export {};
|
|
@@ -36,11 +36,11 @@ declare const schemaUpdate: z.ZodObject<{
|
|
|
36
36
|
}, "strip", z.ZodTypeAny, {
|
|
37
37
|
id: string;
|
|
38
38
|
__component: string;
|
|
39
|
-
title?: string | undefined;
|
|
40
39
|
link?: {
|
|
41
40
|
text?: string | undefined;
|
|
42
41
|
url?: string | undefined;
|
|
43
42
|
} | undefined;
|
|
43
|
+
title?: string | undefined;
|
|
44
44
|
heading?: string | undefined;
|
|
45
45
|
subHeading?: string | undefined;
|
|
46
46
|
subtitle?: string | undefined;
|
|
@@ -52,11 +52,11 @@ declare const schemaUpdate: z.ZodObject<{
|
|
|
52
52
|
}, {
|
|
53
53
|
id: string;
|
|
54
54
|
__component: string;
|
|
55
|
-
title?: string | undefined;
|
|
56
55
|
link?: {
|
|
57
56
|
text?: string | undefined;
|
|
58
57
|
url?: string | undefined;
|
|
59
58
|
} | undefined;
|
|
59
|
+
title?: string | undefined;
|
|
60
60
|
heading?: string | undefined;
|
|
61
61
|
subHeading?: string | undefined;
|
|
62
62
|
subtitle?: string | undefined;
|
|
@@ -67,17 +67,17 @@ declare const schemaUpdate: z.ZodObject<{
|
|
|
67
67
|
} | undefined;
|
|
68
68
|
}>, "many">>;
|
|
69
69
|
}, "strip", z.ZodTypeAny, {
|
|
70
|
-
title: string;
|
|
71
70
|
id: string;
|
|
71
|
+
title: string;
|
|
72
72
|
description: string;
|
|
73
73
|
blocks?: {
|
|
74
74
|
id: string;
|
|
75
75
|
__component: string;
|
|
76
|
-
title?: string | undefined;
|
|
77
76
|
link?: {
|
|
78
77
|
text?: string | undefined;
|
|
79
78
|
url?: string | undefined;
|
|
80
79
|
} | undefined;
|
|
80
|
+
title?: string | undefined;
|
|
81
81
|
heading?: string | undefined;
|
|
82
82
|
subHeading?: string | undefined;
|
|
83
83
|
subtitle?: string | undefined;
|
|
@@ -88,17 +88,17 @@ declare const schemaUpdate: z.ZodObject<{
|
|
|
88
88
|
} | undefined;
|
|
89
89
|
}[] | undefined;
|
|
90
90
|
}, {
|
|
91
|
-
title: string;
|
|
92
91
|
id: string;
|
|
92
|
+
title: string;
|
|
93
93
|
description: string;
|
|
94
94
|
blocks?: {
|
|
95
95
|
id: string;
|
|
96
96
|
__component: string;
|
|
97
|
-
title?: string | undefined;
|
|
98
97
|
link?: {
|
|
99
98
|
text?: string | undefined;
|
|
100
99
|
url?: string | undefined;
|
|
101
100
|
} | undefined;
|
|
101
|
+
title?: string | undefined;
|
|
102
102
|
heading?: string | undefined;
|
|
103
103
|
subHeading?: string | undefined;
|
|
104
104
|
subtitle?: string | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function updatePublicInformationAction(prevState: any, formData: FormData): Promise<any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPublicInformation(): Promise<any>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AddressProps } from "@/types/AddressProps";
|
|
2
|
+
import { BusinessCredentialsProps } from "@/types/e-commerce/BusinessCredentialsProps";
|
|
3
|
+
export interface PublicInformationFormProps {
|
|
4
|
+
publicInformation: PublicInformation;
|
|
5
|
+
}
|
|
6
|
+
export type PublicInformation = {
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
disclaimer_link: string;
|
|
11
|
+
privacypolicy_link: string;
|
|
12
|
+
maxWidth: string;
|
|
13
|
+
email: string;
|
|
14
|
+
phone_number: string;
|
|
15
|
+
business_credentials: BusinessCredentialsProps;
|
|
16
|
+
address: AddressProps;
|
|
17
|
+
socials: string;
|
|
18
|
+
header_logo: string;
|
|
19
|
+
footer_logo: string;
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -4,16 +4,14 @@ import Typography from "@mui/material/Typography";
|
|
|
4
4
|
import HomeIcon from "@mui/icons-material/Home";
|
|
5
5
|
import { AddressProps } from "@/types/AddressProps";
|
|
6
6
|
import React from "react";
|
|
7
|
+
import { AddressFieldsProps } from "@/types/AddressProps";
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
componentReference: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
9
|
+
// TODO: This is not the place for title, first of all it should be optional,
|
|
10
|
+
// second it's not on the address entity
|
|
11
|
+
// third it should be outside of the address display component inside of the actual form
|
|
14
12
|
export default function Address({ data }: { readonly data: AddressProps }) {
|
|
15
13
|
const {
|
|
16
|
-
title,
|
|
14
|
+
/* title, */
|
|
17
15
|
id,
|
|
18
16
|
street,
|
|
19
17
|
street_number,
|
|
@@ -27,7 +25,7 @@ export default function Address({ data }: { readonly data: AddressProps }) {
|
|
|
27
25
|
<Stack spacing={2} direction="row">
|
|
28
26
|
<HomeIcon />
|
|
29
27
|
<Stack>
|
|
30
|
-
<Typography variant="h6">{title}</Typography>
|
|
28
|
+
{/* <Typography variant="h6">{title}</Typography> */}
|
|
31
29
|
<Typography variant="body1" component="p">
|
|
32
30
|
{street} {street_number} {street_number_addition}
|
|
33
31
|
</Typography>
|
|
@@ -5,8 +5,11 @@ import TextField from "@mui/material/TextField";
|
|
|
5
5
|
|
|
6
6
|
import BusinessCenterIcon from "@mui/icons-material/BusinessCenter";
|
|
7
7
|
import { BusinessCredentialsProps } from "../../../types/e-commerce/BusinessCredentialsProps";
|
|
8
|
+
import { BusinessCredentialsFieldsProps } from "../../../types/e-commerce/BusinessCredentialsProps";
|
|
8
9
|
import React from "react";
|
|
9
10
|
|
|
11
|
+
// TODO Move this to common
|
|
12
|
+
|
|
10
13
|
export default function BusinessCredentials({
|
|
11
14
|
data,
|
|
12
15
|
}: {
|
|
@@ -35,12 +38,6 @@ export default function BusinessCredentials({
|
|
|
35
38
|
);
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
interface BusinessCredentialsFieldsProps {
|
|
39
|
-
data: BusinessCredentialsProps;
|
|
40
|
-
componentName: string;
|
|
41
|
-
componentReference: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
41
|
export function BusinessCredentialsFields({
|
|
45
42
|
data,
|
|
46
43
|
componentName,
|
|
@@ -90,18 +90,16 @@ export default function CustomerProfileDisplay({
|
|
|
90
90
|
<Grid container>
|
|
91
91
|
{company_address ? (
|
|
92
92
|
<Grid item xs={12} md={4}>
|
|
93
|
-
<Address
|
|
94
|
-
|
|
95
|
-
/>
|
|
93
|
+
<Typography variant="h6">Company Address</Typography>
|
|
94
|
+
<Address data={{ ...company_address }} />
|
|
96
95
|
</Grid>
|
|
97
96
|
) : (
|
|
98
97
|
<Typography>Company address not available</Typography>
|
|
99
98
|
)}
|
|
100
99
|
{delivery_address ? (
|
|
101
100
|
<Grid item xs={12} md={4}>
|
|
102
|
-
<Address
|
|
103
|
-
|
|
104
|
-
/>
|
|
101
|
+
<Typography variant="h6">Delivery Address</Typography>
|
|
102
|
+
<Address data={{ ...delivery_address }} />
|
|
105
103
|
</Grid>
|
|
106
104
|
) : (
|
|
107
105
|
<Grid item xs={12} md={4}>
|
|
@@ -110,9 +108,8 @@ export default function CustomerProfileDisplay({
|
|
|
110
108
|
)}
|
|
111
109
|
{billing_address ? (
|
|
112
110
|
<Grid item xs={12} md={4}>
|
|
113
|
-
<Address
|
|
114
|
-
|
|
115
|
-
/>
|
|
111
|
+
<Typography variant="h6">Billing Address</Typography>
|
|
112
|
+
<Address data={{ ...billing_address }} />
|
|
116
113
|
</Grid>
|
|
117
114
|
) : (
|
|
118
115
|
<Grid item xs={12} md={4}>
|
|
@@ -66,16 +66,16 @@ export default function CustomerProfileDisplay({
|
|
|
66
66
|
<Grid container>
|
|
67
67
|
{company_address ? (
|
|
68
68
|
<Grid item xs={12} md={4}>
|
|
69
|
-
<
|
|
69
|
+
<Typography variant="h6">Company Address</Typography>
|
|
70
|
+
<Address data={{ ...company_address }} />
|
|
70
71
|
</Grid>
|
|
71
72
|
) : (
|
|
72
73
|
<Typography>Company address not available</Typography>
|
|
73
74
|
)}
|
|
74
75
|
{delivery_address ? (
|
|
75
76
|
<Grid item xs={12} md={4}>
|
|
76
|
-
<Address
|
|
77
|
-
|
|
78
|
-
/>
|
|
77
|
+
<Typography variant="h6">Delivery Address</Typography>
|
|
78
|
+
<Address data={{ ...delivery_address }} />
|
|
79
79
|
</Grid>
|
|
80
80
|
) : (
|
|
81
81
|
<Grid item xs={12} md={4}>
|
|
@@ -84,7 +84,8 @@ export default function CustomerProfileDisplay({
|
|
|
84
84
|
)}
|
|
85
85
|
{billing_address ? (
|
|
86
86
|
<Grid item xs={12} md={4}>
|
|
87
|
-
<
|
|
87
|
+
<Typography variant="h6">Billing Address</Typography>
|
|
88
|
+
<Address data={{ ...billing_address }} />
|
|
88
89
|
</Grid>
|
|
89
90
|
) : (
|
|
90
91
|
<Grid item xs={12} md={4}>
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Divider from "@mui/material/Divider";
|
|
4
|
+
import Paper from "@mui/material/Paper";
|
|
5
|
+
import Box from "@mui/material/Box";
|
|
6
|
+
import Stack from "@mui/material/Stack";
|
|
7
|
+
import Alert from "@mui/material/Alert";
|
|
8
|
+
import TextField from "@mui/material/TextField";
|
|
9
|
+
import Typography from "@mui/material/Typography";
|
|
10
|
+
import { SubmitButton } from "../SubmitButton";
|
|
11
|
+
import { useFormState } from "react-dom";
|
|
12
|
+
import { StrapiErrors } from "../StrapiErrors"; //"@/components/StrapiErrors";
|
|
13
|
+
import { BusinessCredentialsFields } from "../e-commerce/customer/BusinessCredentials";
|
|
14
|
+
import { useSession } from "../../context/auth/SessionContext";
|
|
15
|
+
import React, { useEffect } from "react";
|
|
16
|
+
import { AddressFields } from "../common/Address";
|
|
17
|
+
import {
|
|
18
|
+
PublicInformation,
|
|
19
|
+
PublicInformationFormProps,
|
|
20
|
+
} from "../../types/public-information/types";
|
|
21
|
+
import { updatePublicInformationAction } from "../../data/actions/public-information/updatePublicInformationAction";
|
|
22
|
+
|
|
23
|
+
const INITIAL_STATE = {
|
|
24
|
+
zodErrors: null,
|
|
25
|
+
strapiErrors: null,
|
|
26
|
+
data: null,
|
|
27
|
+
message: null,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function PublicInformationForm({
|
|
31
|
+
publicInformation,
|
|
32
|
+
}: {
|
|
33
|
+
readonly publicInformation: PublicInformation;
|
|
34
|
+
}) {
|
|
35
|
+
console.log(publicInformation);
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
id,
|
|
39
|
+
title,
|
|
40
|
+
description,
|
|
41
|
+
disclaimer_link,
|
|
42
|
+
privacypolicy_link,
|
|
43
|
+
maxWidth,
|
|
44
|
+
email,
|
|
45
|
+
phone_number,
|
|
46
|
+
business_credentials,
|
|
47
|
+
address,
|
|
48
|
+
socials,
|
|
49
|
+
header_logo,
|
|
50
|
+
footer_logo,
|
|
51
|
+
} = publicInformation;
|
|
52
|
+
|
|
53
|
+
const [formState, formAction] = useFormState(
|
|
54
|
+
updatePublicInformationAction,
|
|
55
|
+
INITIAL_STATE
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// TODO useSession doesn't work, this should most definetively be implemented!!
|
|
59
|
+
// const { refreshSession } = useSession();
|
|
60
|
+
//
|
|
61
|
+
// useEffect(() => {
|
|
62
|
+
// if (!formState.strapiErrors && formState.message) {
|
|
63
|
+
// refreshSession();
|
|
64
|
+
// }
|
|
65
|
+
// }, [formState]);
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Box
|
|
69
|
+
/* sx={[
|
|
70
|
+
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
71
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
72
|
+
]} */
|
|
73
|
+
component={Paper}
|
|
74
|
+
sx={{ p: 2 }}
|
|
75
|
+
>
|
|
76
|
+
<form action={formAction}>
|
|
77
|
+
<Stack spacing={2}>
|
|
78
|
+
<Stack
|
|
79
|
+
direction="row-reverse"
|
|
80
|
+
spacing={2}
|
|
81
|
+
alignItems={"center"}
|
|
82
|
+
sx={{
|
|
83
|
+
backgroundColor: "secondary.dark",
|
|
84
|
+
px: 2,
|
|
85
|
+
py: 1,
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<SubmitButton
|
|
89
|
+
text="save changes"
|
|
90
|
+
loadingText="loading"
|
|
91
|
+
sx={{ color: "secondary.contrastText" }}
|
|
92
|
+
/>
|
|
93
|
+
<StrapiErrors error={formState?.strapiErrors} />
|
|
94
|
+
|
|
95
|
+
{formState?.message && (
|
|
96
|
+
<Alert severity="error">{formState?.message}</Alert>
|
|
97
|
+
)}
|
|
98
|
+
</Stack>
|
|
99
|
+
<TextField
|
|
100
|
+
id="title"
|
|
101
|
+
name="title"
|
|
102
|
+
label="Title"
|
|
103
|
+
defaultValue={title}
|
|
104
|
+
// error={}
|
|
105
|
+
// helperText={}
|
|
106
|
+
></TextField>
|
|
107
|
+
<TextField
|
|
108
|
+
id="description"
|
|
109
|
+
name="description"
|
|
110
|
+
label="Description"
|
|
111
|
+
defaultValue={description}
|
|
112
|
+
// error={}
|
|
113
|
+
// helperText={}
|
|
114
|
+
></TextField>
|
|
115
|
+
<TextField
|
|
116
|
+
id="email"
|
|
117
|
+
name="email"
|
|
118
|
+
label="email"
|
|
119
|
+
defaultValue={email}
|
|
120
|
+
// error={}
|
|
121
|
+
// helperText={}
|
|
122
|
+
></TextField>
|
|
123
|
+
<TextField
|
|
124
|
+
id="phone_number"
|
|
125
|
+
name="phone_number"
|
|
126
|
+
label="phone_number"
|
|
127
|
+
defaultValue={phone_number}
|
|
128
|
+
// error={}
|
|
129
|
+
// helperText={}
|
|
130
|
+
></TextField>
|
|
131
|
+
{/*
|
|
132
|
+
TODO Create public_documents / links component
|
|
133
|
+
<TextField
|
|
134
|
+
id="disclaimer_link"
|
|
135
|
+
name="disclaimer_link"
|
|
136
|
+
label="disclaimer_link"
|
|
137
|
+
defaultValue={disclaimer_link}
|
|
138
|
+
// error={}
|
|
139
|
+
// helperText={}
|
|
140
|
+
></TextField>
|
|
141
|
+
<TextField
|
|
142
|
+
id="privacypolicy_link"
|
|
143
|
+
name="privacypolicy_link"
|
|
144
|
+
label="privacypolicy_link"
|
|
145
|
+
defaultValue={privacypolicy_link}
|
|
146
|
+
// error={}
|
|
147
|
+
// helperText={}
|
|
148
|
+
></TextField> */}
|
|
149
|
+
<Typography variant="h6">Company Address</Typography>
|
|
150
|
+
<Divider />
|
|
151
|
+
<AddressFields
|
|
152
|
+
componentName="address"
|
|
153
|
+
componentReference="common.address"
|
|
154
|
+
data={address}
|
|
155
|
+
/>
|
|
156
|
+
<Divider />
|
|
157
|
+
<Typography variant="h6">Business Credentials</Typography>
|
|
158
|
+
<BusinessCredentialsFields
|
|
159
|
+
componentName="business_credentials"
|
|
160
|
+
componentReference="business.credentials"
|
|
161
|
+
data={business_credentials}
|
|
162
|
+
/>
|
|
163
|
+
{/*links component field <p>{publicInformation.socials}</p> */}
|
|
164
|
+
</Stack>
|
|
165
|
+
</form>
|
|
166
|
+
</Box>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/*
|
|
171
|
+
TODO, move to site-settings
|
|
172
|
+
<p>{publicInformation.maxWidth}</p>
|
|
173
|
+
<p>{publicInformation.header_logo}</p>
|
|
174
|
+
<p>{publicInformation.footer_logo}</p>
|
|
175
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use server"; // "use client"; this should be use server but while developing it's easier to use client to do console.log
|
|
2
2
|
|
|
3
3
|
import { mutateData } from "../services/mutate-data";
|
|
4
4
|
import { flattenAttributes } from "../../lib/utils";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client"; // TODO: this should be use server but while developing it's easier to use client to do console.log
|
|
2
|
+
|
|
3
|
+
import { mutateData } from "../../services/mutate-data";
|
|
4
|
+
import { flattenAttributes } from "../../../lib/utils";
|
|
5
|
+
import { parseFormData } from "../../../lib/parseFormData";
|
|
6
|
+
|
|
7
|
+
// TODO Not tested or finished
|
|
8
|
+
|
|
9
|
+
export async function updatePublicInformationAction(
|
|
10
|
+
prevState: any,
|
|
11
|
+
formData: FormData
|
|
12
|
+
) {
|
|
13
|
+
const rawFormData = Object.fromEntries(formData);
|
|
14
|
+
console.log("rawFormData", rawFormData);
|
|
15
|
+
|
|
16
|
+
const parsedFormData = parseFormData(formData); // ?? can i still use this or is it only for the pagebuilder form?
|
|
17
|
+
console.log("parsedFormData", parsedFormData);
|
|
18
|
+
|
|
19
|
+
const id = rawFormData.id;
|
|
20
|
+
|
|
21
|
+
const responseData = await mutateData(
|
|
22
|
+
"PUT",
|
|
23
|
+
`/api/public-information`,
|
|
24
|
+
parsedFormData
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
if (!responseData) {
|
|
28
|
+
return {
|
|
29
|
+
...prevState,
|
|
30
|
+
strapiErrors: null,
|
|
31
|
+
message: "Ops! Something went wrong. Please try again.",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (responseData.error) {
|
|
36
|
+
return {
|
|
37
|
+
...prevState,
|
|
38
|
+
strapiErrors: responseData.error,
|
|
39
|
+
message: "Failed to Register.",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const flattenedData = flattenAttributes(responseData);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
...prevState,
|
|
47
|
+
message: "Public Information Updated",
|
|
48
|
+
data: flattenedData,
|
|
49
|
+
strapiErrors: null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
|
|
3
|
+
import qs from "qs";
|
|
4
|
+
import { fetchData } from "../../loaders";
|
|
5
|
+
import { flattenAttributes, getStrapiURL } from "../../../lib/utils";
|
|
6
|
+
import { unstable_noStore as noStore } from "next/cache";
|
|
7
|
+
|
|
8
|
+
const baseUrl = getStrapiURL();
|
|
9
|
+
|
|
10
|
+
export async function getPublicInformation() {
|
|
11
|
+
noStore();
|
|
12
|
+
|
|
13
|
+
const url = new URL(`/api/public-information`, baseUrl);
|
|
14
|
+
|
|
15
|
+
url.search = qs.stringify({
|
|
16
|
+
populate: {
|
|
17
|
+
address: true,
|
|
18
|
+
business_credentials: true,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return flattenAttributes(await fetchData(url.href));
|
|
23
|
+
}
|
package/src/data/loaders.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"use server";
|
|
2
|
+
|
|
1
3
|
import qs from "qs";
|
|
2
4
|
import { flattenAttributes, getStrapiURL } from "../lib/utils";
|
|
3
5
|
import { unstable_noStore as noStore } from "next/cache";
|
|
@@ -54,10 +56,9 @@ async function getHomePageData() {
|
|
|
54
56
|
async function getPagedata(slug: string) {
|
|
55
57
|
noStore();
|
|
56
58
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
59
|
+
console.log(slug);
|
|
60
|
+
|
|
61
|
+
const url = new URL(`/api/slugify/slugs/page/${slug}`, baseUrl);
|
|
61
62
|
|
|
62
63
|
url.search = qs.stringify({
|
|
63
64
|
populate: {
|
|
@@ -111,7 +112,8 @@ async function getPagedata(slug: string) {
|
|
|
111
112
|
},
|
|
112
113
|
});
|
|
113
114
|
|
|
114
|
-
return await fetchData(url.href);
|
|
115
|
+
// return await fetchData(url.href); //!!
|
|
116
|
+
return flattenAttributes(await fetchData(url.href));
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
async function getDisclaimerData() {
|
|
@@ -196,7 +198,7 @@ async function getPageNames() {
|
|
|
196
198
|
noStore();
|
|
197
199
|
const url = new URL("/api/pages", baseUrl);
|
|
198
200
|
url.search = qs.stringify({
|
|
199
|
-
fields: ["slug"],
|
|
201
|
+
fields: ["slug", "title"],
|
|
200
202
|
});
|
|
201
203
|
|
|
202
204
|
return await fetchData(url.href);
|
|
@@ -4,7 +4,7 @@ import { type PageData } from "../../data/actions/pagebuilder-actions";
|
|
|
4
4
|
const baseUrl = getStrapiURL();
|
|
5
5
|
|
|
6
6
|
export async function updatePageService(pageData: PageData) {
|
|
7
|
-
|
|
7
|
+
console.log("pageData", pageData);
|
|
8
8
|
|
|
9
9
|
const url = new URL(`/api/pages/${pageData.id}`, baseUrl);
|
|
10
10
|
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
export interface AddressFieldsProps {
|
|
2
|
+
data?: AddressProps;
|
|
3
|
+
componentName: string;
|
|
4
|
+
componentReference: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
export interface AddressProps {
|
|
2
|
-
title: string;
|
|
8
|
+
// title: string; // why does an address need a title, shouldn't an address need a type?
|
|
3
9
|
id: string | null;
|
|
4
10
|
street: string;
|
|
5
11
|
street_number: number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AddressProps } from "@/types/AddressProps";
|
|
2
|
+
import { BusinessCredentialsProps } from "@/types/e-commerce/BusinessCredentialsProps";
|
|
3
|
+
|
|
4
|
+
export interface PublicInformationFormProps {
|
|
5
|
+
publicInformation: PublicInformation;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type PublicInformation = {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
disclaimer_link: string;
|
|
13
|
+
privacypolicy_link: string;
|
|
14
|
+
maxWidth: string;
|
|
15
|
+
email: string;
|
|
16
|
+
phone_number: string;
|
|
17
|
+
business_credentials: BusinessCredentialsProps;
|
|
18
|
+
address: AddressProps;
|
|
19
|
+
socials: string;
|
|
20
|
+
header_logo: string;
|
|
21
|
+
footer_logo: string;
|
|
22
|
+
};
|