import "./App.css";
import { open } from "@tauri-apps/plugin-shell";
import { useState, ReactElement } from "react";
import { useStore } from "@/state/store";
import { Toaster } from "@/components/ui/toaster";
import { KeyRoundIcon } from "lucide-react";
import { Icon } from "@iconify/react";
import Home from "./pages/Home.tsx";
import History from "./pages/History.tsx";
import Dotfiles from "./pages/Dotfiles.tsx";
import LoginOrRegister from "./components/LoginOrRegister.tsx";
import Runbooks from "./pages/Runbooks.tsx";
import {
Avatar,
User,
Button,
ScrollShadow,
Spacer,
Dropdown,
DropdownItem,
DropdownMenu,
DropdownSection,
DropdownTrigger,
Modal,
ModalContent,
useDisclosure,
} from "@nextui-org/react";
import Sidebar, { SidebarItem } from "@/components/Sidebar";
import icon from "@/assets/icon.svg";
import { logout } from "./state/client.ts";
enum Section {
Home,
History,
Dotfiles,
Runbooks,
}
function renderMain(section: Section): ReactElement {
switch (section) {
case Section.Home:
return ;
case Section.History:
return ;
case Section.Dotfiles:
return ;
case Section.Runbooks:
return ;
}
}
function App() {
// routers don't really work in Tauri. It's not a browser!
// I think hashrouter may work, but I'd rather avoiding thinking of them as
// pages
const [section, setSection] = useState(Section.Home);
const user = useStore((state: any) => state.user);
const refreshUser = useStore((state: any) => state.refreshUser);
const { isOpen, onOpen, onOpenChange } = useDisclosure();
const navigation: SidebarItem[] = [
{
key: "personal",
title: "Personal",
items: [
{
key: "home",
icon: "solar:home-2-linear",
title: "Home",
onPress: () => setSection(Section.Home),
},
{
key: "runbooks",
icon: "solar:notebook-linear",
title: "Runbooks",
onPress: () => {
console.log("runbooks");
setSection(Section.Runbooks);
},
},
{
key: "history",
icon: "solar:history-outline",
title: "History",
onPress: () => setSection(Section.History),
},
{
key: "dotfiles",
icon: "solar:file-smile-linear",
title: "Dotfiles",
onPress: () => setSection(Section.Dotfiles),
},
],
},
];
return (
}
>
Settings
open("https://forum.atuin.sh")}
startContent={
}
>
Help & Feedback
{(user.username && (
}
onClick={() => {
logout();
refreshUser();
}}
>
Log Out
)) || (
}
onPress={onOpen}
>
Log in or Register
)}
{renderMain(section)}
{(onClose) => (
<>
>
)}
);
}
export default App;