Fix Pilot-conenction

This commit is contained in:
PxlLoewe
2025-07-10 10:19:36 -07:00
parent 3b1ceb8f8c
commit b9eef5252e
6 changed files with 135 additions and 102 deletions

View 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";

View File

@@ -1,3 +1,4 @@
export * from "./Badge";
export * from "./PenaltyDropdown";
export * from "./Maintenance";
export * from "./Button";

View File

@@ -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"