Skip to content
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

Updates to the index section #317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ order: 22

# Navigation Buttons

Let's update the sign in and sign up buttons/links to only display if the user
is **not logged in**
Let's update the sign-in and sign-up buttons/links to only display if the user
is **not logged in**.

```jsx
{
Expand All @@ -19,10 +19,10 @@ is **not logged in**
}
```

Here we test if the user is logged in, and if they are **not** then we show the
Here we test if the user is logged in, and if they are **not**, then we show the
`<Link>`. This works since `isLoggedIn()` returns either `true` or `false` -- If
the value is `false`, JavaScript will interpret and return the second part of
the boolean logic, which is the `<Link>` -- If the value is `true` JavaScript
the boolean logic, which is the `<Link>` -- If the value is `true`, JavaScript
renders that. React renders a value of `true` as nothing. This code effectively
only shows the links if the user is **not** logged in.

Expand Down Expand Up @@ -57,25 +57,25 @@ function handleLogout() {
}
```

Now let's only show the avatar, welcome message, and create new restaurant if
Now let's only show the avatar, welcome message, and create a new restaurant if
the user is logged in.

To determine the user, we'll add a call to `getUser` from `auth.js`
To determine the user, we'll add a call to `getUser` from `auth.js`.

```javascript
const user = getUser()
```

and then we can use that in place of the user's hardcoded name:
And then we can use that in place of the user's hardcoded name:

```jsx
{
isLoggedIn() ? <p>Welcome back, {user.fullName}!</p> : null
}
```

We haven't added an avatar image upload for the user, so we'll leave this hard
coded for the moment.
We haven't added an avatar image upload for the user, so we'll leave this
hardcoded for the moment.

```jsx
{
Expand All @@ -102,8 +102,8 @@ And to update the add new restaurant button:
# Hide the "New Review" form unless logged in

We will wrap the `<h3>` and the `<form>` in a fragment tag to place them in a
group. We then use a ternary operator with `isLoggedIn()` that will show that
JSX for logged-in users.
group. We then use a ternary operator with `isLoggedIn()` that will show JSX for
logged-in users.

```jsx
{
Expand Down