import React from "react"
import type { FC } from "react"
import classNames from "classnames";

interface Props {
    children: React.ReactNode;
    className?: string;
    type: 'error' | 'warning' | 'info' | 'success';
}

const Alert: FC<Props> = ({ children, className, type } ) => {
    let bgColor = 'bg-blue-200'
    let fgColor = 'bg-blue-800'

    if (type == 'error') {
        bgColor = 'bg-red-200'
        fgColor = 'bg-red-800'
    } else if (type == 'warning') {
        bgColor = 'bg-orange-200'
        fgColor = 'bg-orange-800'
    } else if (type == 'success') {
        bgColor = 'border-2 border-green-500'
        fgColor = 'text-green-500'
    }

    const styles = classNames(fgColor, bgColor, className, 'rounded')

    return (
        <div className={styles}>
            { children}
        </div>
    )
}

export default Alert