From e59f3ef788d7b3145d7ed4e5507756a3c530eb59 Mon Sep 17 00:00:00 2001 From: Julia Wegmayr Date: Fri, 13 Dec 2024 13:14:01 +0100 Subject: [PATCH 1/3] add sendingState filter --- demo/api/schema.gql | 7 +++++++ .../admin/src/emailCampaigns/EmailCampaignsGrid.tsx | 12 +++++++++++- .../src/email-campaign/dto/email-campaign.filter.ts | 13 ++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/demo/api/schema.gql b/demo/api/schema.gql index 13a3eacc..4a7fcdb9 100644 --- a/demo/api/schema.gql +++ b/demo/api/schema.gql @@ -666,11 +666,18 @@ input EmailCampaignFilter { updatedAt: DateFilter title: StringFilter subject: StringFilter + sendingState: SendingStateEnumFilter scheduledAt: DateFilter and: [EmailCampaignFilter!] or: [EmailCampaignFilter!] } +input SendingStateEnumFilter { + isAnyOf: [SendingState!] + equal: SendingState + notEqual: SendingState +} + input EmailCampaignSort { field: EmailCampaignSortField! direction: SortDirection! = ASC diff --git a/packages/admin/src/emailCampaigns/EmailCampaignsGrid.tsx b/packages/admin/src/emailCampaigns/EmailCampaignsGrid.tsx index 2fa765da..b0fa34b7 100644 --- a/packages/admin/src/emailCampaigns/EmailCampaignsGrid.tsx +++ b/packages/admin/src/emailCampaigns/EmailCampaignsGrid.tsx @@ -120,6 +120,15 @@ export function EmailCampaignsGrid({ ...usePersistentColumnState("EmailCampaignsGrid"), }; + const sendingStateOptions: { label: string; value: string }[] = [ + { + value: "SENT", + label: intl.formatMessage({ id: "cometBrevoModule.emailCampaign.sent", defaultMessage: "Sent" }), + }, + { value: "DRAFT", label: intl.formatMessage({ id: "cometBrevoModule.emailCampaign.draft", defaultMessage: "Draft" }) }, + { value: "SCHEDULED", label: intl.formatMessage({ id: "cometBrevoModule.emailCampaign.scheduled", defaultMessage: "Scheduled" }) }, + ]; + const columns: GridColDef[] = [ { field: "updatedAt", @@ -144,8 +153,9 @@ export function EmailCampaignsGrid({ headerName: intl.formatMessage({ id: "cometBrevoModule.emailCampaign.sendingState", defaultMessage: "Sending State" }), renderCell: ({ value }) => , width: 150, - filterable: false, sortable: false, + type: "singleSelect", + valueOptions: sendingStateOptions, }, { field: "scheduledAt", diff --git a/packages/api/src/email-campaign/dto/email-campaign.filter.ts b/packages/api/src/email-campaign/dto/email-campaign.filter.ts index a94fb90e..9a77195b 100644 --- a/packages/api/src/email-campaign/dto/email-campaign.filter.ts +++ b/packages/api/src/email-campaign/dto/email-campaign.filter.ts @@ -1,8 +1,13 @@ -import { DateFilter, StringFilter } from "@comet/cms-api"; +import { createEnumFilter, DateFilter, StringFilter } from "@comet/cms-api"; import { Field, InputType } from "@nestjs/graphql"; import { Type } from "class-transformer"; import { IsOptional, ValidateNested } from "class-validator"; +import { SendingState } from "../sending-state.enum"; + +@InputType() +class SendingStateEnumFilter extends createEnumFilter(SendingState) {} + @InputType() export class EmailCampaignFilter { @Field(() => DateFilter, { nullable: true }) @@ -29,6 +34,12 @@ export class EmailCampaignFilter { @Type(() => StringFilter) subject?: StringFilter; + @Field(() => SendingStateEnumFilter, { nullable: true }) + @ValidateNested() + @IsOptional() + @Type(() => SendingStateEnumFilter) + sendingState?: SendingStateEnumFilter; + @Field(() => DateFilter, { nullable: true }) @ValidateNested() @IsOptional() From d47d0f770fa6e78de1926e4f0a64e5160ac50f8e Mon Sep 17 00:00:00 2001 From: Julia Wegmayr Date: Fri, 13 Dec 2024 13:58:36 +0100 Subject: [PATCH 2/3] add changeset --- .changeset/green-flies-beam.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/green-flies-beam.md diff --git a/.changeset/green-flies-beam.md b/.changeset/green-flies-beam.md new file mode 100644 index 00000000..e3e37957 --- /dev/null +++ b/.changeset/green-flies-beam.md @@ -0,0 +1,6 @@ +--- +"@comet/brevo-admin": minor +"@comet/brevo-api": minor +--- + +Add filter for `sendingState` in `EmailCampaignsGrid` From da1a0efd845de909905b71b8c3ae5081c8bea6c9 Mon Sep 17 00:00:00 2001 From: Julia Wegmayr Date: Fri, 20 Dec 2024 09:32:44 +0100 Subject: [PATCH 3/3] generate schema in api package --- packages/api/schema.gql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/api/schema.gql b/packages/api/schema.gql index c2c1609a..48b1ecba 100644 --- a/packages/api/schema.gql +++ b/packages/api/schema.gql @@ -227,11 +227,18 @@ input EmailCampaignFilter { updatedAt: DateFilter title: StringFilter subject: StringFilter + sendingState: SendingStateEnumFilter scheduledAt: DateFilter and: [EmailCampaignFilter!] or: [EmailCampaignFilter!] } +input SendingStateEnumFilter { + isAnyOf: [SendingState!] + equal: SendingState + notEqual: SendingState +} + input EmailCampaignSort { field: EmailCampaignSortField! direction: SortDirection! = ASC