Skip to content

Commit

Permalink
Add accesibility links for supported councils
Browse files Browse the repository at this point in the history
  • Loading branch information
symroe committed Apr 21, 2024
1 parent 440e637 commit fbd7207
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
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', 'NTL', '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

0 comments on commit fbd7207

Please sign in to comment.