Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
feat: pass status when posting job
Browse files Browse the repository at this point in the history
  • Loading branch information
CamiloGarciaLaRotta committed Mar 17, 2019
1 parent ca3c985 commit 75e2b25
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/JobApp.re
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type state = {
companies: array(string),
resumes: array(resume),
resumeValue: string,
status: string,
id: string,
jwt: string,
error: bool,
Expand All @@ -27,6 +28,7 @@ type action =
| UpdateCompanyNames(array(string))
| UpdateResumes(array(resume))
| UpdateResumeValue(string)
| UpdateStatus(string)
| Submit
| SuccesfulSubmit
| FailedSubmit;
Expand All @@ -48,6 +50,8 @@ let reducer = (action, state) =>
| UpdateResumes(value) => ReasonReact.Update({...state, resumes: value})
| UpdateResumeValue(value) =>
ReasonReact.Update({...state, resumeValue: value, error: false})
| UpdateStatus(value) =>
ReasonReact.Update({...state, status: value, error: false})
| Submit =>
ReasonReact.UpdateWithSideEffects(
{...state, loading: true, error: false},
Expand All @@ -60,6 +64,7 @@ let reducer = (action, state) =>
~resume=state.resumeValue,
~date_posted=state.postedDate,
~deadline=state.deadline,
~status=state.status,
~id=state.id,
~jwt=state.jwt,
~callback=() => self.send(SuccesfulSubmit),
Expand Down Expand Up @@ -97,6 +102,7 @@ let make = (~signOutHandler, ~id, ~jwt, _children) => {
companies: [||],
resumes: [||],
resumeValue: "",
status: "",
id,
jwt,
error: false,
Expand Down Expand Up @@ -125,6 +131,7 @@ let make = (~signOutHandler, ~id, ~jwt, _children) => {
let changePostedDate = x => UpdatePostedDate(x) |> self.send;
let changeDeadline = x => UpdateDeadline(x) |> self.send;
let changeResumeValue = x => UpdateResumeValue(x) |> self.send;
let changeStatusValue = x => UpdateStatus(x) |> self.send;
let errorMessage = self.state.error ? "Failed to add application" : "";
let successMessage = self.state.success ? "Added application" : "";
self.state.loading ?
Expand Down Expand Up @@ -158,6 +165,7 @@ let make = (~signOutHandler, ~id, ~jwt, _children) => {
name="company"
placeholder="company"
value=self.state.company
required=(Js.Boolean.to_js_boolean(true))
/>
}
)
Expand All @@ -170,6 +178,7 @@ let make = (~signOutHandler, ~id, ~jwt, _children) => {
name="position"
placeholder="position"
value=self.state.position
required=(Js.Boolean.to_js_boolean(true))
/>
<ScrapingInput
script=ScrapingFunctions.scriptUrl
Expand All @@ -180,6 +189,7 @@ let make = (~signOutHandler, ~id, ~jwt, _children) => {
name="url"
placeholder="url"
value=self.state.url
required=(Js.Boolean.to_js_boolean(true))
/>
<div className="form-horizontal-separator">
<label> ("Date posted" |> str) </label>
Expand All @@ -192,6 +202,7 @@ let make = (~signOutHandler, ~id, ~jwt, _children) => {
name="postedDate"
placeholder=""
value=self.state.postedDate
required=(Js.Boolean.to_js_boolean(false))
/>
</div>
<div className="form-horizontal-separator">
Expand All @@ -205,11 +216,21 @@ let make = (~signOutHandler, ~id, ~jwt, _children) => {
</div>
<div className="form-horizontal-separator">
<label>
<input _type="radio" name="status" value="applied" />
<input
_type="radio"
name="status"
value="applied"
onChange=(ev => valueFromEvent(ev) |> changeStatusValue)
/>
("Applied" |> str)
</label>
<label>
<input _type="radio" name="status" value="toApply" />
<input
_type="radio"
name="status"
value="toApply"
onChange=(ev => valueFromEvent(ev) |> changeStatusValue)
/>
("To apply" |> str)
</label>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/ScrapingInput.re
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ let make =
~name,
~placeholder,
~value,
~required,
_children,
) => {
...component,
Expand All @@ -59,5 +60,6 @@ let make =
/*** Ideally, I would've passed a separate prop such as a "dispatcher" function,
but honestly for the complexity of our app, I wouldn't bother */
onChange=(evt => Utilities.valueFromEvent(evt) |> reducerFn)
required
/>,
};
3 changes: 3 additions & 0 deletions src/Services.re
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ let submitApplication =
~resume,
~date_posted,
~deadline,
~status,
~id,
~jwt,
~callback,
Expand All @@ -115,6 +116,7 @@ let submitApplication =
Js.Dict.set(payload, "resume", Js.Json.string(resume));
Js.Dict.set(payload, "date_posted", Js.Json.string(date_posted));
Js.Dict.set(payload, "deadline", Js.Json.string(deadline));
Js.Dict.set(payload, "status", Js.Json.string(status));
let headers =
Fetch.HeadersInit.make({
"Content-Type": "application/json",
Expand All @@ -135,6 +137,7 @@ let submitApplication =
),
)
|> then_(response => {
Js.log(response);
let status = response |> Fetch.Response.status;
switch (status) {
| 200 =>
Expand Down

0 comments on commit 75e2b25

Please sign in to comment.