-
Notifications
You must be signed in to change notification settings - Fork 91
final commit #91
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
Open
brodieheg
wants to merge
1
commit into
projectshft:main
Choose a base branch
from
brodieheg:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
final commit #91
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import PropTypes from 'prop-types'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
|
|
||
| const ContactRows = (props) => { | ||
| const contacts = props.contacts | ||
| const navigate = useNavigate(); | ||
|
|
||
| return ( | ||
| contacts.map ((contact) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice use of map |
||
| // Map through contacts array and create a table row for each one, complete with navigation on click // | ||
| const ContactView = (event) => { | ||
| navigate(`/${event.currentTarget.id}`)} | ||
| return ( | ||
| <tr onClick = {ContactView} key = {contact.id} id = {contact.id}> | ||
| <td><img alt = "contact" src = {contact.image_url}/></td> | ||
| <td>{contact.name}</td> | ||
| <td>{contact.email}</td> | ||
| <td>{contact.phone_number}</td> | ||
| </tr> | ||
| ) | ||
| })) | ||
| } | ||
|
|
||
| // PropTypes. | ||
| ContactRows.propTypes = { | ||
| contacts: PropTypes.array.isRequired | ||
| } | ||
|
|
||
| export default ContactRows | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import ContactRows from './contact-rows' | ||
| import { useNavigate } from 'react-router-dom' | ||
|
|
||
| const ContactTable = (props) => { | ||
| // New Contact form navigation | ||
| const navigate = useNavigate(); | ||
| const HandleClick = () => { | ||
| navigate("/new") | ||
| } | ||
|
|
||
| return ( | ||
| <div className = "col-md-8 offset-2"> | ||
| <h1 className='mt-4 h1 text-center'>Contact List</h1> | ||
| <table className="mt-3 table"> | ||
| <thead> | ||
| <tr> | ||
| <th className = "text-center" >Profile Pic</th> | ||
| <th className = "text-center" >Name</th> | ||
| <th className = "text-center" >Email</th> | ||
| <th className = "text-center" >Phone Number</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <ContactRows contacts = {props.contacts}/> | ||
| </tbody> | ||
| </table> | ||
| <button className='btn btn-primary' onClick={HandleClick}> New Contact </button> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default ContactTable; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { useNavigate } from "react-router-dom"; | ||
| const ContactView = (props) => { | ||
|
|
||
| // Find contact from state using current URL | ||
| const contactId = window.location.pathname.replace(/\//, ''); | ||
| const contact = props.contacts.find(contact => contact.id == contactId); | ||
|
|
||
| // Navigation back to contact list | ||
| const navigate = useNavigate(); | ||
| const handleBackSubmit = () => { | ||
| navigate('/'); | ||
| } | ||
|
|
||
| return ( | ||
| <div> | ||
| <h1> {contact.name}</h1> | ||
| <img src = {contact.image_url}></img> | ||
| <h3> Phone Number: {contact.phone_number}</h3> | ||
| <h3> Email: {contact.email}</h3> | ||
| <button onClick = {handleBackSubmit} className="btn btn-primary">Back</button> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default ContactView; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,18 @@ | ||
| body { | ||
| margin: 0; | ||
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
| 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
| font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", | ||
| "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", | ||
| sans-serif; | ||
| -webkit-font-smoothing: antialiased; | ||
| -moz-osx-font-smoothing: grayscale; | ||
| } | ||
|
|
||
| code { | ||
| font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
| font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", | ||
| monospace; | ||
| } | ||
|
|
||
| tr:hover td { | ||
| background: gainsboro; | ||
| cursor: pointer; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,13 @@ | ||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom'; | ||
| import { BrowserRouter } from "react-router-dom"; | ||
| import ReactDOM from 'react-dom/client'; | ||
| import 'bootstrap/dist/css/bootstrap.min.css'; | ||
| import './index.css'; | ||
| import App from './App'; | ||
| import reportWebVitals from './reportWebVitals'; | ||
|
|
||
| ReactDOM.render( | ||
| <React.StrictMode> | ||
| const root = ReactDOM.createRoot(document.getElementById('root')); | ||
| root.render( | ||
| <BrowserRouter> | ||
| <App /> | ||
| </React.StrictMode>, | ||
| document.getElementById('root') | ||
| ); | ||
|
|
||
| // If you want to start measuring performance in your app, pass a function | ||
| // to log results (for example: reportWebVitals(console.log)) | ||
| // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | ||
| reportWebVitals(); | ||
| </BrowserRouter> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
|
|
||
| const NewContact = (props) => { | ||
|
|
||
| // New Contact form: all fields are required, according to type. | ||
|
|
||
| return ( | ||
| <form onSubmit = {props.HandleNewContactSubmit} className = "col-md-4 offset-md-4"> | ||
| <h3>Add Contact</h3> | ||
| <span> | ||
| <input required name = "name" type="name" className="form-control" id="InputName" placeholder="Name"/> | ||
| <input required name = "email" type="email" className="form-control" id="InputEmail1" placeholder="Email"/> | ||
| <input required name = "phoneNumber" type="tel" className="form-control" id="InputPhoneNumber" placeholder="Phone Number"/> | ||
| <input required name = "url" type="url" className="form-control" id="InputImageUrl" placeholder="Image Url"/> | ||
| </span> | ||
| <button type="submit" className="btn btn-primary">Add Contact</button> | ||
| </form> | ||
| ) | ||
| } | ||
|
|
||
| export default NewContact |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing semi-colon at end of line