()
| 5 | import {useState, useTransition} from "react"; |
| 6 | import {handleError} from "@/lib/util"; |
| 7 | export default function ErrorButtons() { |
| 8 | const [pending, startTransition] = useTransition(); |
| 9 | const [target, setTarget] = useState(0); |
| 10 | |
| 11 | const onClick = (code: number) => { |
| 12 | setTarget(code); |
| 13 | startTransition(async () => { |
| 14 | const {error} = await triggerError(code); |
| 15 | if (error) handleError(error); |
| 16 | setTarget(0); |
| 17 | }) |
| 18 | } |
| 19 | |
| 20 | return ( |
| 21 | <div className='flex gap-3'> |
| 22 | {[400, 401, 403, 404, 500].map((code) => ( |
| 23 | <Button |
| 24 | onPress={() => onClick(code)} |
| 25 | color='primary' |
| 26 | key={code} |
| 27 | type='button' |
| 28 | isLoading={pending && target === code} |
| 29 | > |
| 30 | Test {code} |
| 31 | </Button> |
| 32 | ))} |
| 33 | </div> |
| 34 | ); |
| 35 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…