-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import { Link } from 'react-router'; | ||
|
||
export default class EmptyBallot extends Component { | ||
static propTypes = { | ||
}; | ||
|
||
constructor (props) { | ||
super(props); | ||
} | ||
|
||
render () { | ||
return ( | ||
<div> | ||
<div className="container-fluid well gutter-top--small fluff-full1"> | ||
<h3 className="text-center"> | ||
Sorry | ||
</h3> | ||
<span className="small"> | ||
Our data providers don't have ballot data for your address yet. | ||
Please check back 1-2 weeks before your election day | ||
</span> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import React, { Component } from "react"; | |
import { Button, ButtonToolbar } from "react-bootstrap"; | ||
import HeaderBackNavigation from "../../components/Navigation/HeaderBackNavigation"; | ||
import VoterStore from "../../stores/VoterStore"; | ||
import BallotStore from "../../stores/BallotStore"; | ||
|
||
export default class Location extends Component { | ||
constructor (props) { | ||
|
@@ -23,10 +24,14 @@ export default class Location extends Component { | |
|
||
saveLocation () { | ||
var { location } = this.state; | ||
VoterStore.saveLocation( location, (err) => { | ||
if (err) return console.error(err); | ||
|
||
window.location.href = "/ballot"; | ||
VoterStore.saveLocation( location, (res) => { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lisamburns
Author
Contributor
|
||
if (res){ | ||
this.props.history.push('/ballot'); | ||
} else { | ||
BallotStore.initialize(function(){}); // reinitialize ballot in case old ballot items from old addresses are stored. | ||
this.props.history.push('/ballot/empty'); | ||
} | ||
}, (err) =>{ | ||
|
||
}); | ||
} | ||
|
@@ -52,7 +57,7 @@ export default class Location extends Component { | |
name="address" | ||
value={location} | ||
className="form-control" | ||
defaultValue="Oakland, CA" | ||
defaultValue="Oakland, CA" | ||
/> | ||
|
||
<div className="gutter-top--small"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,16 +158,22 @@ const VoterStore = createStore({ | |
saveLocation: function (location, callback) { | ||
if (typeof location !== "string") throw new Error("missing location to save"); | ||
if (callback instanceof Function === false) throw new Error("missing callback function"); | ||
var that = this; | ||
|
||
$ajax({ | ||
type: "GET", | ||
data: { text_for_map_search: location }, | ||
endpoint: "voterAddressSave", | ||
success: (res) => { | ||
var { text_for_map_search: savedLocation } = res; | ||
|
||
_setLocation(savedLocation); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lisamburns
Author
Contributor
|
||
callback(null, savedLocation); | ||
cookies.setItem('location', savedLocation); | ||
|
||
if (res.success){ // Successfully saved address and found Google Civic Election ID | ||
callback(true, savedLocation); | ||
This comment has been minimized.
Sorry, something went wrong.
fi0rini
Contributor
|
||
} else if (res.status.indexOf("GOOGLE_CIVIC_API_ERROR") != -1){ // Saved Address but couldn't find election ID | ||
console.log("No election for the address"); | ||
callback(false, savedLocation); | ||
} | ||
}, | ||
error: (err) => callback(err, null) | ||
}); | ||
|
this is the preferred method, to alter the view instead of reloading the page but the dispatcher is not wired to support this functionality.