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

[BitBuilder] Add "Close form" button #109

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 20 additions & 4 deletions src/pages/forms/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,27 @@ export default function FormDetailPage() {
</span>
</div>

<Link href={'/forms/fill/' + form.id}>
<button className="rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
View live form
<div className="flex">
<button className="rounded-md bg-white text-red-600 px-3 py-2 text-sm font-semibold shadow-sm hover:bg-gray-100 mr-2" onClick={async () => {
const { error } = await supabase
.from('forms')
.update({ is_open: !form.is_open })
.eq('id', form.id);
if (error) {
console.error('Error updating form status:', error);
} else {
setForm({ ...form, is_open: !form.is_open });
}
}}>
{form.is_open ? 'Close form' : 'Open form'}
</button>
</Link>

<Link href={'/forms/fill/' + form.id}>
<button className="rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">
View live form
</button>
</Link>
</div>
</div>
{form.created_at && (
<p className="text-xs text-gray-600">
Expand Down