Skip to content

Commit

Permalink
implement #37;
Browse files Browse the repository at this point in the history
  • Loading branch information
ellipsis-dev[bot] authored Oct 7, 2023
1 parent 9686715 commit dfff040
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/pages/forms/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ export default function FormDetailPage() {
</span>
</div>

<button className="rounded-md bg-white text-red-600 px-3 py-2 text-sm font-semibold shadow-sm hover:bg-gray-200 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 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
Expand Down Expand Up @@ -151,4 +165,4 @@ function respectNewLines(text: string | null | undefined) {
<br />
</span>
));
}
}

0 comments on commit dfff040

Please sign in to comment.