Skip to content

Commit

Permalink
chore: simplify advertiser update API (#1232)
Browse files Browse the repository at this point in the history
Uses new GraphQL definition to simplify server interaction
  • Loading branch information
IanKrieger committed Jun 13, 2024
1 parent 7cd99d1 commit c7a54f0
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 34 deletions.
15 changes: 12 additions & 3 deletions src/auth/components/AdvertiserDetailsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useHistory } from "react-router-dom";
import {
AdvertiserBillingAddressDocument,
PaymentType,
UpdateAdvertiserDocument,
} from "@/graphql-client/graphql";
import { AdvertiserAgreed } from "@/auth/components/AdvertiserAgreed";
import { FormikSubmitButton } from "@/form/FormikButton";
Expand All @@ -20,6 +19,16 @@ import { useTrackWithMatomo } from "@/hooks/useTrackWithMatomo";
import _ from "lodash";
import { msg, Trans } from "@lingui/macro";
import { useMutation, useQuery } from "@apollo/client";
import { graphql } from "@/graphql-client/index";

export const Advertiser_Update = graphql(`
mutation UpdateAdvertiser($input: UpdateSelfServeAdvertiserInput!) {
updateSelfServeAdvertiser(updateAdvertiserInput: $input) {
id
publicKey
}
}
`);

export function AdvertiserDetailsForm() {
const { trackMatomoEvent } = useTrackWithMatomo({
Expand All @@ -35,7 +44,7 @@ export function AdvertiserDetailsForm() {
initialAdvertiserForm(!requiresPaymentAgree),
);

const [mutation] = useMutation(UpdateAdvertiserDocument, {
const [mutation] = useMutation(Advertiser_Update, {
async onCompleted() {
const user = await getUser();
setSessionUser(user);
Expand Down Expand Up @@ -63,7 +72,7 @@ export function AdvertiserDetailsForm() {
setSubmitting(true);
await mutation({
variables: {
updateAdvertiserInput: {
input: {
id: advertiser.id,
agreed: v.terms && v.tracking && v.payment && v.language,
billingAddress: v.address.id
Expand Down
9 changes: 7 additions & 2 deletions src/graphql-client/gql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c7a54f0

Please sign in to comment.