Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 2 additions & 25 deletions src/actions/sponsor-pages-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
escapeFilterValue
} from "openstack-uicore-foundation/lib/utils/actions";
import T from "i18n-react/dist/i18n-react";
import moment from "moment-timezone";
import {
getAccessTokenSafely,
normalizeSelectAllField
Expand All @@ -31,8 +30,7 @@ import { snackbarErrorHandler, snackbarSuccessHandler } from "./base-actions";
import {
DEFAULT_CURRENT_PAGE,
DEFAULT_ORDER_DIR,
DEFAULT_PER_PAGE,
PAGES_MODULE_KINDS
DEFAULT_PER_PAGE
} from "../utils/constants";
import { normalizePageTemplateModules } from "../utils/page-template";

Expand Down Expand Up @@ -309,28 +307,7 @@ const normalizeSponsorManagedPageToCustomize = (entity) => {
)
};

normalizedEntity.modules = entity.modules.map((module) => {
const normalizedModule = { ...module };

if (module.kind === PAGES_MODULE_KINDS.MEDIA && module.upload_deadline) {
normalizedModule.upload_deadline = moment
.utc(module.upload_deadline)
.unix();
}

if (module.kind === PAGES_MODULE_KINDS.MEDIA && module.file_type_id) {
normalizedModule.file_type_id =
module.file_type_id?.value || module.file_type_id;
}

if (module.kind === PAGES_MODULE_KINDS.DOCUMENT && module.file) {
normalizedModule.file = module.file[0] || null;
}

delete normalizedModule._tempId;

return normalizedModule;
});
normalizedEntity.modules = normalizePageTemplateModules(entity.modules);

delete normalizedEntity.page_ptr_id;
delete normalizedEntity.sponsorship_types;
Expand Down
61 changes: 12 additions & 49 deletions src/reducers/sponsors/sponsor-page-pages-list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* */

import { LOGOUT_USER } from "openstack-uicore-foundation/lib/security/actions";
import { epochToMomentTimeZone } from "openstack-uicore-foundation/lib/utils/methods";
import {
REQUEST_SPONSOR_MANAGED_PAGES,
RECEIVE_SPONSOR_MANAGED_PAGES,
Expand All @@ -26,10 +25,8 @@ import {
} from "../../actions/sponsor-pages-actions";
import { SET_CURRENT_SUMMIT } from "../../actions/summit-actions";
import { RECEIVE_GLOBAL_SPONSORSHIPS } from "../../actions/sponsor-forms-actions";
import {
PAGE_MODULES_DOWNLOAD,
PAGES_MODULE_KINDS
} from "../../utils/constants";
import { PAGES_MODULE_KINDS } from "../../utils/constants";
import { denormalizePageModules } from "../../utils/page-template";

const DEFAULT_PAGE = {
code: "",
Expand Down Expand Up @@ -180,54 +177,20 @@ const sponsorPagePagesListReducer = (state = DEFAULT_STATE, action) => {
case RECEIVE_SPONSOR_MANAGED_PAGE: {
const editPage = payload.response;

const currentEditPage = {
...editPage,
modules: editPage.modules.map((m) => ({
...m,
...(m.upload_deadline
? {
upload_deadline: epochToMomentTimeZone(
m.upload_deadline,
state.summitTZ || "UTC"
)
}
: {})
}))
};
return { ...state, currentEditPage };
const modules = denormalizePageModules(
editPage.modules,
state.summitTZ || "UTC"
);

return { ...state, currentEditPage: { ...editPage, modules } };
}
case RECEIVE_SPONSOR_CUSTOMIZED_PAGE: {
const customizedPage = payload.response;

const modules = customizedPage.modules.map((module) => {
const tmpModule = {
...module,
...(module.upload_deadline
? {
upload_deadline: epochToMomentTimeZone(
module.upload_deadline,
state.summitTZ || "UTC"
)
}
: {})
};

if (module.kind === PAGES_MODULE_KINDS.DOCUMENT) {
if (module.file) {
tmpModule.file = [
{
...module.file,
file_path: module.file.storage_key,
public_url: module.file.file_url
}
];
tmpModule.type = PAGE_MODULES_DOWNLOAD.FILE;
} else {
tmpModule.type = PAGE_MODULES_DOWNLOAD.URL;
}
}
return tmpModule;
});
const modules = denormalizePageModules(
customizedPage.modules,
state.summitTZ || "UTC"
);

return { ...state, currentEditPage: { ...customizedPage, modules } };
}
Expand Down
Loading