1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00
Jamie Hewitt a545f723e9
Add custom provider to publish form (#707)
* Creating custom provider box selection

* adding provider to Form publish validation schema

* validating custom provider URL

* WIP validation for custom provider

* validating provider uri

* adding success/ error messages

* conditional rendering of custom provider input

* remove console.log

* fixing textFormData

* Publishing custom provider URI in DDO

* Adding serviceEndpoint to Debug

* removing pre-checked default provider

* Refactoring to reduce code duplication

* removing console.log messages

* update submit text

* update submit text

* Placing custom provider field behind Advanced Settings

* removing provider field

* updating placeholder provider

* style for advanced setting button

* refactoring customProvider

* remocing template literal

* fixing linting errors

* restricting advanced publishing settings through env var

* updating example env

* adding custom provider to formAlgoPublish

* refactoring to reduce duplication

* Reducing duplication

* updating types and initial values

* Removing Custom provider input from main algorithm form

* Removing concole.log

* Chaning customProvider to providerUri

* changing customProvider to providerUri

* advanceSettings to PascalCase

* Removing unused useOcean()

* Using useSiteMetadata() hook

* Adding allowAdvancedPublishSettings to query

* Adding temporary console.log(ocean)

* Removing console.log
2021-08-20 15:49:15 +03:00

40 lines
1022 B
TypeScript

import React, { ReactElement } from 'react'
import Button from '../../../atoms/Button'
import { FieldInputProps, useField } from 'formik'
import Loader from '../../../atoms/Loader'
import styles from './Input.module.css'
import InputGroup from '../../../atoms/Input/InputGroup'
export default function URLInput({
submitText,
handleButtonClick,
isLoading,
...props
}: {
submitText: string
handleButtonClick(e: React.SyntheticEvent, data: string): void
isLoading: boolean
}): ReactElement {
const [field, meta] = useField(props as FieldInputProps<any>)
return (
<InputGroup>
<input
className={styles.input}
{...props}
type="url"
onBlur={(e: React.SyntheticEvent) => handleButtonClick(e, field.value)}
/>
<Button
style="primary"
size="small"
onClick={(e: React.SyntheticEvent) => e.preventDefault()}
disabled={!field.value}
>
{isLoading ? <Loader /> : submitText}
</Button>
</InputGroup>
)
}