mirror of
https://github.com/felipegcoutinho/openmonetis.git
synced 2026-05-09 19:01:47 +00:00
refactor: traduz dominio de payers no app
This commit is contained in:
@@ -4,7 +4,7 @@ import MoneyValues from "@/shared/components/money-values";
|
||||
import { CardContent } from "@/shared/components/ui/card";
|
||||
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
||||
import { resolveLogoSrc } from "@/shared/lib/logo";
|
||||
import type { PagadorCardUsageItem } from "@/shared/lib/payers/details";
|
||||
import type { PayerCardUsageItem } from "@/shared/lib/payers/details";
|
||||
|
||||
const buildInitials = (value: string) => {
|
||||
const parts = value.trim().split(/\s+/).filter(Boolean);
|
||||
@@ -19,10 +19,10 @@ const buildInitials = (value: string) => {
|
||||
};
|
||||
|
||||
type PagadorCardUsageCardProps = {
|
||||
items: PagadorCardUsageItem[];
|
||||
items: PayerCardUsageItem[];
|
||||
};
|
||||
|
||||
export function PagadorCardUsageCard({ items }: PagadorCardUsageCardProps) {
|
||||
export function PayerCardUsageCard({ items }: PagadorCardUsageCardProps) {
|
||||
if (items.length === 0) {
|
||||
return (
|
||||
<CardContent className="px-0">
|
||||
|
||||
@@ -13,7 +13,7 @@ import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState, useTransition } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { sendPagadorSummaryAction } from "@/features/payers/detail-actions";
|
||||
import { sendPayerSummaryAction } from "@/features/payers/detail-actions";
|
||||
import { Badge } from "@/shared/components/ui/badge";
|
||||
import { Button } from "@/shared/components/ui/button";
|
||||
import {
|
||||
@@ -30,41 +30,41 @@ import {
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/shared/components/ui/dialog";
|
||||
import { PAGADOR_ROLE_ADMIN } from "@/shared/lib/payers/constants";
|
||||
import { PAYER_ROLE_ADMIN } from "@/shared/lib/payers/constants";
|
||||
import { getAvatarSrc } from "@/shared/lib/payers/utils";
|
||||
import { formatCurrency } from "@/shared/utils/currency";
|
||||
import { formatDateTime } from "@/shared/utils/date";
|
||||
import type { PagadorInfo, PagadorSummaryPreview } from "./types";
|
||||
import type { PayerInfo, PayerSummaryPreview } from "./types";
|
||||
|
||||
type PagadorHeaderCardProps = {
|
||||
pagador: PagadorInfo;
|
||||
type PayerHeaderCardProps = {
|
||||
payer: PayerInfo;
|
||||
selectedPeriod: string;
|
||||
summary: PagadorSummaryPreview;
|
||||
summary: PayerSummaryPreview;
|
||||
};
|
||||
|
||||
export function PagadorHeaderCard({
|
||||
pagador,
|
||||
export function PayerHeaderCard({
|
||||
payer,
|
||||
selectedPeriod,
|
||||
summary,
|
||||
}: PagadorHeaderCardProps) {
|
||||
}: PayerHeaderCardProps) {
|
||||
const router = useRouter();
|
||||
const [isSending, startTransition] = useTransition();
|
||||
const [confirmOpen, setConfirmOpen] = useState(false);
|
||||
|
||||
const avatarSrc = getAvatarSrc(pagador.avatarUrl);
|
||||
const createdAtLabel = formatDate(pagador.createdAt);
|
||||
const isAdmin = pagador.role === PAGADOR_ROLE_ADMIN;
|
||||
const avatarSrc = getAvatarSrc(payer.avatarUrl);
|
||||
const createdAtLabel = formatDate(payer.createdAt);
|
||||
const isAdmin = payer.role === PAYER_ROLE_ADMIN;
|
||||
|
||||
const lastMailLabel =
|
||||
formatDateTime(pagador.lastMailAt, {
|
||||
formatDateTime(payer.lastMailAt, {
|
||||
dateStyle: "short",
|
||||
timeStyle: "short",
|
||||
}) ?? "Nunca enviado";
|
||||
|
||||
const disableSend = isSending || !pagador.email || !pagador.canEdit;
|
||||
const disableSend = isSending || !payer.email || !payer.canEdit;
|
||||
|
||||
const openConfirmDialog = () => {
|
||||
if (!pagador.email) {
|
||||
if (!payer.email) {
|
||||
toast.error("Cadastre um e-mail para este pagador antes de enviar.");
|
||||
return;
|
||||
}
|
||||
@@ -72,14 +72,14 @@ export function PagadorHeaderCard({
|
||||
};
|
||||
|
||||
const handleSendSummary = () => {
|
||||
if (!pagador.email) {
|
||||
if (!payer.email) {
|
||||
toast.error("Cadastre um e-mail para este pagador antes de enviar.");
|
||||
return;
|
||||
}
|
||||
|
||||
startTransition(async () => {
|
||||
const result = await sendPagadorSummaryAction({
|
||||
pagadorId: pagador.id,
|
||||
const result = await sendPayerSummaryAction({
|
||||
payerId: payer.id,
|
||||
period: selectedPeriod,
|
||||
});
|
||||
|
||||
@@ -109,7 +109,7 @@ export function PagadorHeaderCard({
|
||||
<div className="relative flex size-16 shrink-0 items-center justify-center overflow-hidden">
|
||||
<Image
|
||||
src={avatarSrc}
|
||||
alt={`Avatar de ${pagador.name}`}
|
||||
alt={`Avatar de ${payer.name}`}
|
||||
width={64}
|
||||
height={64}
|
||||
className="h-full w-full rounded-full object-cover"
|
||||
@@ -119,7 +119,7 @@ export function PagadorHeaderCard({
|
||||
<div className="flex flex-1 flex-col gap-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<CardTitle className="text-xl font-semibold text-foreground">
|
||||
{pagador.name}
|
||||
{payer.name}
|
||||
</CardTitle>
|
||||
{isAdmin ? (
|
||||
<RiVerifiedBadgeFill
|
||||
@@ -128,12 +128,12 @@ export function PagadorHeaderCard({
|
||||
/>
|
||||
) : null}
|
||||
<Badge
|
||||
variant={getStatusBadgeVariant(pagador.status)}
|
||||
variant={getStatusBadgeVariant(payer.status)}
|
||||
className="text-xs"
|
||||
>
|
||||
{pagador.status}
|
||||
{payer.status}
|
||||
</Badge>
|
||||
{pagador.isAutoSend ? (
|
||||
{payer.isAutoSend ? (
|
||||
<Badge variant="info" className="gap-1 text-xs">
|
||||
<RiMailSendLine className="size-3.5" aria-hidden />
|
||||
Envio automático
|
||||
@@ -144,14 +144,14 @@ export function PagadorHeaderCard({
|
||||
<CardDescription className="flex flex-wrap items-center gap-x-3 gap-y-1 text-sm">
|
||||
<span>Criado em {createdAtLabel}</span>
|
||||
<span className="hidden text-border/80 sm:inline">•</span>
|
||||
{pagador.email ? (
|
||||
{payer.email ? (
|
||||
<Link
|
||||
prefetch
|
||||
href={`mailto:${pagador.email}`}
|
||||
href={`mailto:${payer.email}`}
|
||||
className="inline-flex items-center gap-1.5 text-primary"
|
||||
>
|
||||
<RiMailLine className="size-4" aria-hidden />
|
||||
{pagador.email}
|
||||
{payer.email}
|
||||
</Link>
|
||||
) : (
|
||||
<span>Sem e-mail cadastrado</span>
|
||||
@@ -161,7 +161,7 @@ export function PagadorHeaderCard({
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col items-stretch gap-2 lg:w-auto lg:items-end">
|
||||
{pagador.canEdit ? (
|
||||
{payer.canEdit ? (
|
||||
<>
|
||||
<Button
|
||||
type="button"
|
||||
@@ -184,7 +184,7 @@ export function PagadorHeaderCard({
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
{pagador.canEdit ? (
|
||||
{payer.canEdit ? (
|
||||
<Dialog
|
||||
open={confirmOpen}
|
||||
onOpenChange={(open) => {
|
||||
@@ -202,7 +202,7 @@ export function PagadorHeaderCard({
|
||||
</span>{" "}
|
||||
para{" "}
|
||||
<span className="font-medium text-foreground">
|
||||
{pagador.email}
|
||||
{payer.email}
|
||||
</span>
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
ChartTooltipContent,
|
||||
} from "@/shared/components/ui/chart";
|
||||
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
||||
import type { PagadorHistoryPoint } from "@/shared/lib/payers/details";
|
||||
import type { PayerHistoryPoint } from "@/shared/lib/payers/details";
|
||||
import { currencyFormatter } from "@/shared/utils/currency";
|
||||
|
||||
const chartConfig = {
|
||||
@@ -32,7 +32,7 @@ const chartConfig = {
|
||||
};
|
||||
|
||||
type PagadorHistoryCardProps = {
|
||||
data: PagadorHistoryPoint[];
|
||||
data: PayerHistoryPoint[];
|
||||
};
|
||||
|
||||
const ValueLabel = (props: LabelProps) => {
|
||||
@@ -57,7 +57,7 @@ const ValueLabel = (props: LabelProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
export function PagadorHistoryCard({ data }: PagadorHistoryCardProps) {
|
||||
export function PayerHistoryCard({ data }: PagadorHistoryCardProps) {
|
||||
const hasData = data.length > 0;
|
||||
|
||||
return (
|
||||
|
||||
@@ -8,17 +8,17 @@ import {
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/shared/components/ui/card";
|
||||
import { PAGADOR_ROLE_ADMIN } from "@/shared/lib/payers/constants";
|
||||
import { PAYER_ROLE_ADMIN } from "@/shared/lib/payers/constants";
|
||||
import { formatDateTime } from "@/shared/utils/date";
|
||||
import { cn } from "@/shared/utils/ui";
|
||||
import type { PagadorInfo } from "./types";
|
||||
import type { PayerInfo } from "./types";
|
||||
|
||||
type PagadorInfoCardProps = {
|
||||
pagador: PagadorInfo;
|
||||
type PayerInfoCardProps = {
|
||||
payer: PayerInfo;
|
||||
};
|
||||
|
||||
export function PagadorInfoCard({ pagador }: PagadorInfoCardProps) {
|
||||
const showSensitiveDetails = pagador.canEdit;
|
||||
export function PagadorInfoCard({ payer }: PayerInfoCardProps) {
|
||||
const showSensitiveDetails = payer.canEdit;
|
||||
|
||||
const getStatusBadgeVariant = (status: string): "success" | "outline" => {
|
||||
const normalizedStatus = status.toLowerCase();
|
||||
@@ -32,7 +32,7 @@ export function PagadorInfoCard({ pagador }: PagadorInfoCardProps) {
|
||||
<Card className="border gap-4">
|
||||
<CardHeader className="gap-1.5">
|
||||
<CardTitle className="text-lg font-semibold">
|
||||
Detalhes do pagador
|
||||
Detalhes do payer
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{showSensitiveDetails
|
||||
@@ -46,10 +46,10 @@ export function PagadorInfoCard({ pagador }: PagadorInfoCardProps) {
|
||||
label="Status"
|
||||
value={
|
||||
<Badge
|
||||
variant={getStatusBadgeVariant(pagador.status)}
|
||||
variant={getStatusBadgeVariant(payer.status)}
|
||||
className="text-xs"
|
||||
>
|
||||
{pagador.status}
|
||||
{payer.status}
|
||||
</Badge>
|
||||
}
|
||||
/>
|
||||
@@ -59,23 +59,23 @@ export function PagadorInfoCard({ pagador }: PagadorInfoCardProps) {
|
||||
value={
|
||||
<span className="inline-flex items-center gap-2">
|
||||
<RiUser3Line className="size-4 text-muted-foreground" />
|
||||
{resolveRoleLabel(pagador.role)}
|
||||
{resolveRoleLabel(payer.role)}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
{showSensitiveDetails ? (
|
||||
<InfoItem
|
||||
label="Envio automático"
|
||||
value={pagador.isAutoSend ? "Ativado" : "Desativado"}
|
||||
value={payer.isAutoSend ? "Ativado" : "Desativado"}
|
||||
/>
|
||||
) : null}
|
||||
{showSensitiveDetails ? (
|
||||
<InfoItem
|
||||
label="Último envio"
|
||||
value={formatDateTime(pagador.lastMailAt) ?? "Nunca enviado"}
|
||||
value={formatDateTime(payer.lastMailAt) ?? "Nunca enviado"}
|
||||
/>
|
||||
) : null}
|
||||
{showSensitiveDetails && !pagador.email ? (
|
||||
{showSensitiveDetails && !payer.email ? (
|
||||
<InfoItem
|
||||
label="Aviso"
|
||||
value={
|
||||
@@ -90,8 +90,8 @@ export function PagadorInfoCard({ pagador }: PagadorInfoCardProps) {
|
||||
<InfoItem
|
||||
label="Observações"
|
||||
value={
|
||||
pagador.note ? (
|
||||
<span className="text-muted-foreground">{pagador.note}</span>
|
||||
payer.note ? (
|
||||
<span className="text-muted-foreground">{payer.note}</span>
|
||||
) : (
|
||||
"Sem observações"
|
||||
)
|
||||
@@ -105,8 +105,8 @@ export function PagadorInfoCard({ pagador }: PagadorInfoCardProps) {
|
||||
}
|
||||
|
||||
const resolveRoleLabel = (role: string | null) => {
|
||||
if (role === PAGADOR_ROLE_ADMIN) return "Administrador";
|
||||
return "Pagador";
|
||||
if (role === PAYER_ROLE_ADMIN) return "Administrador";
|
||||
return "Payer";
|
||||
};
|
||||
|
||||
type InfoItemProps = {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { RiLogoutBoxLine } from "@remixicon/react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState, useTransition } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { deletePagadorShareAction } from "@/features/payers/actions";
|
||||
import { deletePayerShareAction } from "@/features/payers/actions";
|
||||
import { Button } from "@/shared/components/ui/button";
|
||||
import {
|
||||
Card,
|
||||
@@ -20,7 +20,7 @@ interface PagadorLeaveShareCardProps {
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export function PagadorLeaveShareCard({
|
||||
export function PayerLeaveShareCard({
|
||||
shareId,
|
||||
pagadorName,
|
||||
createdAt,
|
||||
@@ -31,7 +31,7 @@ export function PagadorLeaveShareCard({
|
||||
|
||||
const handleLeave = () => {
|
||||
startTransition(async () => {
|
||||
const result = await deletePagadorShareAction({ shareId });
|
||||
const result = await deletePayerShareAction({ shareId });
|
||||
|
||||
if (!result.success) {
|
||||
toast.error(result.error);
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/shared/components/ui/card";
|
||||
import type { PagadorMonthlyBreakdown } from "@/shared/lib/payers/details";
|
||||
import type { PayerMonthlyBreakdown } from "@/shared/lib/payers/details";
|
||||
import { cn } from "@/shared/utils/ui";
|
||||
|
||||
const segmentConfig = {
|
||||
@@ -26,10 +26,10 @@ const segmentConfig = {
|
||||
|
||||
type PagadorMonthlySummaryCardProps = {
|
||||
periodLabel: string;
|
||||
breakdown: PagadorMonthlyBreakdown;
|
||||
breakdown: PayerMonthlyBreakdown;
|
||||
};
|
||||
|
||||
export function PagadorMonthlySummaryCard({
|
||||
export function PayerMonthlySummaryCard({
|
||||
periodLabel,
|
||||
breakdown,
|
||||
}: PagadorMonthlySummaryCardProps) {
|
||||
|
||||
@@ -11,18 +11,18 @@ import { CardContent } from "@/shared/components/ui/card";
|
||||
import { Progress } from "@/shared/components/ui/progress";
|
||||
import { WidgetEmptyState } from "@/shared/components/widget-empty-state";
|
||||
import type {
|
||||
PagadorBoletoItem,
|
||||
PagadorPaymentStatusData,
|
||||
PayerBoletoItem,
|
||||
PayerPaymentStatusData,
|
||||
} from "@/shared/lib/payers/details";
|
||||
import { cn } from "@/shared/utils/ui";
|
||||
|
||||
// --- PagadorBoletoCard ---
|
||||
// --- PayerBoletoCard ---
|
||||
|
||||
type PagadorBoletoCardProps = {
|
||||
items: PagadorBoletoItem[];
|
||||
items: PayerBoletoItem[];
|
||||
};
|
||||
|
||||
export function PagadorBoletoCard({ items }: PagadorBoletoCardProps) {
|
||||
export function PayerBoletoCard({ items }: PagadorBoletoCardProps) {
|
||||
if (items.length === 0) {
|
||||
return (
|
||||
<CardContent className="px-0">
|
||||
@@ -72,13 +72,13 @@ export function PagadorBoletoCard({ items }: PagadorBoletoCardProps) {
|
||||
);
|
||||
}
|
||||
|
||||
// --- PagadorPaymentStatusCard ---
|
||||
// --- PayerPaymentStatusCard ---
|
||||
|
||||
type PagadorPaymentStatusCardProps = {
|
||||
data: PagadorPaymentStatusData;
|
||||
data: PayerPaymentStatusData;
|
||||
};
|
||||
|
||||
export function PagadorPaymentStatusCard({
|
||||
export function PayerPaymentStatusCard({
|
||||
data,
|
||||
}: PagadorPaymentStatusCardProps) {
|
||||
const { paidAmount, paidCount, pendingAmount, pendingCount, totalAmount } =
|
||||
|
||||
@@ -5,8 +5,8 @@ import { useRouter } from "next/navigation";
|
||||
import { useState, useTransition } from "react";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
deletePagadorShareAction,
|
||||
regeneratePagadorShareCodeAction,
|
||||
deletePayerShareAction,
|
||||
regeneratePayerShareCodeAction,
|
||||
} from "@/features/payers/actions";
|
||||
import { Button } from "@/shared/components/ui/button";
|
||||
import {
|
||||
@@ -25,13 +25,13 @@ type PagadorShare = {
|
||||
};
|
||||
|
||||
interface PagadorSharingCardProps {
|
||||
pagadorId: string;
|
||||
payerId: string;
|
||||
shareCode: string;
|
||||
shares: PagadorShare[];
|
||||
}
|
||||
|
||||
export function PagadorSharingCard({
|
||||
pagadorId,
|
||||
export function PayerSharingCard({
|
||||
payerId,
|
||||
shareCode,
|
||||
shares,
|
||||
}: PagadorSharingCardProps) {
|
||||
@@ -51,14 +51,14 @@ export function PagadorSharingCard({
|
||||
|
||||
const handleRegenerate = () => {
|
||||
startRegenerate(async () => {
|
||||
const result = await regeneratePagadorShareCodeAction({ pagadorId });
|
||||
const result = await regeneratePayerShareCodeAction({ payerId });
|
||||
|
||||
if (!result.success) {
|
||||
toast.error(result.error);
|
||||
return;
|
||||
}
|
||||
|
||||
setCurrentCode(result.code);
|
||||
if ("code" in result) setCurrentCode(result.code);
|
||||
toast.success("Novo código gerado com sucesso.");
|
||||
router.refresh();
|
||||
});
|
||||
@@ -67,7 +67,7 @@ export function PagadorSharingCard({
|
||||
const handleRemove = (shareId: string) => {
|
||||
setRemovePendingId(shareId);
|
||||
startRegenerate(async () => {
|
||||
const result = await deletePagadorShareAction({ shareId });
|
||||
const result = await deletePayerShareAction({ shareId });
|
||||
|
||||
if (!result.success) {
|
||||
toast.error(result.error);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type PagadorInfo = {
|
||||
export type PayerInfo = {
|
||||
id: string;
|
||||
name: string;
|
||||
email: string | null;
|
||||
@@ -13,7 +13,7 @@ export type PagadorInfo = {
|
||||
canEdit: boolean;
|
||||
};
|
||||
|
||||
export type PagadorSummaryPreview = {
|
||||
export type PayerSummaryPreview = {
|
||||
periodLabel: string;
|
||||
totalExpenses: number;
|
||||
paymentSplits: {
|
||||
|
||||
Reference in New Issue
Block a user