diff --git a/src/components/Dashboard/Sales/Marketplaces/NewMarketplace.jsx b/src/components/Dashboard/Sales/Marketplaces/NewMarketplace.jsx index acda025b..74fbea74 100644 --- a/src/components/Dashboard/Sales/Marketplaces/NewMarketplace.jsx +++ b/src/components/Dashboard/Sales/Marketplaces/NewMarketplace.jsx @@ -77,6 +77,7 @@ const NewMarketplace = ({ onOk, defaultValues }) => { 'config.marketplaceId': false, 'config.sandbox': false, 'config.verificationToken': false, + 'config.webhookUrl': false, 'config.redirectUri': false, 'config.accessToken': false, 'config.refreshToken': false, diff --git a/src/components/Dashboard/Sales/Marketplaces/SyncWebhooks.jsx b/src/components/Dashboard/Sales/Marketplaces/SyncWebhooks.jsx new file mode 100644 index 00000000..23dfccc0 --- /dev/null +++ b/src/components/Dashboard/Sales/Marketplaces/SyncWebhooks.jsx @@ -0,0 +1,20 @@ +import PropTypes from 'prop-types' +import SyncAccountPolicies from './SyncAccountPolicies.jsx' + +const SyncWebhooks = ({ onOk, objectData }) => ( + +) + +SyncWebhooks.propTypes = { + onOk: PropTypes.func.isRequired, + objectData: PropTypes.object +} + +export default SyncWebhooks diff --git a/src/database/models/Marketplace.js b/src/database/models/Marketplace.js index 5504bb0e..dabe1ac9 100644 --- a/src/database/models/Marketplace.js +++ b/src/database/models/Marketplace.js @@ -1,4 +1,5 @@ import { createElement, lazy } from 'react' +import config from '../../config' const MarketplaceInfo = lazy( () => import('../../components/Dashboard/Sales/Marketplaces/MarketplaceInfo') @@ -30,6 +31,9 @@ const SyncReturnPolicies = lazy( const SyncTaxRates = lazy( () => import('../../components/Dashboard/Sales/Marketplaces/SyncTaxRates') ) +const SyncWebhooks = lazy( + () => import('../../components/Dashboard/Sales/Marketplaces/SyncWebhooks') +) const DeleteObject = lazy( () => import('../../components/Dashboard/common/DeleteObject') ) @@ -162,6 +166,19 @@ export const Marketplace = { return createElement(SyncOrders, { objectData, onOk }) } }, + { + name: 'syncWebhooks', + type: 'modal', + modalWidth: 520, + label: 'Sync Webhooks', + icon: ReloadIcon, + disabled: (objectData) => { + return objectData?.state?.type != 'ready' + }, + content: (objectData, { onOk } = {}) => { + return createElement(SyncWebhooks, { objectData, onOk }) + } + }, { name: 'syncFulfillmentPolicies', type: 'modal', @@ -627,6 +644,27 @@ export const Marketplace = { return `${window.location.origin}/auth/marketplace/callback` } }, + { + name: 'config.webhookUrl', + label: 'Webhook URL', + type: 'url', + readOnly: true, + required: false, + columnWidth: 280, + extra: + 'Registered with the marketplace so new and updated orders are written to FarmControl.', + visible: (objectData) => + objectData?.provider === 'ebay' || + objectData?.provider === 'tiktokShop', + value: (objectData) => { + const id = objectData?._id + const base = config.backendUrl?.replace(/\/$/, '') + if (!id || !base) { + return undefined + } + return `${base}/marketplaces/${id}/hook` + } + }, { name: 'defaultFulfillmentPolicy', label: 'Default Fulfillment Policy',