mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { addCurrencyAction, deleteCurrencyAction, editCurrencyAction } from "@/app/settings/actions"
|
|
import { CrudTable } from "@/components/settings/crud"
|
|
import { getCurrencies } from "@/models/currencies"
|
|
|
|
export default async function CurrenciesSettingsPage() {
|
|
const currencies = await getCurrencies()
|
|
const currenciesWithActions = currencies.map((currency) => ({
|
|
...currency,
|
|
isEditable: true,
|
|
isDeletable: true,
|
|
}))
|
|
|
|
return (
|
|
<div className="container">
|
|
<h1 className="text-2xl font-bold mb-6">Currencies</h1>
|
|
<CrudTable
|
|
items={currenciesWithActions}
|
|
columns={[
|
|
{ key: "code", label: "Code", editable: true },
|
|
{ key: "name", label: "Name", editable: true },
|
|
]}
|
|
onDelete={async (code) => {
|
|
"use server"
|
|
await deleteCurrencyAction(code)
|
|
}}
|
|
onAdd={async (data) => {
|
|
"use server"
|
|
await addCurrencyAction(data as { code: string; name: string })
|
|
}}
|
|
onEdit={async (code, data) => {
|
|
"use server"
|
|
await editCurrencyAction(code, data as { name: string })
|
|
}}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|