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

Profile route #6

Merged
merged 3 commits into from
Mar 18, 2024
Merged
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
2 changes: 1 addition & 1 deletion app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function App() {
revalidator.revalidate();
// handle events
if (event === "INITIAL_SESSION") {
if (session?.user) setUser(session.user);
setUser(session?.user);
} else if (event === "SIGNED_IN") {
setUser(session?.user);
} else if (event === "SIGNED_OUT") {
Expand Down
10 changes: 4 additions & 6 deletions app/routes/$.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// 404 route


export default function SplatRoute(){
return <div>
404 Not Found!!
</div>
}
export default function SplatRoute() {
return <div>404 Not Found!!</div>;
}
14 changes: 1 addition & 13 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,9 @@ export const meta: MetaFunction = () => {
};

export default function Index() {
const [isDone, setIsDone] = useState(false);
const headingClicked = () => setIsDone(true);

return (
<div>
<h1
className="text-5xl text-color-2 hover:line-through"
onClick={headingClicked}
>
{isDone ? "done" : "click here"}
</h1>

{Array.from(Array(50)).map((item, index) => (
<p key={index}>{index}</p>
))}
<h1 className="text-5xl text-color-2">Landing page</h1>
</div>
);
}
30 changes: 30 additions & 0 deletions app/routes/profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Link, useOutletContext } from "@remix-run/react";
import { ContextProps } from "~/utils/types/ContextProps.type";

export default function Profile() {
const { supabase, user } = useOutletContext<ContextProps>();

// unauthenticated render
if (!user) {
return (
<div>
<h1>Log in to see your profile.</h1>
<Link to="/login">
<button className="btn">Login</button>
</Link>
</div>
);
}

// authenticated render
return (
<div>
<h1 className="text-3xl">
My Profile (no one else can see my profile)
</h1>
<p>UUID: {user.id}</p>
<p>Name: {user.user_metadata.full_name}</p>
<p>Email: {user.user_metadata.email}</p>
</div>
);
}
9 changes: 0 additions & 9 deletions app/routes/user.$id.tsx

This file was deleted.

8 changes: 6 additions & 2 deletions app/tests/somefile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { render, screen } from "@testing-library/react";
import { userEvent } from "@testing-library/user-event";
import "@testing-library/jest-dom";

import Index from "../routes/_index";
// import Index from "../routes/_index";

describe("App", () => {
it("clicks to change text", async () => {
it("dummy test", async () => {
/*
// ARRANGE
render(<Index />);

Expand All @@ -16,5 +17,8 @@ describe("App", () => {

// ASSERT
expect(screen.getByRole("heading")).toHaveTextContent("done");
*/

expect(1 + 2).toBe(3);
});
});
Loading