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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PUB_API_BASE_URL=
OS_BASE_URL=
SCOPES_BASE_REALM=${API_BASE_URL}
PURCHASES_API_URL=https://purchases-api.dev.fnopen.com
PURCHASES_API_SCOPES="purchases-show-medata/read purchases-show-medata/write show-form/read show-form/write customized-form/write customized-form/read carts/read carts/write purchases/read cart-notes/write payment/write"
PURCHASES_API_SCOPES="purchases-show-medata/read purchases-show-medata/write show-form/read show-form/write customized-form/write customized-form/read carts/read carts/write purchases/read cart-notes/write payment/write payment-profile/read"
SPONSOR_USERS_API_URL=https://sponsor-users-api.dev.fnopen.com
Comment thread
santipalenque marked this conversation as resolved.
SPONSOR_USERS_SCOPES="show-medata/read show-medata/write access-requests/read access-requests/write sponsor-users/read sponsor-users/write groups/read groups/write media-upload/write"
EMAIL_SCOPES="clients/read templates/read templates/write emails/read"
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"@react-pdf/renderer": "^3.1.11",
"@sentry/react": "^8.32.0",
"@sentry/webpack-plugin": "^2.22.4",
"@stripe/react-stripe-js": "^5.4.1",
"@stripe/stripe-js": "^8.5.3",
"@types/googlemaps": "^3.39.3",
"@types/markerclustererplus": "^2.1.29",
"@types/react": "^16.9.32",
Expand Down
101 changes: 68 additions & 33 deletions src/actions/member-actions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2018 OpenStack Foundation
* Copyright 2026 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
Expand All @@ -9,7 +9,8 @@
* 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 {
getRequest,
getCSV,
Expand All @@ -23,16 +24,25 @@ import {
} from "openstack-uicore-foundation/lib/utils/actions";
import moment from "moment-timezone";
import { getAccessTokenSafely } from "../utils/methods";
import { snackbarErrorHandler } from "./base-actions";
import { DEFAULT_PER_PAGE } from "../utils/constants";

export const REQUEST_MEMBERS = "REQUEST_MEMBERS";
export const RECEIVE_MEMBERS = "RECEIVE_MEMBERS";
export const RECEIVE_MEMBER = "RECEIVE_MEMBER";
export const AFFILIATION_SAVED = "AFFILIATION_SAVED";
export const AFFILIATION_DELETED = "AFFILIATION_DELETED";
export const AFFILIATION_ADDED = "AFFILIATION_ADDED";
export const ORGANIZATION_ADDED = "ORGANIZATION_ADDED";

export const getMembers =
(term = null, page = 1, perPage = 10, order = "id", orderDir = 1) =>
(
term = null,
page = 1,
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = 1
) =>
async (dispatch, getState) => {
const { currentSummitState } = getState();
const accessToken = await getAccessTokenSafely();
Expand All @@ -46,7 +56,7 @@ export const getMembers =
}

const params = {
page: page,
page,
per_page: perPage,
access_token: accessToken
};
Expand All @@ -58,7 +68,7 @@ export const getMembers =
// order
if (order != null && orderDir != null) {
const orderDirSign = orderDir === 1 ? "+" : "-";
params["order"] = `${orderDirSign}${order}`;
params.order = `${orderDirSign}${order}`;
}

return getRequest(
Expand All @@ -72,6 +82,29 @@ export const getMembers =
});
};

export const getMemberByExternalId = (externalId) => async (dispatch) => {
const accessToken = await getAccessTokenSafely();

dispatch(startLoading());

const params = {
access_token: accessToken,
relations: "none",
fields: "id,first_name,last_name,email"
};

return getRequest(
null,
createAction(RECEIVE_MEMBER),
`${window.API_BASE_URL}/api/v1/members/external/${externalId}`,
snackbarErrorHandler
)(params)(dispatch)
.catch(console.log)
.finally(() => {
dispatch(stopLoading());
});
};

export const getMembersForEventCSV = (event) => async (dispatch, getState) => {
const { currentSummitState } = getState();
const accessToken = await getAccessTokenSafely();
Expand All @@ -83,8 +116,9 @@ export const getMembersForEventCSV = (event) => async (dispatch, getState) => {
const momentEndDate = moment(event.endDate).tz(currentSummit.time_zone_id);

const date = momentStartDate.format("dddd Do");
const time =
momentStartDate.format("h:mm a") + " - " + momentEndDate.format("h:mm a");
const time = `${momentStartDate.format("h:mm a")} - ${momentEndDate.format(
"h:mm a"
)}`;
const roomName =
event.location && event.location.venueroom
? event.location.venueroom.name
Expand All @@ -111,31 +145,32 @@ export const getMembersForEventCSV = (event) => async (dispatch, getState) => {
);
};

/****************************** AFFILIATIONS **************************************************/
/* ************************************************************************** */
/* AFFILIATIONS */
/* ************************************************************************** */

export const addOrganization =
(organization, callback) => async (dispatch, getState) => {
const accessToken = await getAccessTokenSafely();
export const addOrganization = (organization, callback) => async (dispatch) => {
const accessToken = await getAccessTokenSafely();

const params = {
access_token: accessToken
};
const params = {
access_token: accessToken
};

dispatch(startLoading());
dispatch(startLoading());

postRequest(
null,
createAction(ORGANIZATION_ADDED),
`${window.API_BASE_URL}/api/v1/organizations`,
{ name: organization },
authErrorHandler
)(params)(dispatch).then((payload) => {
dispatch(stopLoading());
callback(payload.response);
});
};
postRequest(
null,
createAction(ORGANIZATION_ADDED),
`${window.API_BASE_URL}/api/v1/organizations`,
{ name: organization },
authErrorHandler
)(params)(dispatch).then((payload) => {
dispatch(stopLoading());
callback(payload.response);
});
};

export const addAffiliation = (affiliation) => async (dispatch, getState) => {
export const addAffiliation = (affiliation) => async (dispatch) => {
const accessToken = await getAccessTokenSafely();

dispatch(startLoading());
Expand All @@ -154,12 +189,12 @@ export const addAffiliation = (affiliation) => async (dispatch, getState) => {
normalizedEntity,
authErrorHandler,
affiliation
)(params)(dispatch).then((payload) => {
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
};

export const saveAffiliation = (affiliation) => async (dispatch, getState) => {
export const saveAffiliation = (affiliation) => async (dispatch) => {
const accessToken = await getAccessTokenSafely();

dispatch(startLoading());
Expand All @@ -176,13 +211,13 @@ export const saveAffiliation = (affiliation) => async (dispatch, getState) => {
`${window.API_BASE_URL}/api/v1/members/${affiliation.owner_id}/affiliations/${affiliation.id}`,
normalizedEntity,
authErrorHandler
)(params)(dispatch).then((payload) => {
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
};

export const deleteAffiliation =
(ownerId, affiliationId) => async (dispatch, getState) => {
(ownerId, affiliationId) => async (dispatch) => {
const accessToken = await getAccessTokenSafely();

const params = {
Expand All @@ -203,13 +238,13 @@ export const deleteAffiliation =
const normalizeEntity = (entity) => {
const normalizedEntity = { ...entity };

if (!normalizedEntity.end_date) delete normalizedEntity["end_date"];
if (!normalizedEntity.end_date) delete normalizedEntity.end_date;

normalizedEntity.organization_id =
normalizedEntity.organization != null
? normalizedEntity.organization.id
: 0;
delete normalizedEntity["organization"];
delete normalizedEntity.organization;

return normalizedEntity;
};
Loading
Loading