@griddo/ax 11.10.10 → 11.10.11-rc.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "11.10.10",
4
+ "version": "11.10.11-rc.0",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Diego M. Béjar <diego.bejar@secuoyas.com>",
@@ -225,5 +225,5 @@
225
225
  "publishConfig": {
226
226
  "access": "public"
227
227
  },
228
- "gitHead": "7ab8ffd85a8673602920d7f585c15e974a77dfe2"
228
+ "gitHead": "e3fdee4be8b2129da8b54ca6a9fc7e6bddc2ad80"
229
229
  }
@@ -622,18 +622,30 @@ function updatePageStatus(
622
622
  const validIds = ids.filter((id) => !pagesWithErrors.includes(id));
623
623
  if (!validIds.length) return false;
624
624
 
625
- const response = await pages.setPageStatus(status, validIds);
626
- const isUpdatingFromPageEditor = isReqOk(response.status) && !updatedFromList;
627
- if (isUpdatingFromPageEditor) {
628
- const currentPageID = ids[0];
629
- const updatedContent = await pages.getPageInfo(currentPageID);
630
- const mappedData = parseData(updatedContent.data, true);
631
- const { pageContent } = generateEditorIDs({ ...mappedData, header, footer });
632
- dispatch(setEditorContent(pageContent));
633
- dispatch(setCurrentPageStatus(status));
634
- }
635
- dispatch(setIsSaving(false));
636
- return true;
625
+ const responseActions = {
626
+ handleSuccess: async () => {
627
+ if (!updatedFromList) {
628
+ const currentPageID = ids[0];
629
+ const updatedContent = await pages.getPageInfo(currentPageID);
630
+ const mappedData = parseData(updatedContent.data, true);
631
+ const { pageContent } = generateEditorIDs({ ...mappedData, header, footer });
632
+ dispatch(setEditorContent(pageContent));
633
+ dispatch(setCurrentPageStatus(status));
634
+ }
635
+ },
636
+ handleError: (response: any) => {
637
+ const {
638
+ data: { message },
639
+ } = response;
640
+ const isMultiple = Array.isArray(message) && message.length > 1;
641
+ const msg = isMultiple ? `This action failed due to ${message.length} errors.` : undefined;
642
+ appActions.handleError(response, isMultiple, msg)(dispatch);
643
+ },
644
+ };
645
+
646
+ const callback = async () => await pages.setPageStatus(status, validIds);
647
+
648
+ return await handleRequest(callback, responseActions, [setIsSaving])(dispatch);
637
649
  } catch (e) {
638
650
  dispatch(setIsSaving(false));
639
651
  console.log(e); // TODO: capturar error bien