2026-06-21 18:14:54 +01:00

260 lines
5.8 KiB
JavaScript

import ListingIcon from '../../components/Icons/ListingIcon'
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 PlusIcon from '../../components/Icons/PlusIcon'
export const Listing = {
name: 'listing',
label: 'Listing',
prefix: 'LST',
icon: ListingIcon,
actions: [
{
name: 'info',
label: 'Info',
default: true,
row: true,
icon: InfoCircleIcon,
url: (_id) => `/dashboard/sales/listings/info?listingId=${_id}`
},
{
name: 'edit',
label: 'Edit',
row: true,
icon: EditIcon,
url: (_id) =>
`/dashboard/sales/listings/info?listingId=${_id}&action=edit`,
visible: (objectData) => {
return !(objectData?._isEditing && objectData?._isEditing == true)
}
},
{
name: 'finishEdit',
label: 'Save Edits',
icon: CheckIcon,
url: (_id) =>
`/dashboard/sales/listings/info?listingId=${_id}&action=finishEdit`,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
{
name: 'cancelEdit',
label: 'Cancel Edits',
icon: XMarkIcon,
url: (_id) =>
`/dashboard/sales/listings/info?listingId=${_id}&action=cancelEdit`,
visible: (objectData) => {
return objectData?._isEditing && objectData?._isEditing == true
}
},
{ type: 'divider' },
{
name: 'newListingVarient',
label: 'New Listing Varient',
type: 'button',
icon: PlusIcon,
url: (_id) =>
`/dashboard/sales/listings/info?listingId=${_id}&action=newListingVarient`
},
{ type: 'divider' },
{
name: 'publish',
label: 'Publish',
type: 'button',
icon: CheckIcon,
url: (_id) =>
`/dashboard/sales/listings/info?listingId=${_id}&action=publish`,
visible: (objectData) =>
objectData?.state?.type === 'draft' ||
objectData?.state?.type === 'inactive',
disabled: (objectData) => objectData?.state?.type === 'syncing'
},
{
name: 'unpublish',
label: 'Unpublish',
type: 'button',
icon: XMarkIcon,
danger: true,
url: (_id) =>
`/dashboard/sales/listings/info?listingId=${_id}&action=unpublish`,
visible: (objectData) => objectData?.state?.type === 'active',
disabled: (objectData) => objectData?.state?.type === 'syncing'
},
{ type: 'divider' },
{
name: 'delete',
label: 'Delete',
icon: BinIcon,
danger: true,
url: (_id) =>
`/dashboard/sales/listings/info?listingId=${_id}&action=delete`
}
],
columns: [
'_reference',
'title',
'product',
'vendor',
'stockLocation',
'marketplace',
'state',
'price',
'currency',
'lastSyncedAt',
'createdAt',
'updatedAt'
],
filters: [
'title',
'_id',
'product',
'vendor',
'stockLocation',
'marketplace',
'state',
'createdAt',
'updatedAt'
],
sorters: [
'title',
'vendor',
'state',
'price',
'lastSyncedAt',
'createdAt',
'updatedAt',
'_id'
],
group: ['marketplace', 'product', 'vendor', 'stockLocation'],
properties: [
{
name: '_id',
label: 'ID',
columnFixed: 'left',
type: 'id',
objectType: 'listing',
showCopy: true,
columnWidth: 140
},
{
name: 'createdAt',
label: 'Created At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{
name: '_reference',
label: 'Reference',
type: 'reference',
columnFixed: 'left',
objectType: 'listing',
showCopy: true,
readOnly: true,
columnWidth: 180
},
{
name: 'updatedAt',
label: 'Updated At',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{
name: 'title',
label: 'Title',
columnFixed: 'left',
type: 'text',
readOnly: false,
required: false,
columnWidth: 250
},
{
name: 'lastSyncedAt',
label: 'Last Synced',
type: 'dateTime',
readOnly: true,
columnWidth: 175
},
{
name: 'product',
label: 'Product',
type: 'object',
objectType: 'product',
showHyperlink: true,
readOnly: false,
required: false,
columnWidth: 200
},
{
name: 'vendor',
label: 'Vendor',
type: 'object',
objectType: 'vendor',
showHyperlink: true,
readOnly: false,
required: true,
columnWidth: 200
},
{
name: 'stockLocation',
label: 'Stock Location',
type: 'object',
objectType: 'stockLocation',
showHyperlink: true,
readOnly: false,
required: true,
columnWidth: 200
},
{
name: 'marketplace',
label: 'Marketplace',
type: 'object',
objectType: 'marketplace',
showHyperlink: true,
readOnly: false,
required: true,
columnWidth: 200
},
{
name: 'state',
label: 'State',
type: 'state',
objectType: 'listing',
readOnly: true,
columnWidth: 130
},
{
name: 'price',
label: 'Price',
type: 'number',
prefix: '£',
min: 0,
step: 0.01,
readOnly: true,
required: false,
columnWidth: 120
},
{
name: 'currency',
label: 'Currency',
type: 'text',
readOnly: true,
required: false,
columnWidth: 100
},
{
name: 'url',
label: 'URL',
type: 'url',
readOnly: true,
required: false,
columnWidth: 250
}
]
}