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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"moment": "^2.29.1",
"moment-duration-format": "^2.3.2",
"moment-timezone": "^0.5.33",
"openstack-uicore-foundation": "5.0.22",
"openstack-uicore-foundation": "5.0.29-beta.0",
"p-limit": "^6.1.0",
"path-browserify": "^1.0.1",
"postcss-loader": "^6.2.1",
Expand Down
142 changes: 132 additions & 10 deletions src/actions/sponsor-purchases-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
postRequest,
putRequest,
startLoading,
stopLoading
stopLoading,
getCSV
} from "openstack-uicore-foundation/lib/utils/actions";
import T from "i18n-react/dist/i18n-react";
import { escapeFilterValue, getAccessTokenSafely } from "../utils/methods";
Expand All @@ -31,6 +32,8 @@ import {
} from "../utils/constants";
import { snackbarErrorHandler, snackbarSuccessHandler } from "./base-actions";

export const REQUEST_ALL_SPONSOR_PURCHASES = "REQUEST_ALL_SPONSOR_PURCHASES";
export const RECEIVE_ALL_SPONSOR_PURCHASES = "RECEIVE_ALL_SPONSOR_PURCHASES";
export const REQUEST_SPONSOR_PURCHASES = "REQUEST_SPONSOR_PURCHASES";
export const RECEIVE_SPONSOR_PURCHASES = "RECEIVE_SPONSOR_PURCHASES";
export const SPONSOR_PURCHASE_STATUS_UPDATED =
Expand All @@ -40,6 +43,127 @@ export const CLEAR_SPONSOR_ORDER = "CLEAR_SPONSOR_ORDER";
export const SPONSOR_CLIENT_ADDRESS_UPDATED = "SPONSOR_CLIENT_ADDRESS_UPDATED";
export const SPONSOR_CLIENT_UPDATED = "SPONSOR_CLIENT_UPDATED";

export const getAllSponsorPurchases =
(
term = "",
page = DEFAULT_CURRENT_PAGE,
perPage = DEFAULT_PER_PAGE,
order = "created",
orderDir = -1
) =>
async (dispatch, getState) => {
const { currentSummitState } = getState();
const { currentSummit } = currentSummitState;
const accessToken = await getAccessTokenSafely();
const filter = [];

dispatch(startLoading());

if (term) {
const escapedTerm = escapeFilterValue(term);
filter.push(
`number==${escapedTerm},sponsor_company_name=@${escapedTerm},purchased_by_email=@${escapedTerm},purchased_by_full_name=@${escapedTerm}`
);
}

const params = {
page,
per_page: perPage,
access_token: accessToken,
expand: "sponsor",
relations: "sponsor",
fields:
"id,number,payment_id,purchased_date,sponsor.id,sponsor.company_name,payment_method,status,net_amount"
};

if (filter.length > 0) {
params["filter[]"] = filter;
}

// order
if (order != null && orderDir != null) {
const orderDirSign = orderDir === 1 ? "" : "-";
switch (order) {
case "purchased":
params.order = `${orderDirSign}created`;
break;
case "amount":
params.order = `${orderDirSign}net_amount`;
break;
case "sponsor_name":
params.order = `${orderDirSign}sponsor_company_name`;
break;
default:
params.order = `${orderDirSign}${order}`;
}
}

return getRequest(
createAction(REQUEST_ALL_SPONSOR_PURCHASES),
createAction(RECEIVE_ALL_SPONSOR_PURCHASES),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/purchases`,
authErrorHandler,
{ order, orderDir, page, perPage, term }
)(params)(dispatch).finally(() => {
dispatch(stopLoading());
});
Comment thread
santipalenque marked this conversation as resolved.
};

export const exportAllSponsorPurchases =
(term = null, order, orderDir) =>
async (dispatch, getState) => {
const { currentSummitState } = getState();
const accessToken = await getAccessTokenSafely();
const { currentSummit } = currentSummitState;
const filter = [];
const filename = `${currentSummit.id}-purchases.csv`;

if (term) {
const escapedTerm = escapeFilterValue(term);
filter.push(
`number==${escapedTerm},sponsor_company_name=@${escapedTerm},purchased_by_email=@${escapedTerm},purchased_by_full_name=@${escapedTerm}`
);
}

const params = {
access_token: accessToken,
expand: "sponsor",
relations: "sponsor",
fields:
"number,payment_id,purchased_date,sponsor.id,sponsor.company_name,payment_method,status,net_amount"
};

if (filter.length > 0) {
params["filter[]"] = filter;
}

// order
if (order != null && orderDir != null) {
const orderDirSign = orderDir === 1 ? "" : "-";
switch (order) {
case "purchased":
params.order = `${orderDirSign}created`;
break;
case "amount":
params.order = `${orderDirSign}net_amount`;
break;
case "sponsor_name":
params.order = `${orderDirSign}sponsor_company_name`;
break;
default:
params.order = `${orderDirSign}${order}`;
}
}

dispatch(
getCSV(
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/purchases/csv`,
params,
filename
)
);
};

export const getSponsorPurchases =
(
term = "",
Expand Down Expand Up @@ -82,7 +206,7 @@ export const getSponsorPurchases =
params.order = `${orderDirSign}created`;
break;
case "amount":
params.order = `${orderDirSign}raw_amount`;
params.order = `${orderDirSign}net_amount`;
break;
default:
params.order = `${orderDirSign}${order}`;
Expand All @@ -101,10 +225,9 @@ export const getSponsorPurchases =
};

