122 lines
3.4 KiB
JavaScript

import PropTypes from 'prop-types'
import ObjectInfo from '../../common/ObjectInfo'
import NewObjectForm from '../../common/NewObjectForm'
import WizardView from '../../common/WizardView'
import { getMarketplaceCallbackUrl } from './authUtils'
const NewMarketplace = ({ onOk, defaultValues }) => {
const callbackUrl = getMarketplaceCallbackUrl()
return (
<NewObjectForm
type={'marketplace'}
defaultValues={{
active: true,
config: {
redirectUri: callbackUrl
},
...defaultValues
}}
>
{({ handleSubmit, submitLoading, objectData, formValid }) => {
const steps = [
{
title: 'Required',
key: 'required',
content: (
<ObjectInfo
type='marketplace'
column={1}
bordered={false}
isEditing={true}
required={true}
objectData={objectData}
/>
)
},
{
title: 'API Configuration',
key: 'config',
content: (
<ObjectInfo
type='marketplace'
column={1}
bordered={false}
isEditing={true}
required={false}
objectData={objectData}
visibleProperties={{
_id: false,
_reference: false,
createdAt: false,
updatedAt: false,
name: false,
provider: false,
active: false
}}
/>
)
},
{
title: 'Summary',
key: 'summary',
content: (
<ObjectInfo
type='marketplace'
column={1}
bordered={false}
visibleProperties={{
_id: false,
createdAt: false,
updatedAt: false,
authConnected: false,
'config.clientId': false,
'config.clientSecret': false,
'config.ruName': false,
'config.marketplaceId': false,
'config.sandbox': false,
'config.verificationToken': false,
'config.redirectUri': false,
'config.accessToken': false,
'config.refreshToken': false,
'config.refreshTokenExpiresAt': false,
'config.accessTokenExpiresAt': false,
'config.lastTokenRefreshAt': false,
connectedAt: false,
'config.appKey': false,
'config.appSecret': false,
'config.shopCipher': false
}}
isEditing={false}
objectData={objectData}
/>
)
}
]
return (
<WizardView
steps={steps}
loading={submitLoading}
formValid={formValid}
title='New Marketplace'
onSubmit={async () => {
const result = await handleSubmit()
if (result) {
onOk()
}
}}
/>
)
}}
</NewObjectForm>
)
}
NewMarketplace.propTypes = {
onOk: PropTypes.func.isRequired,
reset: PropTypes.bool,
defaultValues: PropTypes.object
}
export default NewMarketplace