Skip to content
This repository has been archived by the owner on Feb 12, 2025. It is now read-only.

Commit

Permalink
Add functions to PortfolioHelper to remove Portfolio Items
Browse files Browse the repository at this point in the history
Add removePortfolioItem and removePortfolioItems functions,
fix some small lint errors.
  • Loading branch information
Hilda Stastna committed Jan 22, 2019
1 parent c9bc9a1 commit 4c3a391
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Helpers/Portfolio/PortfolioHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export async function addToPortfolio(portfolioId, items) {
let idx = 0; let newItem = null;

for (idx = 0; idx < items.length; idx++) {
newItem = await userApi.addPortfolioItem (JSON.stringify ({ service_offering_ref: items[idx] }));
newItem = await userApi.addPortfolioItem(JSON.stringify({ serviceOfferingRef: items[idx] }));
if (newItem) {
await userApi.addPortfolioItemToPortfolio(portfolioId, JSON.stringify({ portfolio_item_id: newItem.id }));
await userApi.addPortfolioItemToPortfolio(portfolioId, JSON.stringify({ portfolioItemId: newItem.id }));
}
}

Expand All @@ -59,3 +59,11 @@ export async function updatePortfolio(portfolioData) {
export async function removePortfolio(portfolioId) {
await userApi.destroyPortfolio(portfolioId);
}

export async function removePortfolioItem(portfolioItemId) {
return userApi.destroyPortfolioItem(portfolioItemId);
}

export async function removePortfolioItems(portfolioItemIds) {
return Promise.all(portfolioItemIds.map(async itemId => await removePortfolioItem(itemId)));
}

0 comments on commit 4c3a391

Please sign in to comment.