diff --git a/app/api/hartford-address-lookup.js b/app/api/hartford-address-lookup.js index 1f907b8d..00b5b915 100644 --- a/app/api/hartford-address-lookup.js +++ b/app/api/hartford-address-lookup.js @@ -1,4 +1,5 @@ import getViewersByOffice from '../server/util/get-viewers-by-office' +import _ from 'lodash' /* * function takes an address in Hartford CT @@ -40,64 +41,7 @@ const getOfficials = (long, lat, doOnSuccess, address_found) => { let officeNames = [] districts.forEach(district => { // the upper legislative body is being used for testing - if (district.offices && district.type === 'State Legislative (Lower)') { - district.offices.forEach(office => { - officeNames.push({ - id: office.id, - name: office.name, - district_number: parseInt(office.name[office.name.length - 1]), - type: district.type, - }) - }) - } - }) - - //officeNames.forEach(office => { - //console.log(parseInt(office.name[office.name.length - 1])) - //}) - //TODO remove this later as the tabs should be filled - let viewers = [] - for (let office of officeNames) { - let viewer = await getViewersByOffice(String(office.id)) - viewers.push(viewer) - } - //send info after success - doOnSuccess({ ok: true, address_found, officeNames, viewers }) - } else { - doOnSuccess({ ok: false, error: JSON.parse(data) }) - } - }) - }) - .on('error', err => { - console.log('Error: ' + err) - }) - https - .get(`${process.env.ELECTED_OFFICIALS_URL}?long=${long}&lat=${lat}`, resp => { - let data = '' - resp.on('data', chunk => { - data += chunk - }) - - resp.on('end', async () => { - const success = JSON.parse(data).success - if (success) { - const officials = JSON.parse(data).data[0].elected_officials - const districts = officials.districts - - /* - * districts is an array of objects - * format: - * name: String -> containing district name - * id: Number - * type: String -> containing type of district e.g. School District - * state: 'CT' - * offices: [{id, name:???,office_holders}] - * */ - - let officeNames = [] - districts.forEach(district => { - // the upper legislative body is being used for testing - if (district.offices && district.type === 'State Legislative (Lower)') { + if (district.offices && district.type === 'State Legislative (Upper)') { district.offices.forEach(office => { officeNames.push({ id: office.id, diff --git a/app/components/web-components/HartfordViewers/index.js b/app/components/web-components/HartfordViewers/index.js new file mode 100644 index 00000000..40f29ee8 --- /dev/null +++ b/app/components/web-components/HartfordViewers/index.js @@ -0,0 +1,49 @@ +import React, { useEffect } from 'react' +import { createUseStyles } from 'react-jss' +import FindDistrict from '../HartfordVotes/FindDistrict' +import { AddressProvider, useCandidates } from '../HartfordVotes/user-address-context' + +const useStyles = createUseStyles({ + landingPage: { + fontFamily: 'Libre Franklin', + '& button, & a': { + fontFamily: 'Libre Franklin, SemiBold', + fontWeight: 300, + }, + '& h1, & h2, & h3, & h4': { + fontFamily: 'Libre Franklin, Bold', + }, + fontSize: '10px', + wordSpacing: '0.3em', + letterSpacing: '0.01em', + boxSizing: 'border-box', + '@media (min-width: 1250px) and (min-height: 1000px)': { fontSize: '16px' }, + + '& *': { + boxSizing: 'border-box', + }, + width: '100vw', + textAlign: 'center', + }, +}) + +const HartfordViewers = ({}) => { + return ( + <> + + + + + ) +} + +const DisplayViewers = ({}) => { + const { candidates } = useCandidates() + + //useEffect(() => {}, [candidates]) + //