aboutsummaryrefslogtreecommitdiffstats
path: root/apps/browser-extension/src/Layout.tsx
blob: f8279a185a66d6d2c80d02384fd49565ef92d09a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Outlet } from "react-router-dom";
import { Home, RefreshCw, Settings, X } from "lucide-react";
import { useNavigate } from "react-router-dom";
import usePluginSettings from "./utils/settings";

export default function Layout() {
  const navigate = useNavigate();
  const { settings, isPending: isInit } = usePluginSettings();
  if (!isInit) {
    return <div className="p-4">Loading ... </div>;
  }

  if (!settings.apiKey || !settings.address) {
    navigate("/notconfigured");
    return;
  }

  return (
    <div className="flex flex-col space-y-2">
      <div className="rounded-md bg-yellow-100 p-4">
        <Outlet />
      </div>
      <hr />
      <div className="flex justify-between space-x-3">
        <div className="my-auto">
          <a
            className="flex gap-2 text-black"
            target="_blank"
            href={`${settings.address}/dashboard/bookmarks`}
          >
            <Home />
            <span className="text-md my-auto">Bookmarks</span>
          </a>
        </div>
        <div className="flex space-x-3">
          {process.env.NODE_ENV == "development" && (
            <button onClick={() => navigate(0)}>
              <RefreshCw className="w-4" />
            </button>
          )}
          <button onClick={() => navigate("/options")}>
            <Settings className="w-4" />
          </button>
          <button onClick={() => window.close()}>
            <X className="w-4" />
          </button>
        </div>
      </div>
    </div>
  );
}