From 0ee96e01e672b852281f7dd4bd191910dfc55e16 Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Mon, 5 Apr 2021 09:50:06 -0500 Subject: [PATCH] Loading images --- .../src/components/ArtCard/index.tsx | 14 ++++++----- .../metavinci/src/views/artCreate/index.tsx | 24 +++++++++++-------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/packages/metavinci/src/components/ArtCard/index.tsx b/packages/metavinci/src/components/ArtCard/index.tsx index 714c76d..ec0a34e 100644 --- a/packages/metavinci/src/components/ArtCard/index.tsx +++ b/packages/metavinci/src/components/ArtCard/index.tsx @@ -4,15 +4,17 @@ import { Card, Avatar } from 'antd'; const { Meta } = Card; -export const ArtCard = (file: File) => { +export const ArtCard = ({ file }: { file?: File }) => { const [imgSrc, setImgSrc] = useState(); useLayoutEffect(() => { - const reader = new FileReader(); - reader.onload = function (event) { - setImgSrc(event.target?.result as any); - }; - reader.readAsDataURL(file); + if (file) { + const reader = new FileReader(); + reader.onload = function (event) { + setImgSrc(event.target?.result as any); + }; + reader.readAsDataURL(file); + } }, [file]); return ( diff --git a/packages/metavinci/src/views/artCreate/index.tsx b/packages/metavinci/src/views/artCreate/index.tsx index 8e85225..8f9e0d7 100644 --- a/packages/metavinci/src/views/artCreate/index.tsx +++ b/packages/metavinci/src/views/artCreate/index.tsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { Steps, Row, Button, Upload, Col, Input } from 'antd'; +import { Steps, Row, Button, Upload, Col, Input, Statistic } from 'antd'; import { InboxOutlined } from '@ant-design/icons'; import { ArtCard } from './../../components/ArtCard'; import './styles.less'; @@ -11,6 +11,8 @@ const { Dragger } = Upload; interface IProps { type: String; + title: String; + description: String; files: File[]; } @@ -67,7 +69,9 @@ export const ArtCreateView = () => { confirm={() => setStep(2)} /> )} - {step === 2 && mint()} attributes />} + {step === 2 && ( + mint()} attributes={attributes} /> + )} @@ -207,7 +211,9 @@ const InfoStep = (props: { confirm: () => void; attributes: IProps }) => { ); }; -const RoyaltiesStep = (props: { confirm: () => void }) => { +const RoyaltiesStep = (props: { confirm: () => void; attributes: IProps }) => { + const file = props.attributes.files[0]; + return ( <> @@ -218,9 +224,7 @@ const RoyaltiesStep = (props: { confirm: () => void }) => {

- - - + {file && } void }) => { ); }; -const LaunchStep = (props: { confirm: () => void }) => { +const LaunchStep = (props: { confirm: () => void; attributes: IProps }) => { + const file = props.attributes.files[0]; + return ( <> @@ -254,9 +260,7 @@ const LaunchStep = (props: { confirm: () => void }) => {

- - - + {file && }