mirror of
https://github.com/dap-ps/discover.git
synced 2025-02-07 15:05:07 +00:00
Fixes Edit metadata issues, adds email verification
This commit is contained in:
parent
0368c0f106
commit
b66dbcdef9
@ -265,7 +265,7 @@ class DiscoverService extends BlockchainService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMetadata(id, metadata) {
|
async setMetadata(id, metadata, email) {
|
||||||
const ConnectedDiscoverContract = await super.__unlockServiceAccount(
|
const ConnectedDiscoverContract = await super.__unlockServiceAccount(
|
||||||
DiscoverContract,
|
DiscoverContract,
|
||||||
)
|
)
|
||||||
@ -274,7 +274,7 @@ class DiscoverService extends BlockchainService {
|
|||||||
const dappMetadata = JSON.parse(JSON.stringify(metadata))
|
const dappMetadata = JSON.parse(JSON.stringify(metadata))
|
||||||
dappMetadata.uploader = this.sharedContext.account
|
dappMetadata.uploader = this.sharedContext.account
|
||||||
|
|
||||||
const uploadedMetadata = await MetadataClient.upload(dappMetadata)
|
const uploadedMetadata = await MetadataClient.upload(dappMetadata, email)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const tx = await broadcastContractFn(
|
const tx = await broadcastContractFn(
|
||||||
@ -283,6 +283,7 @@ class DiscoverService extends BlockchainService {
|
|||||||
this.sharedContext.account,
|
this.sharedContext.account,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: This results in endless "Waiting for confirmation... errors, though the tx is successful"
|
||||||
await MetadataClient.update(id, tx)
|
await MetadataClient.update(id, tx)
|
||||||
|
|
||||||
return tx
|
return tx
|
||||||
|
4
src/common/utils/email-utils.js
Normal file
4
src/common/utils/email-utils.js
Normal 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)
|
||||||
|
}
|
@ -15,6 +15,7 @@ import 'rc-slider/assets/index.css'
|
|||||||
import 'rc-tooltip/assets/bootstrap.css'
|
import 'rc-tooltip/assets/bootstrap.css'
|
||||||
import { DappState } from '../../common/data/dapp'
|
import { DappState } from '../../common/data/dapp'
|
||||||
import validator from 'validator'
|
import validator from 'validator'
|
||||||
|
import { emailValidation } from '../../common/utils/email-utils'
|
||||||
|
|
||||||
const getCategoryName = category =>
|
const getCategoryName = category =>
|
||||||
Categories.find(x => x.key === category).value
|
Categories.find(x => x.key === category).value
|
||||||
@ -224,13 +225,12 @@ class Submit extends React.Component {
|
|||||||
visible_submit,
|
visible_submit,
|
||||||
visible_rating,
|
visible_rating,
|
||||||
onClickClose,
|
onClickClose,
|
||||||
email,
|
|
||||||
id,
|
|
||||||
name,
|
name,
|
||||||
desc,
|
desc,
|
||||||
url,
|
url,
|
||||||
img,
|
img,
|
||||||
category,
|
category,
|
||||||
|
email,
|
||||||
imgControl,
|
imgControl,
|
||||||
imgControlZoom,
|
imgControlZoom,
|
||||||
onImgCancel,
|
onImgCancel,
|
||||||
@ -239,7 +239,12 @@ class Submit extends React.Component {
|
|||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const canSubmit =
|
const canSubmit =
|
||||||
name !== '' && desc !== '' && url !== '' && img !== '' && category !== ''
|
name !== '' &&
|
||||||
|
desc !== '' &&
|
||||||
|
url !== '' &&
|
||||||
|
img !== '' &&
|
||||||
|
category !== '' &&
|
||||||
|
emailValidation(email)
|
||||||
|
|
||||||
const visible = visible_submit || visible_rating
|
const visible = visible_submit || visible_rating
|
||||||
|
|
||||||
@ -277,19 +282,6 @@ class Submit extends React.Component {
|
|||||||
{visible_submit && (
|
{visible_submit && (
|
||||||
<div className={imgControl ? styles.cntWithImgControl : ''}>
|
<div className={imgControl ? styles.cntWithImgControl : ''}>
|
||||||
<div className={imgControl ? styles.withImgControl : ''}>
|
<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.block}>
|
||||||
<div className={styles.labelRow}>
|
<div className={styles.labelRow}>
|
||||||
<span>Name of your Ðapp</span>
|
<span>Name of your Ðapp</span>
|
||||||
@ -358,6 +350,17 @@ class Submit extends React.Component {
|
|||||||
}`}
|
}`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</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.block} ${styles.blockSubmit}`}>
|
||||||
<div className={styles.terms}>
|
<div className={styles.terms}>
|
||||||
By continuing you agree to our
|
By continuing you agree to our
|
||||||
|
@ -175,7 +175,7 @@ export const submitAction = (dapp, sntValue) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateAction = (dappId, metadata) => {
|
export const updateAction = (dappId, metadata, email) => {
|
||||||
return async dispatch => {
|
return async dispatch => {
|
||||||
dispatch(closeSubmitAction())
|
dispatch(closeSubmitAction())
|
||||||
dispatch(
|
dispatch(
|
||||||
@ -188,7 +188,18 @@ export const updateAction = (dappId, metadata) => {
|
|||||||
)
|
)
|
||||||
try {
|
try {
|
||||||
const blockchain = await BlockchainSDK.getInstance()
|
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(onReceiveTransactionInfoAction(dappId, tx))
|
||||||
dispatch(checkTransactionStatusAction(tx))
|
dispatch(checkTransactionStatusAction(tx))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user