From 9130751af335840d77c6b3c85e2dd2873fe63d9f Mon Sep 17 00:00:00 2001 From: martin machiebe Date: Tue, 6 Aug 2024 08:24:53 +0100 Subject: [PATCH 1/4] fixed quest issues, takes you back to collection instead of main quest --- app/categories/[category]/category.tsx | 19 ++++++++++++++++--- .../pages/home/questAndCollectionTabs.tsx | 5 ++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/categories/[category]/category.tsx b/app/categories/[category]/category.tsx index ad1998d8..efd77875 100644 --- a/app/categories/[category]/category.tsx +++ b/app/categories/[category]/category.tsx @@ -24,7 +24,6 @@ type CategoryPageProps = { const Category: FunctionComponent = ({ categoryName }) => { const router = useRouter(); const { categories } = useContext(QuestsContext); - const [category, setCategory] = useState(); useEffect(() => { @@ -32,15 +31,29 @@ const Category: FunctionComponent = ({ categoryName }) => { setCategory(categories.find((cat) => cat.name === categoryName)); }, [categories, categoryName]); + const handleBack = () => { + const activeTab = localStorage.getItem("activeTab"); + if (activeTab) { + const tabRoutes = ["/", "/", "/"]; + router.push(tabRoutes[parseInt(activeTab, 10)]); + } else { + router.back(); + } + }; + return (
- router.back()} /> +
- + {(categoryName as string)?.charAt(0)?.toUpperCase() + categoryName?.slice(1)}{" "} quests diff --git a/components/pages/home/questAndCollectionTabs.tsx b/components/pages/home/questAndCollectionTabs.tsx index d73434f0..9f9f0c32 100644 --- a/components/pages/home/questAndCollectionTabs.tsx +++ b/components/pages/home/questAndCollectionTabs.tsx @@ -38,12 +38,15 @@ const QuestAndCollectionTabs: FunctionComponent< > = ({ quests, trendingQuests, categories }) => { const router = useRouter(); const { address, isConnecting } = useAccount(); - const [tabIndex, setTabIndex] = React.useState(0); + const [tabIndex, setTabIndex] = useState( + parseInt(localStorage.getItem("activeTab") || "0", 10) + ); const { getBoostClaimStatus } = useBoost(); const handleChangeTab = useCallback( (event: React.SyntheticEvent, newValue: number) => { setTabIndex(newValue); + localStorage.setItem("activeTab", newValue.toString()); }, [] ); From 5c7ffae90055f4d5b56f10fc9392dd4375729f87 Mon Sep 17 00:00:00 2001 From: martin machiebe Date: Tue, 6 Aug 2024 08:29:16 +0100 Subject: [PATCH 2/4] Revert "fixed quest issues, takes you back to collection instead of main quest" This reverts commit 9130751af335840d77c6b3c85e2dd2873fe63d9f. --- app/categories/[category]/category.tsx | 19 +++---------------- .../pages/home/questAndCollectionTabs.tsx | 5 +---- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/app/categories/[category]/category.tsx b/app/categories/[category]/category.tsx index efd77875..ad1998d8 100644 --- a/app/categories/[category]/category.tsx +++ b/app/categories/[category]/category.tsx @@ -24,6 +24,7 @@ type CategoryPageProps = { const Category: FunctionComponent = ({ categoryName }) => { const router = useRouter(); const { categories } = useContext(QuestsContext); + const [category, setCategory] = useState(); useEffect(() => { @@ -31,29 +32,15 @@ const Category: FunctionComponent = ({ categoryName }) => { setCategory(categories.find((cat) => cat.name === categoryName)); }, [categories, categoryName]); - const handleBack = () => { - const activeTab = localStorage.getItem("activeTab"); - if (activeTab) { - const tabRoutes = ["/", "/", "/"]; - router.push(tabRoutes[parseInt(activeTab, 10)]); - } else { - router.back(); - } - }; - return (
- + router.back()} />
- + {(categoryName as string)?.charAt(0)?.toUpperCase() + categoryName?.slice(1)}{" "} quests diff --git a/components/pages/home/questAndCollectionTabs.tsx b/components/pages/home/questAndCollectionTabs.tsx index 9f9f0c32..d73434f0 100644 --- a/components/pages/home/questAndCollectionTabs.tsx +++ b/components/pages/home/questAndCollectionTabs.tsx @@ -38,15 +38,12 @@ const QuestAndCollectionTabs: FunctionComponent< > = ({ quests, trendingQuests, categories }) => { const router = useRouter(); const { address, isConnecting } = useAccount(); - const [tabIndex, setTabIndex] = useState( - parseInt(localStorage.getItem("activeTab") || "0", 10) - ); + const [tabIndex, setTabIndex] = React.useState(0); const { getBoostClaimStatus } = useBoost(); const handleChangeTab = useCallback( (event: React.SyntheticEvent, newValue: number) => { setTabIndex(newValue); - localStorage.setItem("activeTab", newValue.toString()); }, [] ); From 4bcb58ab4d26d82b1a1698b240a32ed8db960773 Mon Sep 17 00:00:00 2001 From: martin machiebe Date: Tue, 6 Aug 2024 08:42:31 +0100 Subject: [PATCH 3/4] fixed quest issues, takes you back to collection instead of main quest --- app/categories/[category]/category.tsx | 19 ++++++++++++++++--- .../pages/home/questAndCollectionTabs.tsx | 5 ++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/categories/[category]/category.tsx b/app/categories/[category]/category.tsx index ad1998d8..efd77875 100644 --- a/app/categories/[category]/category.tsx +++ b/app/categories/[category]/category.tsx @@ -24,7 +24,6 @@ type CategoryPageProps = { const Category: FunctionComponent = ({ categoryName }) => { const router = useRouter(); const { categories } = useContext(QuestsContext); - const [category, setCategory] = useState(); useEffect(() => { @@ -32,15 +31,29 @@ const Category: FunctionComponent = ({ categoryName }) => { setCategory(categories.find((cat) => cat.name === categoryName)); }, [categories, categoryName]); + const handleBack = () => { + const activeTab = localStorage.getItem("activeTab"); + if (activeTab) { + const tabRoutes = ["/", "/", "/"]; + router.push(tabRoutes[parseInt(activeTab, 10)]); + } else { + router.back(); + } + }; + return (
- router.back()} /> +
- + {(categoryName as string)?.charAt(0)?.toUpperCase() + categoryName?.slice(1)}{" "} quests diff --git a/components/pages/home/questAndCollectionTabs.tsx b/components/pages/home/questAndCollectionTabs.tsx index d73434f0..9f9f0c32 100644 --- a/components/pages/home/questAndCollectionTabs.tsx +++ b/components/pages/home/questAndCollectionTabs.tsx @@ -38,12 +38,15 @@ const QuestAndCollectionTabs: FunctionComponent< > = ({ quests, trendingQuests, categories }) => { const router = useRouter(); const { address, isConnecting } = useAccount(); - const [tabIndex, setTabIndex] = React.useState(0); + const [tabIndex, setTabIndex] = useState( + parseInt(localStorage.getItem("activeTab") || "0", 10) + ); const { getBoostClaimStatus } = useBoost(); const handleChangeTab = useCallback( (event: React.SyntheticEvent, newValue: number) => { setTabIndex(newValue); + localStorage.setItem("activeTab", newValue.toString()); }, [] ); From 99d9a742a4f30bf1ad77335193f953b6f041fea5 Mon Sep 17 00:00:00 2001 From: martin machiebe Date: Tue, 6 Aug 2024 18:45:48 +0100 Subject: [PATCH 4/4] improved code --- app/categories/[category]/category.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/categories/[category]/category.tsx b/app/categories/[category]/category.tsx index efd77875..e97114df 100644 --- a/app/categories/[category]/category.tsx +++ b/app/categories/[category]/category.tsx @@ -31,10 +31,11 @@ const Category: FunctionComponent = ({ categoryName }) => { setCategory(categories.find((cat) => cat.name === categoryName)); }, [categories, categoryName]); + const tabRoutes = ["/", "/", "/"]; + const handleBack = () => { const activeTab = localStorage.getItem("activeTab"); if (activeTab) { - const tabRoutes = ["/", "/", "/"]; router.push(tabRoutes[parseInt(activeTab, 10)]); } else { router.back();