diff --git a/packages/admin/src/targetGroups/TargetGroupsGrid.tsx b/packages/admin/src/targetGroups/TargetGroupsGrid.tsx index ef2eca6a..6886cd82 100644 --- a/packages/admin/src/targetGroups/TargetGroupsGrid.tsx +++ b/packages/admin/src/targetGroups/TargetGroupsGrid.tsx @@ -38,6 +38,7 @@ const targetGroupsFragment = gql` title totalSubscribers totalContactsBlocked + isMainList } `; @@ -123,15 +124,15 @@ export function TargetGroupsGrid({ scope }: { scope: ContentScopeInterface }): R sortable: false, filterable: false, type: "actions", - renderCell: (params) => { + renderCell: ({ row }) => { + if (row.isMainList) return; return ( <> - + { - const row = params.row; return { title: row.title, }; @@ -145,7 +146,7 @@ export function TargetGroupsGrid({ scope }: { scope: ContentScopeInterface }): R onDelete={async () => { await client.mutate({ mutation: deleteTargetGroupMutation, - variables: { id: params.row.id }, + variables: { id: row.id }, }); }} refetchQueries={[targetGroupsQuery]} diff --git a/packages/api/src/target-group/target-group.resolver.ts b/packages/api/src/target-group/target-group.resolver.ts index ef3df9f1..4921b584 100644 --- a/packages/api/src/target-group/target-group.resolver.ts +++ b/packages/api/src/target-group/target-group.resolver.ts @@ -108,6 +108,10 @@ export function createTargetGroupsResolver({ ): Promise { const targetGroup = await this.repository.findOneOrFail(id); + if (targetGroup.isMainList) { + throw new Error("Cannot edit a main target group"); + } + if (lastUpdatedAt) { validateNotModified(targetGroup, lastUpdatedAt); } @@ -135,6 +139,10 @@ export function createTargetGroupsResolver({ async deleteTargetGroup(@Args("id", { type: () => ID }) id: string): Promise { const targetGroup = await this.repository.findOneOrFail(id); + if (targetGroup.isMainList) { + throw new Error("Cannot delete a main target group"); + } + const isDeletedInBrevo = await this.brevoApiContactsService.deleteBrevoContactList(targetGroup.brevoId); if (!isDeletedInBrevo) {