({
pending,
children,
onClick,
}: {
pending: boolean;
children: React.ReactNode;
onClick?: () => void;
})
| 1 | import { Button } from "@/components/ui/button"; |
| 2 | export default function LoadingButton({ |
| 3 | pending, |
| 4 | children, |
| 5 | onClick, |
| 6 | }: { |
| 7 | pending: boolean; |
| 8 | children: React.ReactNode; |
| 9 | onClick?: () => void; |
| 10 | }) { |
| 11 | return ( |
| 12 | <Button |
| 13 | onClick={onClick} |
| 14 | className="w-full" |
| 15 | type="submit" |
| 16 | disabled={pending} |
| 17 | > |
| 18 | {pending ? ( |
| 19 | <div className="flex items-center justify-center"> |
| 20 | <svg |
| 21 | className="animate-spin h-5 w-5 text-white mr-2" |
| 22 | xmlns="http://www.w3.org/2000/svg" |
| 23 | fill="none" |
| 24 | viewBox="0 0 24 24" |
| 25 | > |
| 26 | <circle |
| 27 | className="opacity-25" |
| 28 | cx="12" |
| 29 | cy="12" |
| 30 | r="10" |
| 31 | stroke="currentColor" |
| 32 | strokeWidth="4" |
| 33 | ></circle> |
| 34 | <path |
| 35 | className="opacity-75" |
| 36 | fill="currentColor" |
| 37 | d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" |
| 38 | ></path> |
| 39 | </svg> |
| 40 | </div> |
| 41 | ) : ( |
| 42 | children |
| 43 | )} |
| 44 | </Button> |
| 45 | ); |
| 46 | } |
nothing calls this directly
no outgoing calls
no test coverage detected