Skip to content

Commit

Permalink
implement #0;
Browse files Browse the repository at this point in the history
  • Loading branch information
ellipsis-dev[bot] authored Oct 17, 2023
1 parent 15a0961 commit 18d2f51
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 @@ -15,6 +15,17 @@ import { Database } from '../../../types/supabase';
import ResponsesTable from '../../components/home/modes/ResponsesTable';

export default function FormDetailPage() {
const closeForm = async () => {
const { data, error } = await supabase
.from('forms')
.update({ is_open: false })
.eq('id', form.id);
if (error) {
console.error('Error closing form:', error);
} else {
setForm(data[0]);
}
};
const { isLoading: isSessionLoading, session, error } = useSessionContext();
const supabase = createClientComponentClient<Database>();
const [user, setUser] = useState<null | User>(null);
Expand Down Expand Up @@ -83,6 +94,9 @@ export default function FormDetailPage() {
View live form
</button>
</Link>
<button onClick={closeForm} className={`rounded-md px-3 py-2 text-sm font-semibold shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 ${form.is_open ? 'bg-indigo-600 text-white hover:bg-indigo-500' : 'bg-gray-300 text-gray-500 cursor-not-allowed'}`} disabled={!form.is_open}>
Close form
</button>
</div>
{form.created_at && (
<p className="text-xs text-gray-600">
Expand Down Expand Up @@ -151,4 +165,4 @@ function respectNewLines(text: string | null | undefined) {
<br />
</span>
));
}
}

0 comments on commit 18d2f51

Please sign in to comment.