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` 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/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 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()