From fb7c9fa5384c81bab6517b072f6e61ae80d35e26 Mon Sep 17 00:00:00 2001 From: Alois Date: Tue, 14 Apr 2026 11:04:00 +0200 Subject: [PATCH] (fix): tauth blocking children (feat): update ui components --- apps/web/src/features/settings/components.tsx | 77 ++++++++++++++++++- apps/web/src/features/settings/layout.tsx | 8 +- apps/web/src/routes/settings/profile.tsx | 3 + bun.lock | 4 +- package.json | 2 +- packages/shared/src/settings.ts | 1 + packages/tauth/src/context.tsx | 6 +- 7 files changed, 92 insertions(+), 9 deletions(-) create mode 100644 apps/web/src/routes/settings/profile.tsx diff --git a/apps/web/src/features/settings/components.tsx b/apps/web/src/features/settings/components.tsx index a8483f0..ff1d7f1 100644 --- a/apps/web/src/features/settings/components.tsx +++ b/apps/web/src/features/settings/components.tsx @@ -1,16 +1,43 @@ import { Label } from "@tensamin/ui"; -import { Switch as UISwitch } from "@tensamin/ui"; +import { Switch as UISwitch, Input as UIInput } from "@tensamin/ui"; import { useEffect, useState } from "react"; +import type { Storage } from "@tensamin/shared/data"; import { settingsStorageDefaults } from "@tensamin/shared/settings"; import { useStorage } from "@tensamin/storage/context"; +type BooleanStorageKey = { + [K in keyof Storage]: Storage[K] extends boolean ? K : never; +}[keyof Storage]; + +type StringStorageKey = { + [K in keyof Storage]: Storage[K] extends string ? K : never; +}[keyof Storage]; + +type NumberStorageKey = { + [K in keyof Storage]: Storage[K] extends number ? K : never; +}[keyof Storage]; + +type InputProps = + | { + label: string; + id: StringStorageKey; + placeholder?: string; + type?: "text"; + } + | { + label: string; + id: NumberStorageKey; + placeholder?: string; + type: "number"; + }; + export function Switch({ label, id, }: { label: string; - id: keyof typeof settingsStorageDefaults; + id: keyof typeof settingsStorageDefaults & BooleanStorageKey; }) { const { save, load } = useStorage(); const [value, setValue] = useState(settingsStorageDefaults[id]); @@ -33,3 +60,49 @@ export function Switch({ ); } + +export function Input({ label, id, placeholder, type }: InputProps) { + const { save, load } = useStorage(); + const [value, setValue] = useState( + type === "number" ? 0 : "", + ); + + useEffect(() => { + load(id).then((loadedValue) => { + if (type === "number") { + if (typeof loadedValue === "number") { + setValue(loadedValue); + } + return; + } + + if (typeof loadedValue === "string") { + setValue(loadedValue); + } + }); + }, [id, load, type]); + + return ( +
+ + { + if (type === "number") { + const nextValue = Number(e.target.value); + setValue(nextValue); + save(id, nextValue); + return; + } + + const nextValue = e.target.value; + setValue(nextValue); + save(id, nextValue); + }} + /> +
+ ); +} diff --git a/apps/web/src/features/settings/layout.tsx b/apps/web/src/features/settings/layout.tsx index d6cf360..fa27444 100644 --- a/apps/web/src/features/settings/layout.tsx +++ b/apps/web/src/features/settings/layout.tsx @@ -39,14 +39,16 @@ export function SettingsSidebar() { return (
{/* Settings */} {Object.keys(settingsOptions).map((category) => ( // Category -
+

{category}

{Object.keys(settingsOptions[category]).map((page) => ( // Page diff --git a/apps/web/src/routes/settings/profile.tsx b/apps/web/src/routes/settings/profile.tsx new file mode 100644 index 0000000..0b98f2d --- /dev/null +++ b/apps/web/src/routes/settings/profile.tsx @@ -0,0 +1,3 @@ +export default function Page() { + return
; +} diff --git a/bun.lock b/bun.lock index b90c411..8b6f42a 100644 --- a/bun.lock +++ b/bun.lock @@ -240,7 +240,7 @@ }, "overrides": { "@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.9.tar.gz", - "@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.25.tar.gz", + "@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.26.tar.gz", }, "packages": { "@antfu/ni": ["@antfu/ni@25.0.0", "", { "dependencies": { "ansis": "^4.0.0", "fzf": "^0.5.2", "package-manager-detector": "^1.3.0", "tinyexec": "^1.0.1" }, "bin": { "na": "bin/na.mjs", "ni": "bin/ni.mjs", "nr": "bin/nr.mjs", "nci": "bin/nci.mjs", "nlx": "bin/nlx.mjs", "nun": "bin/nun.mjs", "nup": "bin/nup.mjs" } }, "sha512-9q/yCljni37pkMr4sPrI3G4jqdIk074+iukc5aFJl7kmDCCsiJrbZ6zKxnES1Gwg+i9RcDZwvktl23puGslmvA=="], @@ -693,7 +693,7 @@ "@tensamin/ttp-core": ["@tensamin/ttp-core@https://git.methanium.net/tensamin/ttp/archive/0.0.9.tar.gz", { "dependencies": { "@eslint/js": "^10.0.1", "@typescript-eslint/parser": "^8.58.1", "@webtransport-bun/webtransport": "^0.3.0", "globals": "^17.5.0", "typescript": "^6.0.2", "typescript-eslint": "^8.58.1", "zod": "^4.3.6" } }, "sha512-V9EK/t/tcBe1oNqzUMxtn41wc3UIS0mkLvGeR1mGfZaKn4d9bwwWQ2VmSmRSxodPYiQUJkziJV4fZvdzGjnzFw=="], - "@tensamin/ui": ["@tensamin/ui@https://git.methanium.net/tensamin/ui/archive/0.0.25.tar.gz", { "dependencies": { "@base-ui/react": "^1.3.0", "@fontsource-variable/inter": "^5.2.6", "@tauri-apps/api": "^2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.1.1", "date-fns": "^4.1.0", "embla-carousel-react": "^8.6.0", "input-otp": "^1.4.2", "lucide-react": "^1.8.0", "next-themes": "^0.4.6", "react-day-picker": "^9.14.0", "react-resizable-panels": "^4.10.0", "recharts": "3.8.0", "shadcn": "^3.5.0", "sonner": "^2.0.7", "tailwind-merge": "^3.5.0", "tw-animate-css": "^1.3.0", "vaul": "^1.1.2" }, "peerDependencies": { "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-pYkl4quhAhV/l/j1Yy5m4DDV5fh42H4G8v+FE6qEMCcJIOeA1LU7brIG7X9zURe7F4gyn1LQxMf2yABuV/NsMQ=="], + "@tensamin/ui": ["@tensamin/ui@https://git.methanium.net/tensamin/ui/archive/0.0.26.tar.gz", { "dependencies": { "@base-ui/react": "^1.3.0", "@fontsource-variable/inter": "^5.2.6", "@tauri-apps/api": "^2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.1.1", "date-fns": "^4.1.0", "embla-carousel-react": "^8.6.0", "input-otp": "^1.4.2", "lucide-react": "^1.8.0", "next-themes": "^0.4.6", "react-day-picker": "^9.14.0", "react-resizable-panels": "^4.10.0", "recharts": "3.8.0", "shadcn": "^3.5.0", "sonner": "^2.0.7", "tailwind-merge": "^3.5.0", "tw-animate-css": "^1.3.0", "vaul": "^1.1.2" }, "peerDependencies": { "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-SH+voNvmg2TtTjZH561NZC4ekY0ypFQpPvC0u0s5Jt1nGG243TR3ybX3T3WI83Z59ayC+t7YPZOmQPHTHI9+Mw=="], "@tensamin/user": ["@tensamin/user@workspace:packages/user"], diff --git a/package.json b/package.json index 2427ec0..b911a44 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "typescript-eslint": "^8.58.1" }, "overrides": { - "@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.25.tar.gz", + "@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.26.tar.gz", "@tensamin/ttp-core": "https://git.methanium.net/tensamin/ttp/archive/0.0.9.tar.gz" }, "dependencies": { diff --git a/packages/shared/src/settings.ts b/packages/shared/src/settings.ts index 5fbbb89..05bef09 100644 --- a/packages/shared/src/settings.ts +++ b/packages/shared/src/settings.ts @@ -13,6 +13,7 @@ export type SettingsSchema = Record< const settings = { account: { + profile: {}, security: { login_qr_code: { display: "Login QR Code", diff --git a/packages/tauth/src/context.tsx b/packages/tauth/src/context.tsx index 4d56956..dfecd15 100644 --- a/packages/tauth/src/context.tsx +++ b/packages/tauth/src/context.tsx @@ -121,7 +121,11 @@ export default function Wrapper({ children }: { children: ReactNode }) { const identifier = params.get("identifier"); const redirect = params.get("redirect"); const challenge = params.get("challenge"); - if (!identifier || !redirect) return; + if (!identifier || !redirect) { + // eslint-disable-next-line + setAllowChildern(true); + return; + } load("user_id").then((userId) => { if (!challenge) {