diff --git a/src/actions/attendee-actions.js b/src/actions/attendee-actions.js index f4c04539a..cb13d778f 100644 --- a/src/actions/attendee-actions.js +++ b/src/actions/attendee-actions.js @@ -223,7 +223,7 @@ export const getAttendees = const { currentSummitState } = getState(); const accessToken = await getAccessTokenSafely(); const { currentSummit } = currentSummitState; - const summitTZ = currentSummit.time_zone.name; + const summitTZ = currentSummit.time_zone_id; dispatch(startLoading()); const params = { @@ -311,7 +311,9 @@ export const getAttendee = (attendeeId) => async (dispatch, getState) => { createAction(RECEIVE_ATTENDEE), `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/attendees/${attendeeId}`, authErrorHandler - )(params)(dispatch).then(({ response }) => getAttendeeOrders(response)(dispatch, getState)); + )(params)(dispatch).then(({ response }) => + getAttendeeOrders(response)(dispatch, getState) + ); }; export const getAttendeeOrders = (attendee) => async (dispatch) => { diff --git a/src/actions/audit-log-actions.js b/src/actions/audit-log-actions.js index 4bf9ffc58..e61fb6a24 100644 --- a/src/actions/audit-log-actions.js +++ b/src/actions/audit-log-actions.js @@ -79,7 +79,7 @@ export const getAuditLog = const { currentSummitState } = getState(); const accessToken = await getAccessTokenSafely(); const { currentSummit } = currentSummitState; - const summitTZ = currentSummit.time_zone.name; + const summitTZ = currentSummit.time_zone_id; const summitFilter = [`summit_id==${currentSummit.id}`]; dispatch(startLoading()); diff --git a/src/actions/event-actions.js b/src/actions/event-actions.js index e182ce233..756ba5e7b 100644 --- a/src/actions/event-actions.js +++ b/src/actions/event-actions.js @@ -540,7 +540,7 @@ export const getEvents = const { currentSummitState } = getState(); const accessToken = await getAccessTokenSafely(); const { currentSummit } = currentSummitState; - const summitTZ = currentSummit.time_zone.name; + const summitTZ = currentSummit.time_zone_id; dispatch(startLoading()); @@ -659,7 +659,7 @@ export const getEventsForOccupancy = const accessToken = await getAccessTokenSafely(); const { currentSummit } = currentSummitState; const filter = []; - const summitTZ = currentSummit.time_zone.name; + const summitTZ = currentSummit.time_zone_id; let endPoint = "events/published"; dispatch(startLoading()); @@ -725,7 +725,7 @@ export const getEventsForOccupancyCSV = const accessToken = await getAccessTokenSafely(); const { currentSummit } = currentSummitState; const filter = []; - const summitTZ = currentSummit.time_zone.name; + const summitTZ = currentSummit.time_zone_id; dispatch(startLoading()); @@ -786,7 +786,7 @@ export const getCurrentEventForOccupancy = const accessToken = await getAccessTokenSafely(); const { currentSummit } = currentSummitState; const filter = []; - const summitTZ = currentSummit.time_zone.name; + const summitTZ = currentSummit.time_zone_id; let endPoint = `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}`; dispatch(startLoading()); diff --git a/src/actions/order-actions.js b/src/actions/order-actions.js index 1dee5918b..a185eab4e 100644 --- a/src/actions/order-actions.js +++ b/src/actions/order-actions.js @@ -512,7 +512,7 @@ export const getPurchaseOrders = const { currentSummitState } = getState(); const accessToken = await getAccessTokenSafely(); const { currentSummit } = currentSummitState; - const summitTZ = currentSummit.time_zone.name; + const summitTZ = currentSummit.time_zone_id; dispatch(startLoading()); diff --git a/src/actions/sponsor-actions.js b/src/actions/sponsor-actions.js index 094f733a4..729615047 100644 --- a/src/actions/sponsor-actions.js +++ b/src/actions/sponsor-actions.js @@ -159,50 +159,50 @@ export const getSponsors = order = "order", orderDir = 1 ) => - async (dispatch, getState) => { - const { currentSummitState } = getState(); - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; - const filter = []; + async (dispatch, getState) => { + const { currentSummitState } = getState(); + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; + const filter = []; - dispatch(startLoading()); + dispatch(startLoading()); - if (term) { - const escapedTerm = escapeFilterValue(term); - filter.push( - `company_name=@${escapedTerm},sponsorship_name=@${escapedTerm},sponsorship_size=@${escapedTerm}` - ); - } + if (term) { + const escapedTerm = escapeFilterValue(term); + filter.push( + `company_name=@${escapedTerm},sponsorship_name=@${escapedTerm},sponsorship_size=@${escapedTerm}` + ); + } - const params = { - page, - per_page: perPage, - expand: "company,sponsorship,sponsorship.type", - relations: "company.none,sponsorship.none,sponsorship.type.none,none", - fields: "id,company.name,company.id,sponsorship.id,sponsorship.type.name", - access_token: accessToken - }; + const params = { + page, + per_page: perPage, + expand: "company,sponsorship,sponsorship.type", + relations: "company.none,sponsorship.none,sponsorship.type.none,none", + fields: "id,company.name,company.id,sponsorship.id,sponsorship.type.name", + access_token: accessToken + }; - if (filter.length > 0) { - params["filter[]"] = filter; - } + if (filter.length > 0) { + params["filter[]"] = filter; + } - // order - if (order != null && orderDir != null) { - const orderDirSign = orderDir === 1 ? "+" : "-"; - params.order = `${orderDirSign}${order}`; - } + // order + if (order != null && orderDir != null) { + const orderDirSign = orderDir === 1 ? "+" : "-"; + params.order = `${orderDirSign}${order}`; + } - return getRequest( - createAction(REQUEST_SPONSORS), - createAction(RECEIVE_SPONSORS), - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors`, - authErrorHandler, - { page, perPage, order, orderDir, term } - )(params)(dispatch).then(() => { - dispatch(stopLoading()); - }); - }; + return getRequest( + createAction(REQUEST_SPONSORS), + createAction(RECEIVE_SPONSORS), + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors`, + authErrorHandler, + { page, perPage, order, orderDir, term } + )(params)(dispatch).then(() => { + dispatch(stopLoading()); + }); + }; export const getSponsorsWithBadgeScans = () => async (dispatch, getState) => { const { currentSummitState } = getState(); @@ -457,26 +457,26 @@ export const getExtraQuestionMeta = () => async (dispatch, getState) => { export const updateExtraQuestionOrder = (extraQuestions, sponsorId, questionId, newOrder) => - async (dispatch, getState) => { - const { currentSummitState } = getState(); - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; - - const params = { - access_token: accessToken - }; + async (dispatch, getState) => { + const { currentSummitState } = getState(); + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; - putRequest( - null, - createAction(SPONSOR_EXTRA_QUESTION_ORDER_UPDATED)(extraQuestions), - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/extra-questions/${questionId}`, - { order: newOrder }, - authErrorHandler - )(params)(dispatch).then(() => { - dispatch(stopLoading()); - }); + const params = { + access_token: accessToken }; + putRequest( + null, + createAction(SPONSOR_EXTRA_QUESTION_ORDER_UPDATED)(extraQuestions), + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/extra-questions/${questionId}`, + { order: newOrder }, + authErrorHandler + )(params)(dispatch).then(() => { + dispatch(stopLoading()); + }); + }; + export const deleteExtraQuestion = (sponsorId, questionId) => async (dispatch, getState) => { const { currentSummitState } = getState(); @@ -699,37 +699,37 @@ export const deleteSponsorExtraQuestionValue = export const getSummitSponsorships = (order = "name", orderDir = 1) => - async (dispatch, getState) => { - const { currentSummitState } = getState(); - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; - - dispatch(startLoading()); - - const params = { - page: 1, - per_page: 100, - access_token: accessToken, - expand: "type" - }; + async (dispatch, getState) => { + const { currentSummitState } = getState(); + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; - // order - if (order != null && orderDir != null) { - const orderDirSign = orderDir === 1 ? "+" : "-"; - params.order = `${orderDirSign}${order}`; - } + dispatch(startLoading()); - return getRequest( - createAction(REQUEST_SUMMIT_SPONSORSHIPS), - createAction(RECEIVE_SUMMIT_SPONSORSHIPS), - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsorships-types`, - authErrorHandler, - { order, orderDir } - )(params)(dispatch).then(() => { - dispatch(stopLoading()); - }); + const params = { + page: 1, + per_page: 100, + access_token: accessToken, + expand: "type" }; + // order + if (order != null && orderDir != null) { + const orderDirSign = orderDir === 1 ? "+" : "-"; + params.order = `${orderDirSign}${order}`; + } + + return getRequest( + createAction(REQUEST_SUMMIT_SPONSORSHIPS), + createAction(RECEIVE_SUMMIT_SPONSORSHIPS), + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsorships-types`, + authErrorHandler, + { order, orderDir } + )(params)(dispatch).then(() => { + dispatch(stopLoading()); + }); + }; + export const getSummitSponsorship = (sponsorshipId) => async (dispatch, getState) => { const { currentSummitState } = getState(); @@ -955,86 +955,86 @@ export const getBadgeScans = order = "attendee_last_name", orderDir = 1 ) => - async (dispatch, getState) => { - const { currentSummitState } = getState(); - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; - const filter = []; - const summitTZ = currentSummit.time_zone.name; + async (dispatch, getState) => { + const { currentSummitState } = getState(); + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; + const filter = []; + const summitTZ = currentSummit.time_zone_id; - dispatch(startLoading()); + dispatch(startLoading()); - if (sponsorId) { - filter.push(`sponsor_id==${sponsorId}`); - } + if (sponsorId) { + filter.push(`sponsor_id==${sponsorId}`); + } - const params = { - access_token: accessToken, - page, - per_page: perPage, - expand: - "badge,badge.ticket,badge.ticket.owner,badge.ticket.owner.member,scanned_by", - relations: - "scanned_by,badge,scanned_by.none,badge.none,badge.ticket.none,badge.ticket.owner.none,badge.ticket.owner.member.none", - fields: - "id,created,scan_date,attendee_first_name,attendee_last_name,attendee_email,attendee_company,scanned_by.email,scanned_by.first_name,scanned_by.last_name,badge.ticket,badge.ticket.owner,badge.ticket.owner.member.first_name,badge.ticket.owner.member.last_name,badge.ticket.owner.email,badge.ticket.owner.company,badge.ticket.owner.first_name,badge.ticket.owner.last_name" - }; + const params = { + access_token: accessToken, + page, + per_page: perPage, + expand: + "badge,badge.ticket,badge.ticket.owner,badge.ticket.owner.member,scanned_by", + relations: + "scanned_by,badge,scanned_by.none,badge.none,badge.ticket.none,badge.ticket.owner.none,badge.ticket.owner.member.none", + fields: + "id,created,scan_date,attendee_first_name,attendee_last_name,attendee_email,attendee_company,scanned_by.email,scanned_by.first_name,scanned_by.last_name,badge.ticket,badge.ticket.owner,badge.ticket.owner.member.first_name,badge.ticket.owner.member.last_name,badge.ticket.owner.email,badge.ticket.owner.company,badge.ticket.owner.first_name,badge.ticket.owner.last_name" + }; - if (filter.length > 0) { - params["filter[]"] = filter; - } + if (filter.length > 0) { + params["filter[]"] = filter; + } - // order - if (order != null && orderDir != null) { - const orderDirSign = orderDir === 1 ? "+" : "-"; - params.order = `${orderDirSign}${order}`; - } + // order + if (order != null && orderDir != null) { + const orderDirSign = orderDir === 1 ? "+" : "-"; + params.order = `${orderDirSign}${order}`; + } - return getRequest( - createAction(REQUEST_BADGE_SCANS), - createAction(RECEIVE_BADGE_SCANS), - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/badge-scans`, - authErrorHandler, - { page, perPage, order, orderDir, sponsorId, summitTZ } - )(params)(dispatch).then(() => { - dispatch(stopLoading()); - }); - }; + return getRequest( + createAction(REQUEST_BADGE_SCANS), + createAction(RECEIVE_BADGE_SCANS), + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/badge-scans`, + authErrorHandler, + { page, perPage, order, orderDir, sponsorId, summitTZ } + )(params)(dispatch).then(() => { + dispatch(stopLoading()); + }); + }; export const exportBadgeScans = (sponsor = null, order = "attendee_last_name", orderDir = 1) => - async (dispatch, getState) => { - const { currentSummitState } = getState(); - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; - const filter = []; - const filename = `${sponsor.company.name}-BadgeScans.csv`; - const params = { - access_token: accessToken, - columns: - "scan_date,scanned_by,attendee_first_name,attendee_last_name,attendee_email,attendee_company" - }; + async (dispatch, getState) => { + const { currentSummitState } = getState(); + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; + const filter = []; + const filename = `${sponsor.company.name}-BadgeScans.csv`; + const params = { + access_token: accessToken, + columns: + "scan_date,scanned_by,attendee_first_name,attendee_last_name,attendee_email,attendee_company" + }; - filter.push(`sponsor_id==${sponsor.id}`); + filter.push(`sponsor_id==${sponsor.id}`); - if (filter.length > 0) { - params["filter[]"] = filter; - } + if (filter.length > 0) { + params["filter[]"] = filter; + } - // order - if (order != null && orderDir != null) { - const orderDirSign = orderDir === 1 ? "+" : "-"; - params.order = `${orderDirSign}${order}`; - } + // order + if (order != null && orderDir != null) { + const orderDirSign = orderDir === 1 ? "+" : "-"; + params.order = `${orderDirSign}${order}`; + } - dispatch( - getCSV( - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/badge-scans/csv`, - params, - filename - ) - ); - }; + dispatch( + getCSV( + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/badge-scans/csv`, + params, + filename + ) + ); + }; export const getBadgeScan = (scanId) => async (dispatch, getState) => { const { currentSummitState } = getState(); @@ -1124,10 +1124,10 @@ export const attachSponsorImage = picAttr === "header_image" ? uploadHeaderImage : picAttr === "side_image" - ? uploadSideImage - : picAttr === "header_mobile_image" - ? uploadHeaderMobileImage - : uploadCarouselImage; + ? uploadSideImage + : picAttr === "header_mobile_image" + ? uploadHeaderMobileImage + : uploadCarouselImage; if (entity.id) { dispatch(uploadFile(entity, file)); @@ -1245,10 +1245,10 @@ export const removeSponsorImage = (entity, picAttr) => async (dispatch) => { picAttr === "header_image" ? removeHeaderImage : picAttr === "side_image" - ? removeSideImage - : picAttr === "header_mobile_image" - ? removeHeaderMobileImage - : removeCarouselImage; + ? removeSideImage + : picAttr === "header_mobile_image" + ? removeHeaderMobileImage + : removeCarouselImage; return dispatch(removeFile(entity)); }; @@ -1336,32 +1336,32 @@ export const removeCarouselImage = (entity) => async (dispatch, getState) => { export const getSponsorAdvertisements = (sponsorId, order = "order", orderDir = 1) => - async (dispatch, getState) => { - const { currentSummitState } = getState(); - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; + async (dispatch, getState) => { + const { currentSummitState } = getState(); + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; - dispatch(startLoading()); + dispatch(startLoading()); - const params = { - access_token: accessToken - }; + const params = { + access_token: accessToken + }; - // order - if (order != null && orderDir != null) { - const orderDirSign = orderDir === 1 ? "+" : "-"; - params.order = `${orderDirSign}${order}`; - } + // order + if (order != null && orderDir != null) { + const orderDirSign = orderDir === 1 ? "+" : "-"; + params.order = `${orderDirSign}${order}`; + } - return getRequest( - null, - createAction(RECEIVE_SPONSOR_ADVERTISEMENTS), - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/ads`, - authErrorHandler - )(params)(dispatch).then(() => { - dispatch(stopLoading()); - }); - }; + return getRequest( + null, + createAction(RECEIVE_SPONSOR_ADVERTISEMENTS), + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/ads`, + authErrorHandler + )(params)(dispatch).then(() => { + dispatch(stopLoading()); + }); + }; export const saveSponsorAdvertisement = (entity) => async (dispatch, getState) => { @@ -1581,32 +1581,32 @@ export const removeSponsorAdvertisementImage = export const getSponsorMaterials = (sponsorId, order = "order", orderDir = 1) => - async (dispatch, getState) => { - const { currentSummitState } = getState(); - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; + async (dispatch, getState) => { + const { currentSummitState } = getState(); + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; - dispatch(startLoading()); + dispatch(startLoading()); - const params = { - access_token: accessToken - }; + const params = { + access_token: accessToken + }; - // order - if (order != null && orderDir != null) { - const orderDirSign = orderDir === 1 ? "+" : "-"; - params.order = `${orderDirSign}${order}`; - } + // order + if (order != null && orderDir != null) { + const orderDirSign = orderDir === 1 ? "+" : "-"; + params.order = `${orderDirSign}${order}`; + } - return getRequest( - null, - createAction(RECEIVE_SPONSOR_MATERIALS), - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/materials`, - authErrorHandler - )(params)(dispatch).then(() => { - dispatch(stopLoading()); - }); - }; + return getRequest( + null, + createAction(RECEIVE_SPONSOR_MATERIALS), + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/materials`, + authErrorHandler + )(params)(dispatch).then(() => { + dispatch(stopLoading()); + }); + }; export const saveSponsorMaterial = (entity) => async (dispatch, getState) => { const { currentSummitState, currentSponsorState } = getState(); @@ -1928,91 +1928,91 @@ export const getSponsorPromocodes = order = "order", orderDir = 1 ) => - async (dispatch, getState) => { - const { currentSummitState } = getState(); - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; - const filter = []; + async (dispatch, getState) => { + const { currentSummitState } = getState(); + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; + const filter = []; - dispatch(startLoading()); + dispatch(startLoading()); - if (term) { - const escapedTerm = escapeFilterValue(term); - filter.push( - `sponsor_company_name@@${escapedTerm},tier_name@@${escapedTerm},code@@${escapedTerm}` - ); - } + if (term) { + const escapedTerm = escapeFilterValue(term); + filter.push( + `sponsor_company_name@@${escapedTerm},tier_name@@${escapedTerm},code@@${escapedTerm}` + ); + } - const params = { - page, - per_page: perPage, - expand: - "sponsor,owner,sponsor.company,sponsor.sponsorship,sponsor.sponsorship.type,badge_features,allowed_ticket_types,ticket_types_rules,ticket_types_rules.ticket_type", - access_token: accessToken - }; + const params = { + page, + per_page: perPage, + expand: + "sponsor,owner,sponsor.company,sponsor.sponsorship,sponsor.sponsorship.type,badge_features,allowed_ticket_types,ticket_types_rules,ticket_types_rules.ticket_type", + access_token: accessToken + }; - if (filter.length > 0) { - params["filter[]"] = filter; - } + if (filter.length > 0) { + params["filter[]"] = filter; + } - // order - if (order != null && orderDir != null) { - const orderDirSign = orderDir === 1 ? "+" : "-"; - params.order = `${orderDirSign}${order}`; - } + // order + if (order != null && orderDir != null) { + const orderDirSign = orderDir === 1 ? "+" : "-"; + params.order = `${orderDirSign}${order}`; + } - return getRequest( - createAction(REQUEST_SPONSOR_PROMOCODES), - createAction(RECEIVE_SPONSOR_PROMOCODES), - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsor-promo-codes`, - authErrorHandler, - { page, perPage, order, orderDir, term } - )(params)(dispatch).then(() => { - dispatch(stopLoading()); - }); - }; + return getRequest( + createAction(REQUEST_SPONSOR_PROMOCODES), + createAction(RECEIVE_SPONSOR_PROMOCODES), + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsor-promo-codes`, + authErrorHandler, + { page, perPage, order, orderDir, term } + )(params)(dispatch).then(() => { + dispatch(stopLoading()); + }); + }; export const exportSponsorPromocodes = (term = null, order = "order", orderDir = 1) => - async (dispatch, getState) => { - const { currentSummitState } = getState(); - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; - const filter = []; - const filename = `${currentSummit.name}-SponsorPromocodes.csv`; + async (dispatch, getState) => { + const { currentSummitState } = getState(); + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; + const filter = []; + const filename = `${currentSummit.name}-SponsorPromocodes.csv`; - dispatch(startLoading()); + dispatch(startLoading()); - if (term) { - const escapedTerm = escapeFilterValue(term); - filter.push( - `sponsor_company_name@@${escapedTerm},tier_name@@${escapedTerm},code@@${escapedTerm}` - ); - } + if (term) { + const escapedTerm = escapeFilterValue(term); + filter.push( + `sponsor_company_name@@${escapedTerm},tier_name@@${escapedTerm},code@@${escapedTerm}` + ); + } - const params = { - expand: "", - access_token: accessToken - }; + const params = { + expand: "", + access_token: accessToken + }; - if (filter.length > 0) { - params["filter[]"] = filter; - } + if (filter.length > 0) { + params["filter[]"] = filter; + } - // order - if (order != null && orderDir != null) { - const orderDirSign = orderDir === 1 ? "+" : "-"; - params.order = `${orderDirSign}${order}`; - } + // order + if (order != null && orderDir != null) { + const orderDirSign = orderDir === 1 ? "+" : "-"; + params.order = `${orderDirSign}${order}`; + } - dispatch( - getCSV( - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsor-promo-codes/csv`, - params, - filename - ) - ); - }; + dispatch( + getCSV( + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsor-promo-codes/csv`, + params, + filename + ) + ); + }; export const importSponsorPromocodesCSV = (file) => async (dispatch, getState) => { @@ -2039,67 +2039,67 @@ export const importSponsorPromocodesCSV = export const sendEmails = (recipientEmail = null) => - async (dispatch, getState) => { - const { currentSummitState, currentSponsorPromocodeListState } = getState(); - const { term, currentFlowEvent, selectedAll, selectedIds, excludedIds } = - currentSponsorPromocodeListState; - const accessToken = await getAccessTokenSafely(); - const { currentSummit } = currentSummitState; - const filter = []; - - const params = { - access_token: accessToken - }; + async (dispatch, getState) => { + const { currentSummitState, currentSponsorPromocodeListState } = getState(); + const { term, currentFlowEvent, selectedAll, selectedIds, excludedIds } = + currentSponsorPromocodeListState; + const accessToken = await getAccessTokenSafely(); + const { currentSummit } = currentSummitState; + const filter = []; - if (!selectedAll && selectedIds.length > 0) { - // we don't need the filter criteria, we have the ids - filter.push(`id==${selectedIds.join("||")}`); - } else { - if (term) { - const escapedTerm = escapeFilterValue(term); - filter.push( - `sponsor_company_name@@${escapedTerm},tier_name@@${escapedTerm},code@@${escapedTerm}` - ); - } + const params = { + access_token: accessToken + }; - if (selectedAll && excludedIds.length > 0) { - filter.push(`not_id==${excludedIds.join("||")}`); - } + if (!selectedAll && selectedIds.length > 0) { + // we don't need the filter criteria, we have the ids + filter.push(`id==${selectedIds.join("||")}`); + } else { + if (term) { + const escapedTerm = escapeFilterValue(term); + filter.push( + `sponsor_company_name@@${escapedTerm},tier_name@@${escapedTerm},code@@${escapedTerm}` + ); } - if (filter.length > 0) { - params["filter[]"] = filter; + if (selectedAll && excludedIds.length > 0) { + filter.push(`not_id==${excludedIds.join("||")}`); } + } - const payload = { - email_flow_event: currentFlowEvent - }; + if (filter.length > 0) { + params["filter[]"] = filter; + } - if (recipientEmail) { - payload.test_email_recipient = recipientEmail; - } + const payload = { + email_flow_event: currentFlowEvent + }; - dispatch(startLoading()); + if (recipientEmail) { + payload.test_email_recipient = recipientEmail; + } - const success_message = { - title: T.translate("general.done"), - html: T.translate("registration_invitation_list.resend_done"), - type: "success" - }; + dispatch(startLoading()); - return putRequest( - null, - createAction(SEND_SPONSOR_PROMOCODES_EMAILS), - `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors/all/promo-codes/all/send`, - payload, - authErrorHandler - )(params)(dispatch).then((payload) => { - dispatch(showMessage(success_message)); - dispatch(stopLoading()); - return payload; - }); + const success_message = { + title: T.translate("general.done"), + html: T.translate("registration_invitation_list.resend_done"), + type: "success" }; + return putRequest( + null, + createAction(SEND_SPONSOR_PROMOCODES_EMAILS), + `${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsors/all/promo-codes/all/send`, + payload, + authErrorHandler + )(params)(dispatch).then((payload) => { + dispatch(showMessage(success_message)); + dispatch(stopLoading()); + return payload; + }); + }; + /** **************** LEAD REPORT SETTINGS *************************************** */ export const getSponsorLeadReportSettingsMeta = diff --git a/src/actions/summit-actions.js b/src/actions/summit-actions.js index f60fb0fa7..74be94c79 100644 --- a/src/actions/summit-actions.js +++ b/src/actions/summit-actions.js @@ -63,7 +63,6 @@ export const getSummitById = (summitId) => async (dispatch) => { "track_groups," + "locations," + "locations.rooms," + - "locations.attributes.type," + "locations.floor," + "meeting_booking_room_allowed_attributes," + "meeting_booking_room_allowed_attributes.values," + @@ -74,8 +73,112 @@ export const getSummitById = (summitId) => async (dispatch) => { "badge_types," + "badge_features_types," + "badge_access_level_types," + - "badge_view_types," + - "tax_types" + "badge_view_types", + fields: + "id," + + "name," + + "active," + + "allow_update_attendee_extra_questions," + + "available_on_api," + + "calendar_sync_desc," + + "calendar_sync_name," + + "dates_label," + + "end_date," + + "event_types,event_types.id,event_types.name,event_types.order" + + "link," + + "locations,locations.id,locations.name,locations.order,locations.class_name,locations.rooms,locations.floors," + + "logo," + + "secondary_logo," + + "presentation_voters_count," + + "presentation_votes_count," + + "presentations_submitted_count," + + "published_events_count," + + "reassign_ticket_till_date," + + "registration_begin_date," + + "registration_end_date," + + "registration_link," + + "registration_disclaimer_content," + + "registration_disclaimer_mandatory," + + "registration_slug_prefix," + + "schedule_start_date," + + "secondary_registration_label," + + "secondary_registration_link," + + "speaker_announcement_email_accepted_alternate_count," + + "speaker_announcement_email_accepted_count," + + "speaker_announcement_email_accepted_rejected_count," + + "speaker_announcement_email_alternate_count," + + "speaker_announcement_email_alternate_rejected_count," + + "speaker_announcement_email_rejected_count," + + "speakers_count," + + "start_date," + + "start_showing_venues_date," + + "slug," + + "supported_currencies," + + "default_ticket_type_currency," + + "ticket_types,ticket_types.id,ticket_types.name," + + "time_zone_id," + + "time_zone_label," + + "tracks,tracks.id,tracks.name,tracks.parent_id,tracks.order,tracks.chair_visible,tracks.subtracks," + + "selection_plans,selection_plans.id,selection_plans.name,selection_plans.is_enabled,selection_plans.order,selection_plans.submission_begin_date,selection_plans.submission_end_date,selection_plans.voting_begin_date,selection_plans.voting_end_date,selection_plans.selection_begin_date,selection_plans.selection_end_date,selection_plans.track_groups," + + "meeting_booking_room_allowed_attributes,meeting_booking_room_allowed_attributes.id,meeting_booking_room_allowed_attributes.created,meeting_booking_room_allowed_attributes.last_edited,meeting_booking_room_allowed_attributes.type,meeting_booking_room_allowed_attributes.summit_id,meeting_booking_room_allowed_attributes.values.value," + + "meeting_room_booking_end_time," + + "meeting_room_booking_max_allowed," + + "meeting_room_booking_slot_length," + + "meeting_room_booking_start_time," + + "api_feed_type," + + "api_feed_url," + + "api_feed_key," + + "badge_access_level_types,badge_access_level_types.id,badge_access_level_types.name," + + "badge_types,badge_types.id,badge_types.name,badge_types.allowed_view_types," + + "badge_features," + + "badge_view_types,badge_view_types.id,badge_view_types.name," + + "order_extra_questions," + + "begin_allow_booking_date," + + "end_allow_booking_date," + + "external_summit_id," + + "external_registration_feed_type," + + "external_registration_feed_api_key," + + "virtual_site_url," + + "marketing_site_url," + + "mux_token_id," + + "mux_token_secret," + + "mux_allowed_domains,mux_allowed_domains.label,mux_allowed_domains.value," + + "help_users," + + "registration_send_qr_as_image_attachment_on_ticket_email," + + "registration_send_ticket_as_pdf_attachment_on_ticket_email," + + "registration_allow_automatic_reminder_emails," + + "registration_send_order_email_automatically," + + "qr_codes_enc_key," + + "speaker_confirmation_default_page_url," + + "marketing_site_oauth2_client_id," + + "marketing_site_oauth2_client_scopes," + + "available_lead_report_columns," + + "created," + + "last_edited," + + "invite_only_registration," + + "registration_reminder_email_days_interval," + + "support_email," + + "speakers_support_email," + + "registration_send_ticket_email_automatically," + + "registration_allowed_refund_request_till_date," + + "default_ticket_type_currency_symbol," + + "virtual_site_oauth2_client_id," + + "paid_tickets_count," + + "track_groups,track_groups.id,track_groups.name," + + "lead_report_settings,lead_report_settings.sponsor_id,lead_report_settings.columns," + + "presentation_action_types,presentation_action_types.id,presentation_action_types.label," + + "badge_features_types,badge_features_types.id,badge_features_types.name," + + "", + relations: + "event_types.none," + + "tracks.none," + + "tracks_groups.none," + + "locations,locations.rooms,locations.floor,locations.none," + + "meeting_booking_room_allowed_attributes.values," + + "selection_plans.track_groups,selection_plans.none," + + "ticket_types.none," + + "badge_types.none," + + "none" }; // set id diff --git a/src/actions/summit-builder-actions.js b/src/actions/summit-builder-actions.js index 24ec0975e..d3d812997 100644 --- a/src/actions/summit-builder-actions.js +++ b/src/actions/summit-builder-actions.js @@ -270,7 +270,7 @@ export const changeSource = (selectedSource) => (dispatch) => { export const getPublishedEventsBySummitDayLocation = (currentSummit, currentDay, currentLocation) => async (dispatch) => { const accessToken = await getAccessTokenSafely(); - currentDay = moment.tz(currentDay, currentSummit.time_zone.name); + currentDay = moment.tz(currentDay, currentSummit.time_zone_id); const startDate = currentDay.clone().hours(0).minutes(0).seconds(0).valueOf() / MILLISECONDS_IN_SECOND; @@ -317,7 +317,7 @@ export const getShowAlwaysEvents = const accessToken = await getAccessTokenSafely(); const proposedSchedDayMoment = moment.tz( proposedSchedDay, - summit.time_zone.name + summit.time_zone_id ); const startDate = proposedSchedDayMoment.clone().hours(0).minutes(0).seconds(0).valueOf() / @@ -366,7 +366,7 @@ export const getProposedEvents = const accessToken = await getAccessTokenSafely(); const proposedSchedDayMoment = moment.tz( proposedSchedDay, - summit.time_zone.name + summit.time_zone_id ); const startDate = proposedSchedDayMoment.clone().hours(0).minutes(0).seconds(0).valueOf() / diff --git a/src/actions/ticket-actions.js b/src/actions/ticket-actions.js index 7c81487d6..848a9c8d3 100644 --- a/src/actions/ticket-actions.js +++ b/src/actions/ticket-actions.js @@ -893,7 +893,7 @@ export const getTicketTypes = dispatch(startLoading()); - const summitTZ = currentSummit.time_zone.name; + const summitTZ = currentSummit.time_zone_id; const params = { page: currentPage, diff --git a/src/components/forms/tax-type-form.js b/src/components/forms/tax-type-form.js index 71a6db7bf..22d92d5d6 100644 --- a/src/components/forms/tax-type-form.js +++ b/src/components/forms/tax-type-form.js @@ -9,7 +9,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - **/ + * */ import React from "react"; import T from "i18n-react/dist/i18n-react"; @@ -19,6 +19,7 @@ import { SimpleLinkList } from "openstack-uicore-foundation/lib/components"; import { isEmpty, scrollToError, shallowEqual } from "../../utils/methods"; +import { MILLISECONDS_IN_SECOND } from "../../utils/constants"; class TaxTypeForm extends React.Component { constructor(props) { @@ -36,7 +37,7 @@ class TaxTypeForm extends React.Component { this.handleSubmit = this.handleSubmit.bind(this); } - componentDidUpdate(prevProps, prevState, snapshot) { + componentDidUpdate(prevProps) { const state = {}; scrollToError(this.props.errors); @@ -55,8 +56,8 @@ class TaxTypeForm extends React.Component { } handleChange(ev) { - let entity = { ...this.state.entity }; - let errors = { ...this.state.errors }; + const newEntity = { ...this.state.entity }; + const newErrors = { ...this.state.errors }; let { value, id } = ev.target; if (ev.target.type === "checkbox") { @@ -64,23 +65,23 @@ class TaxTypeForm extends React.Component { } if (ev.target.type === "datetime") { - value = value.valueOf() / 1000; + value = value.valueOf() / MILLISECONDS_IN_SECOND; } - errors[id] = ""; - entity[id] = value; - this.setState({ entity: entity, errors: errors }); + newErrors[id] = ""; + newEntity[id] = value; + this.setState({ entity: newEntity, errors: newErrors }); } handleSubmit(ev) { - let entity = { ...this.state.entity }; + const entity = { ...this.state.entity }; ev.preventDefault(); - this.props.onSubmit(this.state.entity); + this.props.onSubmit(entity); } hasErrors(field) { - let { errors } = this.state; + const { errors } = this.state; if (field in errors) { return errors[field]; } @@ -111,9 +112,8 @@ class TaxTypeForm extends React.Component { render() { const { entity } = this.state; - const { currentSummit } = this.props; - let ticketColumns = [ + const ticketColumns = [ { columnKey: "name", value: T.translate("edit_tax_type.name") }, { columnKey: "description", @@ -121,7 +121,7 @@ class TaxTypeForm extends React.Component { } ]; - let ticketOptions = { + const ticketOptions = { title: T.translate("edit_tax_type.ticket_types"), valueKey: "name", labelKey: "name", diff --git a/src/components/schedule-builder/schedule-admin-dashboard.js b/src/components/schedule-builder/schedule-admin-dashboard.js index 55a4ccb72..9d8f78ebe 100644 --- a/src/components/schedule-builder/schedule-admin-dashboard.js +++ b/src/components/schedule-builder/schedule-admin-dashboard.js @@ -9,12 +9,27 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - **/ + * */ import React from "react"; import { HTML5Backend } from "react-dnd-html5-backend"; import { DndProvider } from "react-dnd"; import { Modal } from "react-bootstrap"; import { connect } from "react-redux"; +import { + BulkActionEdit, + BulkActionUnPublish +} from "openstack-uicore-foundation/lib/components/schedule-builder-constants"; +import T from "i18n-react/dist/i18n-react"; +import moment from "moment-timezone"; +import * as Scroll from "react-scroll"; +import Swal from "sweetalert2"; +import { + Dropdown, + OperatorInput, + BulkActionsSelector, + ScheduleBuilderView +} from "openstack-uicore-foundation/lib/components"; +import { SummitEvent } from "openstack-uicore-foundation/lib/models"; import { getUnScheduleEventsPage, publishEvent, @@ -49,10 +64,6 @@ import { unPublishBulkAction } from "../../actions/summit-event-bulk-actions"; import UnScheduleEventList from "./unschedule-event-list"; -import { - BulkActionEdit, - BulkActionUnPublish -} from "openstack-uicore-foundation/lib/components/schedule-builder-constants"; import ScheduleAdminEventTypeSelector from "./schedule-admin-event-type-selector"; import ScheduleAdminTrackSelector from "./schedule-admin-track-selector"; import ScheduleAdminPresentationSelectionStatusSelector from "./schedule-admin-presentation-selection-status-selector"; @@ -61,21 +72,16 @@ import ScheduleAdminSearchFreeTextUnScheduleEvents from "./schedule-admin-search import ScheduleAdminSearchFreeTextScheduleEvents from "./schedule-admin-search-free-text-schedule-events"; import ScheduleAdminScheduleEventsSearchResults from "./schedule-admin-schedule-events-search-results"; import ScheduleAdminOrderSelector from "./schedule-admin-order-selector"; -import T from "i18n-react/dist/i18n-react"; -import moment from "moment-timezone"; import FragmentParser from "../../utils/fragmen-parser"; -import * as Scroll from "react-scroll"; -import Swal from "sweetalert2"; import ScheduleAdminEmptySpotsModal from "./schedule-admin-empty-spots-modal"; import ScheduleAdminEmptySpotsList from "./schedule-admin-empty-spots-list"; -import { - Dropdown, - OperatorInput, - BulkActionsSelector, - ScheduleBuilderView -} from "openstack-uicore-foundation/lib/components"; -import { SummitEvent } from "openstack-uicore-foundation/lib/models"; import UnlockScheduleButton from "../UnlockScheduleButton"; +import { + MILLISECONDS_IN_SECOND, + MINUTE_STEP_SIZE_5, + TIMEOUT_1500, + TWENTY_PER_PAGE +} from "../../utils/constants"; class ScheduleAdminDashBoard extends React.Component { constructor(props) { @@ -141,13 +147,13 @@ class ScheduleAdminDashBoard extends React.Component { if (!currentSummit) return; - for (let key in hash) { - let value = hash[key]; + for (const key in hash) { + const value = hash[key]; switch (key) { case "day": filters.currentDay = value; break; - case "location_id": + case "location_id": { const location = currentSummit.locations .filter((l) => l.id === parseInt(value)) .shift(); @@ -155,10 +161,11 @@ class ScheduleAdminDashBoard extends React.Component { filters.currentLocation = location; } if (value === 0) { - //special case TBD location + // special case TBD location filters.currentLocation = { id: 0, name: "TBD" }; } break; + } case "event": filters.currentEvent = value; break; @@ -195,7 +202,7 @@ class ScheduleAdminDashBoard extends React.Component { this.props.getUnScheduleEventsPage( currentSummit.id, 1, - 20, + TWENTY_PER_PAGE, eventTypeId, trackId, currentPresentationSelectionStatus, @@ -221,7 +228,7 @@ class ScheduleAdminDashBoard extends React.Component { this.filters.currentLocation ); - window.onhashchange = (event) => { + window.onhashchange = () => { if (this.byPassHashRefresh) { this.byPassHashRefresh = false; return; @@ -271,16 +278,15 @@ class ScheduleAdminDashBoard extends React.Component { onScheduleEvent(event, currentDay, startDateTime, duration = null) { const eventModel = new SummitEvent(event, this.props.currentSummit); - const newDuration = duration - ? duration - : eventModel.getMinutesDuration(this.props.slotSize); + const newDuration = + duration || eventModel.getMinutesDuration(this.props.slotSize); this.props.publishEvent(event, currentDay, startDateTime, newDuration); } onDayChanged(day) { - let { currentLocation } = this.props; + const { currentLocation } = this.props; this.props.changeCurrentSelectedDay(day); - let locationId = currentLocation != null ? currentLocation.id : null; + const locationId = currentLocation != null ? currentLocation.id : null; this.buildFragment(locationId, day); this.filters = this.parseFilterFromFragment(); this.byPassHashRefresh = true; @@ -288,7 +294,7 @@ class ScheduleAdminDashBoard extends React.Component { } onVenueChanged(location) { - let { currentDay } = this.props; + const { currentDay } = this.props; this.props.changeCurrentSelectedLocation(location); this.buildFragment(location.id, currentDay); this.filters = this.parseFilterFromFragment(); @@ -336,12 +342,12 @@ class ScheduleAdminDashBoard extends React.Component { currentUnScheduleOrderBy, currentDuration } = this.props; - let trackId = currentTrack == null ? null : currentTrack.id; - let eventTypeId = currentEventType == null ? null : currentEventType.id; + const trackId = currentTrack == null ? null : currentTrack.id; + const eventTypeId = currentEventType == null ? null : currentEventType.id; this.props.getUnScheduleEventsPage( currentSummit.id, currentPage, - 20, + TWENTY_PER_PAGE, eventTypeId, trackId, currentPresentationSelectionStatus, @@ -363,8 +369,8 @@ class ScheduleAdminDashBoard extends React.Component { currentUnScheduleOrderBy, currentDuration } = this.props; - let trackId = currentTrack == null ? null : currentTrack.id; - let eventTypeId = eventType == null ? null : eventType.id; + const trackId = currentTrack == null ? null : currentTrack.id; + const eventTypeId = eventType == null ? null : eventType.id; let selectionStatus = currentPresentationSelectionStatus; let order = currentUnScheduleOrderBy; if (!eventType || eventType.class_name !== "PresentationType") { @@ -377,7 +383,7 @@ class ScheduleAdminDashBoard extends React.Component { this.props.getUnScheduleEventsPage( currentSummit.id, 1, - 20, + TWENTY_PER_PAGE, eventTypeId, trackId, selectionStatus, @@ -398,13 +404,13 @@ class ScheduleAdminDashBoard extends React.Component { currentUnScheduleOrderBy, currentDuration } = this.props; - let eventTypeId = currentEventType == null ? null : currentEventType.id; - let trackId = track == null ? null : track.id; + const eventTypeId = currentEventType == null ? null : currentEventType.id; + const trackId = track == null ? null : track.id; this.props.changeCurrentTrack(track); this.props.getUnScheduleEventsPage( currentSummit.id, 1, - 20, + TWENTY_PER_PAGE, eventTypeId, trackId, currentPresentationSelectionStatus, @@ -425,8 +431,8 @@ class ScheduleAdminDashBoard extends React.Component { currentUnScheduleOrderBy, currentDuration } = this.props; - let eventTypeId = currentEventType == null ? null : currentEventType.id; - let trackId = currentTrack == null ? null : currentTrack.id; + const eventTypeId = currentEventType == null ? null : currentEventType.id; + const trackId = currentTrack == null ? null : currentTrack.id; let order = currentUnScheduleOrderBy; if (!presentationSelectionStatus) { @@ -443,7 +449,7 @@ class ScheduleAdminDashBoard extends React.Component { this.props.getUnScheduleEventsPage( currentSummit.id, 1, - 20, + TWENTY_PER_PAGE, eventTypeId, trackId, presentationSelectionStatus, @@ -464,9 +470,9 @@ class ScheduleAdminDashBoard extends React.Component { currentUnScheduleOrderBy, currentDuration } = this.props; - let eventTypeId = currentEventType == null ? null : currentEventType.id; - let trackId = currentTrack == null ? null : currentTrack.id; - let order = currentUnScheduleOrderBy; + const eventTypeId = currentEventType == null ? null : currentEventType.id; + const trackId = currentTrack == null ? null : currentTrack.id; + const order = currentUnScheduleOrderBy; this.props.changeCurrentPresentationSelectionPlan( presentationSelectionPlan @@ -474,7 +480,7 @@ class ScheduleAdminDashBoard extends React.Component { this.props.getUnScheduleEventsPage( currentSummit.id, 1, - 20, + TWENTY_PER_PAGE, eventTypeId, trackId, currentPresentationSelectionStatus, @@ -494,13 +500,13 @@ class ScheduleAdminDashBoard extends React.Component { currentPresentationSelectionPlan, currentDuration } = this.props; - let eventTypeId = currentEventType == null ? null : currentEventType.id; - let trackId = currentTrack == null ? null : currentTrack.id; + const eventTypeId = currentEventType == null ? null : currentEventType.id; + const trackId = currentTrack == null ? null : currentTrack.id; this.props.changeCurrentUnscheduleSearchTerm(term); this.props.getUnScheduleEventsPage( currentSummit.id, 1, - 20, + TWENTY_PER_PAGE, eventTypeId, trackId, currentPresentationSelectionStatus, @@ -568,14 +574,14 @@ class ScheduleAdminDashBoard extends React.Component { window.location.hash = this.fragmentParser.serialize(); this.filters = this.parseFilterFromFragment(); } - }, 1500); + }, TIMEOUT_1500); } scrollToElement(elementId) { - var el = document.getElementById(elementId); + const el = document.getElementById(elementId); if (!el) return; - let yPos = el.getClientRects()[0].top; - var scroll = Scroll.animateScroll; + const yPos = el.getClientRects()[0].top; + const scroll = Scroll.animateScroll; scroll.scrollTo(yPos, { duration: 1500, @@ -585,7 +591,7 @@ class ScheduleAdminDashBoard extends React.Component { } onEditEvent(event) { - let { history, currentSummit } = this.props; + const { history, currentSummit } = this.props; history.push(`/app/summits/${currentSummit.id}/events/${event.id}`); } @@ -614,7 +620,7 @@ class ScheduleAdminDashBoard extends React.Component { } onOrderByChanged(orderBy) { - let { + const { currentSummit, currentEventType, currentTrack, @@ -624,14 +630,14 @@ class ScheduleAdminDashBoard extends React.Component { unScheduleEventsCurrentSearchTerm, unScheduleEventsCurrentPage } = this.props; - let eventTypeId = currentEventType == null ? null : currentEventType.id; - let trackId = currentTrack == null ? null : currentTrack.id; + const eventTypeId = currentEventType == null ? null : currentEventType.id; + const trackId = currentTrack == null ? null : currentTrack.id; this.props.changeCurrentUnScheduleOrderBy(orderBy); this.props.getUnScheduleEventsPage( currentSummit.id, unScheduleEventsCurrentPage, - 20, + TWENTY_PER_PAGE, eventTypeId, trackId, currentPresentationSelectionStatus, @@ -661,9 +667,9 @@ class ScheduleAdminDashBoard extends React.Component { onClickSpot(spot) { const { currentSummit } = this.props; - let start_date = moment.tz( - spot.start_date * 1000, - currentSummit.time_zone.name + const start_date = moment.tz( + spot.start_date * MILLISECONDS_IN_SECOND, + currentSummit.time_zone_id ); this.fragmentParser.setParam("q", ""); this.fragmentParser.setParam("event", ""); @@ -672,7 +678,7 @@ class ScheduleAdminDashBoard extends React.Component { // round minutes to upper limit let minute = start_date.minute(); - minute = Math.ceil(minute / 5) * 5; + minute = Math.ceil(minute / MINUTE_STEP_SIZE_5) * MINUTE_STEP_SIZE_5; start_date.minute(minute); this.fragmentParser.setParam("time", start_date.format("hh_mm")); window.location.hash = this.fragmentParser.serialize(); @@ -733,14 +739,14 @@ class ScheduleAdminDashBoard extends React.Component { this.props.setBulkEventSelectedState(evt.target.checked); } - onSelectedBulkActionUnPublished(bulkAction) { - let { selectedUnPublishedEvents, selectedAllUnPublished } = this.props; + onSelectedBulkActionUnPublished() { + const { selectedUnPublishedEvents, selectedAllUnPublished } = this.props; if (selectedUnPublishedEvents.length === 0 && !selectedAllUnPublished) return; this.props.editBulkAction("unpublished"); } - onDurationFilterApplied(ev) { + onDurationFilterApplied() { const { currentSummit, currentEventType, @@ -750,14 +756,14 @@ class ScheduleAdminDashBoard extends React.Component { unScheduleEventsCurrentSearchTerm, currentUnScheduleOrderBy } = this.props; - let eventTypeId = currentEventType == null ? null : currentEventType.id; - let trackId = currentTrack == null ? null : currentTrack.id; + const eventTypeId = currentEventType == null ? null : currentEventType.id; + const trackId = currentTrack == null ? null : currentTrack.id; const { durationFilter } = this.state; this.props.changeCurrentDuration(durationFilter); this.props.getUnScheduleEventsPage( currentSummit.id, 1, - 20, + TWENTY_PER_PAGE, eventTypeId, trackId, currentPresentationSelectionStatus, @@ -769,7 +775,7 @@ class ScheduleAdminDashBoard extends React.Component { } handleDurationFilter(ev) { - let { value, type, id } = ev.target; + let { value, type } = ev.target; if (type === "operatorinput") { value = Array.isArray(value) ? value @@ -902,8 +908,8 @@ class ScheduleAdminDashBoard extends React.Component { // parse event types const eventTypes = []; for (let i = 0; i < currentSummit.event_types.length; i++) { - let event_type = currentSummit.event_types[i]; - let option = { value: event_type, label: event_type.name }; + const event_type = currentSummit.event_types[i]; + const option = { value: event_type, label: event_type.name }; if (currentEventType != null && currentEventType.id === event_type.id) currentEventTypeSelectorItem = option; eventTypes.push(option); @@ -912,8 +918,8 @@ class ScheduleAdminDashBoard extends React.Component { // parse tracks const tracks = []; for (let i = 0; i < currentSummit.tracks.length; i++) { - let track = currentSummit.tracks[i]; - let option = { value: track, label: track.name }; + const track = currentSummit.tracks[i]; + const option = { value: track, label: track.name }; if (currentTrack != null && currentTrack.id === track.id) currentTrackSelectorItem = option; tracks.push(option); @@ -921,7 +927,7 @@ class ScheduleAdminDashBoard extends React.Component { // presentation selection status - let presentationSelectionStatusOptions = [ + const presentationSelectionStatusOptions = [ { value: "selected", label: "Selected" }, { value: "accepted", label: "Accepted" }, { value: "rejected", label: "Rejected" }, @@ -930,33 +936,22 @@ class ScheduleAdminDashBoard extends React.Component { // selection plan options - let presentationSelectionPlanOptions = currentSummit.selection_plans.map( + const presentationSelectionPlanOptions = currentSummit.selection_plans.map( (sp) => ({ value: sp.id, label: sp.name }) ); // sort options - let orderByOptions = [ + const orderByOptions = [ { value: "title", label: "Title" }, { value: "id", label: "Id" }, { value: "start_date", label: "Start Date" }, { value: "trackchairsel", label: "Track Chair Sel." } ]; - // bulk options published - - let bulkOptionsPublished = [ - { - value: BulkActionEdit, - label: T.translate("published_bulk_actions_selector.options.edit") - }, - { - value: BulkActionUnPublish, - label: T.translate("published_bulk_actions_selector.options.unpublish") - } - ]; + // bulk options unpublished - let bulkOptionsUnPublished = [ + const bulkOptionsUnPublished = [ { value: BulkActionEdit, label: T.translate("published_bulk_actions_selector.options.edit") @@ -1048,8 +1043,8 @@ class ScheduleAdminDashBoard extends React.Component { value={selectedFilters} onChange={this.handleFiltersChange} options={filters_ddl} - isClearable={true} - isMulti={true} + isClearable + isMulti /> @@ -1197,7 +1192,7 @@ class ScheduleAdminDashBoard extends React.Component { /> )} {emptySpots.length === 0 && searchingEmpty && ( - + {T.translate("empty_spots_modal.find_empty_spots")} diff --git a/src/components/schedule-builder/schedule-admin-empty-spots-list.js b/src/components/schedule-builder/schedule-admin-empty-spots-list.js index cbe0e4244..91df893cf 100644 --- a/src/components/schedule-builder/schedule-admin-empty-spots-list.js +++ b/src/components/schedule-builder/schedule-admin-empty-spots-list.js @@ -9,61 +9,62 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - **/ + * */ import React from "react"; import moment from "moment-timezone"; +import { MILLISECONDS_IN_SECOND } from "../../utils/constants"; -class ScheduleAdminEmptySpotsList extends React.Component { - render() { - let { emptySpots, currentSummit, onClickSpot } = this.props; - - let emptySpotsItems = []; - let lastLocation = null; - let idx = 1; - for (let spot of emptySpots) { - if (lastLocation == null || lastLocation.id !== spot.location_id) { - lastLocation = currentSummit.locations - .filter((location) => location.id === spot.location_id) - .shift(); - emptySpotsItems.push( -
  • -

    {lastLocation.name}

    -
  • - ); - ++idx; - } - let start_date = moment.tz( - spot.start_date * 1000, - currentSummit.time_zone.name - ); - let end_date = moment.tz( - spot.end_date * 1000, - currentSummit.time_zone.name - ); +const ScheduleAdminEmptySpotsList = ({ + emptySpots, + currentSummit, + onClickSpot +}) => { + const emptySpotsItems = []; + let lastLocation = null; + let idx = 1; + for (const spot of emptySpots) { + if (lastLocation == null || lastLocation.id !== spot.location_id) { + lastLocation = currentSummit.locations + .filter((location) => location.id === spot.location_id) + .shift(); emptySpotsItems.push( -
  • -
    onClickSpot(spot)} - > - From  - - {start_date.format("YYYY-MM-DD hh:mm")} - - To  - {end_date.format("YYYY-MM-DD hh:mm")} -  - Empty Spot ( - {spot.total_minutes} minutes) -
    +
  • +

    {lastLocation.name}

  • ); ++idx; } - return
      {emptySpotsItems}
    ; + const start_date = moment.tz( + spot.start_date * MILLISECONDS_IN_SECOND, + currentSummit.time_zone_id + ); + const end_date = moment.tz( + spot.end_date * MILLISECONDS_IN_SECOND, + currentSummit.time_zone_id + ); + + emptySpotsItems.push( +
  • +
    onClickSpot(spot)} + > + From  + {start_date.format("YYYY-MM-DD hh:mm")} + To  + {end_date.format("YYYY-MM-DD hh:mm")} +  - Empty Spot ( + {spot.total_minutes} minutes) +
    +
  • + ); + ++idx; } -} + + return
      {emptySpotsItems}
    ; +}; export default ScheduleAdminEmptySpotsList; diff --git a/src/components/schedule-builder/schedule-admin-empty-spots-modal.js b/src/components/schedule-builder/schedule-admin-empty-spots-modal.js index 48449c95f..54ae4ebf9 100644 --- a/src/components/schedule-builder/schedule-admin-empty-spots-modal.js +++ b/src/components/schedule-builder/schedule-admin-empty-spots-modal.js @@ -9,7 +9,7 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - **/ + * */ import { Modal, Button, FormGroup, FormControl } from "react-bootstrap"; import React from "react"; import { @@ -18,20 +18,32 @@ import { } from "openstack-uicore-foundation/lib/components"; import moment from "moment-timezone"; import T from "i18n-react/dist/i18n-react"; +import { + GAP_SIZE, + MILLISECONDS_IN_SECOND, + TIME_19_HOURS, + TIME_7_HOURS +} from "../../utils/constants"; class ScheduleAdminEmptySpotsModal extends React.Component { constructor(props) { super(props); const { currentSummit } = this.props; - let defaultValueStart = moment - .tz(currentSummit.start_date * 1000, currentSummit.time_zone.name) - .hour(7) + const defaultValueStart = moment + .tz( + currentSummit.start_date * MILLISECONDS_IN_SECOND, + currentSummit.time_zone_id + ) + .hour(TIME_7_HOURS) .minute(0) .second(0); - let defaultValueEnd = moment - .tz(currentSummit.start_date * 1000, currentSummit.time_zone.name) - .hour(19) + const defaultValueEnd = moment + .tz( + currentSummit.start_date * MILLISECONDS_IN_SECOND, + currentSummit.time_zone_id + ) + .hour(TIME_19_HOURS) .minute(0) .second(0); @@ -58,7 +70,7 @@ class ScheduleAdminEmptySpotsModal extends React.Component { isValidForm() { let valid = true; - for (var key in this.validationState) { + for (const key in this.validationState) { valid = valid && this.validationState[key]; } return valid; @@ -68,32 +80,32 @@ class ScheduleAdminEmptySpotsModal extends React.Component { if (!this.isValidForm()) return; this.props.onFindEmptySpots({ currentLocation: this.state.currentLocation.value, - dateFrom: this.state.dateFrom.valueOf() / 1000, - dateTo: this.state.dateTo.valueOf() / 1000, + dateFrom: this.state.dateFrom.valueOf() / MILLISECONDS_IN_SECOND, + dateTo: this.state.dateTo.valueOf() / MILLISECONDS_IN_SECOND, gapSize: this.state.gapSize }); } handleChangeDateFrom(ev) { - let { value, id } = ev.target; + const { value } = ev.target; this.setState({ ...this.state, dateFrom: value }); } getValidationDateFrom() { - let { dateFrom } = this.state; - let isValid = dateFrom != null && dateFrom !== ""; + const { dateFrom } = this.state; + const isValid = dateFrom != null && dateFrom !== ""; this.validationState = { ...this.validationState, dateFrom: isValid }; return isValid ? "success" : "warning"; } handleChangeDateTo(ev) { - let { value, id } = ev.target; + const { value } = ev.target; this.setState({ ...this.state, dateTo: value }); } getValidationDateTo() { - let { dateTo, dateFrom } = this.state; - let isValid = + const { dateTo, dateFrom } = this.state; + const isValid = dateTo != null && dateTo !== "" && dateFrom != null && @@ -103,15 +115,15 @@ class ScheduleAdminEmptySpotsModal extends React.Component { } onVenueChanged(location) { - let option = + const option = location != null ? { value: location, label: location.name } : null; this.setState({ ...this.state, currentLocation: option }); } getValidationStateVenue() { - let { currentLocation } = this.state; + const { currentLocation } = this.state; - let isValid = currentLocation != null; + const isValid = currentLocation != null; this.validationState = { ...this.validationState, currentLocation: isValid @@ -126,51 +138,48 @@ class ScheduleAdminEmptySpotsModal extends React.Component { getValidationStateGapSize() { let { gapSize } = this.state; gapSize = parseInt(gapSize); - let isValid = gapSize >= 5; + const isValid = gapSize >= GAP_SIZE; this.validationState = { ...this.validationState, gapSize: isValid }; return isValid ? "success" : "warning"; } render() { - let { showModal, onCloseModal, currentSummit } = this.props; - let { currentLocation, dateFrom, dateTo, gapSize } = this.state; + const { showModal, onCloseModal, currentSummit } = this.props; + const { currentLocation, dateFrom, dateTo, gapSize } = this.state; // process venues - let venues = []; + const venues = []; for (let i = 0; i < currentSummit.locations.length; i++) { - let location = currentSummit.locations[i]; + const location = currentSummit.locations[i]; if (location.class_name !== "SummitVenue") continue; - let option = { value: location, label: location.name }; + const option = { value: location, label: location.name }; venues.push(option); if (!location.hasOwnProperty("rooms")) continue; for (let j = 0; j < location.rooms.length; j++) { - let subOption = { + const subOption = { value: location.rooms[j], label: location.rooms[j].name }; venues.push(subOption); } } - let currenSummitStartDate = moment - .tz(currentSummit.start_date * 1000, currentSummit.time_zone.name) + const currenSummitStartDate = moment + .tz( + currentSummit.start_date * MILLISECONDS_IN_SECOND, + currentSummit.time_zone_id + ) .hour(0) .minute(0) .second(0); - let currenSummitEndDate = moment - .tz(currentSummit.end_date * 1000, currentSummit.time_zone.name) - .hour(23) - .minute(59) - .second(59); - let defaultValueStart = moment - .tz(currentSummit.start_date * 1000, currentSummit.time_zone.name) - .hour(7) - .minute(0) - .second(0); - let defaultValueEnd = moment - .tz(currentSummit.start_date * 1000, currentSummit.time_zone.name) - .hour(22) - .minute(0) - .second(0); + const currenSummitEndDate = moment + .tz( + currentSummit.end_date * MILLISECONDS_IN_SECOND, + currentSummit.time_zone_id + ) + .hour(TIME_23_HOURS) + .minute(TIME_59_MINS) + .second(TIME_59_SECS); + return ( @@ -208,11 +217,14 @@ class ScheduleAdminEmptySpotsModal extends React.Component { "empty_spots_modal.placeholders.start_date" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} timeConstraints={{ hours: { min: 7, max: 22 } }} validation={{ - after: currenSummitStartDate.valueOf() / 1000, - before: currenSummitEndDate.valueOf() / 1000 + after: + currenSummitStartDate.valueOf() / + MILLISECONDS_IN_SECOND, + before: + currenSummitEndDate.valueOf() / MILLISECONDS_IN_SECOND }} onChange={this.handleChangeDateFrom} value={dateFrom} @@ -232,10 +244,13 @@ class ScheduleAdminEmptySpotsModal extends React.Component { "empty_spots_modal.placeholders.end_date" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} validation={{ - after: currenSummitStartDate.valueOf() / 1000, - before: currenSummitEndDate.valueOf() / 1000 + after: + currenSummitStartDate.valueOf() / + MILLISECONDS_IN_SECOND, + before: + currenSummitEndDate.valueOf() / MILLISECONDS_IN_SECOND }} onChange={this.handleChangeDateTo} value={dateTo} diff --git a/src/components/schedule-modal/index.js b/src/components/schedule-modal/index.js index 9d8c75ab2..4dccabdfd 100644 --- a/src/components/schedule-modal/index.js +++ b/src/components/schedule-modal/index.js @@ -9,13 +9,14 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - **/ + * */ import React from "react"; import T from "i18n-react/dist/i18n-react"; import moment from "moment-timezone"; import { Modal } from "react-bootstrap"; import "./schedule-modal.less"; +import { MILLISECONDS_IN_SECOND } from "../../utils/constants"; export default class ScheduleModal extends React.Component { constructor(props) { @@ -25,30 +26,30 @@ export default class ScheduleModal extends React.Component { } getFormattedTime(atime) { - atime = atime * 1000; + atime *= MILLISECONDS_IN_SECOND; return moment(atime).tz(this.props.summit.time_zone.name).format("h:mm a"); } getFormattedDay(atime) { - atime = atime * 1000; + atime *= MILLISECONDS_IN_SECOND; return moment(atime).tz(this.props.summit.time_zone.name).format("dddd D"); } getFormattedLocation(location_id) { - let venue = this.props.summit.locations.find( + const venue = this.props.summit.locations.find( (l) => l.id === location_id ).name; return venue; } getFormatedSchedule() { - let groupedSchedule = {}; - let sortedSchedule = this.props.schedule.sort((a, b) => + const groupedSchedule = {}; + const sortedSchedule = this.props.schedule.sort((a, b) => a.start_date > b.start_date ? 1 : a.start_date < b.start_date ? -1 : 0 ); - for (var i in sortedSchedule) { - let day = this.getFormattedDay(sortedSchedule[i].start_date); + for (const i in sortedSchedule) { + const day = this.getFormattedDay(sortedSchedule[i].start_date); if (!groupedSchedule.hasOwnProperty(day)) groupedSchedule[day] = []; groupedSchedule[day].push(sortedSchedule[i]); } @@ -83,7 +84,7 @@ export default class ScheduleModal extends React.Component { } render() { - let { show, title, onClose, schedule } = this.props; + const { show, title, onClose, schedule } = this.props; return ( diff --git a/src/components/summit-event-bulk-actions/summit-event-bulk-editor-form.js b/src/components/summit-event-bulk-actions/summit-event-bulk-editor-form.js index 93f918f1c..f3a671511 100644 --- a/src/components/summit-event-bulk-actions/summit-event-bulk-editor-form.js +++ b/src/components/summit-event-bulk-actions/summit-event-bulk-editor-form.js @@ -342,7 +342,7 @@ class SummitEventBulkEditorForm extends React.Component { const currentSummitStartDate = moment .tz( currentSummit.start_date * MILLISECONDS_IN_SECOND, - currentSummit.time_zone.name + currentSummit.time_zone_id ) .hour(0) .minute(0) @@ -350,7 +350,7 @@ class SummitEventBulkEditorForm extends React.Component { const currentSummitEndDate = moment .tz( currentSummit.end_date * MILLISECONDS_IN_SECOND, - currentSummit.time_zone.name + currentSummit.time_zone_id ) .hour(TIME_23_HOURS) .minute(TIME_59_MINS) @@ -458,7 +458,7 @@ class SummitEventBulkEditorForm extends React.Component { "bulk_actions_page.placeholders.start_date" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} value={epochToMomentTimeZone( currentBulkStartDate, currentSummit.time_zone_id @@ -485,7 +485,7 @@ class SummitEventBulkEditorForm extends React.Component { "bulk_actions_page.placeholders.end_date" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} value={epochToMomentTimeZone( currentBulkEndDate, currentSummit.time_zone_id diff --git a/src/components/summit-event-bulk-actions/summit-event-bulk-editor-item.js b/src/components/summit-event-bulk-actions/summit-event-bulk-editor-item.js index 100921702..6de864b4f 100644 --- a/src/components/summit-event-bulk-actions/summit-event-bulk-editor-item.js +++ b/src/components/summit-event-bulk-actions/summit-event-bulk-editor-item.js @@ -62,7 +62,7 @@ class SummitEventBulkEditorItem extends React.Component { if (atime == null) return ""; if (!atime) return atime; atime *= MILLISECONDS_IN_SECOND; - return moment(atime).tz(this.props.currentSummit.time_zone.name); + return moment(atime).tz(this.props.currentSummit.time_zone_id); } getValidationEventTitle() { @@ -232,7 +232,7 @@ class SummitEventBulkEditorItem extends React.Component { const currentSummitStartDate = moment .tz( currentSummit.start_date * MILLISECONDS_IN_SECOND, - currentSummit.time_zone.name + currentSummit.time_zone_id ) .hour(0) .minute(0) @@ -240,7 +240,7 @@ class SummitEventBulkEditorItem extends React.Component { const currentSummitEndDate = moment .tz( currentSummit.end_date * MILLISECONDS_IN_SECOND, - currentSummit.time_zone.name + currentSummit.time_zone_id ) .hour(TIME_23_HOURS) .minute(TIME_59_MINS) @@ -316,7 +316,7 @@ class SummitEventBulkEditorItem extends React.Component { "bulk_actions_page.placeholders.start_date" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} timeConstraints={{ hours: { min: 7, max: 22 } }} validation={{ after: @@ -341,7 +341,7 @@ class SummitEventBulkEditorItem extends React.Component { "bulk_actions_page.placeholders.end_date" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} validation={{ after: currentSummitStartDate.valueOf() / MILLISECONDS_IN_SECOND, diff --git a/src/pages/attendees/summit-attendees-list-page.js b/src/pages/attendees/summit-attendees-list-page.js index bff014045..ff97fd8d8 100644 --- a/src/pages/attendees/summit-attendees-list-page.js +++ b/src/pages/attendees/summit-attendees-list-page.js @@ -160,7 +160,7 @@ class SummitAttendeeListPage extends React.Component { } handleChangeFlowEvent(ev) { - const { value, id } = ev.target; + const { value } = ev.target; this.props.setCurrentFlowEvent(value); } @@ -298,7 +298,7 @@ class SummitAttendeeListPage extends React.Component { ); } - handleSort(index, key, dir, func) { + handleSort(index, key, dir) { const { page, perPage, term } = this.props; const { attendeeFilters, selectedColumns } = this.state; key = key === "name" ? "full_name" : key; @@ -327,7 +327,7 @@ class SummitAttendeeListPage extends React.Component { ); } - handleNewAttendee(ev) { + handleNewAttendee() { const { currentSummit, history } = this.props; history.push(`/app/summits/${currentSummit.id}/attendees/new`); } @@ -490,8 +490,7 @@ class SummitAttendeeListPage extends React.Component { currentFlowEvent, selectedAll, badgeFeatures, - badgeTypes, - sendEmails + badgeTypes } = this.props; const { @@ -1001,7 +1000,7 @@ class SummitAttendeeListPage extends React.Component { "attendee_list.placeholders.checkin_date_from" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleCheckInDate(ev, false)} value={epochToMomentTimeZone( attendeeFilters.checkinDateFilter[0], @@ -1022,7 +1021,7 @@ class SummitAttendeeListPage extends React.Component { "attendee_list.placeholders.checkin_date_to" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleCheckInDate(ev, true)} value={epochToMomentTimeZone( attendeeFilters.checkinDateFilter[1], diff --git a/src/pages/events/summit-event-list-page.js b/src/pages/events/summit-event-list-page.js index cd863ce67..ee1da3aa7 100644 --- a/src/pages/events/summit-event-list-page.js +++ b/src/pages/events/summit-event-list-page.js @@ -1588,7 +1588,7 @@ class SummitEventListPage extends React.Component { "event_list.placeholders.start_date_from" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, false)} value={epochToMomentTimeZone( eventFilters.start_date_filter[0], @@ -1606,7 +1606,7 @@ class SummitEventListPage extends React.Component { "event_list.placeholders.start_date_to" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, true)} value={epochToMomentTimeZone( eventFilters.start_date_filter[1], @@ -1628,7 +1628,7 @@ class SummitEventListPage extends React.Component { "event_list.placeholders.end_date_from" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, false)} value={epochToMomentTimeZone( eventFilters.end_date_filter[0], @@ -1646,7 +1646,7 @@ class SummitEventListPage extends React.Component { "event_list.placeholders.end_date_to" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, true)} value={epochToMomentTimeZone( eventFilters.end_date_filter[1], @@ -1668,7 +1668,7 @@ class SummitEventListPage extends React.Component { "event_list.placeholders.created_from" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, false)} value={epochToMomentTimeZone( eventFilters.created_filter[0], @@ -1686,7 +1686,7 @@ class SummitEventListPage extends React.Component { "event_list.placeholders.created_to" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, true)} value={epochToMomentTimeZone( eventFilters.created_filter[1], @@ -1708,7 +1708,7 @@ class SummitEventListPage extends React.Component { "event_list.placeholders.modified_from" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, false)} value={epochToMomentTimeZone( eventFilters.modified_filter[0], @@ -1726,7 +1726,7 @@ class SummitEventListPage extends React.Component { "event_list.placeholders.modified_to" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, true)} value={epochToMomentTimeZone( eventFilters.modified_filter[1], diff --git a/src/pages/orders/purchase-order-list-page.js b/src/pages/orders/purchase-order-list-page.js index 1c5258cc8..a9c983084 100644 --- a/src/pages/orders/purchase-order-list-page.js +++ b/src/pages/orders/purchase-order-list-page.js @@ -430,7 +430,7 @@ class PurchaseOrderListPage extends React.Component { "purchase_order_list.placeholders.purchased_from" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, false)} value={epochToMomentTimeZone( purchaseOrderFilters.purchase_date_filter[0], @@ -448,7 +448,7 @@ class PurchaseOrderListPage extends React.Component { "purchase_order_list.placeholders.purchased_to" ) }} - timezone={currentSummit.time_zone.name} + timezone={currentSummit.time_zone_id} onChange={(ev) => this.handleChangeDateFilter(ev, true)} value={epochToMomentTimeZone( purchaseOrderFilters.purchase_date_filter[1], diff --git a/src/pages/summits/summit-dashboard-page.js b/src/pages/summits/summit-dashboard-page.js index 4185da456..c78d5d0f9 100644 --- a/src/pages/summits/summit-dashboard-page.js +++ b/src/pages/summits/summit-dashboard-page.js @@ -9,15 +9,16 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - **/ + * */ import React from "react"; import { connect } from "react-redux"; import moment from "moment-timezone"; -import { getSummitById } from "../../actions/summit-actions"; import T from "i18n-react/dist/i18n-react"; import { Breadcrumb } from "react-breadcrumbs"; +import { getSummitById } from "../../actions/summit-actions"; import Member from "../../models/member"; import "../../styles/summit-dashboard-page.less"; +import { MILLISECONDS_IN_SECOND } from "../../utils/constants"; class SummitDashboardPage extends React.Component { constructor(props) { @@ -37,18 +38,21 @@ class SummitDashboardPage extends React.Component { } onCollapseChange(section) { - let newCollapseState = { ...this.state.collapseState }; + const newCollapseState = { ...this.state.collapseState }; newCollapseState[section] = !newCollapseState[section]; this.setState({ ...this.state, collapseState: newCollapseState }); } componentDidMount() { const { currentSummit } = this.props; - this.interval = setInterval(this.localTimer.bind(this), 1000); + this.interval = setInterval( + this.localTimer.bind(this), + MILLISECONDS_IN_SECOND + ); if (currentSummit) { - let localtime = moment().tz(currentSummit.time_zone.name); - this.setState({ ...this.state, localtime: localtime }); + const localtime = moment().tz(currentSummit.time_zone_id); + this.setState({ ...this.state, localtime }); } } @@ -63,9 +67,9 @@ class SummitDashboardPage extends React.Component { } getFormattedTime(atime) { - atime = atime * 1000; + atime *= MILLISECONDS_IN_SECOND; return moment(atime) - .tz(this.props.currentSummit.time_zone.name) + .tz(this.props.currentSummit.time_zone_id) .format("MMMM Do YYYY, h:mm:ss a"); } @@ -77,8 +81,8 @@ class SummitDashboardPage extends React.Component { render() { const { currentSummit, match, member } = this.props; - let memberObj = new Member(member); - let canEditSummit = memberObj.canEditSummit(); + const memberObj = new Member(member); + const canEditSummit = memberObj.canEditSummit(); if (!currentSummit.id) return
    ; @@ -97,20 +101,19 @@ class SummitDashboardPage extends React.Component {

    {T.translate("dashboard.dates")}

    -
    {currentSummit.time_zone.name}
    +
    {currentSummit.time_zone_id}
    {" "} - {this.getFormattedTime(this.state.localtime / 1000)}{" "} + {this.getFormattedTime( + this.state.localtime / MILLISECONDS_IN_SECOND + )}{" "}
    {" "} @@ -130,13 +133,10 @@ class SummitDashboardPage extends React.Component {
    {" "} @@ -160,17 +160,14 @@ class SummitDashboardPage extends React.Component {
    {canEditSummit && currentSummit.selection_plans.map((sp) => ( -
    +
    {sp.name}
    {" "} @@ -191,13 +188,10 @@ class SummitDashboardPage extends React.Component {
    {" "} @@ -218,13 +212,10 @@ class SummitDashboardPage extends React.Component {
    {" "} @@ -253,24 +244,24 @@ class SummitDashboardPage extends React.Component {

    {T.translate("dashboard.events")}  - {this.state.collapseState["events"] && ( + {this.state.collapseState.events && ( this.onCollapseChange("events")} className="fa fa-plus-square clickable" aria-hidden="true" - > + /> )} - {!this.state.collapseState["events"] && ( + {!this.state.collapseState.events && ( this.onCollapseChange("events")} className="fa fa-minus-square clickable" aria-hidden="true" - > + /> )}

    - {!this.state.collapseState["events"] && ( + {!this.state.collapseState.events && (
    @@ -309,24 +300,24 @@ class SummitDashboardPage extends React.Component {

    {T.translate("dashboard.voting")}  - {this.state.collapseState["voting"] && ( + {this.state.collapseState.voting && ( this.onCollapseChange("voting")} className="fa fa-plus-square clickable" aria-hidden="true" - > + /> )} - {!this.state.collapseState["voting"] && ( + {!this.state.collapseState.voting && ( this.onCollapseChange("voting")} className="fa fa-minus-square clickable" aria-hidden="true" - > + /> )}

    - {!this.state.collapseState["voting"] && ( + {!this.state.collapseState.voting && (
    @@ -345,24 +336,24 @@ class SummitDashboardPage extends React.Component {

    {T.translate("dashboard.emails")}  - {this.state.collapseState["emails"] && ( + {this.state.collapseState.emails && ( this.onCollapseChange("emails")} className="fa fa-plus-square clickable" aria-hidden="true" - > + /> )} - {!this.state.collapseState["emails"] && ( + {!this.state.collapseState.emails && ( this.onCollapseChange("emails")} className="fa fa-minus-square clickable" aria-hidden="true" - > + /> )}

    - {!this.state.collapseState["emails"] && ( + {!this.state.collapseState.emails && (
    diff --git a/src/utils/constants.js b/src/utils/constants.js index 591bcc15a..f68d76b5a 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -89,8 +89,12 @@ export const HOUR_AND_HALF = 5400; export const SECONDS_TO_MINUTES = 60; export const MILLISECONDS_IN_SECOND = 1000; export const TIME_23_HOURS = 23; +export const TIME_7_HOURS = 7; +export const TIME_19_HOURS = 19; export const TIME_59_MINS = 59; export const TIME_59_SECS = 59; +export const MINUTE_STEP_SIZE_5 = 5; +export const GAP_SIZE = 5; export const SORT_ASCENDING = 1; export const SORT_DESCENDING = -1; @@ -147,6 +151,8 @@ export const LANGUAGE_CODE_LENGTH = 2; export const SLICE_TICKET_NUMBER = -15; +export const TIMEOUT_1500 = 1500; + export const MARKETING_SETTING_TYPE_TEXT = "TEXT"; export const MARKETING_SETTING_TYPE_TEXTAREA = "TEXTAREA"; export const MARKETING_SETTING_TYPE_FILE = "FILE"; diff --git a/src/utils/summitUtils.js b/src/utils/summitUtils.js index c31ee8eee..e49ba1287 100644 --- a/src/utils/summitUtils.js +++ b/src/utils/summitUtils.js @@ -23,7 +23,7 @@ const formatDuration = (duration) => { export const formatEventData = (e, summit) => { const published_date = e.is_published ? moment(e.published_date * MILLISECONDS_IN_SECOND) - .tz(summit.time_zone.name) + .tz(summit.time_zone_id) .format("MMMM Do YYYY, h:mm a") : "No"; @@ -116,12 +116,12 @@ export const formatEventData = (e, summit) => { streaming_type: e.streaming_type ? e.streaming_type : "N/A", start_date: e.start_date ? moment(e.start_date * MILLISECONDS_IN_SECOND) - .tz(summit.time_zone.name) + .tz(summit.time_zone_id) .format("MMMM Do YYYY, h:mm a") : "TBD", end_date: e.end_date ? moment(e.end_date * MILLISECONDS_IN_SECOND) - .tz(summit.time_zone.name) + .tz(summit.time_zone_id) .format("MMMM Do YYYY, h:mm a") : "TBD", sponsor: @@ -133,7 +133,7 @@ export const formatEventData = (e, summit) => { ? e?.media_uploads?.map((m) => ({ ...m, created: moment(m.created * MILLISECONDS_IN_SECOND) - .tz(summit.time_zone.name) + .tz(summit.time_zone_id) .format("MMMM Do YYYY, h:mm a") })) : "N/A",