Skip to content

Commit

Permalink
Merge branch 'main' into roadmap-search-redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
Awesome-E committed Jan 13, 2025
2 parents 5cdfee4 + 90898f8 commit d8bee9c
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 75 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
62 changes: 0 additions & 62 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
2 changes: 1 addition & 1 deletion site/src/component/AppHeader/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const AppHeader: FC = () => {
</a>
<a
className="ui button"
href="https://forms.gle/JjwBmELq26daroTh9"
href="https://form.asana.com/?k=4h9ZTRkVUT9ZwfJrmvxDDw&d=1208267282546207"
target="_blank"
rel="noopener noreferrer"
>
Expand Down
6 changes: 5 additions & 1 deletion site/src/component/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ const Footer: FC = () => {
<a href="https://docs.icssc.club/docs/developer/anteaterapi" target="_blank" rel="noreferrer">
API
</a>
<a href="https://forms.gle/JjwBmELq26daroTh9" target="_blank" rel="noreferrer">
<a
href="https://form.asana.com/?k=4h9ZTRkVUT9ZwfJrmvxDDw&d=1208267282546207"
target="_blank"
rel="noreferrer"
>
Feedback
</a>
</div>
Expand Down
5 changes: 0 additions & 5 deletions site/src/component/ReviewForm/ReviewForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,6 @@ const ReviewForm: FC<ReviewFormProps> = ({
);
})}
</Form.Control>
<Form.Text muted>
<a href="https://forms.gle/qAhCng7Ygua7SZ358" target="_blank" rel="noopener noreferrer">
Can't find your professor?
</a>
</Form.Text>
<Form.Control.Feedback type="invalid">Missing instructor</Form.Control.Feedback>
</Form.Group>
);
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 d8bee9c

Please sign in to comment.