-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
271 lines (268 loc) · 9.07 KB
/
app.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
class App extends React.Component {
state = {
jobs: []
}
componentDidMount = () => {
this.updateJobs();
}
// ============== UPDATE event handlers ===============
changeUpdateJobCompany = (event) => {
this.setState({
updateJobCompany:event.target.value
})
}
changeUpdateJobPosition = (event) => {
this.setState({
updateJobPosition:event.target.value
})
}
changeUpdateJobApplication_link = (event) => {
this.setState({
updateJobApplication_link:event.target.value
})
}
changeUpdateJobResources_link = (event) => {
this.setState({
updateJobResources_link:event.target.value
})
}
changeUpdateJobNotes = (event) => {
this.setState({
updateJobNotes:event.target.value
})
}
changeUpdateJobInterest_level = (event) => {
this.setState({
updateJobInterest_level:event.target.value
})
}
changeUpdateJobPhoneScreen = (event) => {
this.setState({
updateJobPhoneScreen:event.target.value
})
}
changeUpdateJobInterviews = (event) => {
this.setState({
updateJobInterviews:event.target.value
})
}
// ================== delete =================
deleteJob = (event) => {
axios.delete('/jobs/' + event.target.value).then(
(response) => {
this.setState(
{
jobs:response.data
}
)
}
)
}
// ================== update =================
updateJob = (event) => {
event.preventDefault();
const id = event.target.getAttribute('id');
axios.put(
'/jobs/'+id,
{
company:this.state.updateJobCompany,
position:this.state.updateJobPosition,
application_link:this.state.updateJobApplication_link,
resources_link:this.state.updateJobResources_link,
notes:this.state.updateJobNotes,
interest_level:this.state.updateJobInterest_level,
phone_screen:this.state.updateJobPhoneScreen,
interviews:this.state.updateJobInterviews
}
).then(
(response) => {
this.setState(
{
jobs:response.data
}
)}
)
}
updateJobs = () => {
axios.get('/jobs').then(
(response) => {
this.setState(
{
jobs:response.data
}
)
}
)
}
// ================== NEW event handlers =================
changeNewJobCompany = (event) => {
this.setState({
newJobCompany:event.target.value
})
}
changeNewJobPosition = (event) => {
this.setState({
newJobPosition:event.target.value
})
}
changeNewJobApplication_link = (event) => {
this.setState({
newJobApplication_link:event.target.value
})
}
changeNewJobResources_link = (event) => {
this.setState({
newJobResources_link:event.target.value
})
}
changeNewJobNotes = (event) => {
this.setState({
newJobNotes:event.target.value
})
}
changeNewJobInterest_level = (event) => {
this.setState({
newJobInterest_level:event.target.value
})
}
changeNewJobPhoneScreen = (event) => {
this.setState({
newJobPhoneScreen:event.target.value
})
}
changeNewJobInterviews = (event) => {
this.setState({
newJobInterviews:event.target.value
})
}
// ========= CREATE event handler ==========
createJob = (event) => {
event.preventDefault();
axios.post(
'/jobs',
{
company:this.state.newJobCompany,
position:this.state.newJobPosition,
application_link:this.state.newJobApplication_link,
resources_link:this.state.newJobResources_link,
notes:this.state.newJobNotes,
interest_level:this.state.newJobInterest_level,
phone_screen:this.state.newJobPhoneScreen,
interviews:this.state.newJobInterviews,
add_date:this.state.add_date
}
).then(
// {
// jobs:response.data
(response) => {
this.setState(
{
jobs:response.data
}
)
}
)
}
// ================== render =================
render = () => {
return ( <div>
<details className="track">
<summary className="track">Track a Job</summary>
<div className="row">
<form className="col s12 add-job" onSubmit={this.createJob}>
<div className="row">
<div className="input-field col s5">
<input onKeyUp={this.changeNewJobCompany} type="text" /><br />
<label htmlFor="company">Company Name</label>
</div>
<div className="input-field col s5">
<input onKeyUp={this.changeNewJobPosition} type="text" /><br />
<label htmlFor="position">Position Title</label>
</div>
<div className="input-field col s2">
<input onKeyUp={this.changeNewJobInterest_level} type="number" min="0" max="10" /><br />
<label htmlFor="notes">Interest Level 1-10</label>
</div>
</div>
<div className="row">
<div className="input-field col s12">
<input onKeyUp={this.changeNewJobApplication_link} type="text" /><br />
<label htmlFor="application">Link to Application</label>
</div>
</div>
<div className="row">
<div className="input-field col s12">
<input onKeyUp={this.changeNewJobResources_link} type="text" /><br />
<label htmlFor="docs">Link to Submitted Docs</label>
</div>
</div>
<div className="row">
<div className="input-field col s12">
<input onKeyUp={this.changeNewJobNotes} type="text" /><br />
<label htmlFor="notes">Notes</label>
</div>
</div>
<div className="row">
<div className=" col s6">
<label htmlFor="phone">Phone Screen Date</label>
<input onKeyUp={this.changeNewJobPhoneScreen} type="date" /><br />
</div>
<div className=" col s6">
<label htmlFor="interviews">In person Date</label>
<input onKeyUp={this.changeNewJobInterviews} type="date" /><br />
</div>
</div>
<input className="post-btn" type="submit" value="Tack Job" />
</form>
</div>
</details>
<h2 className="your-jobs">Your Jobs</h2>
<ul>
{this.state.jobs.map(job => {return (
<li key={job.id} className="joblist">
<h4 className="position">{job.position} at {job.company}</h4>
<p className="added">Added: {(new Date(job.add_date)).toDateString()} </p>
<br />
<br />
<h6 className="link clearfix"><a href={job.application_link} target="_blank" className="link"> Application Link <i className="fas fa-external-link-alt"></i> </a>
<a href={job.resources_link} target="_blank" className="link"> Submitted Docs <i className="fas fa-external-link-alt"></i></a></h6>
<br />
<p className="field">Notes:</p>
<p className="notes"> {job.notes}</p>
<p className="field">Interest Level: {job.interest_level}</p>
<div className="interviews">
<p className="field left"> <i className="fas fa-phone-square-alt"></i> Phone Sreen: {(new Date(job.phone_screen)).toDateString()}</p>
<p className="field right"><i className="fas fa-handshake"></i> In Person: {(new Date(job.interviews)).toDateString()}</p><br /> <br />
</div>
<details>
<summary>Edit Post</summary>
<form className="update-form" id={job.id} onSubmit={this.updateJob}>
<input onKeyUp={this.changeUpdateJobCompany} type="text" placeholder={job.company} /><br />
<input onKeyUp={this.changeUpdateJobPosition} type="text" placeholder={job.position} /><br />
<input onKeyUp={this.changeUpdateJobApplication_link} type="text" placeholder={job.application_link} /><br />
<input onKeyUp={this.changeUpdateJobResources_link} type="text" placeholder={job.resources_link} /><br />
<input onKeyUp={this.changeUpdateJobNotes} type="text" placeholder={job.notes} /><br />
<input onKeyUp={this.changeUpdateJobInterest_level} type="number" placeholder="interest level" /><br />
<input onKeyUp={this.changeUpdateJobPhoneScreen} type="date" /><br />
<input onKeyUp={this.changeUpdateJobInterviews} type="date" /><br />
<input className="button do-it" type="submit" value="Update Job" />
<button className="button delete right" value={job.id} onClick={this.deleteJob}>
Delete
</button>
</form>
</details> <br />
</li>
)
}
)
}
</ul>
</div>
)
}
}
// ======= render to DOM Main ============
ReactDOM.render(
<App></App>,
document.querySelector('main')
);