Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
import { ActivityIndicator, ScrollView, View } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { useQuery } from "@tanstack/react-query";
import { router } from "expo-router";
import { Text } from "@/components/ui/text";
import { Button } from "@/components/ui/button";
import { CardPressable } from "@/components/ui/card";
import { workspaceListOptions } from "@/data/queries/workspaces";
import { useAuthStore } from "@/data/auth-store";
import { useWorkspaceStore } from "@/data/workspace-store";
import { useT } from "@/lib/i18n";
export default function SelectWorkspace() {
const user = useAuthStore((s) => s.user);
const logout = useAuthStore((s) => s.logout);
const setCurrentWorkspace = useWorkspaceStore((s) => s.setCurrentWorkspace);
const { t } = useT("workspace");
const { data, isLoading, error, refetch } = useQuery(workspaceListOptions());
const onSelect = async (id: string, slug: string) => {
await setCurrentWorkspace(id, slug);
router.replace(`/${slug}/inbox`);
};
return (
<SafeAreaView className="flex-1 bg-background">
<ScrollView contentContainerClassName="px-6 py-6 gap-6">
<View className="gap-1">
<Text className="text-xs uppercase tracking-wider text-muted-foreground">
{t("auth.signed_in_as")}
</Text>
<Text className="text-base text-foreground">{user?.email}</Text>
</View>
<View className="gap-3">
<Text className="text-2xl font-semibold text-foreground">
{t("title")}
</Text>
{isLoading ? (
<View className="py-8 items-center">
<ActivityIndicator />
</View>
) : error ? (
<View className="gap-3">
<Text className="text-sm text-destructive">
{t("errors.load_failed", {
message:
error instanceof Error ? error.message : "unknown",
})}
</Text>
<Button variant="outline" onPress={() => refetch()}>
<Text>{t("common:actions.retry")}</Text>
</Button>
</View>
) : !data || data.length === 0 ? (
<Text className="text-sm text-muted-foreground">
{t("empty")}
</Text>
) : (
<View className="gap-3">
{data.map((ws) => (
<CardPressable
key={ws.id}
onPress={() => onSelect(ws.id, ws.slug)}
>
<Text className="text-base font-semibold text-foreground">
{ws.name}
</Text>
<Text className="text-xs text-muted-foreground mt-1">
/{ws.slug}
</Text>
{ws.description ? (
<Text className="text-sm text-muted-foreground mt-2">
{ws.description}
</Text>
) : null}
</CardPressable>
))}
</View>
)}
</View>
<View className="pt-4 border-t border-border">
<Button variant="outline" onPress={() => logout()}>
<Text>{t("actions.sign_out")}</Text>
</Button>
</View>
</ScrollView>
</SafeAreaView>
);
}