import { createElement, lazy } from 'react' const ListingInfo = lazy( () => import('../../components/Dashboard/Sales/Listings/ListingInfo') ) const NewListing = lazy( () => import('../../components/Dashboard/Sales/Listings/NewListing') ) const PublishListing = lazy( () => import('../../components/Dashboard/Sales/Listings/PublishListing') ) const UnpublishListing = lazy( () => import('../../components/Dashboard/Sales/Listings/UnpublishListing') ) const DeleteObject = lazy( () => import('../../components/Dashboard/common/DeleteObject') ) import ListingIcon from '../../components/Icons/ListingIcon' 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 Listing = { name: 'listing', label: 'Listing', labelPlural: 'Listings', url: '/dashboard/sales/listings', prefix: 'LST', icon: ListingIcon, actions: [ { name: 'new', type: 'modal', pageName: 'list', modalWidth: 800, label: 'New Listing', icon: PlusIcon, content: (objectData, { onOk } = {}) => { return createElement(NewListing, { 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: 'newListingVarient', type: 'alias', objectType: 'listingVarient', aliasAction: 'new', objectData: (objectData) => ({ listing: objectData }) }, { 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(PublishListing, { 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(UnpublishListing, { 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(ListingInfo) } ], columns: [ '_reference', 'title', 'product', 'vendor', 'stockLocation', 'stockQuantity', 'marketplace', 'fulfillmentPolicy', 'paymentPolicy', 'returnPolicy', 'courierServices', 'state', 'condition', 'price', 'currency', 'lastSyncedAt', 'createdAt', 'updatedAt' ], filters: [ 'product', 'vendor', 'stockLocation', 'stockQuantity', 'marketplace', 'fulfillmentPolicy', 'paymentPolicy', 'returnPolicy', 'courierServices', 'state', 'state.type', 'condition', 'createdAt', 'updatedAt', '_reference' ], sorters: [ 'title', 'vendor', 'state', 'stockQuantity', 'price', 'lastSyncedAt', 'createdAt', 'updatedAt', '_id' ], group: ['marketplace', 'vendor', 'product', '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: true, columnWidth: 250, value: (objectData) => { if (objectData?.title == undefined) { return objectData?.product?.name } return objectData?.title } }, { name: 'description', label: 'Description', type: 'markdown', readOnly: false, required: false, span: 2, extra: 'Used as the eBay listing description. If empty, the title is sent instead.' }, { name: 'listingImages', label: 'Listing Images', type: 'fileList', gallery: true, required: false, masterFilter: ['.jpg', '.jpeg', '.png', '.gif', '.webp'] }, { name: 'lastSyncedAt', label: 'Last Synced', type: 'dateTime', readOnly: true, columnWidth: 175 }, { name: 'product', label: 'Product', type: 'object', objectType: 'product', showHyperlink: true, readOnly: false, required: true, columnWidth: 200 }, { name: 'vendor', label: 'Vendor', type: 'object', objectType: 'vendor', showHyperlink: true, readOnly: false, required: true, value: (objectData) => { if (objectData?.vendor == undefined) { return objectData?.product?.vendor } return objectData?.vendor }, columnWidth: 200 }, { name: 'stockLocation', label: 'Stock Location', type: 'object', objectType: 'stockLocation', showHyperlink: true, readOnly: false, required: true, columnWidth: 200 }, { name: 'stockQuantity', label: 'Stock Quantity', type: 'number', min: 0, readOnly: true, required: false, columnWidth: 170 }, { name: 'marketplace', label: 'Marketplace', type: 'object', objectType: 'marketplace', showHyperlink: true, readOnly: false, required: true, columnWidth: 200 }, { name: 'fulfillmentPolicy', label: 'Fulfillment Policy', type: 'object', objectType: 'fulfillmentPolicy', showHyperlink: true, readOnly: false, required: false, extra: 'Defaults from the marketplace. Courier services are used as a fallback when this is empty.', value: (objectData) => { if (objectData?.fulfillmentPolicy == undefined) { return objectData?.marketplace?.defaultFulfillmentPolicy } return objectData?.fulfillmentPolicy }, columnWidth: 220 }, { name: 'paymentPolicy', label: 'Payment Policy', type: 'object', objectType: 'paymentPolicy', showHyperlink: true, readOnly: false, required: false, extra: 'Defaults from the marketplace. Required when publishing to eBay.', value: (objectData) => { if (objectData?.paymentPolicy == undefined) { return objectData?.marketplace?.defaultPaymentPolicy } return objectData?.paymentPolicy }, columnWidth: 200 }, { name: 'returnPolicy', label: 'Return Policy', type: 'object', objectType: 'returnPolicy', showHyperlink: true, readOnly: false, required: false, extra: 'Defaults from the marketplace. Required when publishing to eBay.', value: (objectData) => { if (objectData?.returnPolicy == undefined) { return objectData?.marketplace?.defaultReturnPolicy } return objectData?.returnPolicy }, columnWidth: 200 }, { name: 'state', label: 'State', type: 'state', objectType: 'listing', readOnly: true, columnWidth: 260 }, { name: 'condition', label: 'Condition', type: 'select', required: true, extra: 'Required by eBay for most categories. Stored in camel case and converted when publishing.', options: [ { value: 'new', label: 'New' }, { value: 'likeNew', label: 'Like New' }, { value: 'newOther', label: 'New Other' }, { value: 'newWithDefects', label: 'New With Defects' }, { value: 'manufacturerRefurbished', label: 'Manufacturer Refurbished' }, { value: 'certifiedRefurbished', label: 'Certified Refurbished' }, { value: 'excellentRefurbished', label: 'Excellent Refurbished' }, { value: 'veryGoodRefurbished', label: 'Very Good Refurbished' }, { value: 'goodRefurbished', label: 'Good Refurbished' }, { value: 'sellerRefurbished', label: 'Seller Refurbished' }, { value: 'usedExcellent', label: 'Used Excellent' }, { value: 'usedVeryGood', label: 'Used Very Good' }, { value: 'usedGood', label: 'Used Good' }, { value: 'usedAcceptable', label: 'Used Acceptable' }, { value: 'forPartsOrNotWorking', label: 'For Parts Or Not Working' }, { value: 'preOwnedExcellent', label: 'Pre Owned Excellent' }, { value: 'preOwnedFair', label: 'Pre Owned Fair' } ], value: (objectData) => objectData?.condition || 'new', columnWidth: 200 }, { 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 }, { name: 'externalReference', label: 'External Reference', type: 'miscId', readOnly: true, required: false, extra: 'eBay item ID for this listing. Publish and unpublish reuse this ID when set.', showCopy: true, columnWidth: 180 }, { name: 'courierServices', label: 'Courier Services', type: 'objectList', showHyperlink: true, objectType: 'courierService', readOnly: false, required: true, extra: 'Used for order shipping and as the eBay fulfillment fallback when no fulfillment policy is set.', columnWidth: 250 } ], stats: [ { name: 'draft.count', label: 'Draft', type: 'number', color: 'default' }, { name: 'active.count', label: 'Active', type: 'number', color: 'success' }, { name: 'inactive.count', label: 'Inactive', type: 'number', color: 'default' }, { name: 'syncing.count', label: 'Syncing', type: 'number', color: 'processing' }, { name: 'publishing.count', label: 'Publishing', type: 'number', color: 'processing' }, { name: 'unpublishing.count', label: 'Unpublishing', type: 'number', color: 'processing' }, { name: 'suspended.count', label: 'Suspended', type: 'number', color: 'error' }, { name: 'deleted.count', label: 'Deleted', type: 'number', color: 'error' } ] }