44 lines
1.0 KiB
TypeScript
Raw Normal View History

2024-11-08 18:53:30 +00:00
import { Button } from "tamagui";
import React from "react";
import Drawer from "expo-router/drawer";
2024-11-12 19:15:13 +07:00
import HostList from "./components/host-list";
2024-11-09 10:33:07 +00:00
import HostForm, { hostFormModal } from "./components/form";
import Icons from "@/components/ui/icons";
import { initialValues } from "./schema/form";
2024-11-09 18:57:36 +00:00
import KeyForm from "../keychains/components/form";
2024-11-14 17:58:19 +07:00
import { useUser } from "@/hooks/useUser";
import { useTeamId } from "@/stores/auth";
2024-11-08 18:53:30 +00:00
export default function HostsPage() {
2024-11-14 17:58:19 +07:00
const teamId = useTeamId();
const user = useUser();
2024-11-08 18:53:30 +00:00
return (
<>
<Drawer.Screen
options={{
2024-11-14 17:58:19 +07:00
headerRight:
!teamId || user?.teamCanWrite(teamId)
? () => <AddButton />
: undefined,
2024-11-08 18:53:30 +00:00
}}
/>
2024-11-12 19:15:13 +07:00
<HostList />
2024-11-09 10:33:07 +00:00
<HostForm />
2024-11-09 18:57:36 +00:00
<KeyForm />
2024-11-08 18:53:30 +00:00
</>
);
}
2024-11-14 17:58:19 +07:00
const AddButton = () => (
<Button
bg="$colorTransparent"
icon={<Icons name="plus" size={24} />}
onPress={() => hostFormModal.onOpen(initialValues)}
$gtSm={{ mr: "$3" }}
>
New
</Button>
);