Commit 3fd0f9f3 authored by farhan-shahid's avatar farhan-shahid
Browse files

refactoring of roles

parent 3a80bac1
# Rental Nomad
# Crypto Lodging
# Steps to setup
......@@ -100,7 +100,7 @@ Here we are configuring the Access control and port on which ipfs daemon would b
# Steps to interact with the UI
## For Uploading Contract - Valid only for role Employee/Landlord
## For Uploading Contract - Valid only for roles Landlord and Employee
1. Under "Upload Contract", choose a pdf file
2. Click on "Render" button to display the PDF document in the browser
......
......@@ -141,3 +141,19 @@ tr:nth-child(even) {
margin: 4px 2px;
cursor: pointer;
}
.selectEmpl {
position: absolute;
top: 25%;
left: 34%;
width: 300px;
height: 150px;
}
.selectLan {
position: absolute;
top: 42%;
left: 34%;
width: 300px;
height: 150px;
}
......@@ -389,7 +389,7 @@ class Events extends Component {
let role = this.props.role;
return (
<div>
{role === 'Employee/Landlord' && (
{role === 'Landlord' && (
<div>
<h5>Data Access legitimized Events </h5>
<br />
......@@ -514,7 +514,7 @@ class Events extends Component {
<br />
</div>
)}
{role === 'Employee/Landlord' && (
{role === 'Employee' && (
<div>
<input
type="text"
......@@ -569,7 +569,7 @@ class Events extends Component {
<br />
</div>
)}
{role === 'Employee/Landlord' && (
{role === 'Employee' && (
<div>
<h5>Contract Approval Request Events </h5>
<table>
......@@ -606,7 +606,7 @@ class Events extends Component {
</table>
</div>
)}
{role === 'Employee/Landlord' && (
{role === 'Landlord' && (
<div>
<h5>Contract Approval Response Events </h5>
<input type="text" value={this.state.haEmployeeName} placeholder={'Tenant'} onChange={this.haDataEmployeeChange} />
......@@ -870,7 +870,7 @@ class Events extends Component {
</table>
</div>
)}
{role === 'Employee/Landlord' && (
{role === 'Landlord' && (
<div>
<h5>Verification Responses</h5>
<table>
......
......@@ -11,14 +11,7 @@ import UploadContractContainer from '../UploadContract/UploadContractContainer';
class Home extends Component {
constructor(props) {
super(props);
this.state = {
federationDataKey: '',
employerDataKey: '',
bankDataKey: '',
housingAuthorityDataKey: '',
insuranceProviderDataKey: '',
policeDataKey: ''
};
this.state = {};
}
componentDidMount() {
......@@ -40,7 +33,11 @@ class Home extends Component {
this.setState({ policeDataKey: policeDataKey });
}
render() {
componentWillReceiveProps() {
if (this.state.role !== undefined) {
return;
}
if (
!this.props.ProofOfEmployment.initialized ||
!(this.state.federationDataKey in this.props.ProofOfEmployment.federation) ||
......@@ -50,7 +47,7 @@ class Home extends Component {
!(this.state.insuranceProviderDataKey in this.props.ProofOfEmployment.checkInsuranceProvider) ||
!(this.state.policeDataKey in this.props.ProofOfEmployment.checkPolice)
) {
return <span>Loading...</span>;
return;
}
var federation = this.props.ProofOfEmployment.federation[this.state.federationDataKey].value;
......@@ -75,7 +72,18 @@ class Home extends Component {
} else if (police) {
role = 'Police';
}
//handle employer, employee roles...
this.setState({ role: role });
}
render() {
if (this.state.role === undefined) {
return <span>Loading...</span>;
}
var myAddr = this.props.accounts[0];
var role = this.state.role;
let self = this;
return (
<main className="container">
......@@ -88,33 +96,23 @@ class Home extends Component {
<h2>Active Account</h2>
<Blockies seed={myAddr} size={10} scale={10} />
<AccountData accountIndex="0" units="ether" precision="3" />
<p>
<strong>Role</strong>: {role}
</p>
<br />
<br />
</div>
{/*role === 'Federation' && (
<div className="pure-u-1-1">
<h2>Contract data</h2>
<p>
<strong>Federation address</strong>: <ContractData contract="ProofOfEmployment" method="federation" />
</p>
<p>
<strong>Employer 1</strong>: <ContractData contract="ProofOfEmployment" method="employers" methodArgs={[0]} />
</p>
<p>
<strong>Employer 2</strong>: <ContractData contract="ProofOfEmployment" method="employers" methodArgs={[1]} />
</p>
{role === 'Employee/Landlord' && (
<div>
<a>Enter as: </a>
<button onClick={(e) => self.setState({ role: 'Employee' })}>Employee</button>
<a> / </a>
<button onClick={(e) => self.setState({ role: 'Landlord' })}>Landlord</button>
</div>
)}
{role !== 'Employee/Landlord' && (
<p>
<strong>Employer 3</strong>: <ContractData contract="ProofOfEmployment" method="employers" methodArgs={[2]} />
<strong>Role</strong>: {role}
</p>
<strong>...</strong>
<br />
<br />
</div>
)*/}
)}
<br />
<br />
</div>
<div className="pure-u-1-1">
<h2>Contract actions</h2>
......@@ -126,7 +124,7 @@ class Home extends Component {
<FederationSelect />
</div>
)}
{role === 'Employee/Landlord' && (
{role === 'Landlord' && (
<div>
<p>
<strong>Verify Data as a Landlord</strong>:
......@@ -134,7 +132,7 @@ class Home extends Component {
<VerifyDataContainer />
</div>
)}
{role === 'Employee/Landlord' && (
{role === 'Landlord' && (
<div>
<p>
<strong>Upload Contract</strong>:
......@@ -150,7 +148,8 @@ class Home extends Component {
<div className="pure-u-1-1">
{role === 'Federation' && <h2>Events</h2>}
{role === 'Employer' && <h2>Events</h2>}
{role === 'Employee/Landlord' && <h2>Data Requests and Approvals</h2>}
{role === 'Employee' && <h2>Data Requests</h2>}
{role === 'Landlord' && <h2>Data Approvals</h2>}
<EventsContainer role={role} />
<br />
<br />
......
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment