Skip to content

Commit

Permalink
Merge pull request #6 from khanghy2130/profile-route
Browse files Browse the repository at this point in the history
Profile route
  • Loading branch information
khanghy2130 authored Mar 18, 2024
2 parents 1f86d51 + a294401 commit 3a3b845
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 31 deletions.
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);
});
});

0 comments on commit 3a3b845

Please sign in to comment.