Refactor RefreshButton component to accept className and id props

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-04 10:50:17 -03:00
commit 4487a839e6

View file

@ -8,11 +8,15 @@ function RefreshButton({
name, name,
data, data,
handleUpdateValues, handleUpdateValues,
className,
id,
}: { }: {
disabled: boolean; disabled: boolean;
name: string; name: string;
data: NodeDataType; data: NodeDataType;
className?: string;
handleUpdateValues: (name: string, data: NodeDataType) => void; handleUpdateValues: (name: string, data: NodeDataType) => void;
id: string;
}) { }) {
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
@ -37,8 +41,8 @@ function RefreshButton({
} }
}; };
const className = cn( const classNames = cn(
"extra-side-bar-buttons ml-2 mt-1 w-1/6", className,
disabled ? "cursor-not-allowed" : "cursor-pointer" disabled ? "cursor-not-allowed" : "cursor-pointer"
); );
@ -51,10 +55,11 @@ function RefreshButton({
); );
return ( return (
<button className={className} onClick={handleClick}> <button className={classNames} onClick={handleClick} id={id}>
<IconComponent <IconComponent
name={isLoading ? "Loader2" : "RefreshCcw"} name={isLoading ? "Loader2" : "RefreshCcw"}
className={iconClassName} className={iconClassName}
id={id + "-icon"}
/> />
</button> </button>
); );