style: clean up code formatting and remove trailing whitespace

refactor: reorganize imports and fix type imports
This commit is contained in:
Evandro Fonseca Junior committed 2025-11-11 03:08:36 -03:00
1 parent d3704602fd
commit 47c04de6fe
232 files changed
+7140 -4798

No files matched your search

@@ -1,5 +1,7 @@
"use client";
import { useQueryClient } from "@tanstack/react-query";
import { Loader2, RefreshCw } from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import {
@@ -9,6 +11,7 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import { Label } from "@/components/ui/label";
import {
Select,
SelectContent,
@@ -16,9 +19,6 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { Label } from "@/components/ui/label";
import { RefreshCw, Loader2 } from "lucide-react";
import { useQueryClient } from "@tanstack/react-query";
interface ChangePaymentMethodButtonProps {
intentionId: number;
@@ -49,14 +49,15 @@ export function ChangePaymentMethodButton({
canChange,
}: ChangePaymentMethodButtonProps) {
const [open, setOpen] = useState(false);
const [selectedMethod, setSelectedMethod] = useState<string>(currentPaymentMethod);
const [selectedMethod, setSelectedMethod] =
useState<string>(currentPaymentMethod);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const queryClient = useQueryClient();
// Filtrar métodos disponíveis (excluir o atual)
const availableOptions = availableMethods.filter(
(method) => method !== currentPaymentMethod
(method) => method !== currentPaymentMethod,
);
const handleChange = async () => {
@@ -75,7 +76,7 @@ export function ChangePaymentMethodButton({
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ payment_method: selectedMethod }),
}
},
);
const data = await res.json();
@@ -92,7 +93,11 @@ export function ChangePaymentMethodButton({
setOpen(false);
// Opcional: mostrar toast de sucesso
} catch (err) {
setError(err instanceof Error ? err.message : "Erro ao trocar método de pagamento");
setError(
err instanceof Error
? err.message
: "Erro ao trocar método de pagamento",
);
} finally {
setLoading(false);
}
@@ -123,7 +128,8 @@ export function ChangePaymentMethodButton({
<DialogHeader>
<DialogTitle>Trocar Método de Pagamento</DialogTitle>
<DialogDescription>
Você pode trocar o método de pagamento apenas uma vez. Escolha o novo método:
Você pode trocar o método de pagamento apenas uma vez. Escolha o
novo método:
</DialogDescription>
</DialogHeader>
@@ -158,10 +164,17 @@ export function ChangePaymentMethodButton({
)}
<div className="flex gap-2 justify-end">
<Button variant="outline" onClick={() => setOpen(false)} disabled={loading}>
<Button
variant="outline"
onClick={() => setOpen(false)}
disabled={loading}
>
Cancelar
</Button>
<Button onClick={handleChange} disabled={loading || selectedMethod === currentPaymentMethod}>
<Button
onClick={handleChange}
disabled={loading || selectedMethod === currentPaymentMethod}
>
{loading ? (
<>
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
@@ -178,4 +191,3 @@ export function ChangePaymentMethodButton({
</>
);
}