hook up connections to card from form

This commit is contained in:
Jordan Prince 2021-04-05 10:58:13 -05:00
parent b61c59530b
commit 58a0977443
2 changed files with 80 additions and 51 deletions

View File

@ -1,10 +1,17 @@
import React, { useLayoutEffect, useState } from 'react'; import React, { useLayoutEffect, useState } from 'react';
import { Link, useLocation } from 'react-router-dom'; import { Card } from 'antd';
import { Card, Avatar } from 'antd';
const { Meta } = Card; const { Meta } = Card;
export const ArtCard = ({ file }: { file?: File }) => { export const ArtCard = ({
file,
name,
symbol,
}: {
file?: File;
name?: String;
symbol?: String;
}) => {
const [imgSrc, setImgSrc] = useState<string>(); const [imgSrc, setImgSrc] = useState<string>();
useLayoutEffect(() => { useLayoutEffect(() => {
@ -19,13 +26,7 @@ export const ArtCard = ({ file }: { file?: File }) => {
return ( return (
<Card className="custom-card" cover={<img src={imgSrc} />}> <Card className="custom-card" cover={<img src={imgSrc} />}>
<Meta <Meta title={`Title: ${title}`} description={`Symbol: ${symbol}`} />
avatar={
<Avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
}
title="Card title"
description="This is the description"
/>
</Card> </Card>
); );
}; };

View File

@ -1,5 +1,14 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Steps, Row, Button, Upload, Col, Input, Statistic, Descriptions } from 'antd'; import {
Steps,
Row,
Button,
Upload,
Col,
Input,
Statistic,
Descriptions,
} from 'antd';
import { InboxOutlined } from '@ant-design/icons'; import { InboxOutlined } from '@ant-design/icons';
import { ArtCard } from './../../components/ArtCard'; import { ArtCard } from './../../components/ArtCard';
import './styles.less'; import './styles.less';
@ -12,6 +21,7 @@ const { Dragger } = Upload;
interface IProps { interface IProps {
type: string; type: string;
name: string; name: string;
symbol: String;
description: string; description: string;
// preview image // preview image
image: string; image: string;
@ -28,6 +38,7 @@ export const ArtCreateView = () => {
const [attributes, setAttributes] = useState<IProps>({ const [attributes, setAttributes] = useState<IProps>({
type: 'image', type: 'image',
name: '', name: '',
symbol: '',
description: '', description: '',
external_url: '', external_url: '',
image: '', image: '',
@ -81,18 +92,19 @@ export const ArtCreateView = () => {
<InfoStep <InfoStep
attributes={attributes} attributes={attributes}
setAttributes={setAttributes} setAttributes={setAttributes}
confirm={() => setStep(3)} confirm={() => setStep(3)}
/>)} />
)}
{step === 3 && ( {step === 3 && (
<RoyaltiesStep <RoyaltiesStep
attributes={attributes} attributes={attributes}
confirm={() => setStep(4)}
setAttributes={setAttributes} setAttributes={setAttributes}
confirm={() => setStep(4)} />)} />
)}
{step === 4 && ( {step === 4 && (
<LaunchStep <LaunchStep attributes={attributes} confirm={() => mint()} />
attributes={attributes} )}
confirm={() => mint()}
/>)}
</Col> </Col>
</Row> </Row>
</> </>
@ -111,27 +123,27 @@ const CategoryStep = (props: { confirm: (type: string) => void }) => {
</p> </p>
</Row> </Row>
<Row> <Row>
<Button <Button
className="type-btn" className="type-btn"
size="large" size="large"
onClick={() => props.confirm('image')} onClick={() => props.confirm('image')}
> >
Image Image
</Button> </Button>
<Button <Button
className="type-btn" className="type-btn"
size="large" size="large"
onClick={() => props.confirm('video')} onClick={() => props.confirm('video')}
> >
Video Video
</Button> </Button>
<Button <Button
className="type-btn" className="type-btn"
size="large" size="large"
onClick={() => props.confirm('audio')} onClick={() => props.confirm('audio')}
> >
Audio Audio
</Button> </Button>
</Row> </Row>
</> </>
); );
@ -207,7 +219,15 @@ const InfoStep = (props: {
</p> </p>
</Row> </Row>
<Row className="content-action"> <Row className="content-action">
<Col xl={12}>{file && <ArtCard file={file} />}</Col> <Col xl={12}>
{file && (
<ArtCard
file={file}
name={props.attributes.name}
symbol={props.attributes.symbol}
/>
)}
</Col>
<Col className="section" xl={12}> <Col className="section" xl={12}>
<label className="action-field"> <label className="action-field">
<span className="field-title">Title</span> <span className="field-title">Title</span>
@ -216,11 +236,13 @@ const InfoStep = (props: {
placeholder="Max 50 characters" placeholder="Max 50 characters"
allowClear allowClear
value={props.attributes.name} value={props.attributes.name}
onChange={info => props.setAttributes({ onChange={info =>
...props.attributes, props.setAttributes({
name: info.target.value, ...props.attributes,
})} name: info.target.value,
/> })
}
/>
</label> </label>
<label className="action-field"> <label className="action-field">
<span className="field-title">Description</span> <span className="field-title">Description</span>
@ -228,10 +250,12 @@ const InfoStep = (props: {
className="input textarea" className="input textarea"
placeholder="Max 500 characters" placeholder="Max 500 characters"
value={props.attributes.description} value={props.attributes.description}
onChange={info => props.setAttributes({ onChange={info =>
...props.attributes, props.setAttributes({
description: info.target.value, ...props.attributes,
})} description: info.target.value,
})
}
allowClear allowClear
/> />
</label> </label>
@ -271,8 +295,12 @@ const RoyaltiesStep = (props: {
<Col xl={12}>{file && <ArtCard file={file} />}</Col> <Col xl={12}>{file && <ArtCard file={file} />}</Col>
<Col className="section" xl={12}> <Col className="section" xl={12}>
<label className="action-field"> <label className="action-field">
<span className="field-title">Royalty Percentage</span> <span className="field-title">Description</span>
<Input className="input" placeholder="Between 0 and 100" value={props.attributes.royalty.toFixed(0)} allowClear max={100} min={0} /> <Input
className="input"
placeholder="Max 50 characters"
allowClear
/>
</label> </label>
</Col> </Col>
</Row> </Row>