Remove list_name from API calls, use <ol> for listing signupees

This commit is contained in:
Aarni Halinen
2020-06-22 23:01:56 +03:00
parent 4aa6f93b57
commit e4249bde8c
4 changed files with 14 additions and 7 deletions
@@ -32,7 +32,7 @@ class OptionsWidget extends React.Component<OptionsWidgetProps, OptionsWidgetSta
throw new SignupQuestionError(`Question widget type "${type}" not in types array.`);
}
if (type === "text") {
if (type === "text" || type === "email") {
return null;
}
@@ -18,6 +18,7 @@ export const optionTypes = [
"text",
"radiobutton",
"checkbox",
"email"
];
export class SignupQuestionError extends Error { }
-1
View File
@@ -6,7 +6,6 @@ export interface Signup {
id?: number;
signupForm_id: number;
answer: string;
list_name: string;
}
export async function getSignup(id: number): Promise<Signup> {
+12 -5
View File
@@ -75,6 +75,14 @@ class SignUpPage extends React.Component<SignUpPageProps, SignUpPageState> {
uniqueItems: true,
};
}
else if (question.type === "email") {
obj = {
type: "string",
title: question.name,
format: "email",
default: ""
}
}
else {
throw new Error(`No mapping to schema prop for question type ${question.type}`);
}
@@ -151,7 +159,6 @@ class SignUpPage extends React.Component<SignUpPageProps, SignUpPageState> {
id: undefined,
signupForm_id: signUpForm.id,
answer: data.formData,
list_name: data.formData[signUpForm.questions[0].id]
};
if (payload.id === undefined) {
const resp = await createSignup(payload);
@@ -204,11 +211,11 @@ class SignUpPage extends React.Component<SignUpPageProps, SignUpPageState> {
renderList() {
const { signUpForm } = this.state;
return (
<div>
{signUpForm.signups.map(s => (
<p key={s}>{s}</p>
<ol>
{signUpForm.signups.map((s, idx) => (
<li key={idx}>{s}</li>
))}
</div>
</ol>
)
}