From 9e1f46c99598710bca5d1da4e208a04263f3da4c Mon Sep 17 00:00:00 2001 From: Lukas <69743171+quick007@users.noreply.github.com> Date: Sun, 3 Dec 2023 14:45:30 -0800 Subject: [PATCH] navbar btn + ticket fetching --- components/layout/navbar.tsx | 9 +++-- fresh.gen.ts | 3 ++ islands/components/peices/navDropDown.tsx | 40 +++++++++++++++++++++++ islands/components/pickers/dropdown.tsx | 6 ++-- routes/_layout.tsx | 7 ++-- routes/events/[id]/tickets.tsx | 4 +-- routes/kv-insights/_middleware.ts | 4 +-- 7 files changed, 63 insertions(+), 10 deletions(-) create mode 100644 islands/components/peices/navDropDown.tsx diff --git a/components/layout/navbar.tsx b/components/layout/navbar.tsx index 145fab6..3ec556d 100644 --- a/components/layout/navbar.tsx +++ b/components/layout/navbar.tsx @@ -1,8 +1,13 @@ -const Navbar = () => { +import { UserPartial } from "@/utils/db/kv.ts"; +import NavbarDropDown from "@/islands/components/peices/navDropDown.tsx"; + +const Navbar = ({user}: {user: UserPartial | undefined}) => { const loggedIn = true; return ( -
+
+ {user && + }
diff --git a/fresh.gen.ts b/fresh.gen.ts index cef5624..5369df1 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -46,6 +46,7 @@ import * as $kv_insights_layout from "./routes/kv-insights/_layout.tsx"; import * as $kv_insights_middleware from "./routes/kv-insights/_middleware.ts"; import * as $login from "./routes/login.tsx"; import * as $components_dropinUI_trash from "./islands/components/dropinUI/trash.tsx"; +import * as $components_peices_navDropDown from "./islands/components/peices/navDropDown.tsx"; import * as $components_peices_ticket from "./islands/components/peices/ticket.tsx"; import * as $components_pickers_calender from "./islands/components/pickers/calender.tsx"; import * as $components_pickers_dropdown from "./islands/components/pickers/dropdown.tsx"; @@ -138,6 +139,8 @@ const manifest = { }, islands: { "./islands/components/dropinUI/trash.tsx": $components_dropinUI_trash, + "./islands/components/peices/navDropDown.tsx": + $components_peices_navDropDown, "./islands/components/peices/ticket.tsx": $components_peices_ticket, "./islands/components/pickers/calender.tsx": $components_pickers_calender, "./islands/components/pickers/dropdown.tsx": $components_pickers_dropdown, diff --git a/islands/components/peices/navDropDown.tsx b/islands/components/peices/navDropDown.tsx new file mode 100644 index 0000000..8b9d394 --- /dev/null +++ b/islands/components/peices/navDropDown.tsx @@ -0,0 +1,40 @@ +import { UserPartial } from "@/utils/db/kv.types.ts"; +import Selector from "$tabler/selector.tsx"; +import Dropdown from "@/islands/components/pickers/dropdown.tsx"; +import CirclePlus from "$tabler/circle-plus.tsx"; +import Settings from "$tabler/settings.tsx"; +import UserCircle from "$tabler/user-circle.tsx" + +const NavbarDropDown = ({ user }: { user: UserPartial }) => { + return ( + +

New Team

+
+ ), + onClick: () => alert("Teams is coming soon!"), + }, + { + content: ( +
+

Settings

+
+ ), + onClick: () => alert("Settings is coming soon!"), + }, + ]} + > + + + ); +}; + +export default NavbarDropDown; diff --git a/islands/components/pickers/dropdown.tsx b/islands/components/pickers/dropdown.tsx index 747b01e..f5bd399 100644 --- a/islands/components/pickers/dropdown.tsx +++ b/islands/components/pickers/dropdown.tsx @@ -6,12 +6,14 @@ import { useSignal } from "@preact/signals"; export default function Dropdown({ options, children, + className }: { options: { content: ComponentChild; onClick?: () => void; }[]; children: ComponentChild; + className?: string }) { const open = useSignal(false); const dropdown = useRef(null); @@ -20,7 +22,7 @@ export default function Dropdown({ }); return ( <> -
+
{option.content} diff --git a/routes/_layout.tsx b/routes/_layout.tsx index c267e07..6e4c70f 100644 --- a/routes/_layout.tsx +++ b/routes/_layout.tsx @@ -2,11 +2,14 @@ import { defineLayout } from "$fresh/server.ts"; import Footer from "../components/layout/footer.tsx"; import Navbar from "../components/layout/navbar.tsx"; import { Partial } from "$fresh/runtime.ts"; +import { getUser } from "@/utils/db/kv.ts"; + +export default defineLayout(async (req, { Component }) => { + const user = await getUser(req) -export default defineLayout((req, { Component }) => { return (
- + {/* */}
diff --git a/routes/events/[id]/tickets.tsx b/routes/events/[id]/tickets.tsx index 2c22046..8855c43 100644 --- a/routes/events/[id]/tickets.tsx +++ b/routes/events/[id]/tickets.tsx @@ -34,8 +34,8 @@ export default defineRoute( const request = ["ticket", eventID]; if (showTimeID !== "0") request.push(showTimeID); - const tix = kv.list({ prefix: request }, {}); - // we should probably add pagination + + const tix = kv.list({ prefix: request, }); const tickets: Deno.KvEntry[] = []; for await (const ticket of tix) { tickets.push(ticket); diff --git a/routes/kv-insights/_middleware.ts b/routes/kv-insights/_middleware.ts index f446b95..541aec2 100644 --- a/routes/kv-insights/_middleware.ts +++ b/routes/kv-insights/_middleware.ts @@ -1,11 +1,11 @@ -import { MiddlewareHandlerContext } from "$fresh/src/server/types.ts"; +import { FreshContext } from "$fresh/src/server/types.ts"; import { getUser } from "@/utils/db/kv.ts"; export const handler = [handleKVInsightsAuthorization]; async function handleKVInsightsAuthorization( request: Request, - context: MiddlewareHandlerContext, + context: FreshContext, ) { const user = await getUser(request);