1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 01:34:57 +01:00

file api & toast fixes

This commit is contained in:
Matthias Kretschmann 2020-07-10 17:37:45 +02:00
parent 818a399a97
commit aa3244eedf
Signed by: m
GPG Key ID: 606EEEF3C479A91F
7 changed files with 46 additions and 17 deletions

View File

@ -1,16 +1,11 @@
import { File, MetaData, AdditionalInformation } from '@oceanprotocol/squid'
import { ServiceMetadata } from '@oceanprotocol/squid/dist/node/ddo/Service'
export interface Sample {
name: string
url: string
}
export declare type AccessType = 'Download' | 'Compute'
export interface AdditionalInformationMarket extends AdditionalInformation {
description: string
links?: Sample[] // redefine existing key, cause not specific enough in Squid
links?: File[] // redefine existing key, cause not specific enough in Squid
termsAndConditions: boolean
dateRange?: [string, string]
access: AccessType | string
@ -33,7 +28,7 @@ export interface MetaDataPublishForm {
// ---- optional fields ----
copyrightHolder?: string
tags?: string
links?: string
links?: string | File[]
}
export interface ServiceMetaDataMarket extends ServiceMetadata {

View File

@ -13,7 +13,7 @@ export default function FileInput({
handleButtonClick(e: React.SyntheticEvent, data: string): void
isLoading: boolean
}): ReactElement {
const [field] = useField(props)
const [field] = useField(props as any)
return (
<>

View File

@ -13,7 +13,7 @@ interface Values {
export default function FilesInput(
props: FormikProps<Values | File>
): ReactElement {
const [field, meta, helpers] = useField(props)
const [field, meta, helpers] = useField(props as any)
const [isLoading, setIsLoading] = useState(false)
async function handleButtonClick(e: React.SyntheticEvent, url: string) {

View File

@ -1,12 +1,19 @@
import React, { ReactElement, ReactNode } from 'react'
import { ToastContainer } from 'react-toastify'
import '@oceanprotocol/typographies/css/ocean-typo.css'
import '../global/styles.css'
import 'react-toastify/dist/ReactToastify.css'
export default function Styles({
children
}: {
children: ReactNode
}): ReactElement {
return <>{children}</>
return (
<>
{children}
<ToastContainer position="bottom-right" newestOnTop />
</>
)
}

30
src/global/_toast.css Normal file
View File

@ -0,0 +1,30 @@
div.Toastify__toast {
font-family: var(--font-family-base);
font-size: var(--font-size-small);
font-weight: var(--font-weight-bold);
border-radius: var(--border-radius);
box-shadow: 0 6px 15px 0 rgba(0, 0, 0, 0.05);
padding: calc(var(--spacer) / 2) var(--spacer);
background: var(--brand-white);
color: var(--brand-grey);
}
div.Toastify__toast--error {
background: var(--brand-alert-red);
color: var(--brand-white);
}
div.Toastify__toast--success {
background: var(--brand-alert-green);
color: var(--brand-white);
}
div.Toastify__toast--info {
background: var(--brand-white);
color: var(--brand-grey);
}
div.Toastify__toast--warning {
background: var(--brand-alert-yellow);
color: var(--brand-white);
}

View File

@ -133,3 +133,4 @@ fieldset {
}
@import '_code.css';
@import '_toast.css';

View File

@ -58,13 +58,9 @@ export async function getFileInfo(url: string): Promise<File> {
data: { url }
})
if (response.status > 299) {
throw new Error(response.statusText)
}
if (!response.data.result) {
toast.error(response.data.message)
return { contentLength: undefined, contentType: '', url }
if (response.status > 299 || !response.data.result) {
toast.error('Could not connect to File API')
return
}
const { contentLength, contentType } = response.data.result