'use client';
import React, { useState, useEffect } from 'react';
import {
PlusIcon,
BanknotesIcon,
TagIcon,
CheckIcon,
XMarkIcon,
PencilSquareIcon,
TrashIcon,
BuildingLibraryIcon
} from '@heroicons/react/24/outline';
import { erpApi, FinancialCategory, BankAccount } from '@/lib/api-erp';
import { formatCurrency } from '@/lib/format';
import { toast } from 'react-hot-toast';
import {
PageHeader,
DataTable,
Input,
Card,
Tabs
} from "@/components/ui";
export default function ERPSettingsPage() {
return (
,
content:
},
{
label: 'Contas Bancárias',
icon:
,
content:
}
]}
/>
);
}
function CategorySettings() {
const [categories, setCategories] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
fetchData();
}, []);
const fetchData = async () => {
try {
const data = await erpApi.getFinancialCategories();
setCategories(data || []);
} catch (error) {
toast.error('Erro ao carregar categorias');
} finally {
setLoading(false);
}
};
return (
Categorias
(
)
},
{
header: 'Tipo',
accessor: (row) => (
{row.type === 'income' ? 'Receita' : 'Despesa'}
)
},
{
header: 'Status',
accessor: (row) => (
{row.is_active ? 'Ativo' : 'Inativo'}
)
},
{
header: '',
className: 'text-right',
accessor: () => (
)
}
]}
/>
);
}
function AccountSettings() {
const [accounts, setAccounts] = useState([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
fetchData();
}, []);
const fetchData = async () => {
try {
const data = await erpApi.getBankAccounts();
setAccounts(data || []);
} catch (error) {
toast.error('Erro ao carregar contas');
} finally {
setLoading(false);
}
};
return (
Contas Bancárias
(
{row.name}
{row.bank_name}
)
},
{
header: 'Saldo Atual',
className: 'text-right',
accessor: (row) => (
{formatCurrency(row.current_balance)}
)
},
{
header: 'Status',
accessor: (row) => (
{row.is_active ? 'Ativo' : 'Inativo'}
)
},
{
header: '',
className: 'text-right',
accessor: () => (
)
}
]}
/>
);
}