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-11-22 #1399

Merged
merged 4 commits into from
Nov 22, 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
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
uses: github/codeql-action/init@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
uses: github/codeql-action/autobuild@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -67,4 +67,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@4f3212b61783c3c68e8309a0f18a699764811cda # v3.27.1
uses: github/codeql-action/analyze@ea9e4e37992a54ee68a9622e985e60c8e8f12d9f # v3.27.4
9 changes: 4 additions & 5 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
* @brave/ads-dev

# to reduce renovate spam: just send these to the core team
/.github/workflows @tackley @IanKrieger
/.github/workflows @tackley
.node-version @tackley

.node-version @tackley @IanKrieger

package*.json @tackley @IanKrieger
pnpm-lock.yaml @tackley @IanKrieger
package*.json @tackley
pnpm-lock.yaml @tackley


20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"dependencies": {
"@apollo/client": "3.11.9",
"@apollo/client": "3.11.10",
"@emotion/react": "11.13.3",
"@emotion/styled": "11.13.0",
"@fontsource/inter": "5.1.0",
Expand All @@ -18,9 +18,9 @@
"@lingui/format-po": "4.14.0",
"@lingui/macro": "4.14.0",
"@lingui/react": "4.14.0",
"@mui/icons-material": "6.1.6",
"@mui/lab": "6.0.0-beta.14",
"@mui/material": "6.1.6",
"@mui/icons-material": "6.1.7",
"@mui/lab": "6.0.0-beta.15",
"@mui/material": "6.1.7",
"@mui/x-data-grid": "7.22.2",
"@mui/x-date-pickers": "7.22.2",
"bignumber.js": "9.1.2",
Expand Down Expand Up @@ -83,16 +83,16 @@
"eslint-plugin-react": "7.37.2",
"eslint-plugin-react-hooks": "5.0.0",
"husky": "9.1.6",
"knip": "5.36.3",
"knip": "5.37.1",
"lint-staged": "15.2.10",
"npm-run-all2": "7.0.1",
"prettier": "3.3.3",
"typescript": "5.6.3",
"typescript-eslint": "8.13.0",
"vite": "5.4.10",
"typescript-eslint": "8.14.0",
"vite": "5.4.11",
"vite-plugin-checker": "0.8.0",
"vite-tsconfig-paths": "5.1.1",
"vitest": "2.1.4"
"vite-tsconfig-paths": "5.1.2",
"vitest": "2.1.5"
},
"engines": {
"node": ">=20",
Expand Down Expand Up @@ -122,5 +122,5 @@
"cross-spawn@>=7.0.0 <7.0.5": ">=7.0.5"
}
},
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
"packageManager": "pnpm@9.13.2+sha512.88c9c3864450350e65a33587ab801acf946d7c814ed1134da4a924f6df5a2120fd36b46aab68f7cd1d413149112d53c7db3a4136624cfd00ff1846a0c6cef48a"
}
394 changes: 200 additions & 194 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions src/checkout/hooks/useIncreaseCampaignBudget.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useCallback, useState } from "react";
import { useHistory } from "react-router-dom";
import { t } from "@lingui/macro";
import { useAdvertiser } from "@/auth/hooks/queries/useAdvertiser";
import { increaseCampaignBudget } from "@/checkout/lib/index";

export function useIncreaseCampaignBudget() {
const [loading, setLoading] = useState(false);
const history = useHistory();

const { advertiser } = useAdvertiser();
const replaceSession = useCallback(
async (campaignId: string, amount: string) => {
setLoading(true);
await increaseCampaignBudget(advertiser.id, campaignId, amount)
.then((url) => {
window.location.replace(url);
})
.catch(() => {
alert(t`Unable to create payment session. Please try again.`);
setLoading(false);
history.push(`/user/main/adsmanager/advanced/${campaignId}/review`);
});
},
[],
);

return { createPaymentSession: replaceSession, loading };
}
34 changes: 34 additions & 0 deletions src/checkout/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,37 @@ export async function validatePaymentSession(
throw new Error(t`invalid session`);
}
}

export async function increaseCampaignBudget(
advertiserId: string,
campaignId: string,
amount: string,
): Promise<string> {
const res = await fetch(
buildAdServerEndpoint("/payments/checkout-session/increase-budget"),
{
method: "POST",
mode: "cors",
credentials: "include",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
advertiserId,
campaignId,
amount,
}),
},
);

if (res.status !== 200) {
throw new Error(t`cannot create session`);
}

const { url } = await res.json();
if (url) {
return url;
} else {
throw Error(t`no session created`);
}
}
12 changes: 12 additions & 0 deletions src/locales/en.po

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

12 changes: 12 additions & 0 deletions src/locales/es.po

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

12 changes: 12 additions & 0 deletions src/locales/pt.po

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

12 changes: 12 additions & 0 deletions src/locales/test.po

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

Loading