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

Semantic update to userAddress auth-context state value #282

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/app/components/BurgerMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function BurgerMenu() {
onStateChange={state => handleStateChange(state)}
closeMenu={closeMenu}
>
{userAddress === "none" ? (
{userAddress === undefined ? (
<NavLink
onClick={() => closeMenu()}
to={"/join"}
Expand All @@ -35,7 +35,7 @@ export default function BurgerMenu() {
</NavLink>
) : null}

{userAddress === "none" ? (
{userAddress === undefined ? (
<NavLink onClick={() => closeMenu()} to={"/login"}>
LOG IN
</NavLink>
Expand Down Expand Up @@ -64,7 +64,7 @@ export default function BurgerMenu() {
</a>
</div>

{userAddress !== "none" ? (
{userAddress ? (
<NavLink onClick={() => closeMenu()} to={`/profile/${userAddress}`}>
<img className="app__nav__icon" src={IconUser} alt="icon"></img>
MY PROFILE
Expand Down
9 changes: 4 additions & 5 deletions src/app/components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function NavBar(props) {

<div className="nav-bar__route-link-wrapper">
{/* // Welcome button only rendered when user is logged out */}
{userAddress !== "none" ? null : (
{userAddress ? null : (
<div
className={
path === "/"
Expand Down Expand Up @@ -67,7 +67,7 @@ function NavBar(props) {
</div>

{/* // My Profile button only rendered when user is logged in */}
{userAddress !== "none" ? (
{userAddress ? (
<div
className={
path === `/profile/${userAddress}`
Expand Down Expand Up @@ -154,10 +154,9 @@ function NavBar(props) {
</NavLink>
</div>
</div>

<div>
{/* Show Join button when user is not logged in */}
{userAddress === "none" ? (
{/* Show Login and Join buttons when user is not logged in */}
{userAddress === undefined ? (
<Fragment>
<NavLink className="app__nav-link nav-bar__log-in-text" to="/login">
<img className="app__nav__icon" src={IconUser} alt="icon"></img>
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function AuthProvider({ children }) {
const [state, dispatch] = React.useReducer(authReducer, {
isAuthenticating: false,
authType: "",
userAddress: "none",
userAddress: undefined,
authExpiry: ""
});

Expand Down
6 changes: 3 additions & 3 deletions src/submissions/components/MultipleObservationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function MultipleObservationForm() {

return (
<Fragment>
{userAddress === "none" ? (
{userAddress === undefined ? (
<p className="app__error-message">
You need to be logged in to submit your observations.
</p>
Expand Down Expand Up @@ -135,7 +135,7 @@ export default function MultipleObservationForm() {
</span>
</NavLink>

{userAddress === "none" ? null : (
{userAddress === undefined ? null : (
<button
type="submit"
className="submit__submit-button"
Expand All @@ -145,7 +145,7 @@ export default function MultipleObservationForm() {
</button>
)}
</div>
{userAddress === "none" ? null : (
{userAddress === undefined ? null : (
<p className="submit__submit-warning">
Please keep in mind that this data will be automatically
recorded into TruSat's catalog of orbital positions, and
Expand Down
8 changes: 4 additions & 4 deletions src/submissions/components/SingleObservationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function SingleObservationForm() {
}
};
// only do fetch if form does not already have their stations and user is logged in
if (userAddress !== "none" && observationStations === "") {
if (userAddress && observationStations === "") {
fetchObservationStations();
}
}, [userAddress, observationStations]);
Expand Down Expand Up @@ -494,7 +494,7 @@ export default function SingleObservationForm() {

return (
<Fragment>
{userAddress === "none" ? (
{userAddress === undefined ? (
<p className="app__error-message">
You need to be logged in to submit your observations.
</p>
Expand Down Expand Up @@ -1346,7 +1346,7 @@ export default function SingleObservationForm() {
</span>
</NavLink>

{userAddress === "none" ? null : (
{userAddress === undefined ? null : (
<button
className="submit__submit-button"
style={
Expand All @@ -1357,7 +1357,7 @@ export default function SingleObservationForm() {
</button>
)}
</div>
{userAddress === "none" ? null : (
{userAddress === undefined ? null : (
<p className="submit__submit-warning">
Please keep in mind that this data will be automatically
recorded into TruSat's catalog of orbital positions, and
Expand Down
4 changes: 2 additions & 2 deletions src/views/AccountSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function UserSettings({ history }) {
setIsLoading(false);
};

if (userAddress !== "none" && userAddress) {
if (userAddress !== undefined && userAddress) {
doFetch();
}
}, [userAddress, authExpiry, profileDispatch]);
Expand Down Expand Up @@ -121,7 +121,7 @@ function UserSettings({ history }) {
</p>
) : isLoading ? (
<Spinner />
) : userAddress === "none" ? (
) : userAddress === undefined ? (
<div className="app__error-message">
You need to login{" "}
<NavLink className="app__nav-link app__link" to="/login">
Expand Down
4 changes: 2 additions & 2 deletions src/views/AddStation.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function AddStation() {
<div className="add-station">
<h1 className="static-page__main-header--small">Add a location</h1>
{/* Prompt user to log in so they can create a station */}
{userAddress === "none" ? (
{userAddress === undefined ? (
<p className="app__error-message">
You need to be logged in to add a station location.
</p>
Expand Down Expand Up @@ -199,7 +199,7 @@ export default function AddStation() {
) : (
<Fragment>
{/* Only render button to submit form if user is logged in */}
{userAddress === "none" ? null : (
{userAddress === undefined ? null : (
<button type="submit" className="station-form__button">
Add station
</button>
Expand Down
4 changes: 2 additions & 2 deletions src/views/LogIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export default function LogIn() {
return (
<div className="log-in__wrapper">
<h1 className="log-in__header">
{userAddress !== "none" ? "You're logged in" : "Log in"}
{userAddress ? "You're logged in" : "Log in"}
</h1>
{userAddress !== "none" ? (
{userAddress ? (
<div className="login__success-wrapper">
<NavLink className="app__nav-link" to={`/profile/${userAddress}`}>
<span className="app__button--white">Go to Profile</span>
Expand Down
4 changes: 2 additions & 2 deletions src/views/SignUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export default function SignUp() {
return (
<div className="sign-up__wrapper">
<h1 className="sign-up__header">
{userAddress !== "none" ? "YOU'RE IN" : "Sign Up"}
{userAddress !== undefined ? "YOU'RE IN" : "Sign Up"}
</h1>
{userAddress !== "none" ? (
{userAddress !== undefined ? (
<div className="login__success-wrapper">
<NavLink className="app__nav-link" to={`/profile/${userAddress}`}>
<span className="app__button--white">Go to Profile</span>
Expand Down