Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 'use client' import {useRouter} from 'next/navigation' import {useState} from 'react' export default function NewSetlistButton() { const router = useRouter() const [busy, setBusy] = useState(false) async function create() { setBusy(true) const r = await fetch('/api/setlists', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({name: 'New setlist'}), }) if (r.ok) router.push(`/setlists/${(await r.json()).id}/edit`) else setBusy(false) } return ( <button type="button" onClick={create} disabled={busy} className="min-h-11 rounded-lg border border-line-2 px-4 font-semibold disabled:opacity-50" > New setlist </button> ) } |