chore: clean up

This commit is contained in:
Max Koon
2025-11-18 13:29:10 -05:00
parent 801bb1c194
commit b42da83274
4 changed files with 3 additions and 72 deletions

View File

@@ -1,5 +1,4 @@
import { useLocalSearchParams } from "expo-router"; import { useLocalSearchParams } from "expo-router";
import { Text } from "react-native";
import { App, type Route } from "@money/ui"; import { App, type Route } from "@money/ui";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { authClient } from "@/lib/auth-client"; import { authClient } from "@/lib/auth-client";

View File

@@ -1,70 +0,0 @@
import { authClient } from "@/lib/auth-client";
import { queries } from "@money/shared";
import { useQuery } from "@rocicorp/zero/react";
import { Link, usePathname, useRouter, type LinkProps } from "expo-router";
import { useEffect } from "react";
import { View, Text, Platform } from "react-native";
type Page = { name: string, href: LinkProps['href'] };
const PAGES: Page[] = [
{
name: "Home",
href: "/",
},
{
name: "Settings",
href: "/settings",
},
];
export default function Header() {
const router = useRouter();
const { data: session } = authClient.useSession();
const [user] = useQuery(queries.me(session));
useEffect(() => {
if (Platform.OS != 'web') return;
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === "1" && event.ctrlKey) {
router.push(PAGES.at(0)!.href);
} else if (event.key === "2" && event.ctrlKey) {
router.push(PAGES.at(1)!.href);
}
};
window.addEventListener("keydown", handleKeyDown);
return () => {
window.removeEventListener("keydown", handleKeyDown);
};
}, []);
return (
<View style={{ flexDirection: "row", justifyContent: "space-between", backgroundColor: "#f7e2c8" }}>
<View style={{ flexDirection: "row" }}>
{PAGES.map(page => <Page
key={page.name}
name={page.name}
href={page.href}
/>)}
</View>
<Link href={"#" as any}>
<Text style={{ fontFamily: 'mono' }}>{user?.name} </Text>
</Link>
</View>
);
}
function Page({ name, href }: Page) {
const path = usePathname();
return (
<Link href={href }>
<Text style={{ fontFamily: 'mono' }}>{path == href ? `[ ${name} ]` : ` ${name} `}</Text>
</Link>
)
}

View File

@@ -1,8 +1,9 @@
import { config } from "@/src/config";
import { createAuthClient } from "better-auth/client"; import { createAuthClient } from "better-auth/client";
import { deviceAuthorizationClient } from "better-auth/client/plugins"; import { deviceAuthorizationClient } from "better-auth/client/plugins";
export const authClient = createAuthClient({ export const authClient = createAuthClient({
baseURL: "http://laptop:3000", baseURL: config.apiUrl,
plugins: [ plugins: [
deviceAuthorizationClient(), deviceAuthorizationClient(),
] ]

View File

@@ -8,4 +8,5 @@ export const config = {
dir: PATH, dir: PATH,
authPath: AUTH_PATH, authPath: AUTH_PATH,
zeroUrl: "http://laptop:4848", zeroUrl: "http://laptop:4848",
apiUrl: "http://laptop:3000"
}; };