mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 11:01:45 +00:00
feat(ui): padroniza avatares e paleta visual da interface
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
--popover-foreground: var(--foreground);
|
--popover-foreground: var(--foreground);
|
||||||
|
|
||||||
--primary: oklch(72.069% 0.18335 44.069);
|
--primary: oklch(72.069% 0.18335 44.069);
|
||||||
--primary-foreground: oklch(98% 0.008 80);
|
--primary-foreground: oklch(16% 0.004 60);
|
||||||
|
|
||||||
--secondary: oklch(96.2% 0.005 70);
|
--secondary: oklch(96.2% 0.005 70);
|
||||||
--secondary-foreground: oklch(30% 0.01 45);
|
--secondary-foreground: oklch(30% 0.01 45);
|
||||||
@@ -51,6 +51,18 @@
|
|||||||
--chart-9: var(--color-cyan-500);
|
--chart-9: var(--color-cyan-500);
|
||||||
--chart-10: var(--color-lime-500);
|
--chart-10: var(--color-lime-500);
|
||||||
|
|
||||||
|
/* Data palette — análoga quente (hue 0–120), família do primary */
|
||||||
|
--data-1: oklch(58% 0.22 18); /* vermelho-tijolo */
|
||||||
|
--data-2: oklch(64% 0.22 30); /* vermelho-laranja */
|
||||||
|
--data-3: oklch(69% 0.21 42); /* laranja (≈ primary) */
|
||||||
|
--data-4: oklch(74% 0.18 55); /* âmbar */
|
||||||
|
--data-5: oklch(78% 0.16 68); /* âmbar-dourado */
|
||||||
|
--data-6: oklch(76% 0.15 82); /* amarelo-quente */
|
||||||
|
--data-7: oklch(70% 0.17 95); /* amarelo-lima */
|
||||||
|
--data-8: oklch(65% 0.18 108); /* lima-verde */
|
||||||
|
--data-9: oklch(62% 0.17 120); /* verde-oliva claro */
|
||||||
|
--data-10: oklch(56% 0.15 10); /* terracota escuro */
|
||||||
|
|
||||||
--sidebar: oklch(99.3% 0.0015 75);
|
--sidebar: oklch(99.3% 0.0015 75);
|
||||||
--sidebar-foreground: var(--foreground);
|
--sidebar-foreground: var(--foreground);
|
||||||
--sidebar-primary: var(--primary);
|
--sidebar-primary: var(--primary);
|
||||||
@@ -88,7 +100,7 @@
|
|||||||
--popover: oklch(28% 0.004 55);
|
--popover: oklch(28% 0.004 55);
|
||||||
--popover-foreground: var(--foreground);
|
--popover-foreground: var(--foreground);
|
||||||
|
|
||||||
--primary: oklch(66% 0.15 45.139);
|
--primary: oklch(72.069% 0.18335 44.069);
|
||||||
--primary-foreground: oklch(16% 0.004 60);
|
--primary-foreground: oklch(16% 0.004 60);
|
||||||
|
|
||||||
--secondary: oklch(29% 0.004 55);
|
--secondary: oklch(29% 0.004 55);
|
||||||
@@ -124,6 +136,19 @@
|
|||||||
--chart-9: var(--color-cyan-500);
|
--chart-9: var(--color-cyan-500);
|
||||||
--chart-10: var(--color-lime-500);
|
--chart-10: var(--color-lime-500);
|
||||||
|
|
||||||
|
/* Data palette — dark mode (ligeiramente mais vivos) */
|
||||||
|
/* Data palette dark — ligeiramente mais vivos para contrastar no fundo escuro */
|
||||||
|
--data-1: oklch(66% 0.22 18);
|
||||||
|
--data-2: oklch(72% 0.22 30);
|
||||||
|
--data-3: oklch(76% 0.21 42);
|
||||||
|
--data-4: oklch(81% 0.18 55);
|
||||||
|
--data-5: oklch(84% 0.16 68);
|
||||||
|
--data-6: oklch(82% 0.15 82);
|
||||||
|
--data-7: oklch(77% 0.17 95);
|
||||||
|
--data-8: oklch(72% 0.18 108);
|
||||||
|
--data-9: oklch(69% 0.17 120);
|
||||||
|
--data-10: oklch(63% 0.15 10);
|
||||||
|
|
||||||
--sidebar: oklch(19.5% 0.004 55);
|
--sidebar: oklch(19.5% 0.004 55);
|
||||||
--sidebar-foreground: var(--foreground);
|
--sidebar-foreground: var(--foreground);
|
||||||
--sidebar-primary: var(--primary);
|
--sidebar-primary: var(--primary);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
RiPencilLine,
|
RiPencilLine,
|
||||||
} from "@remixicon/react";
|
} from "@remixicon/react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { CategoryIconBadge } from "@/features/categories/components/category-icon-badge";
|
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { Card, CardContent, CardFooter } from "@/shared/components/ui/card";
|
import { Card, CardContent, CardFooter } from "@/shared/components/ui/card";
|
||||||
import { Progress } from "@/shared/components/ui/progress";
|
import { Progress } from "@/shared/components/ui/progress";
|
||||||
@@ -15,7 +15,6 @@ import type { Budget } from "./types";
|
|||||||
|
|
||||||
interface BudgetCardProps {
|
interface BudgetCardProps {
|
||||||
budget: Budget;
|
budget: Budget;
|
||||||
colorIndex: number;
|
|
||||||
periodLabel: string;
|
periodLabel: string;
|
||||||
onEdit: (budget: Budget) => void;
|
onEdit: (budget: Budget) => void;
|
||||||
onRemove: (budget: Budget) => void;
|
onRemove: (budget: Budget) => void;
|
||||||
@@ -34,7 +33,6 @@ const formatCategoryName = (budget: Budget) =>
|
|||||||
|
|
||||||
export function BudgetCard({
|
export function BudgetCard({
|
||||||
budget,
|
budget,
|
||||||
colorIndex,
|
|
||||||
periodLabel,
|
periodLabel,
|
||||||
onEdit,
|
onEdit,
|
||||||
onRemove,
|
onRemove,
|
||||||
@@ -51,7 +49,6 @@ export function BudgetCard({
|
|||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={budget.category?.icon ?? undefined}
|
icon={budget.category?.icon ?? undefined}
|
||||||
name={formatCategoryName(budget)}
|
name={formatCategoryName(budget)}
|
||||||
colorIndex={colorIndex}
|
|
||||||
size="lg"
|
size="lg"
|
||||||
/>
|
/>
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ export function BudgetsPage({
|
|||||||
<BudgetCard
|
<BudgetCard
|
||||||
key={budget.id}
|
key={budget.id}
|
||||||
budget={budget}
|
budget={budget}
|
||||||
colorIndex={index}
|
|
||||||
periodLabel={periodLabel}
|
periodLabel={periodLabel}
|
||||||
onEdit={handleEdit}
|
onEdit={handleEdit}
|
||||||
onRemove={handleRemoveRequest}
|
onRemove={handleRemoveRequest}
|
||||||
|
|||||||
@@ -177,7 +177,6 @@ export function CategoriesPage({ categories }: CategoriesPageProps) {
|
|||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={category.icon}
|
icon={category.icon}
|
||||||
name={category.name}
|
name={category.name}
|
||||||
colorIndex={index}
|
|
||||||
size="md"
|
size="md"
|
||||||
/>
|
/>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ export function CategoryDetailHeader({
|
|||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={category.icon}
|
icon={category.icon}
|
||||||
name={category.name}
|
name={category.name}
|
||||||
colorIndex={0}
|
|
||||||
size="lg"
|
size="lg"
|
||||||
/>
|
/>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
|
|||||||
@@ -1,76 +1,6 @@
|
|||||||
"use client";
|
// Re-export from shared — componente movido para src/shared/components/entity-avatar/
|
||||||
|
export {
|
||||||
import {
|
CategoryIconBadge,
|
||||||
buildCategoryInitials,
|
type CategoryIconBadgeProps,
|
||||||
getCategoryBgColor,
|
type CategoryIconBadgeSize,
|
||||||
getCategoryColor,
|
} from "@/shared/components/entity-avatar";
|
||||||
} from "@/shared/utils/category-colors";
|
|
||||||
import { getIconComponent } from "@/shared/utils/icons";
|
|
||||||
import { cn } from "@/shared/utils/ui";
|
|
||||||
|
|
||||||
const sizeVariants = {
|
|
||||||
sm: {
|
|
||||||
container: "size-8",
|
|
||||||
icon: "size-4",
|
|
||||||
text: "text-[10px]",
|
|
||||||
},
|
|
||||||
md: {
|
|
||||||
container: "size-9",
|
|
||||||
icon: "size-5",
|
|
||||||
text: "text-xs",
|
|
||||||
},
|
|
||||||
lg: {
|
|
||||||
container: "size-12",
|
|
||||||
icon: "size-6",
|
|
||||||
text: "text-sm",
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export type CategoryIconBadgeSize = keyof typeof sizeVariants;
|
|
||||||
|
|
||||||
export interface CategoryIconBadgeProps {
|
|
||||||
/** Nome do ícone Remix (ex: "RiShoppingBag3Line") */
|
|
||||||
icon?: string | null;
|
|
||||||
/** Nome da categoria (usado para gerar iniciais como fallback) */
|
|
||||||
name: string;
|
|
||||||
/** Índice para determinar a cor (cicla entre as cores disponíveis) */
|
|
||||||
colorIndex: number;
|
|
||||||
/** Tamanho do badge: sm (32px), md (36px), lg (48px) */
|
|
||||||
size?: CategoryIconBadgeSize;
|
|
||||||
/** Classes adicionais para o container */
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function CategoryIconBadge({
|
|
||||||
icon,
|
|
||||||
name,
|
|
||||||
colorIndex,
|
|
||||||
size = "md",
|
|
||||||
className,
|
|
||||||
}: CategoryIconBadgeProps) {
|
|
||||||
const IconComponent = icon ? getIconComponent(icon) : null;
|
|
||||||
const initials = buildCategoryInitials(name);
|
|
||||||
const color = getCategoryColor(colorIndex);
|
|
||||||
const bgColor = getCategoryBgColor(colorIndex);
|
|
||||||
const variant = sizeVariants[size];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"flex shrink-0 items-center justify-center overflow-hidden rounded-full",
|
|
||||||
variant.container,
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
style={{ backgroundColor: bgColor }}
|
|
||||||
>
|
|
||||||
{IconComponent ? (
|
|
||||||
// @ts-expect-error icon accepts style but type is too narrow
|
|
||||||
<IconComponent className={variant.icon} style={{ color }} />
|
|
||||||
) : (
|
|
||||||
<span className={cn("uppercase", variant.text)} style={{ color }}>
|
|
||||||
{initials}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
isBillOverdue,
|
isBillOverdue,
|
||||||
} from "@/features/dashboard/bills-helpers";
|
} from "@/features/dashboard/bills-helpers";
|
||||||
import type { DashboardBill } from "@/features/dashboard/bills-queries";
|
import type { DashboardBill } from "@/features/dashboard/bills-queries";
|
||||||
import { EstabelecimentoLogo } from "@/features/transactions/components/shared/establishment-logo";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { Button } from "@/shared/components/ui/button";
|
import { Button } from "@/shared/components/ui/button";
|
||||||
import { cn } from "@/shared/utils/ui";
|
import { cn } from "@/shared/utils/ui";
|
||||||
@@ -21,7 +21,7 @@ export function BillListItem({ bill, onPay }: BillListItemProps) {
|
|||||||
return (
|
return (
|
||||||
<li className="flex items-center justify-between transition-all duration-300 py-1.5">
|
<li className="flex items-center justify-between transition-all duration-300 py-1.5">
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-2 py-1">
|
<div className="flex min-w-0 flex-1 items-center gap-2 py-1">
|
||||||
<EstabelecimentoLogo name={bill.name} size={37} />
|
<EstablishmentLogo name={bill.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<span className="block truncate text-sm font-medium text-foreground">
|
<span className="block truncate text-sm font-medium text-foreground">
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ import {
|
|||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { Pie, PieChart, Tooltip } from "recharts";
|
import { Pie, PieChart, Tooltip } from "recharts";
|
||||||
import { CategoryIconBadge } from "@/features/categories/components/category-icon-badge";
|
|
||||||
import type { DashboardCategoryBreakdownData } from "@/features/dashboard/categories/category-breakdown";
|
import type { DashboardCategoryBreakdownData } from "@/features/dashboard/categories/category-breakdown";
|
||||||
|
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { type ChartConfig, ChartContainer } from "@/shared/components/ui/chart";
|
import { type ChartConfig, ChartContainer } from "@/shared/components/ui/chart";
|
||||||
import {
|
import {
|
||||||
@@ -220,7 +220,6 @@ export function CategoryBreakdownWidgetView({
|
|||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={category.categoryIcon}
|
icon={category.categoryIcon}
|
||||||
name={category.categoryName}
|
name={category.categoryName}
|
||||||
colorIndex={index}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { RiPencilLine } from "@remixicon/react";
|
import { RiPencilLine } from "@remixicon/react";
|
||||||
import { CategoryIconBadge } from "@/features/categories/components/category-icon-badge";
|
|
||||||
import {
|
import {
|
||||||
clampGoalProgress,
|
clampGoalProgress,
|
||||||
formatGoalProgressPercentage,
|
formatGoalProgressPercentage,
|
||||||
getGoalProgressStatusColorClass,
|
|
||||||
} from "@/features/dashboard/goals-progress-helpers";
|
} from "@/features/dashboard/goals-progress-helpers";
|
||||||
import type { GoalProgressItem as GoalProgressItemData } from "@/features/dashboard/goals-progress-queries";
|
import type { GoalProgressItem as GoalProgressItemData } from "@/features/dashboard/goals-progress-queries";
|
||||||
|
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { Button } from "@/shared/components/ui/button";
|
import { Button } from "@/shared/components/ui/button";
|
||||||
import { Progress } from "@/shared/components/ui/progress";
|
import { Progress } from "@/shared/components/ui/progress";
|
||||||
@@ -21,10 +20,14 @@ export function GoalProgressItem({
|
|||||||
index,
|
index,
|
||||||
onEdit,
|
onEdit,
|
||||||
}: GoalProgressItemProps) {
|
}: GoalProgressItemProps) {
|
||||||
const statusColor = getGoalProgressStatusColorClass(item.status);
|
|
||||||
const progressValue = clampGoalProgress(item.usedPercentage, 0, 100);
|
const progressValue = clampGoalProgress(item.usedPercentage, 0, 100);
|
||||||
const percentageDelta = item.usedPercentage - 100;
|
const percentageDelta = item.usedPercentage - 100;
|
||||||
|
const deltaColor =
|
||||||
|
percentageDelta > 0
|
||||||
|
? "text-destructive"
|
||||||
|
: percentageDelta < 0
|
||||||
|
? "text-success"
|
||||||
|
: "text-muted-foreground";
|
||||||
const isExceeded = item.status === "exceeded";
|
const isExceeded = item.status === "exceeded";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -34,7 +37,6 @@ export function GoalProgressItem({
|
|||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={item.categoryIcon}
|
icon={item.categoryIcon}
|
||||||
name={item.categoryName}
|
name={item.categoryName}
|
||||||
colorIndex={index}
|
|
||||||
size="md"
|
size="md"
|
||||||
/>
|
/>
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
@@ -44,19 +46,19 @@ export function GoalProgressItem({
|
|||||||
<p className="mt-0.5 text-xs text-muted-foreground">
|
<p className="mt-0.5 text-xs text-muted-foreground">
|
||||||
<MoneyValues amount={item.spentAmount} /> de{" "}
|
<MoneyValues amount={item.spentAmount} /> de{" "}
|
||||||
<MoneyValues amount={item.budgetAmount} />
|
<MoneyValues amount={item.budgetAmount} />
|
||||||
|
<span className={`ml-1.5 font-medium ${deltaColor}`}>
|
||||||
|
{formatGoalProgressPercentage(percentageDelta, true)}
|
||||||
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex shrink-0 items-center gap-2">
|
<div className="flex shrink-0 items-center gap-2">
|
||||||
<span className={`text-xs font-medium ${statusColor}`}>
|
|
||||||
{formatGoalProgressPercentage(percentageDelta, true)}
|
|
||||||
</span>
|
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="link"
|
||||||
size="icon-sm"
|
size="icon-sm"
|
||||||
className="opacity-30 group-hover:opacity-100 transition-opacity text-muted-foreground hover:text-foreground"
|
className="transition-opacity text-primary hover:opacity-80"
|
||||||
onClick={() => onEdit(item)}
|
onClick={() => onEdit(item)}
|
||||||
aria-label={`Editar orçamento de ${item.categoryName}`}
|
aria-label={`Editar orçamento de ${item.categoryName}`}
|
||||||
>
|
>
|
||||||
@@ -69,7 +71,7 @@ export function GoalProgressItem({
|
|||||||
value={progressValue}
|
value={progressValue}
|
||||||
className={
|
className={
|
||||||
isExceeded
|
isExceeded
|
||||||
? "[&_[data-slot=progress-indicator]]:bg-destructive bg-destructive/20"
|
? "**:data-[slot=progress-indicator]:bg-destructive bg-destructive/20"
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -19,15 +19,15 @@ type IncomeExpenseBalanceWidgetProps = {
|
|||||||
const chartConfig = {
|
const chartConfig = {
|
||||||
receita: {
|
receita: {
|
||||||
label: "Receita",
|
label: "Receita",
|
||||||
color: "var(--chart-1)",
|
color: "var(--data-9)",
|
||||||
},
|
},
|
||||||
despesa: {
|
despesa: {
|
||||||
label: "Despesa",
|
label: "Despesa",
|
||||||
color: "var(--chart-2)",
|
color: "var(--data-1)",
|
||||||
},
|
},
|
||||||
balanco: {
|
balanco: {
|
||||||
label: "Balanço",
|
label: "Balanço",
|
||||||
color: "var(--chart-3)",
|
color: "var(--data-4)",
|
||||||
},
|
},
|
||||||
} satisfies ChartConfig;
|
} satisfies ChartConfig;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import type { InstallmentExpense } from "@/features/dashboard/expenses/installment-expenses-queries";
|
import type { InstallmentExpense } from "@/features/dashboard/expenses/installment-expenses-queries";
|
||||||
import { buildInstallmentExpenseDisplay } from "@/features/dashboard/installment-expenses-helpers";
|
import { buildInstallmentExpenseDisplay } from "@/features/dashboard/installment-expenses-helpers";
|
||||||
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { Progress } from "@/shared/components/ui/progress";
|
import { Progress } from "@/shared/components/ui/progress";
|
||||||
import {
|
import {
|
||||||
@@ -8,7 +9,6 @@ import {
|
|||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@/shared/components/ui/tooltip";
|
} from "@/shared/components/ui/tooltip";
|
||||||
import { getPaymentMethodIcon } from "@/shared/utils/icons";
|
|
||||||
|
|
||||||
type InstallmentExpenseListItemProps = {
|
type InstallmentExpenseListItemProps = {
|
||||||
expense: InstallmentExpense;
|
expense: InstallmentExpense;
|
||||||
@@ -28,9 +28,7 @@ export function InstallmentExpenseListItem({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3 transition-all duration-300 py-2">
|
<div className="flex items-center gap-3 transition-all duration-300 py-2">
|
||||||
<div className="flex size-9.5 shrink-0 items-center justify-center rounded-full bg-muted text-foreground">
|
<EstablishmentLogo name={expense.name} size={37} />
|
||||||
{getPaymentMethodIcon(expense.paymentMethod)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="flex items-center justify-between gap-3">
|
<div className="flex items-center justify-between gap-3">
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ import {
|
|||||||
} from "@/features/dashboard/payment-breakdown-formatters";
|
} from "@/features/dashboard/payment-breakdown-formatters";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { Progress } from "@/shared/components/ui/progress";
|
import { Progress } from "@/shared/components/ui/progress";
|
||||||
|
import {
|
||||||
const ICON_WRAPPER_CLASS =
|
getCategoryBgColorFromName,
|
||||||
"flex size-9.5 shrink-0 items-center justify-center rounded-full bg-muted text-foreground";
|
getCategoryColorFromName,
|
||||||
|
} from "@/shared/utils/category-colors";
|
||||||
|
|
||||||
export type PaymentBreakdownListItemData = {
|
export type PaymentBreakdownListItemData = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -27,7 +28,15 @@ export function PaymentBreakdownListItem({
|
|||||||
}: PaymentBreakdownListItemProps) {
|
}: PaymentBreakdownListItemProps) {
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center gap-3 transition-all duration-300 py-1.5">
|
<div className="flex items-center gap-3 transition-all duration-300 py-1.5">
|
||||||
<div className={ICON_WRAPPER_CLASS}>{item.icon}</div>
|
<div
|
||||||
|
className="flex size-9.5 shrink-0 items-center justify-center rounded-full"
|
||||||
|
style={{
|
||||||
|
backgroundColor: getCategoryBgColorFromName(item.id),
|
||||||
|
color: getCategoryColorFromName(item.id),
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{item.icon}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { RiArrowDownSFill, RiStore3Line } from "@remixicon/react";
|
import { RiArrowDownSFill, RiStore3Line } from "@remixicon/react";
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import type { PurchasesByCategoryData } from "@/features/dashboard/purchases-by-category-queries";
|
import type { PurchasesByCategoryData } from "@/features/dashboard/purchases-by-category-queries";
|
||||||
import { EstabelecimentoLogo } from "@/features/transactions/components/shared/establishment-logo";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
@@ -14,25 +14,12 @@ import {
|
|||||||
} from "@/shared/components/ui/select";
|
} from "@/shared/components/ui/select";
|
||||||
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
||||||
import { CATEGORY_TYPE_LABEL } from "@/shared/lib/categories/constants";
|
import { CATEGORY_TYPE_LABEL } from "@/shared/lib/categories/constants";
|
||||||
|
import { formatTransactionDate } from "@/shared/utils/date";
|
||||||
|
|
||||||
type PurchasesByCategoryWidgetProps = {
|
type PurchasesByCategoryWidgetProps = {
|
||||||
data: PurchasesByCategoryData;
|
data: PurchasesByCategoryData;
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatTransactionDate = (date: Date | string) => {
|
|
||||||
const d = date instanceof Date ? date : new Date(date);
|
|
||||||
const formatter = new Intl.DateTimeFormat("pt-BR", {
|
|
||||||
weekday: "short",
|
|
||||||
day: "2-digit",
|
|
||||||
month: "short",
|
|
||||||
timeZone: "UTC",
|
|
||||||
});
|
|
||||||
|
|
||||||
const formatted = formatter.format(d);
|
|
||||||
// Capitaliza a primeira letra do dia da semana
|
|
||||||
return formatted.charAt(0).toUpperCase() + formatted.slice(1);
|
|
||||||
};
|
|
||||||
|
|
||||||
const STORAGE_KEY = "purchases-by-category-selected";
|
const STORAGE_KEY = "purchases-by-category-selected";
|
||||||
|
|
||||||
export function PurchasesByCategoryWidget({
|
export function PurchasesByCategoryWidget({
|
||||||
@@ -178,7 +165,7 @@ export function PurchasesByCategoryWidget({
|
|||||||
className="flex items-center justify-between gap-3 transition-all duration-300 py-2"
|
className="flex items-center justify-between gap-3 transition-all duration-300 py-2"
|
||||||
>
|
>
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-3">
|
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||||
<EstabelecimentoLogo name={transaction.name} size={37} />
|
<EstablishmentLogo name={transaction.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className="truncate text-sm font-medium text-foreground">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { RiRefreshLine } from "@remixicon/react";
|
import { RiRefreshLine } from "@remixicon/react";
|
||||||
import type { RecurringExpensesData } from "@/features/dashboard/expenses/recurring-expenses-queries";
|
import type { RecurringExpensesData } from "@/features/dashboard/expenses/recurring-expenses-queries";
|
||||||
import { EstabelecimentoLogo } from "@/features/transactions/components/shared/establishment-logo";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ export function RecurringExpensesWidget({
|
|||||||
key={expense.id}
|
key={expense.id}
|
||||||
className="flex items-center gap-2 transition-all duration-300 py-1.5"
|
className="flex items-center gap-2 transition-all duration-300 py-1.5"
|
||||||
>
|
>
|
||||||
<EstabelecimentoLogo name={expense.name} size={37} />
|
<EstablishmentLogo name={expense.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0 flex-1">
|
<div className="min-w-0 flex-1">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { RiStore2Line } from "@remixicon/react";
|
import { RiStore2Line } from "@remixicon/react";
|
||||||
import type { TopEstablishmentsData } from "@/features/dashboard/top-establishments-queries";
|
import type { TopEstablishmentsData } from "@/features/dashboard/top-establishments-queries";
|
||||||
import { EstabelecimentoLogo } from "@/features/transactions/components/shared/establishment-logo";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export function TopEstablishmentsWidget({
|
|||||||
className="flex items-center justify-between gap-3 transition-all duration-300 py-2"
|
className="flex items-center justify-between gap-3 transition-all duration-300 py-2"
|
||||||
>
|
>
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-3">
|
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||||
<EstabelecimentoLogo name={establishment.name} size={37} />
|
<EstablishmentLogo name={establishment.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className="truncate text-sm font-medium text-foreground">
|
||||||
|
|||||||
@@ -6,30 +6,17 @@ import type {
|
|||||||
TopExpense,
|
TopExpense,
|
||||||
TopExpensesData,
|
TopExpensesData,
|
||||||
} from "@/features/dashboard/expenses/top-expenses-queries";
|
} from "@/features/dashboard/expenses/top-expenses-queries";
|
||||||
import { EstabelecimentoLogo } from "@/features/transactions/components/shared/establishment-logo";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { Switch } from "@/shared/components/ui/switch";
|
import { Switch } from "@/shared/components/ui/switch";
|
||||||
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
||||||
|
import { formatTransactionDate } from "@/shared/utils/date";
|
||||||
|
|
||||||
type TopExpensesWidgetProps = {
|
type TopExpensesWidgetProps = {
|
||||||
allExpenses: TopExpensesData;
|
allExpenses: TopExpensesData;
|
||||||
cardOnlyExpenses: TopExpensesData;
|
cardOnlyExpenses: TopExpensesData;
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatTransactionDate = (date: Date | string) => {
|
|
||||||
const d = date instanceof Date ? date : new Date(date);
|
|
||||||
const formatter = new Intl.DateTimeFormat("pt-BR", {
|
|
||||||
weekday: "short",
|
|
||||||
day: "2-digit",
|
|
||||||
month: "short",
|
|
||||||
timeZone: "UTC",
|
|
||||||
});
|
|
||||||
|
|
||||||
const formatted = formatter.format(d);
|
|
||||||
// Capitaliza a primeira letra do dia da semana
|
|
||||||
return formatted.charAt(0).toUpperCase() + formatted.slice(1);
|
|
||||||
};
|
|
||||||
|
|
||||||
const shouldIncludeExpense = (expense: TopExpense) => {
|
const shouldIncludeExpense = (expense: TopExpense) => {
|
||||||
const normalizedName = expense.name.trim().toLowerCase();
|
const normalizedName = expense.name.trim().toLowerCase();
|
||||||
|
|
||||||
@@ -113,7 +100,7 @@ export function TopExpensesWidget({
|
|||||||
className="flex items-center justify-between gap-3 transition-all duration-300 py-2"
|
className="flex items-center justify-between gap-3 transition-all duration-300 py-2"
|
||||||
>
|
>
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-3">
|
<div className="flex min-w-0 flex-1 items-center gap-3">
|
||||||
<EstabelecimentoLogo name={expense.name} size={37} />
|
<EstablishmentLogo name={expense.name} size={37} />
|
||||||
|
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<p className="truncate text-sm font-medium text-foreground">
|
<p className="truncate text-sm font-medium text-foreground">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
RiWallet3Line,
|
RiWallet3Line,
|
||||||
} from "@remixicon/react";
|
} from "@remixicon/react";
|
||||||
import { buildBillStatusLabel } from "@/features/dashboard/bills-helpers";
|
import { buildBillStatusLabel } from "@/features/dashboard/bills-helpers";
|
||||||
import { EstabelecimentoLogo } from "@/features/transactions/components/shared/establishment-logo";
|
import { EstablishmentLogo } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { CardContent } from "@/shared/components/ui/card";
|
import { CardContent } from "@/shared/components/ui/card";
|
||||||
import { Progress } from "@/shared/components/ui/progress";
|
import { Progress } from "@/shared/components/ui/progress";
|
||||||
@@ -44,7 +44,7 @@ export function PayerBoletoCard({ items }: PagadorBoletoCardProps) {
|
|||||||
return (
|
return (
|
||||||
<div key={item.id} className="flex items-center justify-between">
|
<div key={item.id} className="flex items-center justify-between">
|
||||||
<div className="flex min-w-0 flex-1 items-center gap-3 py-2">
|
<div className="flex min-w-0 flex-1 items-center gap-3 py-2">
|
||||||
<EstabelecimentoLogo name={item.name} size={36} />
|
<EstablishmentLogo name={item.name} size={36} />
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<span className="block truncate text-sm font-medium text-foreground">
|
<span className="block truncate text-sm font-medium text-foreground">
|
||||||
{item.name}
|
{item.name}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RiPieChartLine } from "@remixicon/react";
|
import { RiPieChartLine } from "@remixicon/react";
|
||||||
import { CategoryIconBadge } from "@/features/categories/components/category-icon-badge";
|
|
||||||
import type { CardDetailData } from "@/features/reports/cards-report-queries";
|
import type { CardDetailData } from "@/features/reports/cards-report-queries";
|
||||||
|
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
@@ -61,7 +61,6 @@ export function CardCategoryBreakdown({ data }: CardCategoryBreakdownProps) {
|
|||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={category.icon}
|
icon={category.icon}
|
||||||
name={category.name}
|
name={category.name}
|
||||||
colorIndex={index}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Name and percentage */}
|
{/* Name and percentage */}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { CategoryIconBadge } from "@/features/categories/components/category-icon-badge";
|
|
||||||
import { formatPeriodLabel } from "@/features/reports/utils";
|
import { formatPeriodLabel } from "@/features/reports/utils";
|
||||||
|
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
CardContent,
|
CardContent,
|
||||||
@@ -26,15 +26,9 @@ interface CategoryCardProps {
|
|||||||
category: CategoryReportItem;
|
category: CategoryReportItem;
|
||||||
periods: string[];
|
periods: string[];
|
||||||
periodCount: number;
|
periodCount: number;
|
||||||
colorIndex: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CategoryCard({
|
function CategoryCard({ category, periods, periodCount }: CategoryCardProps) {
|
||||||
category,
|
|
||||||
periods,
|
|
||||||
periodCount,
|
|
||||||
colorIndex,
|
|
||||||
}: CategoryCardProps) {
|
|
||||||
const periodParam = formatPeriodForUrl(periods[periods.length - 1]);
|
const periodParam = formatPeriodForUrl(periods[periods.length - 1]);
|
||||||
const averageMonthlyTotal = category.total / periodCount;
|
const averageMonthlyTotal = category.total / periodCount;
|
||||||
|
|
||||||
@@ -42,11 +36,7 @@ function CategoryCard({
|
|||||||
<Card>
|
<Card>
|
||||||
<CardHeader className="pb-3">
|
<CardHeader className="pb-3">
|
||||||
<CardTitle className="flex items-center gap-3">
|
<CardTitle className="flex items-center gap-3">
|
||||||
<CategoryIconBadge
|
<CategoryIconBadge icon={category.icon} name={category.name} />
|
||||||
icon={category.icon}
|
|
||||||
name={category.name}
|
|
||||||
colorIndex={colorIndex}
|
|
||||||
/>
|
|
||||||
<Link
|
<Link
|
||||||
href={`/categories/${category.categoryId}?periodo=${periodParam}`}
|
href={`/categories/${category.categoryId}?periodo=${periodParam}`}
|
||||||
className="flex-1 truncate hover:underline underline-offset-2"
|
className="flex-1 truncate hover:underline underline-offset-2"
|
||||||
@@ -95,7 +85,6 @@ interface SectionProps {
|
|||||||
categories: CategoryReportItem[];
|
categories: CategoryReportItem[];
|
||||||
periods: string[];
|
periods: string[];
|
||||||
periodCount: number;
|
periodCount: number;
|
||||||
colorIndexOffset: number;
|
|
||||||
total: number;
|
total: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +93,6 @@ function Section({
|
|||||||
categories,
|
categories,
|
||||||
periods,
|
periods,
|
||||||
periodCount,
|
periodCount,
|
||||||
colorIndexOffset,
|
|
||||||
total,
|
total,
|
||||||
}: SectionProps) {
|
}: SectionProps) {
|
||||||
if (categories.length === 0) {
|
if (categories.length === 0) {
|
||||||
@@ -134,7 +122,6 @@ function Section({
|
|||||||
category={category}
|
category={category}
|
||||||
periods={periods}
|
periods={periods}
|
||||||
periodCount={periodCount}
|
periodCount={periodCount}
|
||||||
colorIndex={colorIndexOffset + index}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -173,7 +160,6 @@ export function CategoryReportCards({ data }: CategoryReportCardsProps) {
|
|||||||
categories={despesas}
|
categories={despesas}
|
||||||
periods={periods}
|
periods={periods}
|
||||||
periodCount={periodCount}
|
periodCount={periodCount}
|
||||||
colorIndexOffset={0}
|
|
||||||
total={despesasTotal}
|
total={despesasTotal}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -183,7 +169,6 @@ export function CategoryReportCards({ data }: CategoryReportCardsProps) {
|
|||||||
categories={receitas}
|
categories={receitas}
|
||||||
periods={periods}
|
periods={periods}
|
||||||
periodCount={periodCount}
|
periodCount={periodCount}
|
||||||
colorIndexOffset={despesas.length}
|
|
||||||
total={receitasTotal}
|
total={receitasTotal}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -33,20 +33,10 @@ export function CategoryReportTable({ data }: CategoryReportTableProps) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-6">
|
||||||
{/* Despesas Table */}
|
{/* Despesas Table */}
|
||||||
<CategoryTable
|
<CategoryTable title="Despesas" categories={despesas} periods={periods} />
|
||||||
title="Despesas"
|
|
||||||
categories={despesas}
|
|
||||||
periods={periods}
|
|
||||||
colorIndexOffset={0}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Receitas Table */}
|
{/* Receitas Table */}
|
||||||
<CategoryTable
|
<CategoryTable title="Receitas" categories={receitas} periods={periods} />
|
||||||
title="Receitas"
|
|
||||||
categories={receitas}
|
|
||||||
periods={periods}
|
|
||||||
colorIndexOffset={despesas.length}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { CategoryIconBadge } from "@/features/categories/components/category-icon-badge";
|
|
||||||
import { formatPeriodLabel } from "@/features/reports/utils";
|
import { formatPeriodLabel } from "@/features/reports/utils";
|
||||||
|
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||||
import StatusDot from "@/shared/components/status-dot";
|
import StatusDot from "@/shared/components/status-dot";
|
||||||
import { Card } from "@/shared/components/ui/card";
|
import { Card } from "@/shared/components/ui/card";
|
||||||
import {
|
import {
|
||||||
@@ -24,14 +24,12 @@ export interface CategoryTableProps {
|
|||||||
title: string;
|
title: string;
|
||||||
categories: CategoryReportItem[];
|
categories: CategoryReportItem[];
|
||||||
periods: string[];
|
periods: string[];
|
||||||
colorIndexOffset: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CategoryTable({
|
export function CategoryTable({
|
||||||
title,
|
title,
|
||||||
categories,
|
categories,
|
||||||
periods,
|
periods,
|
||||||
colorIndexOffset,
|
|
||||||
}: CategoryTableProps) {
|
}: CategoryTableProps) {
|
||||||
// Calculate section totals
|
// Calculate section totals
|
||||||
const sectionTotals = useMemo(() => {
|
const sectionTotals = useMemo(() => {
|
||||||
@@ -86,7 +84,6 @@ export function CategoryTable({
|
|||||||
|
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{categories.map((category, index) => {
|
{categories.map((category, index) => {
|
||||||
const colorIndex = colorIndexOffset + index;
|
|
||||||
const periodParam = formatPeriodForUrl(periods[periods.length - 1]);
|
const periodParam = formatPeriodForUrl(periods[periods.length - 1]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -104,7 +101,6 @@ export function CategoryTable({
|
|||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={category.icon}
|
icon={category.icon}
|
||||||
name={category.name}
|
name={category.name}
|
||||||
colorIndex={colorIndex}
|
|
||||||
/>
|
/>
|
||||||
<Link
|
<Link
|
||||||
href={`/categories/${category.categoryId}?periodo=${periodParam}`}
|
href={`/categories/${category.categoryId}?periodo=${periodParam}`}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { RiPriceTag3Line } from "@remixicon/react";
|
import { RiPriceTag3Line } from "@remixicon/react";
|
||||||
import { CategoryIconBadge } from "@/features/categories/components/category-icon-badge";
|
|
||||||
import type { TopEstabelecimentosData } from "@/features/reports/establishments/queries";
|
import type { TopEstabelecimentosData } from "@/features/reports/establishments/queries";
|
||||||
|
import { CategoryIconBadge } from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
@@ -64,7 +64,6 @@ export function TopCategories({ categories }: TopCategoriesProps) {
|
|||||||
<CategoryIconBadge
|
<CategoryIconBadge
|
||||||
icon={category.icon}
|
icon={category.icon}
|
||||||
name={category.name}
|
name={category.name}
|
||||||
colorIndex={index}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Name and percentage */}
|
{/* Name and percentage */}
|
||||||
|
|||||||
@@ -1,70 +1,2 @@
|
|||||||
import { cn } from "@/shared/utils/ui";
|
// Re-export from shared — componente movido para src/shared/components/entity-avatar/
|
||||||
|
export { EstablishmentLogo as EstabelecimentoLogo } from "@/shared/components/entity-avatar";
|
||||||
interface EstabelecimentoLogoProps {
|
|
||||||
name: string;
|
|
||||||
size?: number;
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const COLOR_PALETTE = [
|
|
||||||
"bg-purple-400 dark:bg-purple-600",
|
|
||||||
"bg-pink-400 dark:bg-pink-600",
|
|
||||||
"bg-red-400 dark:bg-red-600",
|
|
||||||
"bg-orange-400 dark:bg-orange-600",
|
|
||||||
"bg-indigo-400 dark:bg-indigo-600",
|
|
||||||
"bg-violet-400 dark:bg-violet-600",
|
|
||||||
"bg-fuchsia-400 dark:bg-fuchsia-600",
|
|
||||||
"bg-rose-400 dark:bg-rose-600",
|
|
||||||
"bg-amber-400 dark:bg-amber-600",
|
|
||||||
"bg-emerald-400 dark:bg-emerald-600",
|
|
||||||
];
|
|
||||||
|
|
||||||
function getInitials(name: string): string {
|
|
||||||
if (!name || !name.trim()) return "?";
|
|
||||||
|
|
||||||
const words = name.trim().split(/\s+/);
|
|
||||||
|
|
||||||
if (words.length === 1) {
|
|
||||||
return words[0]?.[0]?.toUpperCase() || "?";
|
|
||||||
}
|
|
||||||
|
|
||||||
const firstInitial = words[0]?.[0]?.toUpperCase() || "";
|
|
||||||
const secondInitial = words[1]?.[0]?.toUpperCase() || "";
|
|
||||||
|
|
||||||
return `${firstInitial}${secondInitial}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateColorFromName(name: string): string {
|
|
||||||
let hash = 0;
|
|
||||||
for (let i = 0; i < name.length; i++) {
|
|
||||||
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
|
||||||
}
|
|
||||||
const index = Math.abs(hash) % COLOR_PALETTE.length;
|
|
||||||
return COLOR_PALETTE[index] || "bg-gray-400";
|
|
||||||
}
|
|
||||||
|
|
||||||
export function EstabelecimentoLogo({
|
|
||||||
name,
|
|
||||||
size = 32,
|
|
||||||
className,
|
|
||||||
}: EstabelecimentoLogoProps) {
|
|
||||||
const initials = getInitials(name);
|
|
||||||
const colorClass = generateColorFromName(name);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"flex items-center justify-center rounded-full text-white font-bold shrink-0",
|
|
||||||
colorClass,
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
style={{
|
|
||||||
width: size,
|
|
||||||
height: size,
|
|
||||||
fontSize: (size ?? 32) * 0.4,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{initials}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import {
|
import {
|
||||||
RiAddCircleFill,
|
|
||||||
RiAddFill,
|
RiAddFill,
|
||||||
RiArrowLeftDoubleLine,
|
RiArrowLeftDoubleLine,
|
||||||
RiArrowLeftRightLine,
|
RiArrowLeftRightLine,
|
||||||
@@ -15,6 +14,7 @@ import {
|
|||||||
RiDeleteBin5Line,
|
RiDeleteBin5Line,
|
||||||
RiFileCopyLine,
|
RiFileCopyLine,
|
||||||
RiFileList2Line,
|
RiFileList2Line,
|
||||||
|
RiFlashlightFill,
|
||||||
RiGroupLine,
|
RiGroupLine,
|
||||||
RiHistoryLine,
|
RiHistoryLine,
|
||||||
RiMoreFill,
|
RiMoreFill,
|
||||||
@@ -35,9 +35,12 @@ import {
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { CategoryIcon } from "@/features/categories/components/category-icon";
|
|
||||||
import { DEFAULT_LANCAMENTOS_COLUMN_ORDER } from "@/features/transactions/column-order";
|
import { DEFAULT_LANCAMENTOS_COLUMN_ORDER } from "@/features/transactions/column-order";
|
||||||
import { EmptyState } from "@/shared/components/empty-state";
|
import { EmptyState } from "@/shared/components/empty-state";
|
||||||
|
import {
|
||||||
|
CategoryIconBadge,
|
||||||
|
EstablishmentLogo,
|
||||||
|
} from "@/shared/components/entity-avatar";
|
||||||
import MoneyValues from "@/shared/components/money-values";
|
import MoneyValues from "@/shared/components/money-values";
|
||||||
import { TransactionTypeBadge } from "@/shared/components/transaction-type-badge";
|
import { TransactionTypeBadge } from "@/shared/components/transaction-type-badge";
|
||||||
import {
|
import {
|
||||||
@@ -83,7 +86,6 @@ import { getAvatarSrc } from "@/shared/lib/payers/utils";
|
|||||||
import { formatDate } from "@/shared/utils/date";
|
import { formatDate } from "@/shared/utils/date";
|
||||||
import { getConditionIcon, getPaymentMethodIcon } from "@/shared/utils/icons";
|
import { getConditionIcon, getPaymentMethodIcon } from "@/shared/utils/icons";
|
||||||
import { cn } from "@/shared/utils/ui";
|
import { cn } from "@/shared/utils/ui";
|
||||||
import { EstabelecimentoLogo } from "../shared/establishment-logo";
|
|
||||||
import { TransactionsExport } from "../transactions-export";
|
import { TransactionsExport } from "../transactions-export";
|
||||||
import type {
|
import type {
|
||||||
AccountCardFilterOption,
|
AccountCardFilterOption,
|
||||||
@@ -192,7 +194,7 @@ const buildColumns = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<EstabelecimentoLogo name={name} size={28} />
|
<EstablishmentLogo name={name} size={28} />
|
||||||
<span className="flex flex-col">
|
<span className="flex flex-col">
|
||||||
<span className="text-[11px] text-muted-foreground">
|
<span className="text-[11px] text-muted-foreground">
|
||||||
{formatDate(purchaseDate)}
|
{formatDate(purchaseDate)}
|
||||||
@@ -375,7 +377,11 @@ const buildColumns = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<CategoryIcon name={categoriaIcon} className="size-4" />
|
<CategoryIconBadge
|
||||||
|
icon={categoriaIcon}
|
||||||
|
name={categoriaName}
|
||||||
|
size="sm"
|
||||||
|
/>
|
||||||
<span>{categoriaName}</span>
|
<span>{categoriaName}</span>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
@@ -909,7 +915,7 @@ export function TransactionsTable({
|
|||||||
size="icon"
|
size="icon"
|
||||||
className="hidden size-9 sm:inline-flex"
|
className="hidden size-9 sm:inline-flex"
|
||||||
>
|
>
|
||||||
<RiAddCircleFill className="size-4" />
|
<RiFlashlightFill className="size-4" />
|
||||||
<span className="sr-only">
|
<span className="sr-only">
|
||||||
Adicionar múltiplos lançamentos
|
Adicionar múltiplos lançamentos
|
||||||
</span>
|
</span>
|
||||||
@@ -1043,7 +1049,7 @@ export function TransactionsTable({
|
|||||||
row.original.dueDate &&
|
row.original.dueDate &&
|
||||||
!row.original.isSettled &&
|
!row.original.isSettled &&
|
||||||
new Date(row.original.dueDate) < new Date()
|
new Date(row.original.dueDate) < new Date()
|
||||||
? "bg-destructive/[0.03] hover:bg-destructive/[0.05]"
|
? "bg-destructive/3 hover:bg-destructive/5"
|
||||||
: undefined,
|
: undefined,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
78
src/shared/components/entity-avatar/category-icon-badge.tsx
Normal file
78
src/shared/components/entity-avatar/category-icon-badge.tsx
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import type { ComponentType } from "react";
|
||||||
|
import {
|
||||||
|
buildInitials,
|
||||||
|
getCategoryBgColorFromName,
|
||||||
|
getCategoryColorFromName,
|
||||||
|
} from "@/shared/utils/category-colors";
|
||||||
|
import { getIconComponent } from "@/shared/utils/icons";
|
||||||
|
import { cn } from "@/shared/utils/ui";
|
||||||
|
|
||||||
|
const sizeVariants = {
|
||||||
|
sm: {
|
||||||
|
container: "size-8",
|
||||||
|
icon: "size-4",
|
||||||
|
text: "text-[10px]",
|
||||||
|
},
|
||||||
|
md: {
|
||||||
|
container: "size-9",
|
||||||
|
icon: "size-5",
|
||||||
|
text: "text-xs",
|
||||||
|
},
|
||||||
|
lg: {
|
||||||
|
container: "size-12",
|
||||||
|
icon: "size-6",
|
||||||
|
text: "text-sm",
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type CategoryIconBadgeSize = keyof typeof sizeVariants;
|
||||||
|
|
||||||
|
export interface CategoryIconBadgeProps {
|
||||||
|
/** Nome do ícone Remix (ex: "RiShoppingBag3Line") */
|
||||||
|
icon?: string | null;
|
||||||
|
/** Nome da categoria — define cor e iniciais de fallback */
|
||||||
|
name: string;
|
||||||
|
/** Tamanho do badge: sm (32px), md (36px), lg (48px) */
|
||||||
|
size?: CategoryIconBadgeSize;
|
||||||
|
/** Classes adicionais para o container */
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CategoryIconBadge({
|
||||||
|
icon,
|
||||||
|
name,
|
||||||
|
size = "md",
|
||||||
|
className,
|
||||||
|
}: CategoryIconBadgeProps) {
|
||||||
|
const IconComponent = icon
|
||||||
|
? (getIconComponent(icon) as ComponentType<{
|
||||||
|
className?: string;
|
||||||
|
style?: React.CSSProperties;
|
||||||
|
}>)
|
||||||
|
: null;
|
||||||
|
const initials = buildInitials(name);
|
||||||
|
const color = getCategoryColorFromName(name);
|
||||||
|
const bgColor = getCategoryBgColorFromName(name);
|
||||||
|
const variant = sizeVariants[size];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex shrink-0 items-center justify-center overflow-hidden rounded-full",
|
||||||
|
variant.container,
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
style={{ backgroundColor: bgColor }}
|
||||||
|
>
|
||||||
|
{IconComponent ? (
|
||||||
|
<IconComponent className={variant.icon} style={{ color }} />
|
||||||
|
) : (
|
||||||
|
<span className={cn("uppercase", variant.text)} style={{ color }}>
|
||||||
|
{initials}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
41
src/shared/components/entity-avatar/establishment-logo.tsx
Normal file
41
src/shared/components/entity-avatar/establishment-logo.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import {
|
||||||
|
buildInitials,
|
||||||
|
getCategoryBgColorFromName,
|
||||||
|
getCategoryColorFromName,
|
||||||
|
} from "@/shared/utils/category-colors";
|
||||||
|
import { cn } from "@/shared/utils/ui";
|
||||||
|
|
||||||
|
interface EstablishmentLogoProps {
|
||||||
|
name: string;
|
||||||
|
size?: number;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EstablishmentLogo({
|
||||||
|
name,
|
||||||
|
size = 32,
|
||||||
|
className,
|
||||||
|
}: EstablishmentLogoProps) {
|
||||||
|
const initials = buildInitials(name);
|
||||||
|
const color = getCategoryColorFromName(name);
|
||||||
|
const bgColor = getCategoryBgColorFromName(name);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"flex shrink-0 items-center justify-center rounded-full font-bold",
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
style={{
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
fontSize: Math.max(10, Math.round(size * 0.38)),
|
||||||
|
backgroundColor: bgColor,
|
||||||
|
color,
|
||||||
|
}}
|
||||||
|
aria-hidden
|
||||||
|
>
|
||||||
|
{initials}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
6
src/shared/components/entity-avatar/index.ts
Normal file
6
src/shared/components/entity-avatar/index.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export type {
|
||||||
|
CategoryIconBadgeProps,
|
||||||
|
CategoryIconBadgeSize,
|
||||||
|
} from "./category-icon-badge";
|
||||||
|
export { CategoryIconBadge } from "./category-icon-badge";
|
||||||
|
export { EstablishmentLogo } from "./establishment-logo";
|
||||||
@@ -142,7 +142,7 @@ export function LogoPickerDialog({
|
|||||||
Nenhum logo encontrado para “{search}”
|
Nenhum logo encontrado para “{search}”
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<div className="grid max-h-custom-height-card grid-cols-4 gap-2 overflow-y-auto p-1 sm:grid-cols-4 md:grid-cols-5">
|
<div className="grid max-h-custom-height-card grid-cols-4 gap-2 overflow-y-auto p-1 md:grid-cols-5">
|
||||||
{filteredLogos.map((logo) => {
|
{filteredLogos.map((logo) => {
|
||||||
const isActive = value === logo;
|
const isActive = value === logo;
|
||||||
const logoLabel = deriveNameFromLogo(logo);
|
const logoLabel = deriveNameFromLogo(logo);
|
||||||
@@ -151,13 +151,10 @@ export function LogoPickerDialog({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
key={logo}
|
key={logo}
|
||||||
onClick={(e) => {
|
onClick={() => onSelect(logo)}
|
||||||
e.stopPropagation();
|
|
||||||
e.preventDefault();
|
|
||||||
onSelect(logo);
|
|
||||||
}}
|
|
||||||
onPointerDown={(e) => e.stopPropagation()}
|
onPointerDown={(e) => e.stopPropagation()}
|
||||||
onTouchStart={(e) => e.stopPropagation()}
|
aria-label={`Selecionar logo ${logoLabel || logo}`}
|
||||||
|
aria-pressed={isActive}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex flex-col items-center gap-1 rounded-md bg-card p-2 text-center text-xs transition-all hover:border-primary hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
"flex flex-col items-center gap-1 rounded-md bg-card p-2 text-center text-xs transition-all hover:border-primary hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
||||||
isActive &&
|
isActive &&
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ interface LogoProps {
|
|||||||
className?: string;
|
className?: string;
|
||||||
showVersion?: boolean;
|
showVersion?: boolean;
|
||||||
invertTextOnDark?: boolean;
|
invertTextOnDark?: boolean;
|
||||||
|
/** Exibe o ícone na cor original, sem filtro preto */
|
||||||
|
colorIcon?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Logo({
|
export function Logo({
|
||||||
@@ -14,6 +16,7 @@ export function Logo({
|
|||||||
className,
|
className,
|
||||||
showVersion = false,
|
showVersion = false,
|
||||||
invertTextOnDark = true,
|
invertTextOnDark = true,
|
||||||
|
colorIcon = false,
|
||||||
}: LogoProps) {
|
}: LogoProps) {
|
||||||
if (variant === "compact") {
|
if (variant === "compact") {
|
||||||
return (
|
return (
|
||||||
@@ -23,7 +26,7 @@ export function Logo({
|
|||||||
alt="OpenMonetis"
|
alt="OpenMonetis"
|
||||||
width={32}
|
width={32}
|
||||||
height={32}
|
height={32}
|
||||||
className="object-contain brightness-0 saturate-0"
|
className={cn("object-contain", !colorIcon && "brightness-0 saturate-0")}
|
||||||
priority
|
priority
|
||||||
/>
|
/>
|
||||||
<Image
|
<Image
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const buttonVariants = cva(
|
|||||||
{
|
{
|
||||||
variants: {
|
variants: {
|
||||||
variant: {
|
variant: {
|
||||||
default: "bg-primary hover:bg-primary/90",
|
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
||||||
destructive:
|
destructive:
|
||||||
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
||||||
outline:
|
outline:
|
||||||
|
|||||||
@@ -1,46 +1,68 @@
|
|||||||
/**
|
/**
|
||||||
* Cores para categorias em widgets e listas
|
* Data palette para categorias e estabelecimentos.
|
||||||
* Usadas para colorir ícones e backgrounds de categorias
|
* Os valores são CSS variables definidas em globals.css,
|
||||||
|
* com variantes light/dark — sem hardcode de hex fora do tema.
|
||||||
*/
|
*/
|
||||||
export const CATEGORY_COLORS = [
|
const DATA_PALETTE_SIZE = 10;
|
||||||
"#ef4444", // red
|
|
||||||
"#3b82f6", // blue
|
|
||||||
"#10b981", // emerald
|
|
||||||
"#f59e0b", // amber
|
|
||||||
"#8b5cf6", // violet
|
|
||||||
"#ec4899", // pink
|
|
||||||
"#14b8a6", // teal
|
|
||||||
"#f97316", // orange
|
|
||||||
"#6366f1", // indigo
|
|
||||||
"#84cc16", // lime
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
/**
|
/** Array de CSS variables da paleta de dados — usado em gráficos e charts. */
|
||||||
* Retorna a cor para um índice específico (com ciclo)
|
export const CATEGORY_COLORS = Array.from(
|
||||||
*/
|
{ length: DATA_PALETTE_SIZE },
|
||||||
export function getCategoryColor(index: number): string {
|
(_, i) => `var(--data-${i + 1})`,
|
||||||
return CATEGORY_COLORS[index % CATEGORY_COLORS.length];
|
) as readonly string[];
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
function hashNameToIndex(name: string): number {
|
||||||
* Retorna a cor de background com transparência
|
let hash = 0;
|
||||||
*/
|
for (let i = 0; i < name.length; i++) {
|
||||||
export function getCategoryBgColor(index: number): string {
|
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
||||||
const color = getCategoryColor(index);
|
|
||||||
return `${color}15`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gera iniciais a partir de um nome
|
|
||||||
*/
|
|
||||||
export function buildCategoryInitials(value: string): string {
|
|
||||||
const parts = value.trim().split(/\s+/).filter(Boolean);
|
|
||||||
if (parts.length === 0) return "CT";
|
|
||||||
if (parts.length === 1) {
|
|
||||||
const firstPart = parts[0];
|
|
||||||
return firstPart ? firstPart.slice(0, 2).toUpperCase() : "CT";
|
|
||||||
}
|
}
|
||||||
const firstChar = parts[0]?.[0] ?? "";
|
return Math.abs(hash) % DATA_PALETTE_SIZE;
|
||||||
const secondChar = parts[1]?.[0] ?? "";
|
}
|
||||||
return `${firstChar}${secondChar}`.toUpperCase() || "CT";
|
|
||||||
|
/**
|
||||||
|
* Retorna a CSS variable de cor para um nome (determinístico via hash).
|
||||||
|
*/
|
||||||
|
export function getCategoryColorFromName(name: string): string {
|
||||||
|
const n = hashNameToIndex(name) + 1;
|
||||||
|
return `var(--data-${n})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retorna o background com transparência usando color-mix.
|
||||||
|
*/
|
||||||
|
export function getCategoryBgColorFromName(name: string): string {
|
||||||
|
const n = hashNameToIndex(name) + 1;
|
||||||
|
return `color-mix(in oklch, var(--data-${n}) 14%, transparent)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gera 1 ou 2 iniciais a partir de um nome.
|
||||||
|
* "Padaria João" → "PJ" | "Alimentação" → "AL" | "" → "?"
|
||||||
|
*/
|
||||||
|
export function buildInitials(name: string): string {
|
||||||
|
const parts = name.trim().split(/\s+/).filter(Boolean);
|
||||||
|
if (parts.length === 0) return "?";
|
||||||
|
if (parts.length === 1) {
|
||||||
|
return (parts[0]?.slice(0, 2) ?? "?").toUpperCase();
|
||||||
|
}
|
||||||
|
const a = parts[0]?.[0] ?? "";
|
||||||
|
const b = parts[1]?.[0] ?? "";
|
||||||
|
return `${a}${b}`.toUpperCase() || "?";
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- compatibilidade retroativa (para não quebrar callers durante migração) ---
|
||||||
|
|
||||||
|
/** @deprecated Use getCategoryColorFromName */
|
||||||
|
export function getCategoryColor(index: number): string {
|
||||||
|
return `var(--data-${(index % DATA_PALETTE_SIZE) + 1})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated Use getCategoryBgColorFromName */
|
||||||
|
export function getCategoryBgColor(index: number): string {
|
||||||
|
return `color-mix(in oklch, var(--data-${(index % DATA_PALETTE_SIZE) + 1}) 14%, transparent)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @deprecated Use buildInitials */
|
||||||
|
export function buildCategoryInitials(value: string): string {
|
||||||
|
return buildInitials(value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,6 +296,23 @@ export function addMonthsToDate(value: Date, offset: number): Date {
|
|||||||
// DATE FORMATTING
|
// DATE FORMATTING
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats a UTC date/datetime to short display format (weekday + day + month), capitalized.
|
||||||
|
* Use this for timestamps stored as UTC (e.g. transaction dates from the DB).
|
||||||
|
* @example
|
||||||
|
* formatTransactionDate("2024-11-14T00:00:00Z") // "Qui 14 nov"
|
||||||
|
*/
|
||||||
|
export function formatTransactionDate(date: Date | string): string {
|
||||||
|
const d = date instanceof Date ? date : new Date(date);
|
||||||
|
const formatted = new Intl.DateTimeFormat("pt-BR", {
|
||||||
|
weekday: "short",
|
||||||
|
day: "2-digit",
|
||||||
|
month: "short",
|
||||||
|
timeZone: "UTC",
|
||||||
|
}).format(d);
|
||||||
|
return formatted.charAt(0).toUpperCase() + formatted.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formats a date value to short display format
|
* Formats a date value to short display format
|
||||||
* @example
|
* @example
|
||||||
|
|||||||
Reference in New Issue
Block a user