General fixes. Still far from good or working

This commit is contained in:
2026-01-11 13:21:01 -05:00
parent 0a361f51a1
commit 67daefb919
83 changed files with 733 additions and 1053 deletions

View File

@@ -1,11 +1,11 @@
import { useColorScheme } from "react-native";
import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";
import { QueryClientProvider } from "@tanstack/react-query";
import { useColorScheme } from 'react-native';
import { Stack } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import { QueryClientProvider } from '@tanstack/react-query';
import { queryClient } from "~/utils/api";
import { queryClient } from '~/utils/api';
import "../styles.css";
import '../styles.css';
// This is the main layout of the app
// It wraps your pages with the providers they need
@@ -20,10 +20,10 @@ export default function RootLayout() {
<Stack
screenOptions={{
headerStyle: {
backgroundColor: "#c03484",
backgroundColor: '#c03484',
},
contentStyle: {
backgroundColor: colorScheme == "dark" ? "#09090B" : "#FFFFFF",
backgroundColor: colorScheme == 'dark' ? '#09090B' : '#FFFFFF',
},
}}
/>

View File

@@ -1,16 +1,16 @@
import { useState } from "react";
import { Pressable, Text, TextInput, View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { Link, Stack } from "expo-router";
import { LegendList } from "@legendapp/list";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useState } from 'react';
import { Pressable, Text, TextInput, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { Link, Stack } from 'expo-router';
import { LegendList } from '@legendapp/list';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import type { RouterOutputs } from "~/utils/api";
import { trpc } from "~/utils/api";
import { authClient } from "~/utils/auth";
import type { RouterOutputs } from '~/utils/api';
import { trpc } from '~/utils/api';
import { authClient } from '~/utils/auth';
function PostCard(props: {
post: RouterOutputs["post"]["all"][number];
post: RouterOutputs['post']['all'][number];
onDelete: () => void;
}) {
return (
@@ -19,7 +19,7 @@ function PostCard(props: {
<Link
asChild
href={{
pathname: "/post/[id]",
pathname: '/post/[id]',
params: { id: props.post.id },
}}
>
@@ -41,14 +41,14 @@ function PostCard(props: {
function CreatePost() {
const queryClient = useQueryClient();
const [title, setTitle] = useState("");
const [content, setContent] = useState("");
const [title, setTitle] = useState('');
const [content, setContent] = useState('');
const { mutate, error } = useMutation(
trpc.post.create.mutationOptions({
async onSuccess() {
setTitle("");
setContent("");
setTitle('');
setContent('');
await queryClient.invalidateQueries(trpc.post.all.queryFilter());
},
}),
@@ -89,7 +89,7 @@ function CreatePost() {
>
<Text className="text-foreground">Create</Text>
</Pressable>
{error?.data?.code === "UNAUTHORIZED" && (
{error?.data?.code === 'UNAUTHORIZED' && (
<Text className="text-destructive mt-2">
You need to be logged in to create a post
</Text>
@@ -104,20 +104,20 @@ function MobileAuth() {
return (
<>
<Text className="text-foreground pb-2 text-center text-xl font-semibold">
{session?.user.name ? `Hello, ${session.user.name}` : "Not logged in"}
{session?.user.name ? `Hello, ${session.user.name}` : 'Not logged in'}
</Text>
<Pressable
onPress={() =>
session
? authClient.signOut()
: authClient.signIn.social({
provider: "discord",
callbackURL: "/",
provider: 'discord',
callbackURL: '/',
})
}
className="bg-primary flex items-center rounded-sm p-2"
>
<Text>{session ? "Sign Out" : "Sign In With Discord"}</Text>
<Text>{session ? 'Sign Out' : 'Sign In With Discord'}</Text>
</Pressable>
</>
);
@@ -138,7 +138,7 @@ export default function Index() {
return (
<SafeAreaView className="bg-background">
{/* Changes page title visible on the header */}
<Stack.Screen options={{ title: "Home Page" }} />
<Stack.Screen options={{ title: 'Home Page' }} />
<View className="bg-background h-full w-full p-4">
<Text className="text-foreground pb-2 text-center text-5xl font-bold">
Create <Text className="text-primary">T3</Text> Turbo

View File

@@ -1,8 +1,8 @@
import { SafeAreaView, Text, View } from "react-native";
import { Stack, useGlobalSearchParams } from "expo-router";
import { useQuery } from "@tanstack/react-query";
import { SafeAreaView, Text, View } from 'react-native';
import { Stack, useGlobalSearchParams } from 'expo-router';
import { useQuery } from '@tanstack/react-query';
import { trpc } from "~/utils/api";
import { trpc } from '~/utils/api';
export default function Post() {
const { id } = useGlobalSearchParams<{ id: string }>();

View File

@@ -1,3 +1,3 @@
@import "tailwindcss";
@import "nativewind/theme";
@import "@acme/tailwind-config/theme";
@import 'tailwindcss';
@import 'nativewind/theme';
@import '@acme/tailwind-config/theme';

View File

@@ -1,12 +1,11 @@
import { QueryClient } from "@tanstack/react-query";
import { createTRPCClient, httpBatchLink, loggerLink } from "@trpc/client";
import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
import superjson from "superjson";
import type { AppRouter } from '@acme/api';
import { QueryClient } from '@tanstack/react-query';
import { createTRPCClient, httpBatchLink, loggerLink } from '@trpc/client';
import { createTRPCOptionsProxy } from '@trpc/tanstack-react-query';
import superjson from 'superjson';
import type { AppRouter } from "@acme/api";
import { authClient } from "./auth";
import { getBaseUrl } from "./base-url";
import { authClient } from './auth';
import { getBaseUrl } from './base-url';
export const queryClient = new QueryClient({
defaultOptions: {
@@ -24,20 +23,20 @@ export const trpc = createTRPCOptionsProxy<AppRouter>({
links: [
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === "development" ||
(opts.direction === "down" && opts.result instanceof Error),
colorMode: "ansi",
process.env.NODE_ENV === 'development' ||
(opts.direction === 'down' && opts.result instanceof Error),
colorMode: 'ansi',
}),
httpBatchLink({
transformer: superjson,
url: `${getBaseUrl()}/api/trpc`,
headers() {
const headers = new Map<string, string>();
headers.set("x-trpc-source", "expo-react");
headers.set('x-trpc-source', 'expo-react');
const cookies = authClient.getCookie();
if (cookies) {
headers.set("Cookie", cookies);
headers.set('Cookie', cookies);
}
return headers;
},
@@ -47,4 +46,4 @@ export const trpc = createTRPCOptionsProxy<AppRouter>({
queryClient,
});
export type { RouterInputs, RouterOutputs } from "@acme/api";
export type { RouterInputs, RouterOutputs } from '@acme/api';

View File

@@ -1,15 +1,15 @@
import * as SecureStore from "expo-secure-store";
import { expoClient } from "@better-auth/expo/client";
import { createAuthClient } from "better-auth/react";
import * as SecureStore from 'expo-secure-store';
import { expoClient } from '@better-auth/expo/client';
import { createAuthClient } from 'better-auth/react';
import { getBaseUrl } from "./base-url";
import { getBaseUrl } from './base-url';
export const authClient = createAuthClient({
baseURL: getBaseUrl(),
plugins: [
expoClient({
scheme: "expo",
storagePrefix: "expo",
scheme: 'expo',
storagePrefix: 'expo',
storage: SecureStore,
}),
],

View File

@@ -1,4 +1,4 @@
import Constants from "expo-constants";
import Constants from 'expo-constants';
/**
* Extend this function when going to production by
@@ -14,12 +14,12 @@ export const getBaseUrl = () => {
* baseUrl to your production API URL.
*/
const debuggerHost = Constants.expoConfig?.hostUri;
const localhost = debuggerHost?.split(":")[0];
const localhost = debuggerHost?.split(':')[0];
if (!localhost) {
// return "https://turbo.t3.gg";
throw new Error(
"Failed to get localhost. Please point to your production server.",
'Failed to get localhost. Please point to your production server.',
);
}
return `http://${localhost}:3000`;

View File

@@ -1,6 +1,6 @@
import * as SecureStore from "expo-secure-store";
import * as SecureStore from 'expo-secure-store';
const key = "session_token";
const key = 'session_token';
export const getToken = () => SecureStore.getItem(key);
export const deleteToken = () => SecureStore.deleteItemAsync(key);