mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 11:01:45 +00:00
refactor(core): centraliza hooks, providers e base compartilhada
This commit is contained in:
63
components/shared/type-badge.tsx
Normal file
63
components/shared/type-badge.tsx
Normal file
@@ -0,0 +1,63 @@
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { cn } from "@/lib/utils/ui";
|
||||
import StatusDot from "./status-dot";
|
||||
|
||||
type TypeBadgeType =
|
||||
| "receita"
|
||||
| "despesa"
|
||||
| "Receita"
|
||||
| "Despesa"
|
||||
| "Transferência"
|
||||
| "transferência"
|
||||
| "Saldo inicial"
|
||||
| "Saldo Inicial";
|
||||
|
||||
interface TypeBadgeProps {
|
||||
type: TypeBadgeType | string;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const TYPE_LABELS: Record<string, string> = {
|
||||
receita: "Receita",
|
||||
despesa: "Despesa",
|
||||
Receita: "Receita",
|
||||
Despesa: "Despesa",
|
||||
Transferência: "Transferência",
|
||||
transferência: "Transferência",
|
||||
"Saldo inicial": "Saldo Inicial",
|
||||
"Saldo Inicial": "Saldo Inicial",
|
||||
};
|
||||
|
||||
export function TypeBadge({ type, className }: TypeBadgeProps) {
|
||||
const normalizedType = type.toLowerCase();
|
||||
const isReceita = normalizedType === "receita";
|
||||
const isTransferencia = normalizedType === "transferência";
|
||||
const isSaldoInicial = normalizedType === "saldo inicial";
|
||||
const label = TYPE_LABELS[type] || type;
|
||||
|
||||
const colorClass = isTransferencia
|
||||
? "text-info"
|
||||
: isReceita || isSaldoInicial
|
||||
? "text-success"
|
||||
: "text-destructive";
|
||||
|
||||
const dotColor = isTransferencia
|
||||
? "bg-info"
|
||||
: isReceita || isSaldoInicial
|
||||
? "bg-success"
|
||||
: "bg-destructive";
|
||||
|
||||
return (
|
||||
<Badge
|
||||
variant={"outline"}
|
||||
className={cn(
|
||||
"flex items-center gap-1 px-2 text-xs",
|
||||
colorClass,
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<StatusDot color={dotColor} />
|
||||
{label}
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user