diff --git a/npm-debug.log b/npm-debug.log new file mode 100644 index 00000000..37e89399 --- /dev/null +++ b/npm-debug.log @@ -0,0 +1,22 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/home/misha/.nvm/versions/node/v6.11.0/bin/node', +1 verbose cli '/home/misha/.nvm/versions/node/v6.11.0/bin/npm', +1 verbose cli 'start' ] +2 info using npm@3.10.10 +3 info using node@v6.11.0 +4 verbose stack Error: ENOENT: no such file or directory, open '/home/misha/ctp/week-03-projects/package.json' +4 verbose stack at Error (native) +5 verbose cwd /home/misha/ctp/week-03-projects +6 error Linux 4.8.0-58-generic +7 error argv "/home/misha/.nvm/versions/node/v6.11.0/bin/node" "/home/misha/.nvm/versions/node/v6.11.0/bin/npm" "start" +8 error node v6.11.0 +9 error npm v3.10.10 +10 error path /home/misha/ctp/week-03-projects/package.json +11 error code ENOENT +12 error errno -2 +13 error syscall open +14 error enoent ENOENT: no such file or directory, open '/home/misha/ctp/week-03-projects/package.json' +15 error enoent ENOENT: no such file or directory, open '/home/misha/ctp/week-03-projects/package.json' +15 error enoent This is most likely not a problem with npm itself +15 error enoent and is related to npm not being able to find a file. +16 verbose exit [ -2, true ] diff --git a/zip-search/src/App.css b/zip-search/src/App.css index 6f9daabd..f0f4f2cf 100644 --- a/zip-search/src/App.css +++ b/zip-search/src/App.css @@ -23,3 +23,30 @@ padding-top: 10px; padding-bottom: 10px; } + +.input-area { + margin: 15px 15px; +} + +.box-text { + width:90px; +} + +.type-button { + height: 35px; + width: 250px; + margin: 10px 0px 0px 35px; +} + +.zip-table { + display: block; +} + +.slot { + text-align: center; + background: #DDDDDD; + width: 150px; + height: 50px; + padding-top: 15px; + margin-left: 5px; +} \ No newline at end of file diff --git a/zip-search/src/App.js b/zip-search/src/App.js index a505dbef..00ba75d1 100644 --- a/zip-search/src/App.js +++ b/zip-search/src/App.js @@ -4,25 +4,123 @@ import './App.css'; function City(props) { - return (
); + const c = props.entry; + return ( + +
+
+ {c.City},{c.State} +
+
+ +
+
); } function ZipSearchField(props) { - return (
); + return ( +
+ + + + +
); } class App extends Component { + constructor(){ + super(); + + this.state = { + zip_city: true, + + out:[], + + input:"" + + }; + + this.zipChanged = this.zipChanged.bind(this); + + this.onTypeButtonClick = this.onTypeButtonClick.bind(this); + } + + zipChanged(event){ + const addon = ((this.state.zip_city ) ? "zip/" : "city/"); + + const textEntry = event.target.value.toUpperCase(); + + let out =
; + + if((this.state.zip_city && textEntry.length === 5) || !this.state.zip_city){ + + fetch("http://ctp-zip-api.herokuapp.com/" + addon + textEntry) + .then((response) => { + return response.json(); + }) + + .then((jsonData) =>{ + + if(this.state.zip_city){ + out = jsonData.map(c=> { + return ; + }); + } + else { + out = jsonData.map(c=> { + return ; + }); + out =
{out}
; + } + + this.setState({ + + input: textEntry, + out: out, + }) + }) + }else { + this.setState({ + out:out, + }) + } + } + + onTypeButtonClick(){ + this.setState({ + zip_city: (this.state.zip_city) ? false : true, + }) + } + render() { + const textLabel = (this.state.zip_city ) ? "Zip Code: " : "City Name: "; + + const textButton = (this.state.zip_city )? "Look up cities by zip-codes" : "Look up zip-codes by city" return (
+

Zip Code Search

+
-
- - + +
+ + + + + +
+ +
{this.state.out}
+
); diff --git a/zip-search/src/index.css b/zip-search/src/index.css index b4cc7250..673b8794 100644 --- a/zip-search/src/index.css +++ b/zip-search/src/index.css @@ -2,4 +2,4 @@ body { margin: 0; padding: 0; font-family: sans-serif; -} +} \ No newline at end of file