Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ellipsis] Prevent responses in form fill page #80

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/components/ClosedForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const ClosedForm = () => {
return (
<div>
<p>This form is no longer accepting responses. If you believe this is an error, contact the form author.</p>
<a href='https://talkform.ai/'><button>Go to Talkform.ai</button></a>
</div>
);
};

export default ClosedForm;
25 changes: 21 additions & 4 deletions src/pages/forms/fill/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function CreateForm() {
export function CreateFormInner(props: { formId: string }) {
const { formId } = props;
const supabase = createClientComponentClient<Database>();
const [form, setForm] = useState<Form | null>(null);
const [isFormOpen, setIsFormOpen] = useState(true);
const [error, setError] = useState<Error | null>(null);
useEffect(() => {
if (!form) {
Expand All @@ -55,9 +55,12 @@ export function CreateFormInner(props: { formId: string }) {
console.error(maybeForm.message);
setError(maybeForm);
} else {
} else {
if (!maybeForm.is_open) {
setIsFormOpen(false);
}
setForm(maybeForm);
}
});
}
}, []); // The empty array ensures this effect runs only once on mount
return form ? (
Expand All @@ -71,7 +74,21 @@ export function CreateFormInner(props: { formId: string }) {
)}
</>
);
}
return isFormOpen ? (
form ? (
<InnerChat form={form} supabase={supabase} />
) : (
<>
{error ? (
ErrorBox(error)
) : (
<h1 className="text-3xl font-extrabold mb-6">Loading...</h1>
)}
</>
)
) : (
<h1 className="text-3xl font-extrabold mb-6">This form is currently closed.</h1>
);
export function InnerChat(props: {
form: Form;
supabase: SupabaseClient<Database>;
Expand Down Expand Up @@ -239,4 +256,4 @@ function SubmissionBox(submission: object): React.ReactNode {
</p>
</div>
);
}
}
Loading