Skip to content

Commit

Permalink
forgot an event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexWang18 committed Jan 21, 2021
1 parent c632eb9 commit 36f9938
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
2 changes: 1 addition & 1 deletion react-ui/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<body><noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/main.6b9a4068.js"></script>
<script type="text/javascript" src="/static/js/main.6b9a4068.js"></script> <!-- not sure if should have this, not loading anyways -->
<script>window.jQuery || document.write('<script src="js/jquery-1.10.2.min.js"><\/script>')</script>
<script type="text/javascript" src="js/jquery-migrate-1.2.1.min.js"></script>
<script src="js/jquery.flexslider.js"></script>
Expand Down
69 changes: 38 additions & 31 deletions react-ui/src/Components/Contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,40 @@ import { contactSubmit } from './services/serverServices'
import { getSOTD } from './services/serverServices'

const Contact = ({ data }) => {
//if(data) getLatest()

const name = data.name;
const city = data.city;
const state = data.state;
const phone = data.phone;
const email = data.email;
const contactMessage = data.contactmessage;
const contactMessage = data.contactmessage;
const pic = 'images/' + data.endingpic

const [newName, setName] = useState('')
const [newEmail, setEmail] = useState('')
const [newSubject, setSubject] = useState('')
const [newMessage, setMessage] = useState('')

const resetForm = () => {
setName('')
setEmail('')
setMessage('')
}

const handleSubmit = (e) => {
e.preventDefault()

const userData = {
name: newName,
email: newEmail,
subject: newSubject,
message: newMessage
}


const resetForm = () => {
setName('')
setEmail('')
setSubject('')
setMessage('')
}
contactSubmit(userData)
.then(data => {
console.log('success submitting data', data);
.then(d => {
console.log('success submitting data', d);
resetForm()
})
}
Expand All @@ -47,21 +50,25 @@ const Contact = ({ data }) => {
//if matches regex
setEmail(event.target.value)
}
const handleSubjectChange = (event) => {
setSubject(event.target.value)
}
const handleMessageChange = (event) => {
setMessage(event.target.value)
}

const [song, setSong] = useState(null)
useEffect(() => {
const fetch = async () => {
const songOTD = await getSOTD()
setSong(songOTD)
}
fetch()
}, [])

useEffect(() => {
const fetch = async () => {
const songOTD = await getSOTD()
setSong(songOTD)
}
fetch()
}, [])
if (song === null) {
return <h1>Loading...</h1>
}
if (song === null) {
return <h1>Loading...</h1>
}
return (
<section id="contact">

Expand Down Expand Up @@ -99,12 +106,12 @@ const Contact = ({ data }) => {

<div>
<label htmlFor="contactSubject">Subject</label>
<input type="text" defaultValue="" size="35" id="contactSubject" name="contactSubject" onChange={handleMessageChange} />
<input type="text" defaultValue="" size="35" id="contactSubject" name="contactSubject" onChange={handleSubjectChange} />
</div>

<div>
<label htmlFor="contactMessage">Message <span className="required">*</span></label>
<textarea cols="50" rows="15" id="contactMessage" name="contactMessage"></textarea>
<textarea cols="50" rows="15" id="contactMessage" name="contactMessage" onChange={handleMessageChange}></textarea>
</div>

<div>
Expand All @@ -128,21 +135,21 @@ const Contact = ({ data }) => {

<h4>Contact Info</h4>
<p className="address">
{name}
<br/>
{name}
<br />
{email}
<br/>
<br />
{city}, {state} <br />
<span>{phone}</span>
</p>
</div>
<div>
<img src= {pic} alt = "closing portrait" width = "200" height = "200"></img>
<img src={pic} alt="closing portrait" width="200" height="200"></img>
</div>
<div className="spotifyplayer">
<a href={song.url} target="_blank" rel="noopener noreferrer" className="button btn spotify-btn"><i><img className="spotifypic" alt="album art" src={song.image} width="100" height="100"></img></i>
<h6>Song of the day: </h6> <p>{song.name} - {song.artist}</p></a>
</div>
<div className = "spotifyplayer">
<a href={song.url} target="_blank" rel="noopener noreferrer" className="button btn spotify-btn"><i><img className="spotifypic" alt = "album art" src={song.image} width="100" height="100"></img></i>
<h6>Song of the day: </h6> <p>{song.name} - {song.artist}</p></a>
</div>
</aside>
</div>
</section>
Expand Down
4 changes: 2 additions & 2 deletions server/resumeData.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"name":"Alex Wang",
"description":"I'm a student at the University of Pittsburgh planning to major in Computer Science and minor in Economics and Philosophy",
"image":"raven.JPG",
"bio":"I am looking for a Software Engineering internship position for Summer 2021 that will allow me to continue to further my technical and soft skills and gain some valuable work experience. When I am not coding or doing coursework, I spend my time either lifting, hiking, or cooking. ",
"bio":"I am looking for a Software Engineering internship or research position for Summer 2021 that will allow me to continue to further my technical and soft skills and gain some valuable work experience. When I am not coding or doing coursework, I spend my time either lifting, hiking, or cooking. ",
"contactmessage":"Send me a message, I'll get back to you within 24 hours",
"email": "[email protected] or [email protected]",
"email": "[email protected]",
"city": "Pittsburgh",
"state": "PA",
"phone": "724-986-8135",
Expand Down

0 comments on commit 36f9938

Please sign in to comment.