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:
parent
818a399a97
commit
aa3244eedf
9
src/@types/MetaData.d.ts
vendored
9
src/@types/MetaData.d.ts
vendored
@ -1,16 +1,11 @@
|
|||||||
import { File, MetaData, AdditionalInformation } from '@oceanprotocol/squid'
|
import { File, MetaData, AdditionalInformation } from '@oceanprotocol/squid'
|
||||||
import { ServiceMetadata } from '@oceanprotocol/squid/dist/node/ddo/Service'
|
import { ServiceMetadata } from '@oceanprotocol/squid/dist/node/ddo/Service'
|
||||||
|
|
||||||
export interface Sample {
|
|
||||||
name: string
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export declare type AccessType = 'Download' | 'Compute'
|
export declare type AccessType = 'Download' | 'Compute'
|
||||||
|
|
||||||
export interface AdditionalInformationMarket extends AdditionalInformation {
|
export interface AdditionalInformationMarket extends AdditionalInformation {
|
||||||
description: string
|
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
|
termsAndConditions: boolean
|
||||||
dateRange?: [string, string]
|
dateRange?: [string, string]
|
||||||
access: AccessType | string
|
access: AccessType | string
|
||||||
@ -33,7 +28,7 @@ export interface MetaDataPublishForm {
|
|||||||
// ---- optional fields ----
|
// ---- optional fields ----
|
||||||
copyrightHolder?: string
|
copyrightHolder?: string
|
||||||
tags?: string
|
tags?: string
|
||||||
links?: string
|
links?: string | File[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServiceMetaDataMarket extends ServiceMetadata {
|
export interface ServiceMetaDataMarket extends ServiceMetadata {
|
||||||
|
@ -13,7 +13,7 @@ export default function FileInput({
|
|||||||
handleButtonClick(e: React.SyntheticEvent, data: string): void
|
handleButtonClick(e: React.SyntheticEvent, data: string): void
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const [field] = useField(props)
|
const [field] = useField(props as any)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -13,7 +13,7 @@ interface Values {
|
|||||||
export default function FilesInput(
|
export default function FilesInput(
|
||||||
props: FormikProps<Values | File>
|
props: FormikProps<Values | File>
|
||||||
): ReactElement {
|
): ReactElement {
|
||||||
const [field, meta, helpers] = useField(props)
|
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,12 +1,19 @@
|
|||||||
import React, { ReactElement, ReactNode } from 'react'
|
import React, { ReactElement, ReactNode } from 'react'
|
||||||
|
import { ToastContainer } from 'react-toastify'
|
||||||
|
|
||||||
import '@oceanprotocol/typographies/css/ocean-typo.css'
|
import '@oceanprotocol/typographies/css/ocean-typo.css'
|
||||||
import '../global/styles.css'
|
import '../global/styles.css'
|
||||||
|
import 'react-toastify/dist/ReactToastify.css'
|
||||||
|
|
||||||
export default function Styles({
|
export default function Styles({
|
||||||
children
|
children
|
||||||
}: {
|
}: {
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
return <>{children}</>
|
return (
|
||||||
|
<>
|
||||||
|
{children}
|
||||||
|
<ToastContainer position="bottom-right" newestOnTop />
|
||||||
|
</>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
30
src/global/_toast.css
Normal file
30
src/global/_toast.css
Normal 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);
|
||||||
|
}
|
@ -133,3 +133,4 @@ fieldset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@import '_code.css';
|
@import '_code.css';
|
||||||
|
@import '_toast.css';
|
||||||
|
@ -58,13 +58,9 @@ export async function getFileInfo(url: string): Promise<File> {
|
|||||||
data: { url }
|
data: { url }
|
||||||
})
|
})
|
||||||
|
|
||||||
if (response.status > 299) {
|
if (response.status > 299 || !response.data.result) {
|
||||||
throw new Error(response.statusText)
|
toast.error('Could not connect to File API')
|
||||||
}
|
return
|
||||||
|
|
||||||
if (!response.data.result) {
|
|
||||||
toast.error(response.data.message)
|
|
||||||
return { contentLength: undefined, contentType: '', url }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { contentLength, contentType } = response.data.result
|
const { contentLength, contentType } = response.data.result
|
||||||
|
Loading…
Reference in New Issue
Block a user