- Updated filters in multiple models such as AppPassword, AuditLog, Client, Courier, and others to include '_reference' and other relevant fields like 'createdAt' and 'updatedAt'. - This change improves data handling and consistency across the application, ensuring that all necessary fields are available for filtering.
282 lines
6.4 KiB
JavaScript
282 lines
6.4 KiB
JavaScript
import CourierServiceIcon from '../../components/Icons/CourierServiceIcon'
|
|
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'
|
|
|
|
export const CourierService = {
|
|
name: 'courierService',
|
|
label: 'Courier Service',
|
|
labelPlural: 'Courier Services',
|
|
url: '/dashboard/management/courierservices',
|
|
prefix: 'COS',
|
|
icon: CourierServiceIcon,
|
|
actions: [
|
|
{
|
|
name: 'info',
|
|
label: 'Info',
|
|
default: true,
|
|
row: true,
|
|
icon: InfoCircleIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/courierservices/info?courierServiceId=${_id}`
|
|
},
|
|
{
|
|
name: 'edit',
|
|
label: 'Edit',
|
|
row: true,
|
|
icon: EditIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/courierservices/info?courierServiceId=${_id}&action=edit`,
|
|
visible: (objectData) => {
|
|
return !(objectData?._isEditing && objectData?._isEditing == true)
|
|
}
|
|
},
|
|
{
|
|
name: 'finishEdit',
|
|
label: 'Save Edits',
|
|
icon: CheckIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/courierservices/info?courierServiceId=${_id}&action=finishEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{
|
|
name: 'cancelEdit',
|
|
label: 'Cancel Edits',
|
|
icon: XMarkIcon,
|
|
url: (_id) =>
|
|
`/dashboard/management/courierservices/info?courierServiceId=${_id}&action=cancelEdit`,
|
|
visible: (objectData) => {
|
|
return objectData?._isEditing && objectData?._isEditing == true
|
|
}
|
|
},
|
|
{ type: 'divider' },
|
|
{
|
|
name: 'delete',
|
|
label: 'Delete',
|
|
icon: BinIcon,
|
|
danger: true,
|
|
url: (_id) =>
|
|
`/dashboard/management/courierservices/info?courierServiceId=${_id}&action=delete`
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'name',
|
|
'courier',
|
|
'tracked',
|
|
'deliveryTime',
|
|
'cost',
|
|
'costWithTax',
|
|
'active'
|
|
],
|
|
filters: [
|
|
'_id',
|
|
'courier',
|
|
'courier._id',
|
|
'name',
|
|
'active',
|
|
'tracked',
|
|
'deliveryTime',
|
|
'cost',
|
|
'costWithTax',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: [
|
|
'name',
|
|
'courier',
|
|
'active',
|
|
'tracked',
|
|
'cost',
|
|
'costWithTax',
|
|
'estimatedDeliveryTime',
|
|
'createdAt',
|
|
'_id',
|
|
'updatedAt'
|
|
],
|
|
group: ['courier'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
columnFixed: 'left',
|
|
type: 'id',
|
|
objectType: 'courierService',
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'courierService',
|
|
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: 'courier',
|
|
label: 'Courier',
|
|
type: 'object',
|
|
objectType: 'courier',
|
|
showHyperlink: true,
|
|
required: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'deliveryTime',
|
|
label: 'Delivery Time',
|
|
type: 'number',
|
|
readOnly: false,
|
|
required: true,
|
|
suffix: 'days',
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'active',
|
|
label: 'Active',
|
|
type: 'bool',
|
|
readOnly: false,
|
|
required: true,
|
|
columnWidth: 125
|
|
},
|
|
{
|
|
name: 'cost',
|
|
label: 'Cost',
|
|
type: 'number',
|
|
prefix: '£',
|
|
min: 0,
|
|
step: 0.01,
|
|
readOnly: false,
|
|
required: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'costWithTax',
|
|
label: 'Cost w/ Tax',
|
|
type: 'number',
|
|
prefix: '£',
|
|
min: 0,
|
|
step: 0.01,
|
|
readOnly: true,
|
|
required: true,
|
|
columnWidth: 150,
|
|
value: (objectData) => {
|
|
const cost = objectData?.cost
|
|
if (cost == null) return 0
|
|
if (objectData?.costTaxRate?.rateType == 'percentage') {
|
|
return (
|
|
(cost * (1 + objectData.costTaxRate.rate / 100)).toFixed(2) || 0
|
|
)
|
|
} else if (objectData?.costTaxRate?.rateType == 'amount') {
|
|
return (cost + objectData.costTaxRate.rate).toFixed(2) || 0
|
|
}
|
|
return cost
|
|
}
|
|
},
|
|
{
|
|
name: 'costTaxRate',
|
|
label: 'Cost Tax Rate',
|
|
required: true,
|
|
type: 'object',
|
|
objectType: 'taxRate',
|
|
showHyperlink: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'additionalCost',
|
|
label: 'Additional Item Cost',
|
|
type: 'number',
|
|
prefix: '£',
|
|
min: 0,
|
|
step: 0.01,
|
|
readOnly: false,
|
|
required: false,
|
|
columnWidth: 220
|
|
},
|
|
{
|
|
name: 'additionalCostWithTax',
|
|
label: 'Additional Item Cost w/ Tax',
|
|
type: 'number',
|
|
prefix: '£',
|
|
min: 0,
|
|
step: 0.01,
|
|
readOnly: true,
|
|
required: false,
|
|
columnWidth: 220,
|
|
value: (objectData) => {
|
|
const cost = objectData?.additionalCost
|
|
if (cost == null) return undefined
|
|
if (objectData?.costTaxRate?.rateType == 'percentage') {
|
|
return (
|
|
(cost * (1 + objectData.costTaxRate.rate / 100)).toFixed(2) || 0
|
|
)
|
|
} else if (objectData?.costTaxRate?.rateType == 'amount') {
|
|
return (cost + objectData.costTaxRate.rate).toFixed(2) || 0
|
|
}
|
|
return cost
|
|
}
|
|
},
|
|
{
|
|
name: 'shippingCurrency',
|
|
label: 'Shipping Currency',
|
|
type: 'text',
|
|
readOnly: false,
|
|
required: true,
|
|
columnWidth: 160
|
|
},
|
|
{
|
|
name: 'international',
|
|
label: 'International Service',
|
|
type: 'bool',
|
|
readOnly: false,
|
|
required: true,
|
|
columnWidth: 170
|
|
},
|
|
{
|
|
name: 'tracked',
|
|
label: 'Tracked',
|
|
type: 'bool',
|
|
readOnly: false,
|
|
required: true,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'website',
|
|
label: 'Website',
|
|
columnWidth: 300,
|
|
type: 'url',
|
|
readOnly: false,
|
|
required: false
|
|
}
|
|
]
|
|
}
|