|
|
@@ -8,8 +8,27 @@ 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',
|
|
|
@@ -26,8 +45,18 @@ export const assignPromotionsToChannelBulkAction = createBulkAssignToChannelActi
|
|
|
location: 'promotion-list',
|
|
|
requiresPermission: Permission.UpdatePromotion,
|
|
|
getItemName: item => item.name,
|
|
|
- bulkAssignToChannel: (dataService, promotionIds, channelIds) =>
|
|
|
- channelIds.map(channelId =>
|
|
|
+ bulkAssignToChannel: (dataService, promotionIds, channelIds) => {
|
|
|
+ console.log({ channelIds });
|
|
|
+ dataService
|
|
|
+ .mutate(AssignPromotionsToChannelDocument, {
|
|
|
+ input: {
|
|
|
+ channelId: channelIds[0],
|
|
|
+ promotionIds,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ .pipe(map(res => res.assignPromotionsToChannel));
|
|
|
+
|
|
|
+ return channelIds.map(channelId =>
|
|
|
dataService
|
|
|
.mutate(AssignPromotionsToChannelDocument, {
|
|
|
input: {
|
|
|
@@ -36,7 +65,8 @@ export const assignPromotionsToChannelBulkAction = createBulkAssignToChannelActi
|
|
|
},
|
|
|
})
|
|
|
.pipe(map(res => res.assignPromotionsToChannel)),
|
|
|
- ),
|
|
|
+ );
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
export const removePromotionsFromChannelBulkAction = createBulkRemoveFromChannelAction<
|