From e51637c03646cc3ec7b7eb929175cf4c67b06335 Mon Sep 17 00:00:00 2001 From: Ian Krieger Date: Wed, 11 Oct 2023 14:55:54 -0400 Subject: [PATCH] chore: simplify campaign management flags --- src/auth/components/AdvertiserAgreed.tsx | 2 +- src/auth/context/auth.interface.ts | 3 +-- src/auth/hooks/queries/useAdvertiser.ts | 3 +-- src/auth/lib/index.ts | 3 +-- src/components/Drawer/MiniSideBar.tsx | 2 +- src/components/Navigation/Navbar.tsx | 2 +- src/components/Navigation/NewCampaignButton.tsx | 2 +- src/components/Navigation/NewImageButton.tsx | 2 +- src/graphql/advertiser.generated.tsx | 6 ++---- src/graphql/advertiser.graphql | 3 +-- src/graphql/types.ts | 2 ++ src/user/User.tsx | 8 ++++++-- src/user/views/user/CampaignView.tsx | 4 +--- 13 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/auth/components/AdvertiserAgreed.tsx b/src/auth/components/AdvertiserAgreed.tsx index d7512c92..3a61f215 100644 --- a/src/auth/components/AdvertiserAgreed.tsx +++ b/src/auth/components/AdvertiserAgreed.tsx @@ -20,7 +20,7 @@ import { PaymentType } from "graphql/types"; export function AdvertiserAgreed() { const { advertiser } = useAdvertiser(); const requiresPaymentAgree = - advertiser.selfServiceCreate && + advertiser.selfServiceManageCampaign && advertiser.selfServicePaymentType !== PaymentType.Netsuite; const history = useHistory(); const { setSessionUser } = useAuthContext(); diff --git a/src/auth/context/auth.interface.ts b/src/auth/context/auth.interface.ts index 5b76cd39..01def0b6 100644 --- a/src/auth/context/auth.interface.ts +++ b/src/auth/context/auth.interface.ts @@ -5,8 +5,7 @@ import { PaymentType } from "graphql/types"; export type IAdvertiser = { id: string; name: string; - selfServiceCreate: boolean; - selfServiceEdit: boolean; + selfServiceManageCampaign: boolean; selfServiceSetPrice: boolean; selfServicePaymentType: PaymentType; publicKey?: string | null; diff --git a/src/auth/hooks/queries/useAdvertiser.ts b/src/auth/hooks/queries/useAdvertiser.ts index fa2330f9..83164060 100644 --- a/src/auth/hooks/queries/useAdvertiser.ts +++ b/src/auth/hooks/queries/useAdvertiser.ts @@ -11,8 +11,7 @@ export function useAdvertiser(): { const defaultAdvertiser: IAdvertiser = { id: "", name: "", - selfServiceCreate: false, - selfServiceEdit: false, + selfServiceManageCampaign: false, selfServiceSetPrice: false, publicKey: null, selfServicePaymentType: PaymentType.Stripe, diff --git a/src/auth/lib/index.ts b/src/auth/lib/index.ts index f87048a9..037187eb 100644 --- a/src/auth/lib/index.ts +++ b/src/auth/lib/index.ts @@ -7,8 +7,7 @@ import { RegistrationForm } from "auth/registration/types"; export type Advertiser = Pick< AdvertiserFragment, | "selfServiceSetPrice" - | "selfServiceCreate" - | "selfServiceEdit" + | "selfServiceManageCampaign" | "id" | "name" | "publicKey" diff --git a/src/components/Drawer/MiniSideBar.tsx b/src/components/Drawer/MiniSideBar.tsx index 88f16990..9c46d1e1 100644 --- a/src/components/Drawer/MiniSideBar.tsx +++ b/src/components/Drawer/MiniSideBar.tsx @@ -54,7 +54,7 @@ export default function MiniSideBar({ children }: PropsWithChildren) { sx={{ color: "text.secondary" }} /> ), - disabled: !advertiser.selfServiceCreate, + disabled: !advertiser.selfServiceManageCampaign, }, { label: "Creatives", diff --git a/src/components/Navigation/Navbar.tsx b/src/components/Navigation/Navbar.tsx index 9716b9b2..150e358b 100644 --- a/src/components/Navigation/Navbar.tsx +++ b/src/components/Navigation/Navbar.tsx @@ -44,7 +44,7 @@ export function Navbar() { Ads - {advertiser.selfServiceCreate && } + {advertiser.selfServiceManageCampaign && }
{ diff --git a/src/components/Navigation/NewCampaignButton.tsx b/src/components/Navigation/NewCampaignButton.tsx index 93674608..9f5fe6c6 100644 --- a/src/components/Navigation/NewCampaignButton.tsx +++ b/src/components/Navigation/NewCampaignButton.tsx @@ -12,7 +12,7 @@ export function NewCampaignButton() { .utc() .valueOf()}/settings`; - if (!advertiser.selfServiceCreate) { + if (!advertiser.selfServiceManageCampaign) { return null; } diff --git a/src/components/Navigation/NewImageButton.tsx b/src/components/Navigation/NewImageButton.tsx index 5ff6d836..aee62d2f 100644 --- a/src/components/Navigation/NewImageButton.tsx +++ b/src/components/Navigation/NewImageButton.tsx @@ -4,7 +4,7 @@ import { Button } from "@mui/material"; export function NewImageButton(props: { onClick: () => void }) { const { advertiser } = useAdvertiser(); - if (!advertiser.selfServiceCreate) { + if (!advertiser.selfServiceManageCampaign) { return null; } diff --git a/src/graphql/advertiser.generated.tsx b/src/graphql/advertiser.generated.tsx index 6357b476..088b0155 100644 --- a/src/graphql/advertiser.generated.tsx +++ b/src/graphql/advertiser.generated.tsx @@ -18,8 +18,7 @@ export type AdvertiserSummaryFragment = { export type AdvertiserFragment = { referrer?: string | null; phone?: string | null; - selfServiceEdit: boolean; - selfServiceCreate: boolean; + selfServiceManageCampaign: boolean; selfServiceSetPrice: boolean; id: string; name: string; @@ -193,8 +192,7 @@ export const AdvertiserFragmentDoc = gql` ...AdvertiserSummary referrer phone - selfServiceEdit - selfServiceCreate + selfServiceManageCampaign selfServiceSetPrice mailingAddress { street1 diff --git a/src/graphql/advertiser.graphql b/src/graphql/advertiser.graphql index 9b1fd5f9..f4565a98 100644 --- a/src/graphql/advertiser.graphql +++ b/src/graphql/advertiser.graphql @@ -13,8 +13,7 @@ fragment Advertiser on Advertiser { ...AdvertiserSummary referrer phone - selfServiceEdit - selfServiceCreate + selfServiceManageCampaign selfServiceSetPrice mailingAddress { street1 diff --git a/src/graphql/types.ts b/src/graphql/types.ts index 24df2ce3..bb73892f 100644 --- a/src/graphql/types.ts +++ b/src/graphql/types.ts @@ -179,6 +179,7 @@ export type CreateAdvertiserInput = { referrer?: InputMaybe; selfServiceCreate?: InputMaybe; selfServiceEdit?: InputMaybe; + selfServiceManageCampaign?: InputMaybe; state?: InputMaybe; url?: InputMaybe; userId?: InputMaybe; @@ -459,6 +460,7 @@ export type UpdateAdvertiserInput = { referrer?: InputMaybe; selfServiceCreate?: InputMaybe; selfServiceEdit?: InputMaybe; + selfServiceManageCampaign?: InputMaybe; state?: InputMaybe; url?: InputMaybe; userId?: InputMaybe; diff --git a/src/user/User.tsx b/src/user/User.tsx index 066857a1..6ad65b7b 100644 --- a/src/user/User.tsx +++ b/src/user/User.tsx @@ -66,13 +66,17 @@ export function User() { a.selfServiceCreate} + validateAdvertiserProperty={(a) => + a.selfServiceManageCampaign + } /> a.selfServiceEdit} + validateAdvertiserProperty={(a) => + a.selfServiceManageCampaign + } /> ([]); - const advertiserCanAction = - advertiser.selfServiceCreate && advertiser.selfServiceEdit; const handleCampaignSelect = useCallback( (c: string, include: boolean) => { @@ -60,7 +58,7 @@ export function CampaignView() { ) : ( "Campaigns"