mtg-lets-trade

Website/webapp to facilitate trading between players of Magic: The Gathering
git clone https://kevincorvisier.fr/git/mtg-lets-trade.git
Log | Files | Refs

MutationButton.tsx (651B)


      1 import { UseMutationResult } from "@tanstack/react-query";
      2 import Spinner from "react-bootstrap/Spinner";
      3 import Button, { ButtonProps } from "react-bootstrap/Button";
      4 
      5 interface Props extends Omit<ButtonProps, 'children' | 'as'> {
      6 	mutation: UseMutationResult<any, any, any, any>,
      7 	label: string,
      8 	loadingLabel: string
      9 };
     10 
     11 export default function MutationButton({ mutation, label, loadingLabel, ...props }: Props) {
     12 	if (mutation.isPending) {
     13 		return (
     14 			<Button {...props}><Spinner animation="border" size="sm" role="status" aria-hidden="true" />{loadingLabel}</Button>
     15 		);
     16 	}
     17 	else {
     18 		return (
     19 			<Button {...props}>{label}</Button>
     20 		);
     21 	}
     22 };