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 9b1784c1b..a4e39c81c 100644
--- a/src/actions/event-actions.js
+++ b/src/actions/event-actions.js
@@ -546,7 +546,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());
@@ -665,7 +665,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());
@@ -731,7 +731,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());
@@ -792,7 +792,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/location-actions.js b/src/actions/location-actions.js
index 935d86e3c..bea2c9888 100644
--- a/src/actions/location-actions.js
+++ b/src/actions/location-actions.js
@@ -28,10 +28,15 @@ import {
getCSV,
geoCodeAddress,
geoCodeLatLng,
- authErrorHandler
+ authErrorHandler,
+ escapeFilterValue,
+ fetchResponseHandler,
+ fetchErrorHandler
} from "openstack-uicore-foundation/lib/utils/actions";
+import URI from "urijs";
import history from "../history";
import { getAccessTokenSafely } from "../utils/methods";
+import { DEBOUNCE_WAIT, TWO_HUNDRED_PER_PAGE } from "../utils/constants";
export const REQUEST_LOCATIONS = "REQUEST_LOCATIONS";
export const RECEIVE_LOCATIONS = "RECEIVE_LOCATIONS";
@@ -1013,3 +1018,125 @@ const normalizeMapEntity = (entity) => {
return normalizedEntity;
};
+
+export const queryGroupLocations = _.debounce(
+ async (summitId, input, callback) => {
+ const accessToken = await getAccessTokenSafely();
+
+ const endpoint = URI(
+ `${window.API_BASE_URL}/api/v1/summits/${summitId}/locations`
+ );
+
+ endpoint.addQuery("access_token", accessToken);
+ endpoint.addQuery("per_page", TWO_HUNDRED_PER_PAGE);
+ endpoint.addQuery("expand", "rooms,floors");
+ endpoint.addQuery("fields", "id,name,order,class_name,rooms,floors");
+ endpoint.addQuery("relations", "rooms,floors,none");
+
+ if (input) {
+ input = escapeFilterValue(input);
+ endpoint.addQuery("filter[]", `rooms=@${input}`);
+ }
+
+ fetch(endpoint)
+ .then(fetchResponseHandler)
+ .then((json) => {
+ const options = [...json.data];
+ callback(options);
+ })
+ .catch(fetchErrorHandler);
+ },
+ DEBOUNCE_WAIT
+);
+
+export const queryAllRooms = _.debounce(async (summitId, input, callback) => {
+ const accessToken = await getAccessTokenSafely();
+
+ console.log("query all rooms");
+
+ const endpoint = URI(
+ `${window.API_BASE_URL}/api/v1/summits/${summitId}/locations/venues/all/rooms`
+ );
+
+ endpoint.addQuery("access_token", accessToken);
+ endpoint.addQuery("per_page", TWO_HUNDRED_PER_PAGE);
+
+ if (input) {
+ input = escapeFilterValue(input);
+ endpoint.addQuery("filter[]", `name=@${input}`);
+ }
+
+ fetch(endpoint)
+ .then(fetchResponseHandler)
+ .then((json) => {
+ const options = [...json.data];
+ callback(options);
+ })
+ .catch(fetchErrorHandler);
+}, DEBOUNCE_WAIT);
+
+export const queryBookableRooms = _.debounce(
+ async (summitId, input, callback) => {
+ const accessToken = await getAccessTokenSafely();
+
+ const endpoint = URI(
+ `${window.API_BASE_URL}/api/v1/summits/${summitId}/locations/venues/all/bookable-rooms`
+ );
+
+ endpoint.addQuery("access_token", accessToken);
+ endpoint.addQuery("per_page", TWO_HUNDRED_PER_PAGE);
+ endpoint.addQuery("expand", "attributes.type, floor");
+ endpoint.addQuery(
+ "fields",
+ "id,name,image.url,currency,time_slot_cost,capacity,attributes.type.type,attributes.value,floor.name"
+ );
+ endpoint.addQuery("relations", "none");
+
+ if (input) {
+ input = escapeFilterValue(input);
+ endpoint.addQuery("filter[]", `name=@${input}`);
+ }
+
+ fetch(endpoint)
+ .then(fetchResponseHandler)
+ .then((json) => {
+ const options = [...json.data];
+ callback(options);
+ })
+ .catch(fetchErrorHandler);
+ },
+ DEBOUNCE_WAIT
+);
+
+export const queryVenues = _.debounce(
+ async (summitId, input, callback, venuesRooms) => {
+ const accessToken = await getAccessTokenSafely();
+
+ const endpoint = URI(
+ `${window.API_BASE_URL}/api/v1/summits/${summitId}/locations/venues`
+ );
+
+ endpoint.addQuery("access_token", accessToken);
+ endpoint.addQuery("per_page", TWO_HUNDRED_PER_PAGE);
+ endpoint.addQuery("expand", "rooms");
+
+ if (input) {
+ input = escapeFilterValue(input);
+ endpoint.addQuery("filter[]", `rooms=@${input}`);
+ }
+
+ fetch(endpoint)
+ .then(fetchResponseHandler)
+ .then((json) => {
+ const options = venuesRooms
+ ? [...json.data]
+ .map((v) => v.rooms)
+ .flat()
+ .filter((r) => r.class_name === "SummitVenueRoom")
+ : [...json.data];
+ callback(options);
+ })
+ .catch(fetchErrorHandler);
+ },
+ DEBOUNCE_WAIT
+);
diff --git a/src/actions/order-actions.js b/src/actions/order-actions.js
index 6c521553a..7ff6646fc 100644
--- a/src/actions/order-actions.js
+++ b/src/actions/order-actions.js
@@ -524,7 +524,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 129fefde4..ea7b82e67 100644
--- a/src/actions/summit-actions.js
+++ b/src/actions/summit-actions.js
@@ -63,20 +63,123 @@ export const getSummitById = (summitId) => async (dispatch) => {
"track_groups," +
"locations," +
"locations.rooms," +
- "locations.attributes.type," +
- "locations.floor," +
+ "locations.rooms.floor," +
"meeting_booking_room_allowed_attributes," +
"meeting_booking_room_allowed_attributes.values," +
"lead_report_settings," +
"presentation_action_types," +
- "selection_plans," +
+ "selection_plans,selection_plans.track_groups," +
"ticket_types," +
"badge_types," +
"badge_features," +
"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,event_types.allows_attachment,event_types.allows_level,event_types.allows_location,event_types.allows_location_timeframe_collision,event_types.allows_publishing_dates," +
+ "link," +
+ "locations,locations.id,locations.name,locations.order,locations.class_name,locations.rooms.id,locations.rooms.name,locations.rooms.floor.id,locations.rooms.floor.name," +
+ "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,tracks.track_groups," +
+ "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,selection_plans.allowed_presentation_questions," +
+ "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.subtracks,tracks.track_groups," +
+ "tracks_groups.none," +
+ "locations,locations.rooms,locations.rooms.none,locations.floor,locations.none," +
+ "meeting_booking_room_allowed_attributes.values," +
+ "selection_plans.track_groups,selection_plans.allowed_presentation_questions," +
+ "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/filters/room-filter.js b/src/components/filters/room-filter.js
index 5bfc4f41d..2d392a6ca 100644
--- a/src/components/filters/room-filter.js
+++ b/src/components/filters/room-filter.js
@@ -9,10 +9,10 @@
* 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 Select from "react-select";
+import VenuesDropdown from "../inputs/venue-input";
export default class RoomFilter extends React.Component {
constructor(props) {
@@ -22,29 +22,23 @@ export default class RoomFilter extends React.Component {
}
handleFilterChange(value) {
- let theValue = this.props.isMulti ? value.map((v) => v.value) : value.value;
+ const theValue = this.props.isMulti ? value.map((v) => v.id) : value.value;
this.props.onChange(theValue);
}
render() {
- let { rooms, value, onChange, ...rest } = this.props;
- let theValue = null;
- let options = rooms.map((t) => ({ value: t.id, label: t.name }));
-
- if (value) {
- theValue = this.props.isMulti
- ? options.filter((op) => value.includes(op.value))
- : options.find((op) => op.value === value);
- }
+ const { value, onChange, summitId, ...rest } = this.props;
return (
-
diff --git a/src/components/forms/event-form.js b/src/components/forms/event-form.js
index 2cf51f5f5..f249c42db 100644
--- a/src/components/forms/event-form.js
+++ b/src/components/forms/event-form.js
@@ -20,7 +20,6 @@ import { epochToMomentTimeZone } from "openstack-uicore-foundation/lib/utils/met
import {
TextEditor,
Dropdown,
- GroupedDropdown,
DateTimePicker,
TagInput,
SpeakerInput,
@@ -64,6 +63,7 @@ import {
ONE_MINUTE
} from "../../utils/constants";
import CopyClipboard from "../buttons/copy-clipboard";
+import LocationGroupedAsyncDropdown from "../inputs/location-grouped-dropdown";
class EventForm extends React.Component {
constructor(props) {
@@ -855,7 +855,6 @@ class EventForm extends React.Component {
levelOpts,
typeOpts,
trackOpts,
- locationOpts,
rsvpTemplateOpts,
selectionPlansOpts,
history,
@@ -895,18 +894,6 @@ class EventForm extends React.Component {
.filter((track) => track.subtracks.length === 0)
.map((t) => ({ label: t.name, value: t.id }));
- const venues = locationOpts
- .filter((v) => v.class_name === "SummitVenue")
- .map((l) => {
- let options = [];
- if (l.rooms) {
- options = l.rooms.map((r) => ({ label: r.name, value: r.id }));
- }
- return { label: l.name, value: l.id, options };
- });
-
- const locations_ddl = [{ label: "TBD", value: 0 }, ...venues];
-
const levels_ddl = levelOpts.map((l) => ({ label: l, value: l }));
let selection_plans_ddl = [];
@@ -1018,7 +1005,7 @@ class EventForm extends React.Component {
- {entity?.created_by && (
+ {entity.created_by && (
- {
if (newEntity.id) {
- const currentRoom = currentSummit.locations.find(
- (l) => l.id === newEntity.room_id
- );
+ const currentRoom = newEntity.room_id;
const availableDates = getAvailableBookingDates(currentSummit);
const bookingDate = getDayFromReservation(newEntity, availableDates);
if (bookingDate) getAvailableSlots(currentRoom.id, bookingDate);
@@ -70,11 +69,12 @@ const RoomBookingForm = ({
};
const handleRoomChange = (ev) => {
- const { value } = ev.target;
- const currentRoom = currentSummit.locations.find(
- (l) => l.id === parseInt(value)
- );
- setCurrentRoom(currentRoom);
+ const { value, room } = ev.target;
+ setCurrentRoom(room);
+ setStateEntity((prevState) => ({
+ ...prevState,
+ room_id: value.id
+ }));
};
const handleBookingDateChange = (ev) => {
@@ -144,10 +144,6 @@ const RoomBookingForm = ({
return "";
};
- const rooms_ddl = currentSummit.locations
- .filter((v) => v.class_name === "SummitBookableVenueRoom")
- .map((l) => ({ label: l.name, value: l.id }));
-
const available_booking_dates_ddl = getAvailableBookingDates(
currentSummit
).map((v) => ({ value: v.epoch, label: v.str }));
@@ -172,11 +168,11 @@ const RoomBookingForm = ({
-
{currentRoom.attributes.length > 0
? currentRoom.attributes
- .map((a) => `${a.type.type}: ${a.value}`)
+ .map((a) => `${a.type?.type}: ${a.value}`)
.join(" | ")
: ""}
diff --git a/src/components/forms/tax-type-form.js b/src/components/forms/tax-type-form.js
index a81b7955c..04cab57dd 100644
--- a/src/components/forms/tax-type-form.js
+++ b/src/components/forms/tax-type-form.js
@@ -101,7 +101,6 @@ class TaxTypeForm extends React.Component {
render() {
const { entity } = this.state;
- const { currentSummit } = this.props;
const ticketColumns = [
{ columnKey: "name", value: T.translate("edit_tax_type.name") },
diff --git a/src/components/inputs/bookable-room-input.js b/src/components/inputs/bookable-room-input.js
new file mode 100644
index 000000000..4794173bb
--- /dev/null
+++ b/src/components/inputs/bookable-room-input.js
@@ -0,0 +1,123 @@
+/**
+ * Copyright 2017 OpenStack Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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, { useEffect, useState } from "react";
+import AsyncSelect from "react-select/lib/Async";
+import { queryBookableRooms } from "../../actions/location-actions";
+
+const BookableRoomsDropdown = ({
+ summitId,
+ placeholder,
+ error,
+ value,
+ onChange,
+ id,
+ multi,
+ ...rest
+}) => {
+ const [theValue, setTheValue] = useState(null);
+ const [allOptions, setAllOptions] = useState([]);
+ const [allOptionsWithData, setAllOptionsWithData] = useState([]);
+
+ const isMulti = multi || rest.isMulti;
+
+ useEffect(() => {
+ if (isMulti && value.length > 0) {
+ const updatedValue = [];
+ allOptions.forEach((op) => {
+ if (value.includes(op.value)) {
+ updatedValue.push(op);
+ }
+ });
+ setTheValue(updatedValue);
+ } else if (!isMulti && value) {
+ allOptions.forEach((op) => {
+ if (op.value === value) {
+ setTheValue(op);
+ }
+ });
+ }
+ }, [allOptions]);
+
+ const handleChange = (value) => {
+ let theValue = null;
+ let roomData = null;
+ if (value) {
+ theValue = isMulti
+ ? value.map((v) => ({ id: v.value, value: v.label }))
+ : { id: value.value, value: value.label };
+ roomData = isMulti
+ ? allOptionsWithData.filter((opt) =>
+ value.some((v) => v.value === opt.id)
+ )
+ : allOptionsWithData.find((opt) => opt.id === value.value);
+ }
+
+ const ev = {
+ target: {
+ id,
+ value: theValue,
+ type: "bookableroominput",
+ room: roomData
+ }
+ };
+
+ onChange(ev);
+ };
+
+ const getRooms = (input, callback) => {
+ // we need to map into value/label because of a bug in react-select 2
+ // https://github.com/JedWatson/react-select/issues/2998
+
+ const translateOptions = (locations) => {
+ const newOptions = locations.map((c) => ({
+ value: c.id,
+ label: c.name
+ }));
+
+ if (!allOptions.length && !input) {
+ setAllOptions(newOptions);
+ setAllOptionsWithData(locations);
+ }
+
+ callback(newOptions);
+ };
+
+ queryBookableRooms(summitId, input, translateOptions);
+ };
+
+ const has_error = error && error !== "";
+
+ return (
+
+
({
+ ...baseStyles,
+ zIndex: 2000
+ })
+ }}
+ {...rest}
+ />
+ {has_error && {error}
}
+
+ );
+};
+
+export default BookableRoomsDropdown;
diff --git a/src/components/inputs/location-grouped-dropdown.js b/src/components/inputs/location-grouped-dropdown.js
index 050d45d75..815303852 100644
--- a/src/components/inputs/location-grouped-dropdown.js
+++ b/src/components/inputs/location-grouped-dropdown.js
@@ -1,95 +1,150 @@
-import React from "react";
-import Select, { createFilter } from "react-select";
+/**
+ * Copyright 2017 OpenStack Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ * */
-const RoomLabel = ({ room }) => (
-
- {room.name} - {room.id}
-
-);
+import React, { useState, useEffect } from "react";
+import AsyncSelect from "react-select/lib/Async";
+import { queryGroupLocations } from "../../actions/location-actions";
-const LocationGroupedDropdown = ({
- value,
- locations,
- className,
+const LocationGroupedAsyncDropdown = ({
+ summitId,
placeholder,
+ error,
+ value,
+ onChange,
+ id,
+ multi,
...rest
}) => {
- let options = [];
- let theValue = null;
-
- const filterOptions = (candidate, input) => {
- if (input) {
- return candidate.label.props.room?.name
- .toLowerCase()
- .includes(input.toLowerCase());
+ const [theValue, setTheValue] = useState(null);
+ const [allOptions, setAllOptions] = useState([]);
+
+ const isMulti = multi || rest.isMulti;
+
+ useEffect(() => {
+ if (isMulti) {
+ const updatedValue = allOptions
+ .flatMap((op) => (op.options ? op.options : op))
+ .filter((op) => value.includes(op.value));
+ setTheValue(updatedValue);
+ } else if (!isMulti && value) {
+ const foundOption = allOptions
+ .flatMap((op) => (op.options ? op.options : op))
+ .find((op) => op.value === value);
+ if (foundOption) {
+ setTheValue(foundOption);
+ }
}
- return true;
+ }, [allOptions, value]);
+
+ const handleChange = (value) => {
+ let newValue = null;
+ const isMulti = multi || rest.isMulti;
+ if (value) {
+ newValue = isMulti ? value.map((v) => v.value) : value.value;
+ }
+
+ const ev = {
+ target: {
+ id,
+ value: newValue,
+ type: "groupedlocationinput"
+ }
+ };
+
+ onChange(ev);
};
- locations.forEach((loc) => {
- const roomsWithoutFloors =
- loc.rooms?.filter((rm) => rm.floor_id === 0) || [];
-
- options.push({
- label: (
-
- All {loc.name} locations
-
- ),
- value: loc.id
- });
- options = options.concat(
- roomsWithoutFloors.map((rm) => ({
- label:
,
- value: rm.id
- }))
- );
-
- loc.floors?.forEach((fl) => {
- const floorRooms = loc.rooms.filter((rm) => rm.floor_id === fl.id);
- options.push({
- label: fl.name,
- options: floorRooms.map((rm) => ({
- label:
,
- value: rm.id
- }))
+ const RoomLabel = ({ room }) => (
+
+ {room.name}{" "}
+ - {room.id}
+
+ );
+
+ const getLocations = (input, callback) => {
+ // we need to map into value/label because of a bug in react-select 2
+ // https://github.com/JedWatson/react-select/issues/2998
+
+ const translateOptions = (locations) => {
+ let newOptions = [];
+
+ locations.forEach((loc) => {
+ const roomsWithoutFloors =
+ loc.rooms?.filter((rm) => rm.floor_id === 0) || [];
+
+ newOptions.push({
+ label: (
+
+ All {loc.name} locations
+
+ ),
+ value: loc.id
+ });
+ newOptions = newOptions.concat(
+ roomsWithoutFloors.map((rm) => ({
+ label:
,
+ value: rm.id
+ }))
+ );
+
+ loc.floors?.forEach((fl) => {
+ const floorRooms = loc.rooms.filter((rm) => rm.floor_id === fl.id);
+ newOptions.push({
+ label: fl.name,
+ options: floorRooms.map((rm) => ({
+ label:
,
+ value: rm.id
+ }))
+ });
+ });
});
- });
- });
- options.forEach((op) => {
- if (op.value === value) {
- theValue = op;
- return;
- }
- if (op.options) {
- const foundOption = op.options.find((opp) => opp.value === value);
- if (foundOption) {
- theValue = foundOption;
- return;
+ if (!input) {
+ setAllOptions(newOptions);
}
- }
- });
+
+ callback(newOptions);
+ };
+
+ queryGroupLocations(summitId, input, translateOptions);
+ };
+
+ const has_error = error && error !== "";
return (
-