Tom Butcher 26132d206c
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
Add Payment and Fulfillment Policy Components with SVG Icons
- Introduced new components for managing Payment Policies and Fulfillment Policies, enhancing the dashboard's functionality for financial management.
- Added corresponding SVG icons for Payment Policy, Fulfillment Policy, and Return Policy to improve visual representation.
- Updated App.css with new styles for file gallery previews, ensuring a cohesive layout and user experience across the dashboard.
- Implemented new object forms and tables for Payment Policies, allowing for better data handling and user interaction.
2026-08-29 00:47:46 +01:00

55 lines
1.4 KiB
JavaScript

import { useState, useContext } from 'react'
import PropTypes from 'prop-types'
import { ApiServerContext } from '../../context/ApiServerContext'
import { message } from 'antd'
import MessageDialogView from '../../common/MessageDialogView.jsx'
const PublishListing = ({ onOk, objectData }) => {
const [loading, setLoading] = useState(false)
const { sendObjectFunction } = useContext(ApiServerContext)
const handlePublish = async () => {
setLoading(true)
try {
const result = await sendObjectFunction(
objectData._id,
'Listing',
'publish'
)
if (result) {
message.success('Publishing started...')
onOk(result)
}
} catch (error) {
console.error('Error publishing listing:', error)
} finally {
setLoading(false)
}
}
const ref =
objectData?.title ||
objectData?._reference ||
objectData?.name ||
objectData?._id
return (
<MessageDialogView
title='Publish this listing on the marketplace?'
description={`Each variant with a SKU will be published on the connected marketplace. Variants that are already active are skipped.${
ref ? ` (listing: ${ref})` : ''
}`}
onOk={handlePublish}
okText='Publish'
okLoading={loading}
/>
)
}
PublishListing.propTypes = {
onOk: PropTypes.func.isRequired,
objectData: PropTypes.object
}
export default PublishListing