Skip to content

Commit c7a083d

Browse files
authored
Fix tree history (#118)
* Try with enabled * Try adding some logging * Interesting semantics * We are erroring out * We were not erroring out, thanks copilot * Remove unnecesary code * Add link to tree history from new thing * Remove console log
1 parent fda8e33 commit c7a083d

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/components/upload/Tos/New.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createOpenAlexTree } from "./createTree";
77
import { useMutation } from "@tanstack/react-query";
88
import { logEvent } from "firebase/analytics";
99
import { useState } from "react";
10-
import { useNavigate } from "react-router-dom";
10+
import { Link, useNavigate } from "react-router-dom";
1111

1212
const New = () => {
1313
const navigate = useNavigate();
@@ -22,7 +22,7 @@ const New = () => {
2222
});
2323

2424
return (
25-
<div>
25+
<div className="flex flex-col gap-8">
2626
<form
2727
className="flex flex-col gap-8"
2828
onSubmit={(e) => {
@@ -50,6 +50,14 @@ const New = () => {
5050
</button>
5151
</div>
5252
</form>
53+
<div className="flex flex-row items-center justify-center">
54+
<Link
55+
className="text-sky-600 hover:text-sky-800 active:text-sky-800"
56+
to="/history"
57+
>
58+
Tree History
59+
</Link>
60+
</div>
5361
</div>
5462
);
5563
};

src/components/upload/TreeHistory/hooks/useTrees.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const useTrees = (userId: string, max: number) => {
2525
const firebase = useFirebase();
2626
const [limit, setLimit] = useState(25);
2727
const query = useQuery({
28-
queryKey: ["trees", limit],
28+
queryKey: ["trees", userId, limit],
2929
queryFn: async () => {
3030
const query = getQuery(firebase.firestore, userId, limit);
3131
return (await getDocs(query)).docs;

src/components/upload/TreeHistory/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const TreeHistory = ({ userId }: Props) => {
3939

4040
if (!user) return "You must log in to see your history";
4141
if (!trees.query.data?.length) return "No trees found";
42+
if (trees.query.isError) return "There was an error loading your trees";
4243

4344
const data = sortBy(
4445
trees.query.data.map((doc) => {
@@ -57,7 +58,7 @@ const TreeHistory = ({ userId }: Props) => {
5758
<div className="flex flex-col gap-3">
5859
{user.plan === "basic" ? (
5960
<ul className="flex flex-col gap-2">
60-
<Items trees={data.slice(3)} />
61+
<Items trees={data.slice(0, 3)} />
6162
</ul>
6263
) : (
6364
<div className="flex flex-col gap-8">

0 commit comments

Comments
 (0)