Skip to content

Commit

Permalink
Merge pull request #870 from brave/master
Browse files Browse the repository at this point in the history
Production Release 2023-08-24
  • Loading branch information
IanKrieger authored Aug 24, 2023
2 parents d99ebf0 + a8e5af9 commit bf5ab79
Show file tree
Hide file tree
Showing 21 changed files with 182 additions and 423 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/*.generated.tsx
codegen.ts
2 changes: 1 addition & 1 deletion codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const config: CodegenConfig = {
baseTypesPath: "graphql/types.ts",
},
plugins: ["typescript-operations", "typescript-react-apollo"],
config: { withHooks: true, withRefetchFn: true },
config: { withHooks: true, withRefetchFn: true, skipTypename: true },
},
"src/graphql/types.ts": {
plugins: ["typescript"],
Expand Down
10 changes: 5 additions & 5 deletions src/components/Campaigns/CampaignAgeFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { FormControlLabel, Switch, Typography } from "@mui/material";
import _ from "lodash";
import moment from "moment";
import { Dispatch } from "react";
import { useContext } from "react";
import { FilterContext } from "state/context";

interface Props {
fromDate: Date | null;
onChange: Dispatch<Date | null>;
disabled?: boolean;
}

export const CampaignAgeFilter = ({ fromDate, onChange, disabled }: Props) => {
export const CampaignAgeFilter = ({ disabled }: Props) => {
const { fromDate, setFromDate } = useContext(FilterContext);
const onOldCampaignToggle = (showOld: boolean) => {
onChange(
setFromDate(
showOld ? null : moment().subtract(6, "month").startOf("day").toDate(),
);
};
Expand Down
12 changes: 8 additions & 4 deletions src/components/Campaigns/CloneCampaign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import {
useCreateCampaignMutation,
} from "graphql/campaign.generated";
import { useHistory } from "react-router-dom";
import { useState } from "react";
import { AdvertiserCampaignsDocument } from "graphql/advertiser.generated";
import { useContext, useState } from "react";
import { refetchAdvertiserCampaignsQuery } from "graphql/advertiser.generated";
import { createCampaignFromFragment } from "form/fragmentUtil";
import { useAdvertiser } from "auth/hooks/queries/useAdvertiser";
import ContentCopyIcon from "@mui/icons-material/ContentCopy";
import { useUser } from "auth/hooks/queries/useUser";
import { FilterContext } from "state/context";

interface Props {
campaignFragment?: CampaignFragment | null;
Expand All @@ -28,15 +29,18 @@ interface Props {

export function CloneCampaign({ campaignFragment, useChip }: Props) {
const { advertiser } = useAdvertiser();
const { fromDate } = useContext(FilterContext);
const { userId } = useUser();
const history = useHistory();
const [open, setOpen] = useState(false);

const [copyCampaign, { loading }] = useCreateCampaignMutation({
refetchQueries: [
{
query: AdvertiserCampaignsDocument,
variables: { id: advertiser.id },
...refetchAdvertiserCampaignsQuery({
id: advertiser.id,
filter: { from: fromDate },
}),
},
],
onCompleted(data) {
Expand Down
54 changes: 9 additions & 45 deletions src/components/EnhancedTable/renderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,20 @@ import { Box, Tooltip } from "@mui/material";
import _ from "lodash";
import { format, formatDistanceToNow, parseISO } from "date-fns";
import { CellValue } from "./EnhancedTable";
import { ReactChild, ReactNode } from "react";
import { ReactChild, ReactNode, useContext } from "react";
import { formatInTimeZone } from "date-fns-tz";
import enUS from "date-fns/locale/en-US";
import {
CampaignSummaryFragment,
LoadCampaignAdsDocument,
useUpdateCampaignMutation,
} from "graphql/campaign.generated";
import { AdvertiserCampaignsDocument } from "graphql/advertiser.generated";
import {
useUpdateAdMutation,
useUpdateAdSetMutation,
} from "graphql/ad-set.generated";
import { useUpdateAdSetMutation } from "graphql/ad-set.generated";
import { OnOff } from "../Switch/OnOff";
import { AdDetails } from "user/ads/AdList";
import { displayFromCampaignState } from "util/displayState";
import { AdSetDetails } from "user/adSet/AdSetList";
import { FilterContext } from "state/context";
import { refetchAdvertiserCampaignsQuery } from "graphql/advertiser.generated";

export type CellValueRenderer = (value: CellValue) => ReactNode;
const ADS_DEFAULT_TIMEZONE = "America/New_York";
Expand Down Expand Up @@ -94,16 +91,16 @@ export function renderMonetaryAmount(
}

export function campaignOnOffState(
c: CampaignSummaryFragment & { fromDate: Date | null; advertiserId: string },
c: CampaignSummaryFragment & { advertiserId: string },
): ReactNode {
const { fromDate } = useContext(FilterContext);
const [updateCampaign, { loading }] = useUpdateCampaignMutation({
refetchQueries: [
{
query: AdvertiserCampaignsDocument,
variables: {
...refetchAdvertiserCampaignsQuery({
id: c.advertiserId,
filter: { from: c.fromDate },
},
filter: { from: fromDate },
}),
},
],
});
Expand Down Expand Up @@ -163,36 +160,3 @@ export function adSetOnOffState(c: AdSetDetails): ReactNode {
/>
);
}

export function adOnOffState(c: AdDetails): ReactNode {
const [updateAd, { loading }] = useUpdateAdMutation({
refetchQueries: [
{
query: AdvertiserCampaignsDocument,
variables: { id: c.campaignId },
},
],
});

return (
<OnOff
onChange={(s) => {
{
updateAd({
variables: {
updateAdInput: {
id: c.id,
state: s,
},
},
});
}
}}
loading={loading}
state={c.state}
end={c.campaignEnd}
source={c.campaignSource}
type="Ad"
/>
);
}
Loading

0 comments on commit bf5ab79

Please sign in to comment.