Skip to content

Commit

Permalink
feat: add back button in setup screen (#337)
Browse files Browse the repository at this point in the history
* feat: add back button in setup screen

* fix: whitelist setup pages for back button

* fix: use standard conditional react rather than css hidden

---------

Co-authored-by: Roland Bewick <roland.bewick@gmail.com>
  • Loading branch information
im-adithya and rolznz authored Jul 25, 2024
1 parent b86c39d commit e136b23
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions frontend/src/components/layouts/TwoColumnFullScreenLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ChevronLeft } from "lucide-react";
import { useEffect, useState } from "react";
import { Outlet, useLocation } from "react-router-dom";
import { Outlet, useLocation, useNavigate } from "react-router-dom";
import { Button } from "src/components/ui/button.tsx";
import { useInfo } from "src/hooks/useInfo";

const quotes = [
Expand Down Expand Up @@ -51,6 +53,7 @@ const quotes = [

export default function TwoColumnFullScreenLayout() {
const { data: info } = useInfo();
const navigate = useNavigate();
const { pathname } = useLocation();
const [quote, setQuote] = useState(
quotes[Math.floor(Math.random() * quotes.length)]
Expand Down Expand Up @@ -84,7 +87,22 @@ export default function TwoColumnFullScreenLayout() {
</div>
</div>
</div>
<div className="flex items-center justify-center py-12 text-foreground">
<div className="flex items-center justify-center py-12 text-foreground relative">
{pathname.startsWith("/setup") &&
!pathname.startsWith("/setup/finish") && (
// show the back button on setup pages, except the setup finish page
<Button
type="button"
variant="secondary"
onClick={() => {
navigate(-1);
}}
className="top-4 left-4 md:top-10 md:left-10 absolute mr-4"
>
<ChevronLeft className="w-4 h-4 mr-2" />
Back
</Button>
)}
<Outlet />
</div>
</div>
Expand Down

0 comments on commit e136b23

Please sign in to comment.