@appcorp/fusion-storybook 0.1.84 → 0.1.86

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.
@@ -137,6 +137,34 @@ export const useCampusModule = () => {
137
137
  payload: { drawer: null },
138
138
  });
139
139
  }, [dispatch]);
140
+ const resetRecordFormState = useCallback(() => {
141
+ dispatch({
142
+ type: CAMPUS_ACTION_TYPES.SET_ERRORS,
143
+ payload: { errors: {} },
144
+ });
145
+ dispatch({
146
+ type: CAMPUS_ACTION_TYPES.SET_DISABLE_SAVE_BUTTON,
147
+ payload: { disabled: false },
148
+ });
149
+ dispatch({
150
+ type: CAMPUS_ACTION_TYPES.SET_FORM_DATA,
151
+ payload: {
152
+ form: {
153
+ address: null,
154
+ city: null,
155
+ code: "",
156
+ country: null,
157
+ enabled: true,
158
+ filterEnabled: undefined,
159
+ id: "",
160
+ name: "",
161
+ phone: null,
162
+ schoolId,
163
+ state: null,
164
+ },
165
+ },
166
+ });
167
+ }, [dispatch, schoolId]);
140
168
  // ============================================================================
141
169
  // 1.4.4 API CALLBACKS
142
170
  // ============================================================================
@@ -247,19 +275,21 @@ export const useCampusModule = () => {
247
275
  });
248
276
  }, [dispatch]);
249
277
  const handleView = useCallback((row) => {
278
+ resetRecordFormState();
250
279
  byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
251
280
  dispatch({
252
281
  type: CAMPUS_ACTION_TYPES.SET_DRAWER,
253
282
  payload: { drawer: CAMPUS_DRAWER.VIEW_DRAWER },
254
283
  });
255
- }, [byIdFetchNow, dispatch]);
284
+ }, [byIdFetchNow, dispatch, resetRecordFormState]);
256
285
  const handleEdit = useCallback((row) => {
286
+ resetRecordFormState();
257
287
  byIdFetchNow === null || byIdFetchNow === void 0 ? void 0 : byIdFetchNow(undefined, { params: { id: row === null || row === void 0 ? void 0 : row.id } });
258
288
  dispatch({
259
289
  type: CAMPUS_ACTION_TYPES.SET_DRAWER,
260
290
  payload: { drawer: CAMPUS_DRAWER.FORM_DRAWER },
261
291
  });
262
- }, [byIdFetchNow, dispatch]);
292
+ }, [byIdFetchNow, dispatch, resetRecordFormState]);
263
293
  const handleDelete = useCallback((row) => {
264
294
  if (!confirm(t("messagesDeleteConfirmation")))
265
295
  return;
@@ -13,5 +13,5 @@ export const CampusForm = () => {
13
13
  const { state, handleChange } = useCampusModule();
14
14
  const { address, city, code, country, enabled, errors, name, phone, state: campusState, } = state;
15
15
  const t = useTranslations("campus");
16
- return (_jsx("div", { className: "space-y-4", children: _jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { error: errors.name, id: "name", info: t("campusNameInfo"), label: t("campusName"), onChange: (e) => handleChange("name", e.target.value), placeholder: t("campusNamePlaceholder"), required: true, value: name }), _jsx(EnhancedInput, { error: errors.code, id: "code", info: t("campusCodeInfo"), label: t("campusCode"), onChange: (e) => handleChange("code", e.target.value), placeholder: t("campusCodePlaceholder"), required: true, value: code }), _jsx(EnhancedInput, { error: errors.address, id: "address", label: t("address"), onChange: (e) => handleChange("address", e.target.value), placeholder: t("addressPlaceholder"), value: address || "" }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx(EnhancedInput, { error: errors.city, id: "city", label: t("city"), onChange: (e) => handleChange("city", e.target.value), placeholder: t("cityPlaceholder"), value: city || "" }), _jsx(EnhancedInput, { error: errors.state, id: "state", label: t("state"), onChange: (e) => handleChange("state", e.target.value), placeholder: t("statePlaceholder"), value: campusState || "" })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsx(EnhancedInput, { error: errors.country, id: "country", label: t("country"), onChange: (e) => handleChange("country", e.target.value), placeholder: t("countryPlaceholder"), value: country || "" }), _jsx(EnhancedInput, { error: errors.phone, id: "phone", label: t("phone"), onChange: (e) => handleChange("phone", e.target.value), placeholder: t("phonePlaceholder"), value: phone || "" })] }), _jsx(EnhancedCheckbox, { label: t("activeCampus"), defaultChecked: enabled, onCheckedChange: (checked) => handleChange("enabled", checked) })] }) }));
16
+ return (_jsxs("div", { className: "grid grid-cols-1 gap-4", children: [_jsx(EnhancedInput, { error: errors.name, id: "name", info: t("campusNameInfo"), label: t("campusName"), onChange: (e) => handleChange("name", e.target.value), placeholder: t("campusNamePlaceholder"), required: true, value: name }), _jsx(EnhancedInput, { error: errors.code, id: "code", info: t("campusCodeInfo"), label: t("campusCode"), onChange: (e) => handleChange("code", e.target.value), placeholder: t("campusCodePlaceholder"), required: true, value: code }), _jsx(EnhancedInput, { error: errors.address, id: "address", info: t("addressInfo"), label: t("address"), onChange: (e) => handleChange("address", e.target.value), placeholder: t("addressPlaceholder"), value: address || "" }), _jsx(EnhancedInput, { error: errors.city, id: "city", info: t("cityInfo"), label: t("city"), onChange: (e) => handleChange("city", e.target.value), placeholder: t("cityPlaceholder"), value: city || "" }), _jsx(EnhancedInput, { error: errors.state, id: "state", info: t("stateInfo"), label: t("state"), onChange: (e) => handleChange("state", e.target.value), placeholder: t("statePlaceholder"), value: campusState || "" }), _jsx(EnhancedInput, { error: errors.country, id: "country", info: t("countryInfo"), label: t("country"), onChange: (e) => handleChange("country", e.target.value), placeholder: t("countryPlaceholder"), value: country || "" }), _jsx(EnhancedInput, { error: errors.phone, id: "phone", info: t("phoneInfo"), label: t("phone"), onChange: (e) => handleChange("phone", e.target.value), placeholder: t("phonePlaceholder"), value: phone || "" }), _jsx(EnhancedCheckbox, { info: t("activeCampusInfo"), label: t("activeCampus"), defaultChecked: enabled, onCheckedChange: (checked) => handleChange("enabled", checked) })] }));
17
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appcorp/fusion-storybook",
3
- "version": "0.1.84",
3
+ "version": "0.1.86",
4
4
  "scripts": {
5
5
  "build-storybook": "storybook build",
6
6
  "build:next": "next build",