mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
typing fixes
This commit is contained in:
parent
d7ff2694f7
commit
b09c1dbc27
@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { ReactNode, ReactElement } from 'react'
|
||||||
import styles from './BaseDialog.module.css'
|
import styles from './BaseDialog.module.css'
|
||||||
import { Modal } from 'react-responsive-modal'
|
import { Modal } from 'react-responsive-modal'
|
||||||
|
|
||||||
@ -14,10 +14,10 @@ export default function BaseDialog({
|
|||||||
open: boolean
|
open: boolean
|
||||||
title: string
|
title: string
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
children: React.ReactNode
|
children: ReactNode
|
||||||
disableClose?: boolean
|
disableClose?: boolean
|
||||||
actions?: any
|
actions?: any
|
||||||
}) {
|
}): ReactElement {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
open={open}
|
open={open}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useCallback } from 'react'
|
import React, { ReactElement, useCallback } from 'react'
|
||||||
import { useDropzone } from 'react-dropzone'
|
import { useDropzone } from 'react-dropzone'
|
||||||
import styles from './Dropzone.module.css'
|
import styles from './Dropzone.module.css'
|
||||||
import { formatBytes } from '../../utils'
|
import { formatBytes } from '../../utils'
|
||||||
@ -13,7 +13,7 @@ export default function Dropzone({
|
|||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
multiple?: boolean
|
multiple?: boolean
|
||||||
error?: string
|
error?: string
|
||||||
}) {
|
}): ReactElement {
|
||||||
const onDrop = useCallback((acceptedFiles) => handleOnDrop(acceptedFiles), [
|
const onDrop = useCallback((acceptedFiles) => handleOnDrop(acceptedFiles), [
|
||||||
handleOnDrop
|
handleOnDrop
|
||||||
])
|
])
|
||||||
|
@ -64,7 +64,7 @@ class PersistImpl extends React.Component<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render(): any {
|
render(): null {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React, { ReactElement, ReactNode } from 'react'
|
||||||
import styles from './Row.module.css'
|
import styles from './Row.module.css'
|
||||||
|
|
||||||
const Row = ({ children }: { children: any }) => (
|
const Row = ({ children }: { children: ReactNode }): ReactElement => (
|
||||||
<div className={styles.row}>{children}</div>
|
<div className={styles.row}>{children}</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
import React from 'react'
|
import React, { ReactElement, ReactNode } from 'react'
|
||||||
import styles from './Lists.module.css'
|
import styles from './Lists.module.css'
|
||||||
|
|
||||||
export function ListItem({ children, ol }: { children: any; ol?: boolean }) {
|
export function ListItem({
|
||||||
|
children,
|
||||||
|
ol
|
||||||
|
}: {
|
||||||
|
children: ReactNode
|
||||||
|
ol?: boolean
|
||||||
|
}): ReactElement {
|
||||||
const classes = ol
|
const classes = ol
|
||||||
? `${styles.item} ${styles.olItem}`
|
? `${styles.item} ${styles.olItem}`
|
||||||
: `${styles.item} ${styles.ulItem}`
|
: `${styles.item} ${styles.ulItem}`
|
||||||
|
@ -22,7 +22,7 @@ export default function Table({
|
|||||||
columns: any
|
columns: any
|
||||||
data: any
|
data: any
|
||||||
pagination?: AssetTablePagination
|
pagination?: AssetTablePagination
|
||||||
}) {
|
}): ReactElement {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{data?.length ? (
|
{data?.length ? (
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import { format, formatDistance } from 'date-fns'
|
import { format, formatDistance } from 'date-fns'
|
||||||
|
|
||||||
export default function Time({
|
export default function Time({
|
||||||
@ -7,7 +7,7 @@ export default function Time({
|
|||||||
}: {
|
}: {
|
||||||
date: string
|
date: string
|
||||||
relative?: boolean
|
relative?: boolean
|
||||||
}) {
|
}): ReactElement {
|
||||||
const dateNew = new Date(date)
|
const dateNew = new Date(date)
|
||||||
const dateIso = dateNew.toISOString()
|
const dateIso = dateNew.toISOString()
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ export default function Tooltip({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function onHide({ unmount }: { unmount: any }) {
|
function onHide({ unmount }: { unmount: () => void }) {
|
||||||
setSpring({
|
setSpring({
|
||||||
...animation.from,
|
...animation.from,
|
||||||
onRest: unmount,
|
onRest: unmount,
|
||||||
|
@ -58,7 +58,7 @@ export default function Dynamic({
|
|||||||
return () => {
|
return () => {
|
||||||
clearInterval(balanceInterval)
|
clearInterval(balanceInterval)
|
||||||
}
|
}
|
||||||
}, [ocean, chainId, account])
|
}, [ocean, chainId, account, refreshBalance])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.dynamic}>
|
<div className={styles.dynamic}>
|
||||||
|
@ -8,13 +8,11 @@ import InputGroup from '../atoms/Input/InputGroup'
|
|||||||
export default function SearchBar({
|
export default function SearchBar({
|
||||||
placeholder,
|
placeholder,
|
||||||
initialValue,
|
initialValue,
|
||||||
filters,
|
filters
|
||||||
large
|
|
||||||
}: {
|
}: {
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
initialValue?: string
|
initialValue?: string
|
||||||
filters?: boolean
|
filters?: boolean
|
||||||
large?: true
|
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [value, setValue] = useState(initialValue || '')
|
const [value, setValue] = useState(initialValue || '')
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, ReactElement } from 'react'
|
import React, { useState, ReactElement, ChangeEvent } from 'react'
|
||||||
import { DDO } from '@oceanprotocol/lib'
|
import { DDO } from '@oceanprotocol/lib'
|
||||||
import Loader from '../../atoms/Loader'
|
import Loader from '../../atoms/Loader'
|
||||||
import Web3Feedback from '../../molecules/Wallet/Feedback'
|
import Web3Feedback from '../../molecules/Wallet/Feedback'
|
||||||
@ -45,13 +45,13 @@ export default function Compute({
|
|||||||
!ocean ||
|
!ocean ||
|
||||||
!isBalanceSufficient
|
!isBalanceSufficient
|
||||||
|
|
||||||
const onDrop = async (files: any) => {
|
const onDrop = async (files: File[]) => {
|
||||||
setFile(files[0])
|
setFile(files[0])
|
||||||
const fileText = await readFileContent(files[0])
|
const fileText = await readFileContent(files[0])
|
||||||
setAlgorithmRawCode(fileText)
|
setAlgorithmRawCode(fileText)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSelectChange = (event: any) => {
|
const handleSelectChange = (event: ChangeEvent<HTMLSelectElement>) => {
|
||||||
const comType = event.target.value
|
const comType = event.target.value
|
||||||
setComputeType(comType)
|
setComputeType(comType)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { ReactElement, useState, ChangeEvent, useEffect } from 'react'
|
import React, { ReactElement, useState, ChangeEvent } from 'react'
|
||||||
import styles from './Add.module.css'
|
import styles from './Add.module.css'
|
||||||
import { useOcean } from '@oceanprotocol/react'
|
import { useOcean } from '@oceanprotocol/react'
|
||||||
import Header from './Header'
|
import Header from './Header'
|
||||||
|
@ -118,7 +118,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
init()
|
init()
|
||||||
}, [ocean, accountId, price])
|
}, [ocean, accountId, price, ddo.dataToken])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -32,7 +32,7 @@ export default function MetaFull({
|
|||||||
setDtSymbol(symbol)
|
setDtSymbol(symbol)
|
||||||
}
|
}
|
||||||
getDataTokenInfo()
|
getDataTokenInfo()
|
||||||
}, [ocean])
|
}, [ocean, accountId, dataToken])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.metaFull}>
|
<div className={styles.metaFull}>
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import React from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import styles from './Footer.module.css'
|
import styles from './Footer.module.css'
|
||||||
import Markdown from '../atoms/Markdown'
|
import Markdown from '../atoms/Markdown'
|
||||||
import { useSiteMetadata } from '../../hooks/useSiteMetadata'
|
import { useSiteMetadata } from '../../hooks/useSiteMetadata'
|
||||||
|
|
||||||
export default function Footer() {
|
export default function Footer(): ReactElement {
|
||||||
const { copyright } = useSiteMetadata()
|
const { copyright } = useSiteMetadata()
|
||||||
const year = new Date().getFullYear()
|
const year = new Date().getFullYear()
|
||||||
|
|
||||||
|
@ -38,12 +38,12 @@ export default function HomePage(): ReactElement {
|
|||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
init()
|
init()
|
||||||
}, [])
|
}, [config.metadataStoreUri])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Container narrow className={styles.searchWrap}>
|
<Container narrow className={styles.searchWrap}>
|
||||||
<SearchBar large />
|
<SearchBar />
|
||||||
</Container>
|
</Container>
|
||||||
|
|
||||||
<section className={styles.latest}>
|
<section className={styles.latest}>
|
||||||
|
@ -28,19 +28,18 @@ export default function PublishForm({
|
|||||||
initialValues
|
initialValues
|
||||||
} = useFormikContext()
|
} = useFormikContext()
|
||||||
const formName = 'ocean-publish-form'
|
const formName = 'ocean-publish-form'
|
||||||
|
|
||||||
// reset form validation on every mount
|
// reset form validation on every mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setErrors({})
|
setErrors({})
|
||||||
setTouched({})
|
setTouched({})
|
||||||
|
|
||||||
// setSubmitting(false)
|
// setSubmitting(false)
|
||||||
}, [])
|
}, [setErrors, setTouched])
|
||||||
|
|
||||||
const resetFormAndClearStorage = async (e: FormEvent<Element>) => {
|
const resetFormAndClearStorage = (e: FormEvent<Element>) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
resetForm({ values: initialValues, status: 'empty' })
|
||||||
await resetForm({ values: initialValues, status: 'empty' })
|
|
||||||
|
|
||||||
setStatus('empty')
|
setStatus('empty')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ import { FormContent } from '../../../@types/Form'
|
|||||||
import { initialValues, validationSchema } from '../../../models/FormPublish'
|
import { initialValues, validationSchema } from '../../../models/FormPublish'
|
||||||
import { transformPublishFormToMetadata } from './utils'
|
import { transformPublishFormToMetadata } from './utils'
|
||||||
import Preview from './Preview'
|
import Preview from './Preview'
|
||||||
import { MetadataPublishForm } from '../../../@types/MetaData'
|
import { MetadataMarket, MetadataPublishForm } from '../../../@types/MetaData'
|
||||||
import { useUserPreferences } from '../../../providers/UserPreferences'
|
import { useUserPreferences } from '../../../providers/UserPreferences'
|
||||||
import { Logger } from '@oceanprotocol/lib'
|
import { Logger, Metadata } from '@oceanprotocol/lib'
|
||||||
|
|
||||||
export default function PublishPage({
|
export default function PublishPage({
|
||||||
content
|
content
|
||||||
@ -35,7 +35,7 @@ export default function PublishPage({
|
|||||||
Logger.log('Publish with ', price, serviceType, price.datatoken)
|
Logger.log('Publish with ', price, serviceType, price.datatoken)
|
||||||
|
|
||||||
const ddo = await publish(
|
const ddo = await publish(
|
||||||
metadata as any,
|
(metadata as unknown) as Metadata,
|
||||||
{
|
{
|
||||||
...price,
|
...price,
|
||||||
liquidityProviderFee: `${price.liquidityProviderFee}`
|
liquidityProviderFee: `${price.liquidityProviderFee}`
|
||||||
|
@ -34,7 +34,7 @@ export default function SearchPage({
|
|||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
initSearch()
|
initSearch()
|
||||||
}, [text, tag, page])
|
}, [text, tag, page, config.metadataStoreUri, parsed])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className={styles.grid}>
|
<section className={styles.grid}>
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
import React, { useEffect } from 'react'
|
import React, { ReactElement, useEffect } from 'react'
|
||||||
import { useOcean } from '@oceanprotocol/react'
|
import { useOcean } from '@oceanprotocol/react'
|
||||||
import { getOceanConfig } from './wrapRootElement'
|
import { getOceanConfig } from './wrapRootElement'
|
||||||
|
|
||||||
export function NetworkMonitor() {
|
export function NetworkMonitor(): ReactElement {
|
||||||
const { connect, web3Provider } = useOcean()
|
const { connect, web3Provider } = useOcean()
|
||||||
|
|
||||||
const handleNetworkChanged = (chainId: number) => {
|
|
||||||
const config = getOceanConfig(chainId)
|
|
||||||
connect(config)
|
|
||||||
}
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!web3Provider) return
|
if (!web3Provider) return
|
||||||
|
|
||||||
|
async function handleNetworkChanged(chainId: number) {
|
||||||
|
const config = getOceanConfig(chainId)
|
||||||
|
await connect(config)
|
||||||
|
}
|
||||||
|
|
||||||
web3Provider.on('chainChanged', handleNetworkChanged)
|
web3Provider.on('chainChanged', handleNetworkChanged)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
web3Provider.removeListener('chainChanged', handleNetworkChanged)
|
web3Provider.removeListener('chainChanged', handleNetworkChanged)
|
||||||
}
|
}
|
||||||
}, [web3Provider])
|
}, [web3Provider, connect])
|
||||||
|
|
||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const cleanupContentType = (contentType: string) => {
|
const cleanupContentType = (contentType: string): string => {
|
||||||
// strip away the 'application/' part
|
// strip away the 'application/' part
|
||||||
const contentTypeSplit = contentType.split('/')[1]
|
const contentTypeSplit = contentType.split('/')[1]
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export async function getFileInfo(url: string): Promise<FileMetadata> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchData(url: string): Promise<any> {
|
export async function fetchData(url: string): Promise<AxiosResponse['data']> {
|
||||||
try {
|
try {
|
||||||
const response = await axios(url)
|
const response = await axios(url)
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ export function setProperty<T extends Record<string, unknown>>(
|
|||||||
objectToBeUpdated: T,
|
objectToBeUpdated: T,
|
||||||
propertyName: keyof T,
|
propertyName: keyof T,
|
||||||
value?: T[keyof T]
|
value?: T[keyof T]
|
||||||
) {
|
): void {
|
||||||
if (value) {
|
if (value) {
|
||||||
objectToBeUpdated[propertyName] = value
|
objectToBeUpdated[propertyName] = value
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user