|
|
@@ -8,27 +8,8 @@ import {
|
|
|
Permission,
|
|
|
RemovePromotionsFromChannelDocument,
|
|
|
} from '@vendure/admin-ui/core';
|
|
|
-import { gql } from 'apollo-angular';
|
|
|
import { map } from 'rxjs/operators';
|
|
|
|
|
|
-const ASSIGN_PROMOTIONS_TO_CHANNEL = gql`
|
|
|
- mutation AssignPromotionsToChannel($input: AssignPromotionsToChannelInput!) {
|
|
|
- assignPromotionsToChannel(input: $input) {
|
|
|
- id
|
|
|
- name
|
|
|
- }
|
|
|
- }
|
|
|
-`;
|
|
|
-
|
|
|
-const REMOVE_PROMOTIONS_FROM_CHANNEL = gql`
|
|
|
- mutation RemovePromotionsFromChannel($input: RemovePromotionsFromChannelInput!) {
|
|
|
- removePromotionsFromChannel(input: $input) {
|
|
|
- id
|
|
|
- name
|
|
|
- }
|
|
|
- }
|
|
|
-`;
|
|
|
-
|
|
|
export const deletePromotionsBulkAction = createBulkDeleteAction<ItemOf<GetPromotionListQuery, 'promotions'>>(
|
|
|
{
|
|
|
location: 'promotion-list',
|
|
|
@@ -45,15 +26,17 @@ export const assignPromotionsToChannelBulkAction = createBulkAssignToChannelActi
|
|
|
location: 'promotion-list',
|
|
|
requiresPermission: Permission.UpdatePromotion,
|
|
|
getItemName: item => item.name,
|
|
|
- bulkAssignToChannel: (dataService, promotionIds, channelId) =>
|
|
|
- dataService
|
|
|
- .mutate(AssignPromotionsToChannelDocument, {
|
|
|
- input: {
|
|
|
- channelId,
|
|
|
- promotionIds,
|
|
|
- },
|
|
|
- })
|
|
|
- .pipe(map(res => res.assignPromotionsToChannel)),
|
|
|
+ bulkAssignToChannel: (dataService, promotionIds, channelIds) =>
|
|
|
+ channelIds.map(channelId =>
|
|
|
+ dataService
|
|
|
+ .mutate(AssignPromotionsToChannelDocument, {
|
|
|
+ input: {
|
|
|
+ channelId,
|
|
|
+ promotionIds,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .pipe(map(res => res.assignPromotionsToChannel)),
|
|
|
+ ),
|
|
|
});
|
|
|
|
|
|
export const removePromotionsFromChannelBulkAction = createBulkRemoveFromChannelAction<
|