Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add accesibility links for supported councils #695

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/example-responses/postcode-AA12AA.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
}
],
"electoral_services": {
"council_id": "E09000033",
"council_id": "WAE",
"name": "City of Westminster",
"email": "[email protected]",
"phone": "020 7641 2730",
Expand Down
5 changes: 4 additions & 1 deletion src/AddressPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ class AddressPicker extends React.Component {

setAddress(event) {
this.setState({ address: event.target.value });
if (event.target.selectedOptions.length > 0) {
this.props.setUPRN(event.target.selectedOptions[0].dataset.uprn);
}
}

addressOption(address, index) {
return (
<option key={index} value={address.url}>
<option key={index} value={address.url} data-uprn={address.slug}>
{address.address}
</option>
);
Expand Down
12 changes: 11 additions & 1 deletion src/ElectionInformationWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function ElectionInformationWidget(props) {
const [notifications, setNotifications] = useState(undefined);
const [addressList, setAddressList] = useState(undefined);
const [postcode, setPostcode] = useState(undefined);
const [uprn, setUPRN] = useState(undefined);
const [dates, setDates] = useState(undefined);
const [electoralServices, setElectoralServices] = useState(undefined);
const dataSource = process.env.REACT_APP_API;
Expand Down Expand Up @@ -156,6 +157,7 @@ function ElectionInformationWidget(props) {
<AddressPicker
addressList={addressList}
lookupChosenAddress={lookupChosenAddress}
setUPRN={setUPRN}
{...props}
/>
)}
Expand All @@ -167,7 +169,15 @@ function ElectionInformationWidget(props) {
notifications={notifications}
/>
)}
{station && <PollingStation station={station} notifications={notifications} />}
{station && (
<PollingStation
station={station}
notifications={notifications}
postcode={postcode}
uprn={uprn}
electoralServices={electoralServices}
/>
)}
{stationNotFound && (
<StationNotFound notifications={notifications} electoral_services={electoralServices} />
)}
Expand Down
17 changes: 17 additions & 0 deletions src/PollingStation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ import { Directions } from './Directions';

function PollingStation(props) {
let splitAddress = [];
var wdiv_link;
if (props.uprn) {
wdiv_link = `https://wheredoivote.co.uk/address/${props.uprn}/`;
} else {
wdiv_link = `https://wheredoivote.co.uk/postcode/${props.postcode}/`;
}
var show_i18n_link = false;
const i18n_councils = ['CGN', 'CMN', 'COV', 'CRF', 'NTL', 'NWP', 'STY', 'VGL', 'WAE'];
if (i18n_councils.indexOf(props.electoralServices.council_id) > -1) {
show_i18n_link = true;
}

props.station.address.split(',').forEach(function (line, index) {
splitAddress.push(line.trim());
Expand All @@ -25,6 +36,12 @@ function PollingStation(props) {
description="Polling stations are open from 7am to 10pm on polling day."
/>
</p>
{show_i18n_link && (
<p>
For detailed information on accessibility, see <a href={wdiv_link}>WhereDoIVote.co.uk</a>
</p>
)}

{props.station.coordinates && (
<Directions
origin={props.station.coordinates.origin}
Expand Down
Loading