1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

data structure change

This commit is contained in:
Matthias Kretschmann 2021-11-19 13:47:58 +00:00
parent d3810168aa
commit 713de2eb94
Signed by: m
GPG Key ID: 606EEEF3C479A91F
7 changed files with 24 additions and 16 deletions

View File

@ -10,7 +10,6 @@ export function renderStaticWaves(): string {
const svg = d3.create('svg') const svg = d3.create('svg')
const width = 1000 const width = 1000
const height = 250 const height = 250
console.log(height)
const x = d3.scaleLinear().range([0, width]) const x = d3.scaleLinear().range([0, width])
const angles = d3.range(Math.random(), 4 * Math.PI, Math.PI / 20) const angles = d3.range(Math.random(), 4 * Math.PI, Math.PI / 20)

View File

@ -21,21 +21,23 @@ export default function Actions({
function handleNext(e: FormEvent) { function handleNext(e: FormEvent) {
e.preventDefault() e.preventDefault()
setFieldValue('stepCurrent', values.stepCurrent + 1) setFieldValue('stepCurrent', values.user.stepCurrent + 1)
scrollToRef.current.scrollIntoView() scrollToRef.current.scrollIntoView()
} }
function handlePrevious(e: FormEvent) { function handlePrevious(e: FormEvent) {
e.preventDefault() e.preventDefault()
setFieldValue('stepCurrent', values.stepCurrent - 1) setFieldValue('stepCurrent', values.user.stepCurrent - 1)
scrollToRef.current.scrollIntoView() scrollToRef.current.scrollIntoView()
} }
return ( return (
<footer className={styles.actions}> <footer className={styles.actions}>
{values.stepCurrent > 1 && <Button onClick={handlePrevious}>Back</Button>} {values.user.stepCurrent > 1 && (
<Button onClick={handlePrevious}>Back</Button>
)}
{values.stepCurrent < wizardSteps.length ? ( {values.user.stepCurrent < wizardSteps.length ? (
<Button style="primary" onClick={handleNext}> <Button style="primary" onClick={handleNext}>
Continue Continue
</Button> </Button>

View File

@ -20,7 +20,9 @@ export default function Navigation(): ReactElement {
key={step.title} key={step.title}
onClick={() => handleStepClick(step.step)} onClick={() => handleStepClick(step.step)}
// TODO: add success class // TODO: add success class
className={values.stepCurrent === step.step ? styles.current : null} className={
values.user.stepCurrent === step.step ? styles.current : null
}
> >
{step.title} {step.title}
</li> </li>

View File

@ -11,12 +11,12 @@ export function Steps(): ReactElement {
useEffect(() => { useEffect(() => {
if (!chainId || !accountId) return if (!chainId || !accountId) return
setFieldValue('chainId', chainId) setFieldValue('user.chainId', chainId)
setFieldValue('accountId', accountId) setFieldValue('user.accountId', accountId)
}, [chainId, accountId, setFieldValue]) }, [chainId, accountId, setFieldValue])
const { component } = wizardSteps.filter( const { component } = wizardSteps.filter(
(stepContent) => stepContent.step === values.stepCurrent (stepContent) => stepContent.step === values.user.stepCurrent
)[0] )[0]
return component return component

View File

@ -32,9 +32,11 @@ export const wizardSteps: StepContent[] = [
] ]
export const initialValues: FormPublishData = { export const initialValues: FormPublishData = {
user: {
stepCurrent: 1, stepCurrent: 1,
chainId: 1, chainId: 1,
accountId: '', accountId: ''
},
metadata: { metadata: {
nft: { name: '', symbol: '', description: '', image: '' }, nft: { name: '', symbol: '', description: '', image: '' },
type: 'dataset', type: 'dataset',

View File

@ -12,9 +12,11 @@ export interface FormPublishService {
} }
export interface FormPublishData { export interface FormPublishData {
user: {
stepCurrent: number stepCurrent: number
accountId: string accountId: string
chainId: number chainId: number
}
metadata: { metadata: {
nft: NftOptions nft: NftOptions
type: 'Dataset' | 'Algorithm' | string type: 'Dataset' | 'Algorithm' | string

View File

@ -30,7 +30,8 @@ export async function transformPublishFormToDdo(
datatokenAddress: string, datatokenAddress: string,
nftAddress: string nftAddress: string
): Promise<DDO> { ): Promise<DDO> {
const { chainId, accountId, metadata, services } = values const { metadata, services } = values
const { chainId, accountId } = values.user
const did = sha256(`${nftAddress}${chainId}`) const did = sha256(`${nftAddress}${chainId}`)
const currentTime = dateToStringNoMS(new Date()) const currentTime = dateToStringNoMS(new Date())
const { const {