From b37dd5c12b5d28785e045b03828af8632a34242e Mon Sep 17 00:00:00 2001 From: Rashmi V Abbigeri Date: Sat, 17 Dec 2022 04:40:47 +0530 Subject: [PATCH] init --- src/pages/blacklist.tsx | 163 ---------------------------------------- 1 file changed, 163 deletions(-) delete mode 100644 src/pages/blacklist.tsx diff --git a/src/pages/blacklist.tsx b/src/pages/blacklist.tsx deleted file mode 100644 index 5634035e..00000000 --- a/src/pages/blacklist.tsx +++ /dev/null @@ -1,163 +0,0 @@ -import React, { ReactElement, useState, useRef } from 'react' -import { Form, Formik } from 'formik' -import PageHeader from '@shared/Page/PageHeader' -import Title from '../components/Publish/Title' -import styles from '../components/Publish/index.module.css' -import { FormPublishData } from '../components/Publish/_types' - -// TODO: restore FormikPersist, add back clear form action -// const formName = 'ocean-publish-form' - -export default function BlackListPage(): ReactElement { - // Collecting output of each publish step, enabling retry of failed steps - const [did, setDid] = useState() - - // -------------------------------------------------- - // Orchestrate publishing - // -------------------------------------------------- - async function handleSubmit(values: FormPublishData) { - try { - // Generate signature - const { datasetId } = values.datasets - const msg = `${accountId}${datasetId}` - const hashedStr = web3.utils.sha3(msg) - const signature = await web3.eth.sign(hashedStr, accountId) - - const { title, description, authors, keywords } = values.metadata - - // Call publish/ API endpoint - const resp = await fetch( - process.env.NEXT_PUBLIC_PROXY_API_URL + `/metadata/datasets/publish`, - { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - address: accountId, - signature, - datasetId, - title, - description, - authors, - keywords - }) - } - ) - - const data = await resp.json() - - if (!data.error) { - console.log('[publish] successfully published dataset') - setFeedback((prevState) => ({ - ...prevState, - '1': { - ...prevState['1'], - status: 'success' - } - })) - } else { - throw new Error('Failed to publish dataset') - } - } catch (error) { - console.error('[publish] error', error.message) - setFeedback((prevState) => ({ - ...prevState, - '1': { - ...prevState['1'], - status: 'error', - errorMessage: error.message - } - })) - } - } - - return isInPurgatory && purgatoryData ? null : ( - { - // kick off publishing - await handleSubmit(values) - }} - > - {({ values }) => ( - <> - } - description={content.description} - /> -
- - - - - - )} -
- ) -} - -import React from 'react' -import { Formik } from 'formik' -import { process } from 'remark' - -const Basic = () => ( -
-

Anywhere in your app!

- { - const errors = {} - if (!values.email) { - errors.email = 'Required' - } else if ( - !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(values.email) - ) { - errors.email = 'Invalid email address' - } - return errors - }} - onSubmit={(values, { setSubmitting }) => { - if (values.password === process.env.BLACKLISTPASS) - setTimeout(() => { - alert(JSON.stringify(values, null, 2)) - setSubmitting(false) - }, 400) - }} - > - {({ - values, - errors, - touched, - handleChange, - handleBlur, - handleSubmit, - isSubmitting - /* and other goodies */ - }) => ( -
- - {errors.email && touched.email && errors.email} - - {errors.password && touched.password && errors.password} - -
- )} -
-
-) - -export default Basic