export const approveSponsorPurchase =
(paymentId) => async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
(sponsorId, paymentId) => async (dispatch, getState) => {
const { currentSummitState } = getState();
const { currentSummit } = currentSummitState;
const { entity: sponsor } = currentSponsorState;
const accessToken = await getAccessTokenSafely();

const params = {
Expand All @@ -119,7 +242,7 @@ export const approveSponsorPurchase =
paymentId,
status: PURCHASE_STATUS.PAID
}),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsor.id}/payments/${paymentId}/approve`,
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/payments/${paymentId}/approve`,
{},
snackbarErrorHandler
)(params)(dispatch)
Expand All @@ -138,10 +261,9 @@ export const approveSponsorPurchase =
};

export const rejectSponsorPurchase =
(paymentId) => async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
(sponsorId, paymentId) => async (dispatch, getState) => {
const { currentSummitState } = getState();
const { currentSummit } = currentSummitState;
const { entity: sponsor } = currentSponsorState;
const accessToken = await getAccessTokenSafely();

const params = {
Expand All @@ -156,7 +278,7 @@ export const rejectSponsorPurchase =
paymentId,
status: PURCHASE_STATUS.CANCELLED
}),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsor.id}/payments/${paymentId}/cancel`,
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/payments/${paymentId}/cancel`,
null,
snackbarErrorHandler
)(params)(dispatch)
Expand Down
5 changes: 5 additions & 0 deletions src/components/menu/menu-definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ export const getSummitItems = (summitId) => [
linkUrl: `summits/${summitId}/sponsors/pages`,
accessRoute: "admin-sponsors"
},
{
name: "sponsor_purchases",
linkUrl: `summits/${summitId}/sponsors/purchases`,
accessRoute: "admin-sponsors"
},
{
name: "sponsorship_list",
linkUrl: `summits/${summitId}/sponsorships`,
Expand Down
17 changes: 15 additions & 2 deletions src/components/mui/RefundForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import { Box, Button, Grid2 } from "@mui/material";
import MuiFormikTextField from "openstack-uicore-foundation/lib/components/mui/formik-inputs/textfield";
import MuiFormikPriceField from "openstack-uicore-foundation/lib/components/mui/formik-inputs/price-field";
import InfoNote from "openstack-uicore-foundation/lib/components/mui/info-note";
import CustomAlert from "openstack-uicore-foundation/lib/components/mui/custom-alert";

const RefundForm = ({ onSubmit }) => {
const RefundForm = ({ onSubmit, disabled = false }) => {
const formik = useFormik({
initialValues: {
reason: "",
Expand Down Expand Up @@ -56,6 +57,7 @@ const RefundForm = ({ onSubmit }) => {
fullWidth
size="small"
label={T.translate("refund_form.reason")}
disabled={disabled}
/>
</Grid2>
<Grid2 size={4}>
Expand All @@ -65,6 +67,7 @@ const RefundForm = ({ onSubmit }) => {
size="small"
inCents
label={T.translate("refund_form.amount")}
disabled={disabled}
/>
</Grid2>
<Grid2 size={2} sx={{ pt: 2 }}>
Expand All @@ -74,13 +77,23 @@ const RefundForm = ({ onSubmit }) => {
color="primary"
fullWidth
size="small"
disabled={disabled}
>
{T.translate("refund_form.queue_refund")}
</Button>
</Grid2>
</Grid2>
</Box>
<InfoNote message={T.translate("refund_form.info")} sx={{ mt: 2 }} />
<Box sx={{ mt: 2 }}>
{disabled ? (
<CustomAlert
message={T.translate("refund_form.only_online_payments")}
severity="warning"
/>
) : (
<InfoNote message={T.translate("refund_form.info")} />
)}
</Box>
</FormikProvider>
);
};
Expand Down
15 changes: 14 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"to": "To",
"from": "From",
"placeholders": {
"search": "Search...",
"search_speakers": "Search Speakers by Name, Email, Speaker Id or Member Id",
"select_acceptance_criteria": "Select acceptance criteria",
"select_invitation_status": "Select status"
Expand Down Expand Up @@ -186,6 +187,7 @@
"sponsor_list": "Sponsor List",
"sponsor_forms": "Forms",
"sponsor_pages": "Pages",
"sponsor_purchases": "Purchases",
"sponsorship_list": "Tiers",
"sponsor_users": "Users",
"sponsors_promocodes": "Promo Codes",
Expand Down Expand Up @@ -2881,6 +2883,16 @@
}
}
},
"sponsor_show_purchases": {
"order": "Order",
"purchased": "Purchased",
"sponsor": "Sponsor",
"payment_method": "Payment Method",
"status": "Status",
"amount": "Amount",
"details": "Details",
"purchases": "Purchases"
},
"sponsor_users": {
"users": "Users",
"access_request": "access request",
Expand Down Expand Up @@ -4191,7 +4203,8 @@
"reason": "Reason for Refund",
"amount": "Amount",
"queue_refund": "Queue refund",
"info": "If the original payment was made via Stripe, the refund will be automatically queued and processed."
"info": "If the original payment was made via Stripe, the refund will be automatically queued and processed.",
"only_online_payments": "Only online payments are eligible for refunds"
},
"client_card": {
"title": "Client & Address Details",
Expand Down
Loading
Loading