@plusscommunities/pluss-feature-builder-web-b 1.0.2-beta.5 → 1.0.2-beta.6
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/index.cjs.js +825 -823
- package/package.json +1 -1
- package/src/actions/featureDefinitionsIndex.js +2 -3
- package/src/actions/formActions.js +148 -158
- package/src/actions/listingActions.js +1 -1
- package/src/actions/wizardActions.js +169 -184
- package/src/components/BaseFieldConfig.jsx +234 -234
- package/src/components/IconLoader.jsx +138 -138
- package/src/components/IconSelector.jsx +0 -1
- package/src/components/ListingEditor.jsx +0 -1
- package/src/components/SidebarLayout.jsx +4 -1
- package/src/components/index.js +0 -2
- package/src/components/listing/GalleryDisplay.jsx +0 -1
- package/src/components/listing/ListingGalleryInput.jsx +4 -1
- package/src/reducers/featureBuilderReducer.js +14 -25
- package/src/screens/FormLayoutStep.jsx +10 -13
- package/src/screens/FormOverviewStep.jsx +351 -358
- package/src/screens/ListingScreen.jsx +0 -1
- package/src/selectors/featureBuilderSelectors.js +49 -44
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wizard Actions for Feature Builder
|
|
3
|
-
* Manages wizard state including navigation, step validation, and mode switching
|
|
4
|
-
* Provides validation logic for overview, fields, and layout steps
|
|
5
|
-
* Coordinates with form state and step progression
|
|
6
|
-
*
|
|
7
|
-
* @namespace wizardActions
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// Import selectors for form state access
|
|
11
1
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
selectFormTitle,
|
|
3
|
+
selectFormIcon,
|
|
4
|
+
selectFormDisplayName,
|
|
5
|
+
selectFormLayout,
|
|
6
|
+
selectFormFields,
|
|
17
7
|
} from "../selectors/featureBuilderSelectors";
|
|
18
8
|
|
|
9
|
+
import { clearFormSubmissionState } from "./formActions"
|
|
10
|
+
|
|
19
11
|
import { values } from "../values.config";
|
|
20
12
|
|
|
21
13
|
// Wizard action types
|
|
@@ -29,215 +21,208 @@ export const VALIDATE_AND_UPDATE_STEP = `${REDUCER_PREFIX}_VALIDATE_AND_UPDATE_S
|
|
|
29
21
|
|
|
30
22
|
// Mode setters
|
|
31
23
|
export const setWizardMode = (mode) => ({
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
type: SET_WIZARD_MODE,
|
|
25
|
+
payload: mode,
|
|
34
26
|
});
|
|
35
27
|
|
|
36
28
|
// Navigation actions
|
|
37
29
|
export const setNavigationState = (navigationState) => ({
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
type: SET_NAVIGATION_STATE,
|
|
31
|
+
payload: navigationState,
|
|
40
32
|
});
|
|
41
33
|
|
|
42
34
|
export const setCurrentStep = (step, previousStep = null) => ({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
type: SET_NAVIGATION_STATE,
|
|
36
|
+
payload: {
|
|
37
|
+
currentStep: step,
|
|
38
|
+
previousStep,
|
|
39
|
+
canGoBack: step !== "welcome",
|
|
40
|
+
canGoForward: true,
|
|
41
|
+
},
|
|
50
42
|
});
|
|
51
43
|
|
|
52
44
|
export const goToStep = (step) => (dispatch, getState) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// Clear form submission state when changing steps
|
|
61
|
-
const { clearFormSubmissionState } = require("./formActions");
|
|
62
|
-
dispatch(clearFormSubmissionState());
|
|
63
|
-
|
|
64
|
-
dispatch(setCurrentStep(step, currentStep));
|
|
45
|
+
const state = getState()[values.reducerKey];
|
|
46
|
+
const currentStep = state?.wizard?.navigation?.currentStep;
|
|
47
|
+
|
|
48
|
+
// Clear form submission state when changing steps
|
|
49
|
+
dispatch(clearFormSubmissionState());
|
|
50
|
+
|
|
51
|
+
dispatch(setCurrentStep(step, currentStep));
|
|
65
52
|
};
|
|
66
53
|
|
|
67
54
|
export const updateStepValidation = (step, isValid, errors = {}) => ({
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
55
|
+
type: UPDATE_STEP_VALIDATION,
|
|
56
|
+
payload: {
|
|
57
|
+
step,
|
|
58
|
+
isValid,
|
|
59
|
+
errors,
|
|
60
|
+
},
|
|
74
61
|
});
|
|
75
62
|
|
|
76
63
|
export const validateAndUpdateStep = (step) => (dispatch, getState) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
64
|
+
// Use existing selectors to get form data
|
|
65
|
+
const state = getState();
|
|
66
|
+
const title = selectFormTitle(state);
|
|
67
|
+
const icon = selectFormIcon(state);
|
|
68
|
+
const displayName = selectFormDisplayName(state);
|
|
69
|
+
const layout = selectFormLayout(state);
|
|
70
|
+
const fields = selectFormFields(state);
|
|
84
71
|
|
|
85
|
-
|
|
72
|
+
const form = { title, icon, displayName, layout, fields };
|
|
86
73
|
|
|
87
|
-
|
|
74
|
+
const { isValid, errors } = getFormValidation(form, step);
|
|
88
75
|
|
|
89
|
-
|
|
76
|
+
dispatch(updateStepValidation(step, isValid, errors));
|
|
90
77
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
78
|
+
// If valid, mark as complete
|
|
79
|
+
if (isValid) {
|
|
80
|
+
dispatch({
|
|
81
|
+
type: MARK_STEP_COMPLETE,
|
|
82
|
+
payload: step,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
98
85
|
|
|
99
|
-
|
|
86
|
+
return { isValid, errors };
|
|
100
87
|
};
|
|
101
88
|
|
|
102
89
|
// Step completion
|
|
103
90
|
export const markStepComplete = (step) => ({
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
type: MARK_STEP_COMPLETE,
|
|
92
|
+
payload: step,
|
|
106
93
|
});
|
|
107
94
|
|
|
108
95
|
// Reset wizard state
|
|
109
96
|
export const resetWizardState = () => ({
|
|
110
|
-
|
|
97
|
+
type: RESET_WIZARD_STATE,
|
|
111
98
|
});
|
|
112
99
|
|
|
113
100
|
const getFormValidation = (form, step) => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return { isValid: true, errors: {} };
|
|
219
|
-
}
|
|
101
|
+
// Return validation results for undefined form (prevent crashes)
|
|
102
|
+
if (!form) {
|
|
103
|
+
switch (step) {
|
|
104
|
+
case "overview":
|
|
105
|
+
return {
|
|
106
|
+
isValid: false,
|
|
107
|
+
errors: {
|
|
108
|
+
title: "Title is required",
|
|
109
|
+
displayName: "Display name is required",
|
|
110
|
+
icon: "Icon is required",
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
case "fields":
|
|
114
|
+
return {
|
|
115
|
+
isValid: false,
|
|
116
|
+
errors: {
|
|
117
|
+
missingTitle: "Title field is required",
|
|
118
|
+
missingImage: "Feature image field is required",
|
|
119
|
+
fieldLabels: "Some fields are missing labels",
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
case "layout":
|
|
123
|
+
return {
|
|
124
|
+
isValid: false,
|
|
125
|
+
errors: {
|
|
126
|
+
layoutType: "Layout type is required",
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
default:
|
|
130
|
+
return { isValid: false, errors: {} };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
switch (step) {
|
|
135
|
+
case "overview": {
|
|
136
|
+
const hasTitle = form.title?.trim().length > 0;
|
|
137
|
+
const hasDisplayName = form.displayName?.trim().length > 0;
|
|
138
|
+
const hasIcon = form.icon?.length > 0;
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
isValid: hasTitle && hasDisplayName && hasIcon,
|
|
142
|
+
errors: {
|
|
143
|
+
title: !hasTitle ? "Title is required" : null,
|
|
144
|
+
displayName: !hasDisplayName ? "Display name is required" : null,
|
|
145
|
+
icon: !hasIcon ? "Icon is required" : null,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
case "fields": {
|
|
150
|
+
const hasTitleField = form.fields?.some(
|
|
151
|
+
(field) => field.id === "mandatory-title",
|
|
152
|
+
);
|
|
153
|
+
const hasImageField = form.fields?.some(
|
|
154
|
+
(field) => field.id === "mandatory-feature-image",
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
// Check each field for missing labels and create field-specific errors
|
|
158
|
+
const fieldErrors = {};
|
|
159
|
+
let allFieldsHaveLabels = true;
|
|
160
|
+
|
|
161
|
+
if (form.fields) {
|
|
162
|
+
form.fields.forEach((field) => {
|
|
163
|
+
if (
|
|
164
|
+
(field.type === "text" ||
|
|
165
|
+
field.type === "description" ||
|
|
166
|
+
field.type === "title" ||
|
|
167
|
+
field.type === "image" ||
|
|
168
|
+
field.type === "gallery" ||
|
|
169
|
+
field.type === "feature-image" ||
|
|
170
|
+
field.type === "file" ||
|
|
171
|
+
field.type === "cta") &&
|
|
172
|
+
field.values
|
|
173
|
+
) {
|
|
174
|
+
if (!field.values.label || field.values.label.trim().length === 0) {
|
|
175
|
+
fieldErrors[field.id] = "Field label is required";
|
|
176
|
+
allFieldsHaveLabels = false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
isValid: hasTitleField && hasImageField && allFieldsHaveLabels,
|
|
184
|
+
errors: {
|
|
185
|
+
missingTitle: !hasTitleField ? "Title field is required" : null,
|
|
186
|
+
missingImage: !hasImageField
|
|
187
|
+
? "Feature image field is required"
|
|
188
|
+
: null,
|
|
189
|
+
...fieldErrors,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
case "layout": {
|
|
194
|
+
const hasLayoutType = form.layout?.type?.length > 0;
|
|
195
|
+
return {
|
|
196
|
+
isValid: hasLayoutType,
|
|
197
|
+
errors: {
|
|
198
|
+
layoutType: !hasLayoutType ? "Layout type is required" : null,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
default:
|
|
203
|
+
return { isValid: true, errors: {} };
|
|
204
|
+
}
|
|
220
205
|
};
|
|
221
206
|
|
|
222
207
|
export const setWizardModeAndSave = (mode) => (dispatch) => {
|
|
223
|
-
|
|
208
|
+
dispatch(setWizardMode(mode));
|
|
224
209
|
};
|
|
225
210
|
|
|
226
211
|
export const setCurrentStepAndSave =
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
212
|
+
(step, previousStep = null) =>
|
|
213
|
+
(dispatch) => {
|
|
214
|
+
dispatch(setCurrentStep(step, previousStep));
|
|
215
|
+
};
|
|
231
216
|
|
|
232
217
|
export const updateStepValidationAndSave =
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
218
|
+
(step, isValid, errors = {}) =>
|
|
219
|
+
(dispatch) => {
|
|
220
|
+
dispatch(updateStepValidation(step, isValid, errors));
|
|
221
|
+
if (isValid) {
|
|
222
|
+
dispatch(markStepComplete(step));
|
|
223
|
+
}
|
|
224
|
+
};
|
|
240
225
|
|
|
241
226
|
export const markStepCompleteAndSave = (step) => (dispatch) => {
|
|
242
|
-
|
|
227
|
+
dispatch(markStepComplete(step));
|
|
243
228
|
};
|