- Updated lazy loading syntax for component imports across multiple models to enhance code clarity. - Reformatted content return statements in various components for better readability. - Adjusted column widths for date fields from 175 to 200 to improve layout consistency across models. - Ensured consistent formatting and structure in model definitions for better maintainability.
360 lines
8.1 KiB
JavaScript
360 lines
8.1 KiB
JavaScript
import { createElement, lazy } from 'react'
|
|
|
|
const ListingVarientInfo = lazy(
|
|
() =>
|
|
import('../../components/Dashboard/Sales/ListingVarients/ListingVarientInfo')
|
|
)
|
|
const NewListingVarient = lazy(
|
|
() =>
|
|
import('../../components/Dashboard/Sales/ListingVarients/NewListingVarient')
|
|
)
|
|
const PublishListingVarient = lazy(
|
|
() =>
|
|
import('../../components/Dashboard/Sales/ListingVarients/PublishListingVarient')
|
|
)
|
|
const UnpublishListingVarient = lazy(
|
|
() =>
|
|
import('../../components/Dashboard/Sales/ListingVarients/UnpublishListingVarient')
|
|
)
|
|
const DeleteObject = lazy(
|
|
() => import('../../components/Dashboard/common/DeleteObject')
|
|
)
|
|
import ListingVarientIcon from '../../components/Icons/ListingVarientIcon'
|
|
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 ListingVarient = {
|
|
name: 'listingVarient',
|
|
url: '/dashboard/sales/listingvarients',
|
|
label: 'Listing Varient',
|
|
labelPlural: 'Listing Varients',
|
|
prefix: 'LVR',
|
|
icon: ListingVarientIcon,
|
|
actions: [
|
|
{
|
|
name: 'new',
|
|
type: 'modal',
|
|
pageName: 'list',
|
|
modalWidth: 700,
|
|
label: 'New Listing Varient',
|
|
icon: PlusIcon,
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(NewListingVarient, {
|
|
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: 'publish',
|
|
type: 'modal',
|
|
modalWidth: 520,
|
|
label: 'Publish',
|
|
icon: CheckIcon,
|
|
visible: (objectData) =>
|
|
objectData?.state?.type === 'draft' ||
|
|
objectData?.state?.type === 'inactive',
|
|
disabled: (objectData) =>
|
|
['syncing', 'publishing', 'unpublishing'].includes(
|
|
objectData?.state?.type
|
|
),
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(PublishListingVarient, { objectData, onOk })
|
|
}
|
|
},
|
|
{
|
|
name: 'unpublish',
|
|
type: 'modal',
|
|
modalWidth: 520,
|
|
label: 'Unpublish',
|
|
icon: XMarkIcon,
|
|
danger: true,
|
|
visible: (objectData) => objectData?.state?.type === 'active',
|
|
disabled: (objectData) =>
|
|
['syncing', 'publishing', 'unpublishing'].includes(
|
|
objectData?.state?.type
|
|
),
|
|
content: (objectData, { onOk } = {}) => {
|
|
return createElement(UnpublishListingVarient, { objectData, onOk })
|
|
}
|
|
},
|
|
{ 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(ListingVarientInfo)
|
|
}
|
|
],
|
|
columns: [
|
|
'_reference',
|
|
'listing',
|
|
'product',
|
|
'productSku',
|
|
'stockQuantity',
|
|
'state',
|
|
'price',
|
|
'currency',
|
|
'lastSyncedAt',
|
|
'createdAt',
|
|
'updatedAt'
|
|
],
|
|
filters: [
|
|
'listing',
|
|
'product',
|
|
'productSku',
|
|
'stockQuantity',
|
|
'state',
|
|
'state.type',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_reference'
|
|
],
|
|
sorters: [
|
|
'state',
|
|
'stockQuantity',
|
|
'price',
|
|
'lastSyncedAt',
|
|
'createdAt',
|
|
'updatedAt',
|
|
'_id'
|
|
],
|
|
group: ['listing', 'state'],
|
|
properties: [
|
|
{
|
|
name: '_id',
|
|
label: 'ID',
|
|
columnFixed: 'left',
|
|
type: 'id',
|
|
objectType: 'listingVarient',
|
|
showCopy: true,
|
|
columnWidth: 140
|
|
},
|
|
{
|
|
name: 'createdAt',
|
|
label: 'Created At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: '_reference',
|
|
label: 'Reference',
|
|
type: 'reference',
|
|
columnFixed: 'left',
|
|
objectType: 'listingVarient',
|
|
showCopy: true,
|
|
readOnly: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'updatedAt',
|
|
label: 'Updated At',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'listing',
|
|
label: 'Listing',
|
|
type: 'object',
|
|
objectType: 'listing',
|
|
showHyperlink: true,
|
|
readOnly: false,
|
|
required: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'product',
|
|
label: 'Product',
|
|
type: 'object',
|
|
objectType: 'product',
|
|
showHyperlink: true,
|
|
readOnly: true,
|
|
value: (objectData) => {
|
|
return objectData?.listing?.product
|
|
},
|
|
required: true,
|
|
columnWidth: 200
|
|
},
|
|
{
|
|
name: 'productSku',
|
|
label: 'Product SKU',
|
|
type: 'object',
|
|
objectType: 'productSku',
|
|
showHyperlink: true,
|
|
readOnly: false,
|
|
required: true,
|
|
columnWidth: 200,
|
|
masterFilter: (objectData) => {
|
|
return { product: objectData?.listing?.product?._id }
|
|
}
|
|
},
|
|
{
|
|
name: 'stockQuantity',
|
|
label: 'Stock Quantity',
|
|
type: 'number',
|
|
min: 0,
|
|
readOnly: true,
|
|
required: false,
|
|
columnWidth: 170
|
|
},
|
|
{
|
|
name: 'state',
|
|
label: 'State',
|
|
type: 'state',
|
|
objectType: 'listingVarient',
|
|
readOnly: true,
|
|
columnWidth: 260
|
|
},
|
|
{
|
|
name: 'price',
|
|
label: 'Price',
|
|
type: 'number',
|
|
prefix: '£',
|
|
min: 0,
|
|
step: 0.01,
|
|
readOnly: false,
|
|
required: false,
|
|
columnWidth: 120
|
|
},
|
|
{
|
|
name: 'currency',
|
|
label: 'Currency',
|
|
type: 'text',
|
|
readOnly: false,
|
|
required: false,
|
|
columnWidth: 100
|
|
},
|
|
{
|
|
name: 'priceTaxRate',
|
|
label: 'Tax Rate',
|
|
type: 'object',
|
|
objectType: 'taxRate',
|
|
showHyperlink: true,
|
|
required: false,
|
|
columnWidth: 150
|
|
},
|
|
{
|
|
name: 'priceWithTax',
|
|
label: 'Price w/ Tax',
|
|
type: 'number',
|
|
prefix: '£',
|
|
min: 0,
|
|
step: 0.01,
|
|
readOnly: true,
|
|
required: false,
|
|
columnWidth: 130
|
|
},
|
|
{
|
|
name: 'lastSyncedAt',
|
|
label: 'Last Synced',
|
|
type: 'dateTime',
|
|
readOnly: true,
|
|
columnWidth: 175
|
|
},
|
|
{
|
|
name: 'listingImages',
|
|
label: 'Listing Images',
|
|
type: 'fileList',
|
|
gallery: true,
|
|
required: false,
|
|
masterFilter: ['.jpg', '.jpeg', '.png', '.gif', '.webp']
|
|
},
|
|
{
|
|
name: 'aspects',
|
|
label: 'Aspects',
|
|
type: 'objectChildren',
|
|
required: false,
|
|
canAddRemove: true,
|
|
size: 'medium',
|
|
span: 2,
|
|
extra:
|
|
'Required for multi-variation eBay listings. Use the same aspect names on every varient in a listing (e.g. Color, Size).',
|
|
columns: ['name', 'value'],
|
|
properties: [
|
|
{
|
|
name: 'name',
|
|
label: 'Name',
|
|
type: 'text',
|
|
required: true,
|
|
columnWidth: 180
|
|
},
|
|
{
|
|
name: 'value',
|
|
label: 'Value',
|
|
type: 'text',
|
|
required: true,
|
|
columnWidth: 180
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|