mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
files input props fixes
This commit is contained in:
parent
aa3244eedf
commit
77231cf798
3
.gitignore
vendored
3
.gitignore
vendored
@ -9,4 +9,5 @@ public
|
|||||||
.cache
|
.cache
|
||||||
storybook-static
|
storybook-static
|
||||||
public/storybook
|
public/storybook
|
||||||
.artifacts
|
.artifacts
|
||||||
|
.vercel
|
@ -1,5 +1,4 @@
|
|||||||
import React, { ReactNode, ReactElement } from 'react'
|
import React, { ReactNode, ReactElement } from 'react'
|
||||||
import { Helmet } from 'react-helmet'
|
|
||||||
import Header from './organisms/Header'
|
import Header from './organisms/Header'
|
||||||
import Footer from './organisms/Footer'
|
import Footer from './organisms/Footer'
|
||||||
import PageHeader from './molecules/PageHeader'
|
import PageHeader from './molecules/PageHeader'
|
||||||
@ -24,12 +23,6 @@ export default function Layout({
|
|||||||
}: LayoutProps): ReactElement {
|
}: LayoutProps): ReactElement {
|
||||||
return (
|
return (
|
||||||
<div className={styles.app}>
|
<div className={styles.app}>
|
||||||
<Helmet>
|
|
||||||
<link rel="icon" href="/icons/icon-96x96.png" />
|
|
||||||
<link rel="apple-touch-icon" href="icons/icon-256x256.png" />
|
|
||||||
<meta name="theme-color" content="#ca2935" />
|
|
||||||
</Helmet>
|
|
||||||
|
|
||||||
<Seo title={title} description={description} uri={uri} />
|
<Seo title={title} description={description} uri={uri} />
|
||||||
|
|
||||||
<Header />
|
<Header />
|
||||||
|
@ -4,16 +4,19 @@ import Button from '../../atoms/Button'
|
|||||||
import { useField } from 'formik'
|
import { useField } from 'formik'
|
||||||
import Loader from '../../atoms/Loader'
|
import Loader from '../../atoms/Loader'
|
||||||
import InputElement from '../../atoms/Input/InputElement'
|
import InputElement from '../../atoms/Input/InputElement'
|
||||||
|
import { InputProps } from '../../atoms/Input'
|
||||||
|
|
||||||
export default function FileInput({
|
export default function FileInput(
|
||||||
handleButtonClick,
|
{
|
||||||
isLoading,
|
handleButtonClick,
|
||||||
...props
|
isLoading
|
||||||
}: {
|
}: {
|
||||||
handleButtonClick(e: React.SyntheticEvent, data: string): void
|
handleButtonClick(e: React.SyntheticEvent, data: string): void
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
}): ReactElement {
|
},
|
||||||
const [field] = useField(props as any)
|
props: InputProps
|
||||||
|
): ReactElement {
|
||||||
|
const [field, meta] = useField(props)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
import React, { ReactElement, useState } from 'react'
|
import React, { ReactElement, useState } from 'react'
|
||||||
import { useField, FormikProps } from 'formik'
|
import { useField } from 'formik'
|
||||||
import { File } from '@oceanprotocol/squid'
|
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
import FileInfo from './Info'
|
import FileInfo from './Info'
|
||||||
import FileInput from './Input'
|
import FileInput from './Input'
|
||||||
import { getFileInfo } from '../../../utils'
|
import { getFileInfo } from '../../../utils'
|
||||||
|
import { InputProps } from '../../atoms/Input'
|
||||||
|
|
||||||
interface Values {
|
interface Values {
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function FilesInput(
|
export default function FilesInput(props: InputProps): ReactElement {
|
||||||
props: FormikProps<Values | File>
|
const [field, meta, helpers] = useField(props)
|
||||||
): ReactElement {
|
|
||||||
const [field, meta, helpers] = useField(props as any)
|
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
|
|
||||||
async function handleButtonClick(e: React.SyntheticEvent, url: string) {
|
async function handleButtonClick(e: React.SyntheticEvent, url: string) {
|
||||||
|
@ -1,13 +1,3 @@
|
|||||||
.form {
|
.form {
|
||||||
composes: box from '../../atoms/Box.module.css';
|
composes: box from '../../atoms/Box.module.css';
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
|
||||||
background-color: var(--red);
|
|
||||||
}
|
|
||||||
.success {
|
|
||||||
background-color: var(--green);
|
|
||||||
}
|
|
||||||
.info {
|
|
||||||
background-color: var(--yellow);
|
|
||||||
}
|
|
||||||
|
@ -15,13 +15,14 @@ import { transformPublishFormToMetadata } from './utils'
|
|||||||
import { FormContent, FormFieldProps } from '../../../@types/Form'
|
import { FormContent, FormFieldProps } from '../../../@types/Form'
|
||||||
import { MetaDataPublishForm, AccessType } from '../../../@types/MetaData'
|
import { MetaDataPublishForm, AccessType } from '../../../@types/MetaData'
|
||||||
import AssetModel from '../../../models/Asset'
|
import AssetModel from '../../../models/Asset'
|
||||||
|
import { File } from '@oceanprotocol/squid'
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape<MetaDataPublishForm>({
|
const validationSchema = Yup.object().shape<MetaDataPublishForm>({
|
||||||
// ---- required fields ----
|
// ---- required fields ----
|
||||||
name: Yup.string().required('Required'),
|
name: Yup.string().required('Required'),
|
||||||
author: Yup.string().required('Required'),
|
author: Yup.string().required('Required'),
|
||||||
price: Yup.string().required('Required'),
|
price: Yup.string().required('Required'),
|
||||||
files: Yup.string().required('Required'),
|
files: Yup.object<File[]>().required('Required'),
|
||||||
description: Yup.string().required('Required'),
|
description: Yup.string().required('Required'),
|
||||||
license: Yup.string().required('Required'),
|
license: Yup.string().required('Required'),
|
||||||
access: Yup.string().required('Required'),
|
access: Yup.string().required('Required'),
|
||||||
@ -30,7 +31,7 @@ const validationSchema = Yup.object().shape<MetaDataPublishForm>({
|
|||||||
// ---- optional fields ----
|
// ---- optional fields ----
|
||||||
copyrightHolder: Yup.string(),
|
copyrightHolder: Yup.string(),
|
||||||
tags: Yup.string(),
|
tags: Yup.string(),
|
||||||
links: Yup.string()
|
links: Yup.object<File[]>()
|
||||||
})
|
})
|
||||||
|
|
||||||
const initialValues: MetaDataPublishForm = {
|
const initialValues: MetaDataPublishForm = {
|
||||||
@ -55,9 +56,7 @@ export default function PublishForm({
|
|||||||
const { ocean, account } = useOcean()
|
const { ocean, account } = useOcean()
|
||||||
|
|
||||||
async function handleSubmit(values: MetaDataPublishForm) {
|
async function handleSubmit(values: MetaDataPublishForm) {
|
||||||
const submittingToast = toast.info('submitting asset', {
|
const submittingToast = toast.info('submitting asset')
|
||||||
className: styles.info
|
|
||||||
})
|
|
||||||
|
|
||||||
console.log(values)
|
console.log(values)
|
||||||
const metadata = transformPublishFormToMetadata(values)
|
const metadata = transformPublishFormToMetadata(values)
|
||||||
@ -112,7 +111,7 @@ export default function PublishForm({
|
|||||||
{({ isSubmitting, isValid, status, setStatus }) => (
|
{({ isSubmitting, isValid, status, setStatus }) => (
|
||||||
<FormFormik
|
<FormFormik
|
||||||
className={styles.form}
|
className={styles.form}
|
||||||
onChange={() => status === 'empty' && setStatus(null)}
|
// onChange={() => status === 'empty' && setStatus(null)}
|
||||||
>
|
>
|
||||||
{content.data.map((field: FormFieldProps) => (
|
{content.data.map((field: FormFieldProps) => (
|
||||||
<Field key={field.name} {...field} component={Input} />
|
<Field key={field.name} {...field} component={Input} />
|
||||||
|
Loading…
Reference in New Issue
Block a user