From 4462ac84a4baf24240ab9fa955266a6a5211b9be Mon Sep 17 00:00:00 2001 From: Jacob Sommer Date: Tue, 7 Jan 2025 18:14:49 -0800 Subject: [PATCH 1/2] Remove axios (#539) --- api/package.json | 1 - api/src/helpers/recaptcha.ts | 12 ++++++++---- pnpm-lock.yaml | 35 +++++++++++++++-------------------- site/package.json | 1 - 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/api/package.json b/api/package.json index 4b4aa4cd..12f71f1c 100644 --- a/api/package.json +++ b/api/package.json @@ -14,7 +14,6 @@ "dependencies": { "@trpc/server": "^10.45.2", "@vendia/serverless-express": "^4.12.6", - "axios": "^1.7.8", "connect-pg-simple": "^10.0.0", "cookie-parser": "^1.4.7", "dotenv-flow": "^4.1.0", diff --git a/api/src/helpers/recaptcha.ts b/api/src/helpers/recaptcha.ts index 61d40268..a2fcf4a8 100644 --- a/api/src/helpers/recaptcha.ts +++ b/api/src/helpers/recaptcha.ts @@ -1,5 +1,4 @@ import { ReviewSubmission } from '@peterportal/types'; -import axios from 'axios'; export async function verifyCaptcha(review: ReviewSubmission) { const reqBody = { @@ -7,9 +6,14 @@ export async function verifyCaptcha(review: ReviewSubmission) { response: review.captchaToken ?? '', }; const query = new URLSearchParams(reqBody); - const response = await axios - .post('https://www.google.com/recaptcha/api/siteverify?' + query) - .then((x) => x.data) + const response = await fetch('https://www.google.com/recaptcha/api/siteverify?' + query, { method: 'POST' }) + .then((res) => { + if (res.ok) { + return res.json(); + } else { + throw new Error(res.statusText); + } + }) .catch((e) => { console.error('Error validating captcha response', e); return { success: false }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2fde7963..535334f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,9 +54,6 @@ importers: '@vendia/serverless-express': specifier: ^4.12.6 version: 4.12.6 - axios: - specifier: ^1.7.8 - version: 1.7.9 connect-pg-simple: specifier: ^10.0.0 version: 10.0.0 @@ -163,9 +160,6 @@ importers: '@trpc/client': specifier: ^10.45.2 version: 10.45.2(@trpc/server@10.45.2) - axios: - specifier: ^1.7.8 - version: 1.7.9 bootstrap: specifier: ^4.6.2 version: 4.6.2(jquery@3.7.1)(popper.js@1.16.1) @@ -3960,9 +3954,6 @@ packages: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - rfdc@1.3.1: - resolution: {integrity: sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg==} - rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} @@ -6642,7 +6633,8 @@ snapshots: ast-types-flow@0.0.8: {} - asynckit@0.4.0: {} + asynckit@0.4.0: + optional: true available-typed-arrays@1.0.7: dependencies: @@ -6675,6 +6667,7 @@ snapshots: proxy-from-env: 1.1.0 transitivePeerDependencies: - debug + optional: true axobject-query@4.1.0: {} @@ -6846,6 +6839,7 @@ snapshots: combined-stream@1.0.8: dependencies: delayed-stream: 1.0.0 + optional: true commander@12.1.0: {} @@ -7035,7 +7029,8 @@ snapshots: has-property-descriptors: 1.0.2 object-keys: 1.1.1 - delayed-stream@1.0.0: {} + delayed-stream@1.0.0: + optional: true depd@2.0.0: {} @@ -7659,7 +7654,8 @@ snapshots: flatted@3.3.1: {} - follow-redirects@1.15.6: {} + follow-redirects@1.15.6: + optional: true for-each@0.3.3: dependencies: @@ -7670,6 +7666,7 @@ snapshots: asynckit: 0.4.0 combined-stream: 1.0.8 mime-types: 2.1.35 + optional: true forwarded@0.2.0: {} @@ -8195,7 +8192,7 @@ snapshots: mqtt-packet@6.10.0: dependencies: bl: 4.1.0 - debug: 4.3.4 + debug: 4.3.7 process-nextick-args: 2.0.1 transitivePeerDependencies: - supports-color @@ -8205,7 +8202,7 @@ snapshots: dependencies: commist: 1.1.0 concat-stream: 2.0.0 - debug: 4.3.4 + debug: 4.3.7 duplexify: 4.1.3 help-me: 3.0.0 inherits: 2.0.4 @@ -8216,7 +8213,7 @@ snapshots: pump: 3.0.0 readable-stream: 3.6.2 reinterval: 1.1.0 - rfdc: 1.3.1 + rfdc: 1.4.1 split2: 3.2.2 ws: 7.5.9 xtend: 4.0.2 @@ -8279,7 +8276,7 @@ snapshots: number-allocator@1.0.14: dependencies: - debug: 4.3.4 + debug: 4.3.7 js-sdsl: 4.3.0 transitivePeerDependencies: - supports-color @@ -8564,7 +8561,8 @@ snapshots: forwarded: 0.2.0 ipaddr.js: 1.9.1 - proxy-from-env@1.1.0: {} + proxy-from-env@1.1.0: + optional: true pstree.remy@1.1.8: {} @@ -8848,9 +8846,6 @@ snapshots: reusify@1.0.4: {} - rfdc@1.3.1: - optional: true - rfdc@1.4.1: {} rimraf@3.0.2: diff --git a/site/package.json b/site/package.json index ad60ac9b..b2125fcf 100644 --- a/site/package.json +++ b/site/package.json @@ -9,7 +9,6 @@ "@nivo/pie": "^0.88.0", "@reduxjs/toolkit": "^2.4.0", "@trpc/client": "^10.45.2", - "axios": "^1.7.8", "bootstrap": "^4.6.2", "node-html-parser": "^6.1.13", "react": "^18.3.1", From aecd5d1747221d068690efbbb3cb1f46cce77e21 Mon Sep 17 00:00:00 2001 From: Timofey Obraztsov <35554964+timobraz@users.noreply.github.com> Date: Sat, 11 Jan 2025 13:07:24 -0800 Subject: [PATCH 2/2] added button to duplicate roadmap (#532) * added button to duplicate roadmap * fix: improved duplicate panel to be more like AA * fix: brought back copy index --- .../pages/RoadmapPage/RoadmapMultiplan.tsx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/site/src/pages/RoadmapPage/RoadmapMultiplan.tsx b/site/src/pages/RoadmapPage/RoadmapMultiplan.tsx index 362c1431..026a09b2 100644 --- a/site/src/pages/RoadmapPage/RoadmapMultiplan.tsx +++ b/site/src/pages/RoadmapPage/RoadmapMultiplan.tsx @@ -20,6 +20,7 @@ interface RoadmapSelectableItemProps { index: number; clickHandler: () => void; editHandler: () => void; + duplicateHandler: () => void; deleteHandler: () => void; } @@ -28,6 +29,7 @@ const RoadmapSelectableItem: FC = ({ index, clickHandler, editHandler, + duplicateHandler, deleteHandler, }) => { return ( @@ -38,6 +40,9 @@ const RoadmapSelectableItem: FC = ({ + @@ -89,6 +94,24 @@ const RoadmapMultiplan: FC = () => { setEditIdx(-1); }; + const duplicatePlan = (plan: RoadmapPlan) => { + let newName = `${plan.name} (Copy)`; + let counter = 1; + while (allPlans.plans.find((p) => p.name === newName)) { + counter++; + newName = `${plan.name} (Copy ${counter})`; + } + dispatch( + addRoadmapPlan({ + name: newName, + content: JSON.parse(JSON.stringify(plan.content)), + }), + ); + const newIndex = allPlans.plans.length; + setCurrentPlanIndex(newIndex); + dispatch(setPlanIndex(newIndex)); + }; + useEffect(() => { document.title = `${name} | PeterPortal`; }, [name]); @@ -121,6 +144,7 @@ const RoadmapMultiplan: FC = () => { setCurrentPlanIndex(index); }} editHandler={() => setEditIdx(index)} + duplicateHandler={() => duplicatePlan(plan)} deleteHandler={() => setDelIdx(index)} /> ))}