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

fix: back button works on Collection quest #806

Closed
wants to merge 4 commits into from
Closed
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
20 changes: 17 additions & 3 deletions app/categories/[category]/category.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,37 @@ type CategoryPageProps = {
const Category: FunctionComponent<CategoryPageProps> = ({ categoryName }) => {
const router = useRouter();
const { categories } = useContext(QuestsContext);

const [category, setCategory] = useState<QuestCategory | undefined>();

useEffect(() => {
if (!categoryName) return;
setCategory(categories.find((cat) => cat.name === categoryName));
}, [categories, categoryName]);

const tabRoutes = ["/", "/", "/"];

const handleBack = () => {
const activeTab = localStorage.getItem("activeTab");
if (activeTab) {
router.push(tabRoutes[parseInt(activeTab, 10)]);
} else {
router.back();
}
};

return (
<div className={styles.screen}>
<div className={homeStyles.blur1}>
<Blur />
</div>
<div className={styles.backButton}>
<BackButton onClick={() => router.back()} />
<BackButton onClick={handleBack} />
</div>
<Typography type={TEXT_TYPE.H1} className={homeStyles.title} color="transparent">
<Typography
type={TEXT_TYPE.H1}
className={homeStyles.title}
color="transparent"
>
{(categoryName as string)?.charAt(0)?.toUpperCase() +
categoryName?.slice(1)}{" "}
quests
Expand Down
5 changes: 4 additions & 1 deletion components/pages/home/questAndCollectionTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
},
[]
);
Expand Down