mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-29 06:28:23 +02:00
Phase 1: Monorepo infrastructure - Add Turborepo with turbo.json pipeline (build, dev, typecheck, test) - Update pnpm-workspace.yaml to include packages/* - Create shared TypeScript config (packages/tsconfig) Phase 2: Extract packages/core (zero react-dom, all-platform reuse) - Move domain types, API client, logger, utils → packages/core/ - Move TanStack Query modules (issues, inbox, workspace, runtimes) - Move Zustand stores (auth, workspace, issues, navigation, modals) - Move realtime sync (WSProvider, hooks, ws-updaters) - Refactor auth/workspace stores to factory pattern for DI - Refactor ApiClient with onUnauthorized callback - Refactor useWorkspaceId to React Context (WorkspaceIdProvider) - Refactor WSProvider to accept wsUrl + store props - Create apps/web/platform/ bridge layer (api singleton, store instances) - Update 91 import paths across apps/web/ - Fix 3 test files for new import paths Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { useWorkspaceId } from "../hooks";
|
|
import { memberListOptions, agentListOptions } from "./queries";
|
|
|
|
export function useActorName() {
|
|
const wsId = useWorkspaceId();
|
|
const { data: members = [] } = useQuery(memberListOptions(wsId));
|
|
const { data: agents = [] } = useQuery(agentListOptions(wsId));
|
|
|
|
const getMemberName = (userId: string) => {
|
|
const m = members.find((m) => m.user_id === userId);
|
|
return m?.name ?? "Unknown";
|
|
};
|
|
|
|
const getAgentName = (agentId: string) => {
|
|
const a = agents.find((a) => a.id === agentId);
|
|
return a?.name ?? "Unknown Agent";
|
|
};
|
|
|
|
const getActorName = (type: string, id: string) => {
|
|
if (type === "member") return getMemberName(id);
|
|
if (type === "agent") return getAgentName(id);
|
|
return "System";
|
|
};
|
|
|
|
const getActorInitials = (type: string, id: string) => {
|
|
const name = getActorName(type, id);
|
|
return name
|
|
.split(" ")
|
|
.map((w) => w[0])
|
|
.join("")
|
|
.toUpperCase()
|
|
.slice(0, 2);
|
|
};
|
|
|
|
const getActorAvatarUrl = (type: string, id: string): string | null => {
|
|
if (type === "member") return members.find((m) => m.user_id === id)?.avatar_url ?? null;
|
|
if (type === "agent") return agents.find((a) => a.id === id)?.avatar_url ?? null;
|
|
return null;
|
|
};
|
|
|
|
return { getMemberName, getAgentName, getActorName, getActorInitials, getActorAvatarUrl };
|
|
}
|