forked from b00tc4mp/isdi-bootcamp-202409
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f1ec40
commit f846569
Showing
18 changed files
with
211 additions
and
282 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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 +1 @@ | ||
[{"id":"m34nya7bwg","image":"https://www.alltrails.com/_next/image?url=https%3A%2F%2Fimages.alltrails.com%2FeyJidWNrZXQiOiJhc3NldHMuYWxsdHJhaWxzLmNvbSIsImtleSI6InVwbG9hZHMvcGhvdG8vaW1hZ2UvNjM0MDYyOTUvOWU5NWZhNDcyNzc0YjcxMGJiNTI3NTVjZGZhZmVkZWIuanBnIiwiZWRpdHMiOnsidG9Gb3JtYXQiOiJ3ZWJwIiwicmVzaXplIjp7IndpZHRoIjoxMDgwLCJoZWlnaHQiOjcwMCwiZml0IjoiY292ZXIifSwicm90YXRlIjpudWxsLCJqcGVnIjp7InRyZWxsaXNRdWFudGlzYXRpb24iOnRydWUsIm92ZXJzaG9vdERlcmluZ2luZyI6dHJ1ZSwib3B0aW1pc2VTY2FucyI6dHJ1ZSwicXVhbnRpc2F0aW9uVGFibGUiOjN9fX0%3D&w=3840&q=90","text":"Yo he estado en ese lago","author":"m34apnqkwjc","date":"2024-11-05T16:27:32.519Z","likes":["m2w6ehc8bg"],"comments":[{"id":"m34nzupejfl","author":"m2w6ehc8bg","text":"De k vas flipao","date":"2024-11-05T16:28:45.746Z"}],"saves":[]},{"id":"m34nzmywn5f","image":"https://a1.elespanol.com/metropoliabierta/2022/03/12/el-pulso-de-la-ciudad/656694325_9262068_1706x960.jpg","text":"Yo vengo del barri","author":"m2w6ehc8bg","date":"2024-11-05T16:28:35.720Z","likes":[],"comments":[],"saves":[]}] | ||
[{"id":"m34nya7bwg","image":"https://www.alltrails.com/_next/image?url=https%3A%2F%2Fimages.alltrails.com%2FeyJidWNrZXQiOiJhc3NldHMuYWxsdHJhaWxzLmNvbSIsImtleSI6InVwbG9hZHMvcGhvdG8vaW1hZ2UvNjM0MDYyOTUvOWU5NWZhNDcyNzc0YjcxMGJiNTI3NTVjZGZhZmVkZWIuanBnIiwiZWRpdHMiOnsidG9Gb3JtYXQiOiJ3ZWJwIiwicmVzaXplIjp7IndpZHRoIjoxMDgwLCJoZWlnaHQiOjcwMCwiZml0IjoiY292ZXIifSwicm90YXRlIjpudWxsLCJqcGVnIjp7InRyZWxsaXNRdWFudGlzYXRpb24iOnRydWUsIm92ZXJzaG9vdERlcmluZ2luZyI6dHJ1ZSwib3B0aW1pc2VTY2FucyI6dHJ1ZSwicXVhbnRpc2F0aW9uVGFibGUiOjN9fX0%3D&w=3840&q=90","text":"Yo he estado en ese lago","author":"m34apnqkwjc","date":"2024-11-05T16:27:32.519Z","likes":["m2w6ehc8bg","m34apnqkwjc"],"comments":[{"id":"m34nzupejfl","author":"m2w6ehc8bg","text":"De k vas flipao","date":"2024-11-05T16:28:45.746Z"}],"saves":[]},{"id":"m34nzmywn5f","image":"https://a1.elespanol.com/metropoliabierta/2022/03/12/el-pulso-de-la-ciudad/656694325_9262068_1706x960.jpg","text":"Yo vengo del barri","author":"m2w6ehc8bg","date":"2024-11-05T16:28:35.720Z","likes":["m34apnqkwjc"],"comments":[],"saves":[]},{"id":"m35u1jifjz","image":"https://images.travelandleisureasia.com/wp-content/uploads/sites/3/2024/02/29031558/Bergen.jpg","text":"A winter in Norway","author":"m34apnqkwjc","date":"2024-11-06T12:05:48.423Z","likes":["m34apnqkwjc"],"comments":[{"id":"m35u1pbt0lu","author":"m34apnqkwjc","text":"Woooowwwww","date":"2024-11-06T12:05:55.961Z"}],"saves":["m34apnqkwjc"]}] |
This file contains 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 +1 @@ | ||
[{"id":"m2w6ehc8bg","name":"Pepito Grillo","email":"[email protected]","username":"pepitogrillo","password":"123123123"},{"id":"m2x9gwhcj9","name":"Pin Otto","email":"[email protected]","username":"pinotto","password":"123123123"},{"id":"m333adaqub","name":"Javi","email":"[email protected]","username":"javi","password":"123123123"},{"id":"m334sfuvens","name":"Aaron","email":"[email protected]","username":"aaron","password":"123123123"},{"id":"m33a9ffghob","name":"Pepita Grillo","email":"[email protected]","username":"pepitagrillo","password":"123123123"},{"id":"m34apnqkwjc","name":"Peter","email":"[email protected]","username":"peterpan","password":"123123123"}] | ||
[{"id":"m2w6ehc8bg","name":"Pepito Grillo","email":"[email protected]","username":"pepitogrillo","password":"123123123"},{"id":"m2x9gwhcj9","name":"Pin Otto","email":"[email protected]","username":"pinotto","password":"123123123"},{"id":"m333adaqub","name":"Javi","email":"[email protected]","username":"javi","password":"123123123"},{"id":"m334sfuvens","name":"Aaron","email":"[email protected]","username":"aaron","password":"123123123"},{"id":"m33a9ffghob","name":"Pepita Grillo","email":"[email protected]","username":"pepitagrillo","password":"123123123"},{"id":"m34apnqkwjc","name":"Peter","email":"[email protected]","username":"peterpan","password":"123123123"},{"id":"m360g4wlpds","name":"Aleix","email":"[email protected]","username":"aleix","password":"123123123"}] |
This file contains 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 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 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 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
75 changes: 34 additions & 41 deletions
75
staff/anna-gonzalez/unsocial/app/src/components/functional/Header.jsx
This file contains 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,69 +1,62 @@ | ||
import { Component } from 'react' | ||
import { useState, useEffect } from 'react' | ||
|
||
import { Button, Anchor } from '../library' | ||
|
||
import logic from '../../logic' | ||
|
||
import './Header.css' | ||
|
||
export default class extends Component { | ||
constructor(props) { | ||
console.log('Header -> constructor') | ||
export default function Header({ view, onHomeClick, onLoggedOut }) { | ||
const [name, setName] = useState(null) | ||
|
||
super(props) | ||
useEffect(() => { | ||
console.log('Header -> componentDidMount & componentWillReceiveProps') | ||
|
||
this.state = { name: null } | ||
} | ||
|
||
componentDidMount() { | ||
console.log('Header -> componentDidMount') | ||
if (logic.isUserLoggedIn()) { | ||
if (!name) | ||
try { | ||
logic.getUserName((error, name) => { | ||
if (error) { | ||
alert(error.message) | ||
|
||
if (logic.isUserLoggedIn()) | ||
try { | ||
logic.getUserName((error, name) => { | ||
if (error) { | ||
alert(error.message) | ||
console.error(error) | ||
|
||
console.error(error) | ||
return | ||
} | ||
|
||
return | ||
} | ||
setName(name) | ||
}) | ||
} catch (error) { | ||
alert(error.message) | ||
|
||
this.setState({ name }) | ||
}) | ||
} catch (error) { | ||
alert(error.message) | ||
console.error(error) | ||
} | ||
} else setName(null) | ||
}, [view]) | ||
|
||
console.error(error) | ||
} | ||
|
||
} | ||
|
||
handleHomeClick = event => { | ||
const handleHomeClick = event => { | ||
event.preventDefault() | ||
|
||
this.props.onHomeClick() | ||
onHomeClick() | ||
} | ||
|
||
handleLogout = () => { | ||
const handleLogout = () => { | ||
if (confirm('Logout?')) { | ||
logic.logoutUser() | ||
|
||
this.props.onLoggedOut() | ||
onLoggedOut() | ||
} | ||
} | ||
|
||
render() { | ||
return <header className={`Header ${this.props.view !== 'posts' && this.props.view !== 'new-post' ? 'Header--transparent' : ''}`}> | ||
return <header className={`Header ${view !== 'posts' && view !== 'new-post' ? 'Header--transparent' : ''}`}> | ||
|
||
<h1>{this.props.view === 'new-post' ? <Anchor className="header-anchor" href="" | ||
onClick={this.handleHomeClick}>UNSOCIAL</Anchor> : 'UNSOCIAL'}</h1> | ||
<h1>{view === 'new-post' ? <Anchor className="header-anchor" href="" | ||
onClick={handleHomeClick}>UNSOCIAL</Anchor> : 'UNSOCIAL'}</h1> | ||
|
||
{this.state.name && <h3>{this.state.name}</h3>} | ||
{logic.isUserLoggedIn() && <h3>{name}</h3>} | ||
|
||
{logic.isUserLoggedIn() && <Button className="header-button" type="button" | ||
onClick={this.handleLogout}>Logout</Button> | ||
} | ||
</header > | ||
} | ||
{logic.isUserLoggedIn() && <Button className="header-button" type="button" | ||
onClick={handleLogout}>Logout</Button> | ||
} | ||
</header > | ||
} |
Oops, something went wrong.