41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import React from "react";
|
|
|
|
type ButtonType = 'alert' | 'danger' | 'informatif' | 'success';
|
|
|
|
interface ConfirmButtonProps {
|
|
text: string;
|
|
callBackFunction?: () => void;
|
|
buttonType?: ButtonType;
|
|
}
|
|
|
|
export default function ConfirmButton(
|
|
{
|
|
text,
|
|
callBackFunction,
|
|
buttonType = 'success'
|
|
}: ConfirmButtonProps) {
|
|
function getButtonType(alertType: ButtonType): string {
|
|
switch (alertType) {
|
|
case 'alert':
|
|
return 'bg-warning';
|
|
case 'danger':
|
|
return 'bg-error';
|
|
case 'informatif':
|
|
return 'bg-info';
|
|
case 'success':
|
|
default:
|
|
return 'bg-success';
|
|
}
|
|
}
|
|
|
|
const applyType: string = getButtonType(buttonType);
|
|
return (
|
|
<button
|
|
onClick={callBackFunction}
|
|
className={`rounded-lg ${applyType} px-5 py-2.5 text-white font-semibold shadow-md hover:shadow-lg transition-all duration-200 hover:scale-105 focus:outline-none focus:ring-4 focus:ring-primary/20`}
|
|
>
|
|
{text}
|
|
</button>
|
|
)
|
|
}
|