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

Production Release 2024-07-30 #1281

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 12 additions & 11 deletions src/components/Creatives/CreativeStatusSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ import {
AdvertiserCreativesDocument,
CampaignsForCreativeDocument,
CreativeFragment,
UpdateCreativeDocument,
} from "@/graphql-client/graphql";
import { useLazyQuery, useMutation } from "@apollo/client";
import { graphql } from "@/graphql-client/index";

interface Props {
creative: CreativeFragment;
}

const Creative_State_Update = graphql(`
mutation AdsManagerUpdateCreativeState($id: String!, $state: String!) {
adsManagerUpdateCreativeState(id: $id, state: $state) {
id
}
}
`);

type RelatedCampaign = { id: string; name: string; state: string };
export function CreativeStatusSwitch({ creative }: Props) {
const { advertiser } = useAdvertiser();
Expand All @@ -41,20 +49,13 @@ export function CreativeStatusSwitch({ creative }: Props) {
);
const [creativeState, setCreativeState] = useState(input.state);
const [update, { loading: updateLoading }] = useMutation(
UpdateCreativeDocument,
Creative_State_Update,
{
refetchQueries: [
{
query: AdvertiserCreativesDocument,
variables: { advertiserId: advertiser.id },
},
{
query: CampaignsForCreativeDocument,
variables: {
creativeId: creative.id,
advertiserId: advertiser.id,
},
},
],
onCompleted() {
setRelatedCampaigns([]);
Expand Down Expand Up @@ -86,7 +87,7 @@ export function CreativeStatusSwitch({ creative }: Props) {
update({
variables: {
id: creative.id,
input: { ...input, state: theState },
state: theState,
},
});
}
Expand Down Expand Up @@ -137,7 +138,7 @@ export function CreativeStatusSwitch({ creative }: Props) {
update({
variables: {
id: creative.id,
input: { ...input, state: creativeState },
state: creativeState,
},
});
}}
Expand Down
25 changes: 22 additions & 3 deletions src/components/Creatives/hooks/useSubmitCreative.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useCallback } from "react";
import {
AdvertiserCreativesDocument,
CreateCreativeDocument,
UpdateCreativeDocument,
} from "@/graphql-client/graphql";
import { useAdvertiser } from "@/auth/hooks/queries/useAdvertiser";
import { useHistory } from "react-router-dom";
Expand All @@ -11,6 +10,17 @@ import _ from "lodash";
import { useTrackMatomoEvent } from "@/hooks/useTrackWithMatomo";
import { useMutation } from "@apollo/client";
import { CreativeInputWithType } from "@/user/views/adsManager/types";
import { graphql } from "@/graphql-client/index";

const Update_Creative_Payload = graphql(`
mutation AdsManagerUpdateCreativePayload(
$input: AdsManagerUpdateCreativeInput!
) {
adsManagerUpdateCreativePayload(adsManagerUpdateCreativeInput: $input) {
id
}
}
`);

export function useSubmitCreative(props: { id: string }) {
const { trackMatomoEvent } = useTrackMatomoEvent();
Expand Down Expand Up @@ -39,7 +49,7 @@ export function useSubmitCreative(props: { id: string }) {
});

const [updateCreative, { error: updateError, loading: updateLoading }] =
useMutation(UpdateCreativeDocument, {
useMutation(Update_Creative_Payload, {
refetchQueries,
onCompleted,
onError,
Expand All @@ -65,7 +75,16 @@ export function useSubmitCreative(props: { id: string }) {
});
} else {
await updateCreative({
variables: { input: input, id: props.id },
variables: {
input: {
id: props.id,
payloadNotification: input.payloadNotification,
payloadInlineContent: _.omit(
input.payloadInlineContent,
"dimensions",
),
},
},
});
}
} finally {
Expand Down
14 changes: 12 additions & 2 deletions src/graphql-client/gql.ts

Large diffs are not rendered by default.

67 changes: 51 additions & 16 deletions src/graphql-client/graphql.ts

Large diffs are not rendered by default.

Loading