diff --git a/src/pages/admin/signups/[id].tsx b/src/pages/admin/signups/[id].tsx
index 7135748..62aa0d7 100644
--- a/src/pages/admin/signups/[id].tsx
+++ b/src/pages/admin/signups/[id].tsx
@@ -102,15 +102,16 @@ const SignupCreatePage: NextPage = () => {
const router = useRouter();
- let id: number;
+ let id: string;
if (router.query?.id && router.query.id !== "create") {
- id = Number(router.query.id);
+ id = router.query.id as string;
}
useEffect(() => {
- if (!Number.isNaN(id)) {
- SignupApi.getForm(id, true)
+ const suId = id && Number(id);
+ if (suId !== undefined && !Number.isNaN(suId)) {
+ SignupApi.getForm(suId, true)
.then((res) => {
setFormData({
...res,
diff --git a/src/pages/admin/signups/[id]/list.tsx b/src/pages/admin/signups/[id]/list.tsx
index a3723dc..d3c005b 100644
--- a/src/pages/admin/signups/[id]/list.tsx
+++ b/src/pages/admin/signups/[id]/list.tsx
@@ -26,13 +26,19 @@ const SignupEmailPage: NextPage = () => {
const { id } = router.query;
useEffect(() => {
- const formId = Number(id);
- SignupApi.getForm(formId, true)
- .then((res) => setSignupForm(res));
-
- SignupApi.getSignups(formId).then((res) => setSignups(res));
+ const formId = id && Number(id);
+ if (formId !== undefined && !Number.isNaN(formId)) {
+ SignupApi.getForm(formId, true).then((res) => {
+ setSignupForm(res);
+ });
+ SignupApi.getSignups(formId).then((res) => {
+ setSignups(res);
+ });
+ }
}, [id]);
+ const title = signupForm ? signupForm.title_fi : "Loading...";
+
const confirmDelete = async (signup: Signup, question: any) => {
if (window.confirm(`Delete: ${signup.id}: ${signup.answer[question.id]}; Are you sure?`) === true) {
try {
@@ -45,27 +51,25 @@ const SignupEmailPage: NextPage = () => {
}
};
- const title = signupForm ? signupForm.title_fi : "Loading...";
+ const renderData = () => {
+ if (!signupForm || !signups || signups.length === 0) {
+ return
No signups.
;
+ }
- // TODO: ATM we filter 'info' questions from table here. Maybe remove them from answer JSON altogether?
- const questions = signupForm ? signupForm.questions.filter((q) => q.type !== "info").map((q) => ({
- title: q.title_fi,
- id: q.id,
- })) : [];
+ // TODO: ATM we filter 'info' questions from table here. Maybe remove them from answer JSON altogether?
+ const questions = signupForm ? signupForm.questions.filter((q) => q.type !== "info").map((q) => ({
+ title: q.title_fi,
+ id: q.id,
+ })) : [];
- // Generate 2-dimensional array where rows are signups and columns are answers to questions.
- const CSVData = signups.map((s) => questions.map((q) => s.answer[q.id]));
- // Add reserve signup "header"
- if (signupForm?.quota) {
- CSVData.splice(signupForm.quota, 0, ["RESERVE-SIGNUPS"]);
- }
+ // Generate 2-dimensional array where rows are signups and columns are answers to questions.
+ const CSVData = signups.map((s) => questions.map((q) => s.answer[q.id]));
+ // Add reserve signup "header"
+ if (signupForm?.quota) {
+ CSVData.splice(signupForm.quota, 0, ["RESERVE-SIGNUPS"]);
+ }
- return (
-
-
- {title}
- : Sign-ups
-
+ return (
@@ -81,7 +85,6 @@ const SignupEmailPage: NextPage = () => {
-
{signups.map((s) => (
@@ -99,6 +102,16 @@ const SignupEmailPage: NextPage = () => {
))}
+ );
+ };
+
+ return (
+
+
+ {title}
+ : Sign-ups
+
+ {renderData()}
);
};
diff --git a/src/views/CorporatePage/CorporatePageView.tsx b/src/views/CorporatePage/CorporatePageView.tsx
index 289effa..432786f 100644
--- a/src/views/CorporatePage/CorporatePageView.tsx
+++ b/src/views/CorporatePage/CorporatePageView.tsx
@@ -100,7 +100,7 @@ const CorporatePageView: React.FC = ({ jobAds }) => (
Mainos Sössöön?
diff --git a/src/views/FreshmenPage/FreshmenPageHero.tsx b/src/views/FreshmenPage/FreshmenPageHero.tsx
index 948c0ba..0c2d82f 100644
--- a/src/views/FreshmenPage/FreshmenPageHero.tsx
+++ b/src/views/FreshmenPage/FreshmenPageHero.tsx
@@ -19,7 +19,7 @@ const FreshmenPageHero: React.FC = () => (
= ({ events, feed }) => (
-
-
-
-
-
+
+
@@ -115,14 +108,8 @@ const FrontPageView: React.FC = ({ events, feed }) => (
-
-
-
-
-
-
-
-
+
+
Haluatko kuulla lisää yhteistyöstä kanssamme?
diff --git a/tests/testcafe/utils.ts b/tests/testcafe/utils.ts
index e734fd7..d2401f5 100644
--- a/tests/testcafe/utils.ts
+++ b/tests/testcafe/utils.ts
@@ -7,7 +7,7 @@ const API_URL = "https://api.dev.sahkoinsinoorikilta.fi/api";
export const getSiteRoot = (): string => process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000";
export const getPageUrl = ClientFunction(() => window.location.pathname);
-export const getPostRequestLogger = (url: string) => RequestLogger({ url: `${API_URL}/${url}`, method: "post" }, {
+export const getPostRequestLogger = (url: string) => RequestLogger({ url: `${API_URL}/${url}`, method: "POST" }, {
// logResponseHeaders: true,
logResponseBody: true,
stringifyResponseBody: true,