From 041fd8bb216c69a37c2bd450854c96ad7112f08e Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Mon, 8 Jan 2024 15:23:46 -0600 Subject: [PATCH 1/5] use const --- routes/api/user.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/routes/api/user.ts b/routes/api/user.ts index db29129..0c96325 100644 --- a/routes/api/user.ts +++ b/routes/api/user.ts @@ -56,7 +56,9 @@ export const handler: Handlers = { }, async PUT(req, _ctx) { // TODO: form or json - let model = UserModel.omit({ createdAt: true }).partial({ avatarUrl: true }) + const model = UserModel.omit({ createdAt: true }).partial({ + avatarUrl: true, + }) let user: z.infer let redirectInstead = false if (req.headers.get('content-type')?.includes('json')) { From 86ecb24eeceee4d24073e6229a27d8ae2f4b945a Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Tue, 9 Jan 2024 21:52:47 -0600 Subject: [PATCH 2/5] Lots of cleanup --- components/Dialog.tsx | 44 +++++++++ components/Nav.tsx | 16 +-- components/TodoList.tsx | 16 ++- deno.json | 1 + islands/Admin.tsx | 210 ++++++++++++++-------------------------- routes/api/todo.ts | 59 ++++++++--- routes/api/user.ts | 105 +++++++------------- 7 files changed, 217 insertions(+), 234 deletions(-) create mode 100644 components/Dialog.tsx diff --git a/components/Dialog.tsx b/components/Dialog.tsx new file mode 100644 index 0000000..d7fb690 --- /dev/null +++ b/components/Dialog.tsx @@ -0,0 +1,44 @@ +import { createRef, JSX } from 'preact' +import { Button } from '@homeman/components/Button.tsx' +import { useEffect } from 'preact/hooks' + +interface Props extends JSX.HTMLAttributes { + headerTitle: string + show?: boolean +} + +export function Dialog( + { show, headerTitle, children, className, ...props }: Props, +) { + const self = createRef() + + useEffect(() => { + if (show) { + self.current?.showModal() + } else { + self.current?.close() + } + return () => { + // cleanup + } + }, [show]) + + return ( + +
+

{headerTitle}

+ +
+ {children} +
+ ) +} diff --git a/components/Nav.tsx b/components/Nav.tsx index 09a4cf3..06b0ca8 100644 --- a/components/Nav.tsx +++ b/components/Nav.tsx @@ -1,26 +1,14 @@ // import { JSX } from 'preact' // import { IS_BROWSER } from '$fresh/runtime.ts' +import { Bars3Outline } from 'preact-heroicons' import { Clock } from '@homeman/islands/Clock.tsx' export function Nav(/* props: {} */) { return (