1
0
mirror of https://github.com/dap-ps/discover.git synced 2025-01-31 11:35:18 +00:00

Fixes Edit metadata issues, adds email verification

This commit is contained in:
andytudhope 2019-08-10 21:57:22 +02:00 committed by Andy Tudhope
parent 0368c0f106
commit b66dbcdef9
4 changed files with 39 additions and 20 deletions

View File

@ -265,7 +265,7 @@ class DiscoverService extends BlockchainService {
}
}
async setMetadata(id, metadata) {
async setMetadata(id, metadata, email) {
const ConnectedDiscoverContract = await super.__unlockServiceAccount(
DiscoverContract,
)
@ -274,7 +274,7 @@ class DiscoverService extends BlockchainService {
const dappMetadata = JSON.parse(JSON.stringify(metadata))
dappMetadata.uploader = this.sharedContext.account
const uploadedMetadata = await MetadataClient.upload(dappMetadata)
const uploadedMetadata = await MetadataClient.upload(dappMetadata, email)
try {
const tx = await broadcastContractFn(
@ -283,6 +283,7 @@ class DiscoverService extends BlockchainService {
this.sharedContext.account,
)
// TODO: This results in endless "Waiting for confirmation... errors, though the tx is successful"
await MetadataClient.update(id, tx)
return tx

View File

@ -0,0 +1,4 @@
// eslint-disable-next-line import/prefer-default-export
export const emailValidation = email => {
return new RegExp(/[\w-]+@([\w-]+\.)+[\w-]+/gm).test(email)
}

View File

@ -15,6 +15,7 @@ import 'rc-slider/assets/index.css'
import 'rc-tooltip/assets/bootstrap.css'
import { DappState } from '../../common/data/dapp'
import validator from 'validator'
import { emailValidation } from '../../common/utils/email-utils'
const getCategoryName = category =>
Categories.find(x => x.key === category).value
@ -224,13 +225,12 @@ class Submit extends React.Component {
visible_submit,
visible_rating,
onClickClose,
email,
id,
name,
desc,
url,
img,
category,
email,
imgControl,
imgControlZoom,
onImgCancel,
@ -239,7 +239,12 @@ class Submit extends React.Component {
} = this.props
const canSubmit =
name !== '' && desc !== '' && url !== '' && img !== '' && category !== ''
name !== '' &&
desc !== '' &&
url !== '' &&
img !== '' &&
category !== '' &&
emailValidation(email)
const visible = visible_submit || visible_rating
@ -277,19 +282,6 @@ class Submit extends React.Component {
{visible_submit && (
<div className={imgControl ? styles.cntWithImgControl : ''}>
<div className={imgControl ? styles.withImgControl : ''}>
{id === '' && (
<div className={styles.block}>
<div className={styles.labelRow}>
<span>Your email</span>
</div>
<input
className={styles.input}
placeholder="email"
value={email}
onChange={this.onInputEmail}
/>
</div>
)}
<div className={styles.block}>
<div className={styles.labelRow}>
<span>Name of your Ðapp</span>
@ -358,6 +350,17 @@ class Submit extends React.Component {
}`}
/>
</div>
<div className={styles.block}>
<div className={styles.labelRow}>
<span>Your email</span>
</div>
<input
className={styles.input}
placeholder="email"
value={email}
onChange={this.onInputEmail}
/>
</div>
<div className={`${styles.block} ${styles.blockSubmit}`}>
<div className={styles.terms}>
By continuing you agree to our

View File

@ -175,7 +175,7 @@ export const submitAction = (dapp, sntValue) => {
}
}
export const updateAction = (dappId, metadata) => {
export const updateAction = (dappId, metadata, email) => {
return async dispatch => {
dispatch(closeSubmitAction())
dispatch(
@ -188,7 +188,18 @@ export const updateAction = (dappId, metadata) => {
)
try {
const blockchain = await BlockchainSDK.getInstance()
const tx = await blockchain.DiscoverService.setMetadata(dappId, metadata)
const tx = await blockchain.DiscoverService.setMetadata(
dappId,
{
name: metadata.name,
url: metadata.url,
description: metadata.description,
category: metadata.category,
image: metadata.image,
dateAdded: metadata.dateAdded,
},
metadata.email,
)
dispatch(onReceiveTransactionInfoAction(dappId, tx))
dispatch(checkTransactionStatusAction(tx))
} catch (e) {