Skip to content

Commit

Permalink
Merge branch 'main' into asana-feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Awesome-E authored Jan 13, 2025
2 parents 621e3eb + aecd5d1 commit fae766b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
1 change: 0 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 8 additions & 4 deletions api/src/helpers/recaptcha.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { ReviewSubmission } from '@peterportal/types';
import axios from 'axios';

export async function verifyCaptcha(review: ReviewSubmission) {
const reqBody = {
secret: process.env.GRECAPTCHA_SECRET ?? '',
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 };
Expand Down
35 changes: 15 additions & 20 deletions pnpm-lock.yaml

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

1 change: 0 additions & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 24 additions & 0 deletions site/src/pages/RoadmapPage/RoadmapMultiplan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface RoadmapSelectableItemProps {
index: number;
clickHandler: () => void;
editHandler: () => void;
duplicateHandler: () => void;
deleteHandler: () => void;
}

Expand All @@ -28,6 +29,7 @@ const RoadmapSelectableItem: FC<RoadmapSelectableItemProps> = ({
index,
clickHandler,
editHandler,
duplicateHandler,
deleteHandler,
}) => {
return (
Expand All @@ -38,6 +40,9 @@ const RoadmapSelectableItem: FC<RoadmapSelectableItemProps> = ({
<Button onClick={editHandler}>
<Icon.PencilFill width="16" height="16" />
</Button>
<Button onClick={duplicateHandler}>
<Icon.Files width="16" height="16" />
</Button>
<Button onClick={deleteHandler}>
<Icon.TrashFill width="16" height="16" />
</Button>
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -121,6 +144,7 @@ const RoadmapMultiplan: FC = () => {
setCurrentPlanIndex(index);
}}
editHandler={() => setEditIdx(index)}
duplicateHandler={() => duplicatePlan(plan)}
deleteHandler={() => setDelIdx(index)}
/>
))}
Expand Down

0 comments on commit fae766b

Please sign in to comment.