format: format with biome
This commit is contained in:
@@ -5,7 +5,9 @@ import { authClient } from "@/lib/auth-client";
|
||||
|
||||
export default function Page() {
|
||||
const { route: initalRoute } = useLocalSearchParams<{ route: string[] }>();
|
||||
const [route, setRoute] = useState(initalRoute ? "/" + initalRoute.join("/") : "/");
|
||||
const [route, setRoute] = useState(
|
||||
initalRoute ? "/" + initalRoute.join("/") : "/",
|
||||
);
|
||||
|
||||
const { data } = authClient.useSession();
|
||||
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
import { Stack } from 'expo-router';
|
||||
import 'react-native-reanimated';
|
||||
import { Stack } from "expo-router";
|
||||
import "react-native-reanimated";
|
||||
|
||||
import { authClient } from '@/lib/auth-client';
|
||||
import { ZeroProvider } from '@rocicorp/zero/react';
|
||||
import { useMemo } from 'react';
|
||||
import { authDataSchema } from '@money/shared/auth';
|
||||
import { Platform } from 'react-native';
|
||||
import type { ZeroOptions } from '@rocicorp/zero';
|
||||
import { schema, type Schema, createMutators, type Mutators, BASE_URL } from '@money/shared';
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
import { ZeroProvider } from "@rocicorp/zero/react";
|
||||
import { useMemo } from "react";
|
||||
import { authDataSchema } from "@money/shared/auth";
|
||||
import { Platform } from "react-native";
|
||||
import type { ZeroOptions } from "@rocicorp/zero";
|
||||
import {
|
||||
schema,
|
||||
type Schema,
|
||||
createMutators,
|
||||
type Mutators,
|
||||
BASE_URL,
|
||||
} from "@money/shared";
|
||||
import { expoSQLiteStoreProvider } from "@rocicorp/zero/react-native";
|
||||
|
||||
export const unstable_settings = {
|
||||
anchor: 'index',
|
||||
anchor: "index",
|
||||
};
|
||||
|
||||
const kvStore = Platform.OS === "web" ? undefined : expoSQLiteStoreProvider();
|
||||
@@ -25,19 +31,22 @@ export default function RootLayout() {
|
||||
}, [session]);
|
||||
|
||||
const cookie = useMemo(() => {
|
||||
return Platform.OS == 'web' ? undefined : authClient.getCookie();
|
||||
return Platform.OS == "web" ? undefined : authClient.getCookie();
|
||||
}, [session, isPending]);
|
||||
|
||||
const zeroProps = useMemo(() => {
|
||||
return {
|
||||
storageKey: 'money',
|
||||
storageKey: "money",
|
||||
kvStore,
|
||||
server: process.env.NODE_ENV == 'production' ? 'https://zero.koon.us' : `${BASE_URL}:4848`,
|
||||
server:
|
||||
process.env.NODE_ENV == "production"
|
||||
? "https://zero.koon.us"
|
||||
: `${BASE_URL}:4848`,
|
||||
userID: authData?.user.id ?? "anon",
|
||||
schema,
|
||||
mutators: createMutators(authData),
|
||||
auth: cookie,
|
||||
} as const satisfies ZeroOptions<Schema, Mutators>;
|
||||
} as const satisfies ZeroOptions<Schema, Mutators>;
|
||||
}, [authData, cookie]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,7 +4,7 @@ import { useEffect } from "react";
|
||||
import { Text } from "react-native";
|
||||
|
||||
export default function Page() {
|
||||
const { code } = useLocalSearchParams<{code: string }>();
|
||||
const { code } = useLocalSearchParams<{ code: string }>();
|
||||
const { isPending, data } = authClient.useSession();
|
||||
if (isPending) return <Text>Loading...</Text>;
|
||||
if (!isPending && !data) return <Text>Please log in</Text>;
|
||||
@@ -13,11 +13,7 @@ export default function Page() {
|
||||
authClient.device.approve({
|
||||
userCode: code,
|
||||
});
|
||||
|
||||
}, []);
|
||||
|
||||
return <Text>
|
||||
Approving: {code}
|
||||
</Text>
|
||||
return <Text>Approving: {code}</Text>;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,10 @@ export default function Auth() {
|
||||
const onLogin = () => {
|
||||
authClient.signIn.oauth2({
|
||||
providerId: "koon-family",
|
||||
callbackURL: process.env.NODE_ENV == 'production' ? 'https://money.koon.us' : `${BASE_URL}:8081`,
|
||||
callbackURL:
|
||||
process.env.NODE_ENV == "production"
|
||||
? "https://money.koon.us"
|
||||
: `${BASE_URL}:8081`,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -14,5 +17,5 @@ export default function Auth() {
|
||||
<View>
|
||||
<Button onPress={onLogin} title="Login with Koon Family" />
|
||||
</View>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import { authClient } from '@/lib/auth-client';
|
||||
import { RefreshControl, ScrollView, StatusBar, Text, View } from 'react-native';
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
import {
|
||||
RefreshControl,
|
||||
ScrollView,
|
||||
StatusBar,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { useQuery, useZero } from "@rocicorp/zero/react";
|
||||
import { queries, type Mutators, type Schema } from '@money/shared';
|
||||
import { useState } from 'react';
|
||||
import { queries, type Mutators, type Schema } from "@money/shared";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function HomeScreen() {
|
||||
const { data: session } = authClient.useSession();
|
||||
@@ -20,16 +26,43 @@ export default function HomeScreen() {
|
||||
return (
|
||||
<>
|
||||
<StatusBar barStyle="dark-content" />
|
||||
<ScrollView contentContainerStyle={{ paddingTop: StatusBar.currentHeight, flexGrow: 1 }} refreshControl={<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />} style={{ paddingHorizontal: 10 }}>
|
||||
{balances.map(balance => <Balance key={balance.id} balance={balance} />)}
|
||||
<ScrollView
|
||||
contentContainerStyle={{
|
||||
paddingTop: StatusBar.currentHeight,
|
||||
flexGrow: 1,
|
||||
}}
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
|
||||
}
|
||||
style={{ paddingHorizontal: 10 }}
|
||||
>
|
||||
{balances.map((balance) => (
|
||||
<Balance key={balance.id} balance={balance} />
|
||||
))}
|
||||
</ScrollView>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Balance({ balance }: { balance: { name: string, current: number, avaliable: number } }) {
|
||||
return <View style={{ backgroundColor: "#eee", borderColor: "#ddd", borderWidth: 1, marginBottom: 10, borderRadius: 10 }}>
|
||||
<Text style={{ fontSize: 15, textAlign: "center" }}>{balance.name}</Text>
|
||||
<Text style={{ fontSize: 30, textAlign: "center" }}>{balance.current}</Text>
|
||||
</View>
|
||||
function Balance({
|
||||
balance,
|
||||
}: {
|
||||
balance: { name: string; current: number; avaliable: number };
|
||||
}) {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#eee",
|
||||
borderColor: "#ddd",
|
||||
borderWidth: 1,
|
||||
marginBottom: 10,
|
||||
borderRadius: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, textAlign: "center" }}>{balance.name}</Text>
|
||||
<Text style={{ fontSize: 30, textAlign: "center" }}>
|
||||
{balance.current}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user