-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
162 lines (145 loc) · 4.61 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import Mail from './Mail';
class App extends React.Component{
constructor(props){
super(props);
this.state = {
loader: 0,
stage : 1,
activeIndex: 0,
info: []
};
this.nextStage = this.nextStage.bind(this);
this.takeInfo = this.takeInfo.bind(this);
}
nextStage(){
var changeState = () => {
this.setState({
activeIndex : this.state.activeIndex + 1,
loader : this.state.loader + 20,
stage: this.state.stage < 6 ? this.state.stage + 1 : this.state.stage
});
}
if(this.state.activeIndex == 0 ) {
let name = document.getElementById('name');
if((name.value) == ""){
name.setAttribute("error", true);
}
else{
changeState();
var changedInfo = this.state.info.concat(name.value);
this.setState({
info : changedInfo
});
console.log(this.state.info);
}
}
if(this.state.activeIndex == 1) {
var email = document.getElementById('email');
if((email.value) == ""){
email.setAttribute("error", true);
}
else{
changeState();
var changedInfo = this.state.info.concat(email.value);
this.setState({
info : changedInfo
});
console.log(this.state.info);
}
}
if(this.state.activeIndex == 2) {
var company = document.getElementById('company');
if((company.value) == ""){
company.setAttribute("error", true);
}
else{
changeState();
var changedInfo = this.state.info.concat(company.value);
this.setState({
info : changedInfo
});
console.log(this.state.info);
}
}
if(this.state.activeIndex == 3) {
var number = document.getElementById('number');
if((number.value) == ""){
number.setAttribute("error", true);
}
else{
changeState();
var changedInfo = this.state.info.concat(number.value);
this.setState({
info : changedInfo
});
console.log(this.state.info);
}
}
if(this.state.activeIndex == 4) {
var message = document.getElementById('message');
if((message.value) == ""){
message.setAttribute("error", true);
}
else{
changeState();
var changedInfo = this.state.info.concat(message.value);
this.setState({
info : changedInfo
});
console.log(this.state.info);
}
}
}
takeInfo(){
}
render(){
return(
<React.Fragment>
<header>
<a href="indar.xyz" className="logo"><img src={process.env.PUBLIC_URL + '/images/indar-white.png'} alt="logo" /></a>
<h1>Minimal Form</h1>
<h2 className={this.state.activeIndex == 5 ? 'show' : ''}>Thanks for filling the form.</h2>
<ul>
<li className={this.state.activeIndex === 0 ? 'current' : '' }>
<label>First Name</label>
<input type="text" name="Name" id="name" value={this.state.info[0]} onChange={this.takeInfo} />
<span className="error">Please provide your name</span>
</li>
<li className={this.state.activeIndex === 1 ? 'current' : '' }>
<label>Email Id</label>
<input type="email" id="email" value={this.state.info[1]} onChange={this.takeInfo} />
<span>Please provide your email</span>
</li>
<li className={this.state.activeIndex === 2 ? 'current' : '' }>
<label>Company</label>
<input type="text" id="company" value={this.state.info[2]} onChange={this.takeInfo} />
<span>Please provide your company name</span>
</li>
<li className={this.state.activeIndex === 3 ? 'current' : '' }>
<label>Phone Number</label>
<input type="number" id="number" value={this.state.info[3]} onChange={this.takeInfo} />
<span>Please provide your contact number</span>
</li>
<li className={this.state.activeIndex === 4 ? 'current' : '' }>
<label>Message</label>
<input type="text" id="message" value={this.state.info[4]} onChange={this.takeInfo} />
<span>Please write something for us</span>
</li>
<button onClick={this.state.stage <= 5 ? this.nextStage : null}></button>
</ul>
<div className={["loader", this.state.loader == 100 ? 'hidden' : ''].join(" ")}>
<span style={{'width': this.state.loader + '%'}}></span>
</div>
<div className={["stage-holder", this.state.stage == 6 ? 'hidden' : ''].join(" ")}>
<span>{this.state.stage}</span> <i>/</i> <span>5</span>
</div>
</header>
<Mail info={this.state.info} show={this.state.stage == 6 ? 'true' : 'false'} />
</React.Fragment>
);
}
}
ReactDOM.render(<App />, document.getElementById('root'));