Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Added Create token page
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh391 committed Sep 2, 2020
1 parent 91a7f35 commit 25a3712
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions webapp/src/containers/TokensPage/components/CreateToken/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import React, { useState } from 'react';
import { connect } from 'react-redux';
import { RouteComponentProps } from 'react-router-dom';
import { TabContent, TabPane } from 'reactstrap';

import DCTDistribution from './DCTDistribution';
import CreateDCT from './CreateDCT';
import { createToken } from '../../reducer';
import { CREATE_DCT, DCT_DISTRIBUTION } from '../../../../constants';

interface CreateTokenProps extends RouteComponentProps {
createToken: (tokenData) => void;
}

const CreateToken: React.FunctionComponent<CreateTokenProps> = (
props: CreateTokenProps
) => {
const [activeTab, setActiveTab] = useState<string>(CREATE_DCT);
const [formState, setFormState] = useState<any>({
nameLabel: '',
tickerSymbol: '',
divisibility: '8',
initialSupply: '',
mintingSupport: 'no',
optionalFinalSupplyLimit: '',
tradable: 'no',
});
const [csvData, setCsvData] = React.useState<any>([]);

const { createToken } = props;

const handleSubmit = () => {
const tokenData = { ...formState, collateralAddresses: csvData };
createToken(tokenData);
};

const handleChange = (e) => {
setFormState({
...formState,
[e.target.name]: e.target.value,
});
};

const handleActiveTab = (active: string) => {
setActiveTab(active);
};

return (
<TabContent activeTab={activeTab}>
<TabPane tabId={CREATE_DCT}>
<div className='main-wrapper position-relative'>
<CreateDCT
handleActiveTab={handleActiveTab}
handleChange={handleChange}
formState={formState}
/>
</div>
</TabPane>
<TabPane tabId={DCT_DISTRIBUTION}>
<div className='main-wrapper position-relative'>
<DCTDistribution
handleActiveTab={handleActiveTab}
csvData={csvData}
setCsvData={setCsvData}
handleSubmit={handleSubmit}
/>
</div>
</TabPane>
</TabContent>
);
};

const mapStateToProps = (state) => {
const { tokens } = state;
return {
isTokenCreating: tokens.isTokenCreating,
createdTokenData: tokens.createdTokenData,
isErrorCreatingToken: tokens.isErrorCreatingToken,
};
};

const mapDispatchToProps = {
createToken: (tokenData) => createToken({ tokenData }),
};

export default connect(mapStateToProps, mapDispatchToProps)(CreateToken);

0 comments on commit 25a3712

Please sign in to comment.