Skip to content

Commit

Permalink
implement #119;
Browse files Browse the repository at this point in the history
  • Loading branch information
ellipsis-dev[bot] authored Nov 2, 2023
1 parent 4b29558 commit a8954dd
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 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 Expand Up @@ -151,4 +167,4 @@ function respectNewLines(text: string | null | undefined) {
<br />
</span>
));
}
}

0 comments on commit a8954dd

Please sign in to comment.