Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sendingState filter in EmailCampaignsGrid #249

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/green-flies-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@comet/brevo-admin": minor
"@comet/brevo-api": minor
---

Add filter for `sendingState` in `EmailCampaignsGrid`
7 changes: 7 additions & 0 deletions demo/api/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Comment on lines +669 to +680
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema changes of the packages/api/schema.gql are missing in this PR, they should be here as wenn

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added here: da1a0ef after fixing generate-scheme file in the main branch.

input EmailCampaignSort {
field: EmailCampaignSortField!
direction: SortDirection! = ASC
Expand Down
12 changes: 11 additions & 1 deletion packages/admin/src/emailCampaigns/EmailCampaignsGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<GQLEmailCampaignsListFragment>[] = [
{
field: "updatedAt",
Expand All @@ -144,8 +153,9 @@ export function EmailCampaignsGrid({
headerName: intl.formatMessage({ id: "cometBrevoModule.emailCampaign.sendingState", defaultMessage: "Sending State" }),
renderCell: ({ value }) => <SendingStateColumn sendingState={value} />,
width: 150,
filterable: false,
sortable: false,
type: "singleSelect",
valueOptions: sendingStateOptions,
},
{
field: "scheduledAt",
Expand Down
13 changes: 12 additions & 1 deletion packages/api/src/email-campaign/dto/email-campaign.filter.ts
Original file line number Diff line number Diff line change
@@ -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 })
Expand All @@ -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()
Expand Down
Loading