Fix Pilot-conenction
This commit is contained in:
43
packages/shared-components/components/Button.tsx
Normal file
43
packages/shared-components/components/Button.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
"use client";
|
||||
import React, {
|
||||
ButtonHTMLAttributes,
|
||||
DetailedHTMLProps,
|
||||
useEffect,
|
||||
useState,
|
||||
forwardRef,
|
||||
} from "react";
|
||||
import { cn } from "@repo/shared-components";
|
||||
|
||||
export const Button = forwardRef<
|
||||
HTMLButtonElement,
|
||||
DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> & {
|
||||
isLoading?: boolean;
|
||||
}
|
||||
>(({ isLoading, ...props }, ref) => {
|
||||
const [isLoadingState, setIsLoadingState] = useState(isLoading);
|
||||
|
||||
useEffect(() => {
|
||||
setIsLoadingState(isLoading);
|
||||
}, [isLoading]);
|
||||
|
||||
return (
|
||||
<button
|
||||
{...props}
|
||||
ref={ref}
|
||||
className={cn("btn", props.className)}
|
||||
disabled={isLoadingState || props.disabled}
|
||||
onClick={async (e) => {
|
||||
if (props.onClick) {
|
||||
setIsLoadingState(true);
|
||||
await props.onClick(e);
|
||||
setIsLoadingState(false);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isLoadingState && <span className="loading loading-spinner loading-sm"></span>}
|
||||
{props.children}
|
||||
</button>
|
||||
);
|
||||
});
|
||||
|
||||
Button.displayName = "Button";
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./Badge";
|
||||
export * from "./PenaltyDropdown";
|
||||
export * from "./Maintenance";
|
||||
export * from "./Button";
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"tailwind-merge": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^19.1.6",
|
||||
"@types/react": "^19.1.8",
|
||||
"@types/react-dom": "^19.1.5",
|
||||
"react": "^19.1.0",
|
||||
"react-dom": "^19.1.0"
|
||||
|
||||
Reference in New Issue
Block a user