- Removed the delete action from various components including InvoiceInfo, PaymentInfo, and others to streamline functionality. - Introduced a new DeleteObject component to handle deletion logic in a centralized manner, enhancing code maintainability. - Updated models to utilize the new DeleteObject component for consistent deletion handling across the application. - Simplified ObjectForm by eliminating the previous delete modal, improving component structure and clarity.
250 lines
5.3 KiB
JavaScript
250 lines
5.3 KiB
JavaScript
import { createElement, lazy } from 'react'
|
|
|
|
const TaxRateInfo = lazy(
|
|
() => import('../../components/Dashboard/Management/TaxRates/TaxRateInfo')
|
|
)
|
|
const NewTaxRate = lazy(
|
|
() => import('../../components/Dashboard/Management/TaxRates/NewTaxRate')
|
|
)
|
|
const DeleteObject = lazy(
|
|
() => import('../../components/Dashboard/common/DeleteObject')
|
|
)
|
|
import TaxRateIcon from '../../components/Icons/TaxRateIcon'
|
|
import PlusIcon from '../../components/Icons/PlusIcon'
|
|
import InfoCircleIcon from '../../components/Icons/InfoCircleIcon'
|
|
import EditIcon from '../../components/Icons/EditIcon'
|
|
import CheckIcon from '../../components/Icons/CheckIcon'
|
|
import XMarkIcon from '../../components/Icons/XMarkIcon'
|
|
import BinIcon from '../../components/Icons/BinIcon'
|
|
import ListIcon from '../../components/Icons/ListIcon'
|
|
|
|
export const TaxRate = {
|
|
name: 'taxRate',
|
|
label: 'Tax Rate',
|
|
labelPlural: 'Tax Rates',
|
|
url: '/dashboard/management/taxrates',
|
|
prefix: 'TXR',
|
|
icon: TaxRateIcon,
|
|
actions: [
|
|
{
|
|
name: 'new',
|
|
type: 'modal',
|
|
pageName: 'list',
|
|
modalWidth: 700,
|
|
label: 'New Tax Rate',
|
|
icon: PlusIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(NewTaxRate, { defaultValues: objectData, onOk, reset: true })
|
|
}
|
|
},
|
|
{
|
|
name: 'list',
|
|
type: 'page',
|
|
pageName: 'list',
|
|
label: 'List',
|
|
icon: ListIcon
|
|
},
|
|
{
|
|
name: 'info',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon
|
|
},
|
|
{
|
|
name: 'edit',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
label: 'Edit',
|
|
row: true,
|
|
icon: EditIcon,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edits',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
icon: XMarkIcon,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Save Edits',
|
|
type: 'page',
|
|
pageName: 'info',
|
|
icon: CheckIcon,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'delete',
|
|
type: 'modal',
|
|
modalWidth: 520,
|
|
modalCentered: true,
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(DeleteObject, { objectData, onOk })
|
|
}
|
|
}
|
|
],
|
|
pages: [
|
|
{
|
|
name: 'info',
|
|
content: () => createElement(TaxRateInfo)
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'name',
|
|
'rate',
|
|
'rateType',
|
|
'active',
|
|
'country',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
filters: [
|
|
'name',
|
|
'rate',
|
|
'rateType',
|
|
'active',
|
|
'country',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: [
|
|
'name',
|
|
'rate',
|
|
'rateType',
|
|
'active',
|
|
'country',
|
|
'createdAt',
|
|
'_id',
|
|
'updatedAt'
|
|
],
|
|
group: ['country', 'rateType'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
columnFixed: 'left',
|
|
type: 'id',
|
|
objectType: 'taxRate',
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'taxRate',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
columnFixed: 'left',
|
|
required: true,
|
|
type: 'text',
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'active',
|
|
label: 'Active',
|
|
required: true,
|
|
type: 'bool',
|
|
default: true,
|
|
columnWidth: 125
|
|
},
|
|
{
|
|
name: 'effectiveFrom',
|
|
label: 'Effective From',
|
|
type: 'date',
|
|
readOnly: false,
|
|
required: false,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'rate',
|
|
label: 'Rate',
|
|
required: true,
|
|
type: 'number',
|
|
min: 0,
|
|
step: 0.01,
|
|
prefix: (objectData) => {
|
|
return objectData?.rateType == 'amount' ? '£' : undefined
|
|
},
|
|
suffix: (objectData) => {
|
|
return objectData?.rateType == 'percentage' ? '%' : undefined
|
|
},
|
|
columnWidth: 100
|
|
},
|
|
|
|
{
|
|
name: 'effectiveTo',
|
|
label: 'Effective To',
|
|
type: 'date',
|
|
readOnly: false,
|
|
required: false,
|
|
columnWidth: 150
|
|
},
|
|
|
|
{
|
|
name: 'rateType',
|
|
label: 'Rate Type',
|
|
required: true,
|
|
type: 'select',
|
|
options: [
|
|
{ label: 'Percentage', value: 'percentage' },
|
|
{ label: 'Amount', value: 'amount' }
|
|
],
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'country',
|
|
label: 'Country',
|
|
type: 'country',
|
|
readOnly: false,
|
|
required: false,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'description',
|
|
label: 'Description',
|
|
type: 'text',
|
|
readOnly: false,
|
|
required: false,
|
|
columnWidth: 200
|
|
}
|
|
]
|
|
}
|