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

feat: add back button in setup screen #337

Merged
merged 3 commits into from
Jul 25, 2024
Merged
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
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
Loading