A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat: permissions
dextmorgne2dd454d6e6c
diff --git a/flowsint-web/src/app/api/chat/route.ts b/flowsint-web/src/app/api/chat/route.tsdeleted file mode 100644index a4fcd73d..00000000--- a/flowsint-web/src/app/api/chat/route.ts+++ /dev/null@@ -1,26 +0,0 @@-import { mistral } from '@ai-sdk/mistral';-import { streamText } from 'ai';-import { createClient } from "@/lib/supabase/server"-import { NextResponse } from "next/server"-// Allow streaming responses up to 30 seconds-export const maxDuration = 30;--export async function POST(req: Request) {- const supabase = await createClient()-- const {- data: { user },- error: userError,- } = await supabase.auth.getUser();- if (!user || userError) {- return NextResponse.json({ error: "Unauthorized" }, { status: 401 })- }- const { messages } = await req.json();-- const result = streamText({- model: mistral('mistral-tiny'),- messages,- });-- return result.toDataStreamResponse();-}\ No newline at end of filediff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/route.tsindex 5c9eac00..80ae73b5 100644--- a/flowsint-web/src/app/api/investigations/[investigation_id]/route.ts+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/route.ts@@ -13,7 +13,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigatreturn NextResponse.json({ error: "Unauthorized" }, { status: 401 })}const { data: investigation, error } = await supabase.from("investigations")- .select("*, members:investigations_profiles(profile:profiles(id, first_name, last_name), role), sketches(*, owner:owner_id(first_name, last_name), individuals(id)), owner:owner_id(first_name, last_name)")+ .select("*, members:investigations_profiles(profile:profiles(id, first_name, last_name), role), sketches(*, members:sketches_profiles(profile:profiles(id, first_name, last_name), role), individuals(id)), owner_id").eq("id", investigation_id).single()if (error) {diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/route.tsindex 3acdc901..786ede73 100644--- a/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/route.ts+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/route.ts@@ -13,7 +13,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigatreturn NextResponse.json({ error: "Unauthorized" }, { status: 401 })}const { data: sketches, error } = await supabase.from("sketches")- .select("id, title, description, status, investigation_id, last_updated_at, investigation:investigations(id, name), members:sketches_profiles(profile:profiles(id, first_name, last_name), role)")+ .select("id, title, description, status, owner_id, investigation_id, last_updated_at, investigation:investigations(id, name), members:sketches_profiles(profile:profiles(id, first_name, last_name), role)").order("last_updated_at", { ascending: false }).eq("investigation_id", investigation_id)if (error) {diff --git a/flowsint-web/src/app/api/investigations/route.ts b/flowsint-web/src/app/api/investigations/route.tsindex 29ce7e92..b50b1a1b 100644--- a/flowsint-web/src/app/api/investigations/route.ts+++ b/flowsint-web/src/app/api/investigations/route.ts@@ -12,7 +12,7 @@ export async function GET() {return NextResponse.json({ error: "Unauthorized" }, { status: 401 })}const { data: investigations, error } = await supabase.from("investigations")- .select("*, sketches(*), owner:owner_id(first_name, last_name), members:investigations_profiles(profile:profiles(id, first_name, last_name), role)")+ .select("*, sketches(*), owner_id, members:investigations_profiles(profile:profiles(id, first_name, last_name), role)")if (error) {return NextResponse.json({ error: error.message }, { status: 500 })}diff --git a/flowsint-web/src/app/api/latest-sketches/route.ts b/flowsint-web/src/app/api/latest-sketches/route.tsindex 750f70bb..3afc0cda 100644--- a/flowsint-web/src/app/api/latest-sketches/route.ts+++ b/flowsint-web/src/app/api/latest-sketches/route.ts@@ -12,7 +12,7 @@ export async function GET() {return NextResponse.json({ error: "Unauthorized" }, { status: 401 })}const { data: sketches, error } = await supabase.from("sketches")- .select("id, title, description, last_updated_at, investigation_id, investigation:investigations(id, name), members:sketches_profiles(profile:profiles(id, first_name, last_name), role)")+ .select("id, title, owner_id, description, last_updated_at, investigation_id, investigation:investigations(id, name), members:sketches_profiles(profile:profiles(id, first_name, last_name), role)").order("last_updated_at", { ascending: false }).limit(4)if (error) {diff --git a/flowsint-web/src/app/api/profiles/[profile_id]/route.ts b/flowsint-web/src/app/api/profiles/[profile_id]/route.tsnew file mode 100644index 00000000..ae3e2504--- /dev/null+++ b/flowsint-web/src/app/api/profiles/[profile_id]/route.ts@@ -0,0 +1,27 @@+import { createClient } from "@/lib/supabase/server"+import { NextResponse } from "next/server"++export async function GET(_: Request, { params }: { params: Promise<{ profile_id: string }> }) {+ const { profile_id } = await (params)+ try {+ const supabase = await createClient()+ const {+ data: { user },+ error: userError,+ } = await supabase.auth.getUser();+ if (!user || userError) {+ return NextResponse.json({ error: "Unauthorized" }, { status: 401 })+ }+ const { data: profile, error } = await supabase.from("profiles")+ .select("id, first_name, last_name, avatar_url")+ .eq("id", profile_id)+ .single()+ if (error) {+ return NextResponse.json({ error: error.message }, { status: 500 })+ }+ return NextResponse.json(profile)+ } catch (error) {+ return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })+ }+}+diff --git a/flowsint-web/src/app/api/profiles/route.ts b/flowsint-web/src/app/api/profiles/route.tsnew file mode 100644index 00000000..0d4a6a07--- /dev/null+++ b/flowsint-web/src/app/api/profiles/route.ts@@ -0,0 +1,25 @@+import { createClient } from "@/lib/supabase/server"+import { NextResponse } from "next/server"++export async function GET() {+ try {+ const supabase = await createClient()+ const {+ data: { user },+ error: userError,+ } = await supabase.auth.getUser();+ if (!user || userError) {+ return NextResponse.json({ error: "Unauthorized" }, { status: 401 })+ }+ const { data: profiles, error } = await supabase.from("profiles")+ .select("*")+ .neq("id", user.id)+ if (error) {+ return NextResponse.json({ error: error.message }, { status: 500 })+ }+ return NextResponse.json(profiles)+ } catch (error) {+ return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })+ }+}+diff --git a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/page.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/page.tsxindex cacf9ba3..976eb290 100644--- a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/page.tsx+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/page.tsx@@ -17,6 +17,7 @@ import { DocumentList } from "@/components/investigations/documents-list"import { cn } from "@/lib/utils"import { InvestigationNavigation } from "@/components/investigations/investigation-navigation"import { Card } from "@/components/ui/card"+import { AvatarList } from "@/components/avatar-list"const DashboardPage = () => {const { investigation_id } = useParams()@@ -81,7 +82,7 @@ const DashboardPage = () => {</NewSketch><DropdownMenu><DropdownMenuTrigger asChild>- <Button variant="outline" size="sm" className="gap-2">+ <Button variant="outline" className="gap-2"><SlidersHorizontal className="h-4 w-4" /><span className="hidden sm:inline">Sort by</span></Button>@@ -94,7 +95,7 @@ const DashboardPage = () => {<DropdownMenuItem>Size</DropdownMenuItem></DropdownMenuContent></DropdownMenu>- <Button onClick={handleRefetch} disabled={isLoading || isRefetching} variant={"outline"} size="sm" className="gap-2">+ <Button onClick={handleRefetch} disabled={isLoading || isRefetching} variant={"outline"} className="gap-2"><RotateCwIcon className={cn("h-4 w-4", isLoading || isRefetching && "animate-spin")} /> Refresh</Button></div>@@ -110,8 +111,8 @@ const DashboardPage = () => {<TableRow><TableHead>Name</TableHead><TableHead>Type</TableHead>- <TableHead>Owner</TableHead><TableHead className="hidden md:table-cell">Size</TableHead>+ <TableHead className="hidden sm:table-cell">Members</TableHead><TableHead className="hidden sm:table-cell">Last modified</TableHead><TableHead className="hidden sm:table-cell">Creation</TableHead><TableHead className="w-[50px]"></TableHead>@@ -141,15 +142,17 @@ const DashboardPage = () => {</Link></TableCell><TableCell className="text-muted-foreground">{"Sketch"}</TableCell>- <TableCell className="text-muted-foreground">{`${sketch?.owner?.first_name} ${investigation?.owner?.last_name}` || "You"}</TableCell><TableCell className="hidden md:table-cell text-muted-foreground">{(sketch?.individuals?.length || 0) > 0 ? `${sketch?.individuals?.length} items` : "Empty"}</TableCell>+ <TableCell className="hidden sm:table-cell text-muted-foreground">+ <AvatarList users={sketch?.members?.map(({ profile }: { profile: { first_name: string, last_name: string, id: string } }) => ({ id: profile.id, name: `${profile.first_name} ${profile.last_name}`, owner: profile.id === sketch.owner_id })) || []} size="sm" />+ </TableCell><TableCell className="hidden sm:table-cell text-muted-foreground">{formatDistanceToNow(new Date(sketch.last_updated_at), { addSuffix: true })}</TableCell><TableCell className="hidden sm:table-cell text-muted-foreground">- {format(new Date(investigation.created_at), "dd/MM/yyyy")}+ {format(new Date(sketch.created_at), "dd/MM/yyyy")}</TableCell><TableCell><DropdownMenu>diff --git a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/layout.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/layout.tsxindex c57bb9b6..9eef1a91 100644--- a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/layout.tsx+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/layout.tsx@@ -1,7 +1,7 @@import { SketchProvider } from '@/components/contexts/sketch-provider';import { createClient } from "@/lib/supabase/server";import { notFound, redirect } from "next/navigation";-import { SketchNavigation } from '@/components/sketches/investigation-navigation';+import { SketchNavigation } from '@/components/sketches/sketch-navigation';import { ScanDrawer } from '@/components/sketches/scan-drawer';import { Sketch } from '@/types/sketch';const DashboardLayout = async ({@@ -17,14 +17,14 @@ const DashboardLayout = async ({if (userError || !data?.user) {redirect('/login')}- const { data: sketch, error } = await supabase.from("sketches").select("id, members:sketches_profiles(profile:profiles(id, first_name, last_name), role)").eq("id", sketch_id).single()+ const { data: sketch, error } = await supabase.from("sketches").select("id, owner_id, members:sketches_profiles(profile:profiles(id, first_name, last_name), role)").eq("id", sketch_id).single()if (!sketch || error) {return notFound()}return (<SketchProvider><div className="sticky z-40 bg-background w-full hidden md:flex top-[48px] border-b">- <SketchNavigation investigation_id={investigation_id} sketch_id={sketch_id} sketch={sketch as Sketch} />+ <SketchNavigation user_id={data?.user?.id} investigation_id={investigation_id} sketch_id={sketch_id} sketch={sketch as Sketch} /></div>{children}<ScanDrawer />diff --git a/flowsint-web/src/app/dashboard/keys/page.tsx b/flowsint-web/src/app/dashboard/keys/page.tsxindex 47ebd27c..8eb701e6 100644--- a/flowsint-web/src/app/dashboard/keys/page.tsx+++ b/flowsint-web/src/app/dashboard/keys/page.tsx@@ -4,7 +4,6 @@ import { useState } from "react"import { Button } from "@/components/ui/button"import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"import { Trash2 } from "lucide-react"-import DashboardLayout from "@/components/dashboard/layout"import { Separator } from "@/components/ui/separator"export default function TokensPage() {diff --git a/flowsint-web/src/app/dashboard/layout.tsx b/flowsint-web/src/app/dashboard/layout.tsxindex 1a8e674e..969a83db 100644--- a/flowsint-web/src/app/dashboard/layout.tsx+++ b/flowsint-web/src/app/dashboard/layout.tsx@@ -4,14 +4,12 @@ import {SidebarProvider,} from "@/components/ui/sidebar"import { redirect } from "next/navigation";-import { FingerprintIcon, Radar, Settings } from "lucide-react";+import { FingerprintIcon } from "lucide-react";import { Button } from "@/components/ui/button";import { MainNav } from "@/components/dashboard/main-nav";import { NavUser } from "@/components/nav-user";-import { SubNav } from "@/components/dashboard/sub-nav";import Feedback from "@/components/dashboard/feedback";import Link from "next/link";-import { Separator } from "@/components/ui/separator";const DashboardLayout = async ({children,@@ -44,7 +42,7 @@ const DashboardLayout = async ({<Button size={"sm"} variant={"ghost"}>Changelog</Button><Button size={"sm"} variant={"ghost"}>Docs</Button></div>- <NavUser user={data?.user} />+ <NavUser profile_id={data?.user.id} /></div></div></header>diff --git a/flowsint-web/src/app/dashboard/page.tsx b/flowsint-web/src/app/dashboard/page.tsxindex 9e249d7a..20ae67f2 100644--- a/flowsint-web/src/app/dashboard/page.tsx+++ b/flowsint-web/src/app/dashboard/page.tsx@@ -79,11 +79,11 @@ const DashboardPage = () => {</DropdownMenuContent></DropdownMenu>- <div className="flex items-center border rounded-md overflow-hidden">+ <div className="flex items-center border bg-background rounded-md overflow-hidden"><Buttonvariant="ghost"size="icon"- className={`h-10 w-10 rounded-none ${viewMode === "grid" ? "bg-accent" : ""}`}+ className={`rounded-none ${viewMode === "grid" ? "bg-accent" : ""}`}onClick={() => setViewMode("grid")}><Grid className="h-4 w-4" />@@ -91,14 +91,14 @@ const DashboardPage = () => {<Buttonvariant="ghost"size="icon"- className={`h-10 w-10 rounded-none ${viewMode === "list" ? "bg-accent" : ""}`}+ className={`rounded-none ${viewMode === "list" ? "bg-accent" : ""}`}onClick={() => setViewMode("list")}><List className="h-4 w-4" /></Button></div><NewInvestigation>- <Button className="gap-2 h-10">+ <Button className="gap-2"><PlusIcon className="h-4 w-4" /> New</Button></NewInvestigation>@@ -138,7 +138,6 @@ const DashboardPage = () => {<TableHeader><TableRow><TableHead>Name</TableHead>- <TableHead>Owner</TableHead><TableHead className="hidden md:table-cell">Size</TableHead><TableHead className="hidden sm:table-cell">Last modified</TableHead><TableHead className="hidden sm:table-cell">Members</TableHead>@@ -169,7 +168,6 @@ const DashboardPage = () => {<span>{investigation.name}</span></Link></TableCell>- <TableCell className="text-muted-foreground">{`${investigation?.owner?.first_name} ${investigation?.owner?.last_name}` || "You"}</TableCell><TableCell className="hidden md:table-cell text-muted-foreground">{(investigation.sketches?.length || 0) > 0 ? `${investigation.sketches.length} items` : "Empty"}</TableCell>@@ -177,7 +175,7 @@ const DashboardPage = () => {{formatDistanceToNow(new Date(investigation.last_updated_at), { addSuffix: true })}</TableCell><TableCell className="hidden sm:table-cell text-muted-foreground">- <AvatarList users={investigation?.members?.map(({ profile }: { profile: { first_name: string, last_name: string, id: string } }) => ({ id: profile.id, name: `${profile.first_name} ${profile.last_name}` })) || []} size="sm" />+ <AvatarList users={investigation?.members?.map(({ profile }: { profile: { first_name: string, last_name: string, id: string } }) => ({ id: profile.id, name: `${profile.first_name} ${profile.last_name}`, owner: profile.id === investigation.owner_id })) || []} size="sm" /></TableCell><TableCell className="hidden sm:table-cell text-muted-foreground">{format(new Date(investigation.created_at), "dd.MM.yyyy")}diff --git a/flowsint-web/src/app/dashboard/settings/layout.tsx b/flowsint-web/src/app/dashboard/settings/layout.tsxindex 18a1fcc2..ae9f18bd 100644--- a/flowsint-web/src/app/dashboard/settings/layout.tsx+++ b/flowsint-web/src/app/dashboard/settings/layout.tsx@@ -1,9 +1,6 @@import { Metadata } from "next"-import Image from "next/image"-import { Separator } from "@/components/ui/separator"import { SidebarNav } from "./components/sidebar-nav"-import DashboardLayout from "@/components/dashboard/layout"export const metadata: Metadata = {title: "Forms",diff --git a/flowsint-web/src/app/layout.tsx b/flowsint-web/src/app/layout.tsxindex 3a788f0e..0868535d 100644--- a/flowsint-web/src/app/layout.tsx+++ b/flowsint-web/src/app/layout.tsx@@ -36,12 +36,12 @@ export default function RootLayout({return (<html suppressHydrationWarning lang="en"><head>- {process.env.NODE_ENV === "development" && (+ {/* {process.env.NODE_ENV === "development" && (<scriptcrossOrigin="anonymous"src="//unpkg.com/react-scan/dist/auto.global.js"/>- )}+ )} */}</head><bodyclassName={clsx(diff --git a/flowsint-web/src/components/assistant.tsx b/flowsint-web/src/components/assistant.tsxdeleted file mode 100644index ac39f040..00000000--- a/flowsint-web/src/components/assistant.tsx+++ /dev/null@@ -1,12 +0,0 @@-import { Button } from "@/components/ui/button"--import { GemIcon, ScanIcon } from "lucide-react"-import { useChatContext } from "./contexts/chatbot-context"--const Assistant = () => {- const { handleOpenChat } = useChatContext()- return (- <Button onClick={() => handleOpenChat(null)} variant="ghost" size={"icon"} className="h-full w-12 rounded-none"><ScanIcon strokeWidth={3} className="h-12 w-12 text-primary font-bold" /></Button>- )-}-export default Assistant\ No newline at end of filediff --git a/flowsint-web/src/components/avatar-list.tsx b/flowsint-web/src/components/avatar-list.tsxindex 3da04893..f423dd74 100644--- a/flowsint-web/src/components/avatar-list.tsx+++ b/flowsint-web/src/components/avatar-list.tsx@@ -4,12 +4,14 @@ import type * as React from "react"import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"import { cn, getAvatarColor } from "@/lib/utils"-+import { CrownIcon } from "lucide-react"+import { getInitials } from "@/lib/utils"export interface User {id: stringname: stringemail?: stringimage?: string+ owner?: boolean}interface AvatarListProps extends React.HTMLAttributes<HTMLDivElement> {@@ -40,7 +42,7 @@ export function AvatarList({more: "h-6 w-6 text-xs",},md: {- avatar: "h-8 w-8",+ avatar: "h-7 w-7",container: "space-x-[-11px]",more: "h-8 w-8 text-sm",},@@ -50,40 +52,32 @@ export function AvatarList({more: "h-10 w-10 text-base",},}-- const getInitials = (name: string) => {- return name- .split(" ")- .map((part) => part[0])- .join("")- .toUpperCase()- .substring(0, 2)- }-const renderAvatar = (user: User) => {const avatarColor = getAvatarColor(user.name)const avatar = (- <Avatar- key={user.id}- className={cn(- sizeClasses[size].avatar,- "border-2 border-background bg-background",- "transition-transform",- "ring-0 ring-offset-0",- )}- >- <AvatarImage src={user.image} alt={`${user.name}'s avatar`} />- <AvatarFallback className={cn("text-xs text-white", avatarColor)}>{getInitials(user.name)}</AvatarFallback>- </Avatar>+ <div className="relative">+ <Avatar+ key={user.id}+ className={cn(+ sizeClasses[size].avatar,+ "border-2 border-background bg-background relative",+ "transition-transform",+ "ring-0 ring-offset-0",+ )}+ >+ <AvatarImage src={user.image} alt={`${user.name}'s avatar`} />+ <AvatarFallback className={cn("text-xs text-white", avatarColor)}>{getInitials(user.name)}</AvatarFallback>+ </Avatar>+ {user?.owner && <span className="block z-50 absolute -top-1.5 left-1.5"><CrownIcon fill="yellow" className="h-3 w-3 text-yellow-500 opacity-70" /></span>}+ </div>)-if (showTooltips) {return (<TooltipProvider key={user.id} delayDuration={300}><Tooltip><TooltipTrigger asChild>{avatar}</TooltipTrigger><TooltipContent side="bottom" align="center" className="shadow">- {user.name}+ {user.name} {user.owner && `(owner)`}</TooltipContent></Tooltip></TooltipProvider>diff --git a/flowsint-web/src/components/contexts/sketch-provider.tsx b/flowsint-web/src/components/contexts/sketch-provider.tsxindex c66efa2a..da51c3de 100644--- a/flowsint-web/src/components/contexts/sketch-provider.tsx+++ b/flowsint-web/src/components/contexts/sketch-provider.tsx@@ -9,13 +9,14 @@ import { Dialog, DialogContent, DialogDescription, DialogClose, DialogTitle } frimport { Button } from "@/components/ui/button"import { Switch } from "@/components/ui/switch"import { cn } from "@/lib/utils"+import { toast } from "sonner"interface SketchProviderProps {children: ReactNode}export const SketchProvider: React.FC<SketchProviderProps> = ({ children }) => {- const { sketch_id } = useParams()+ const { sketch_id, investigation_id } = useParams()const router = useRouter()const pathname = usePathname()const searchParams = useSearchParams()@@ -27,7 +28,6 @@ export const SketchProvider: React.FC<SketchProviderProps> = ({ children }) => {setOpenSettingsModal,setHandleOpenIndividualModal,setHandleDeleteSketch,- openNewNode, setOpenNewNode} = useSketchStore()useEffect(() => {@@ -36,27 +36,29 @@ export const SketchProvider: React.FC<SketchProviderProps> = ({ children }) => {title: "Delete sketch",message: "Are you really sure you want to delete this sketch ?",})-if (!confirmDelete) return-const confirmFinal = await confirm({title: "Just making sure",message: "You will definitely delete all nodes, edges and relationships.",})if (!confirmFinal) returntry {- const { error } = await supabase- .from("Sketchs")- .update({ status: "archived" })+ const { data, error } = await supabase+ .from("sketches")+ .delete().eq("id", sketch_id)-- if (error) throw error-- router.push("/dashboard")+ .select("id")+ if (!data || !data.length)+ return toast.error("The sketch could not be deleted. Are you sure you are the owner ?")+ if (error)+ return toast.error("An error occured. Try again later.")+ router.push(`/dashboard/investigations/${investigation_id}`)+ toast.success("The sketch was successfully deleted.")} catch (error) {- console.error("Error deleting sketch:", error)+ toast.error("An error occured.")}}+ // @ts-ignoresetHandleDeleteSketch(handleDeleteSketch)}, [sketch_id,diff --git a/flowsint-web/src/components/dashboard/new-investigation.tsx b/flowsint-web/src/components/dashboard/new-investigation.tsxindex 1dda8432..c450a157 100644--- a/flowsint-web/src/components/dashboard/new-investigation.tsx+++ b/flowsint-web/src/components/dashboard/new-investigation.tsx@@ -43,7 +43,7 @@ export default function NewInvestigation({ children, noDropDown }: { children: Rrouter.push(`/dashboard/investigations/${result.id}`)setOpen(false)} else {- toast.error("Could not create new investigation.")+ toast.error(result.error)}}diff --git a/flowsint-web/src/components/dashboard/new-sketch.tsx b/flowsint-web/src/components/dashboard/new-sketch.tsxindex bd294e2e..8307bc2a 100644--- a/flowsint-web/src/components/dashboard/new-sketch.tsx+++ b/flowsint-web/src/components/dashboard/new-sketch.tsx@@ -35,11 +35,9 @@ function SubmitButton() {export default function NewSketch({ children, noDropDown = false }: { children: React.ReactNode, noDropDown?: boolean }) {const [open, setOpen] = useState(false)const { setOpenUploadModal } = useInvestigationStore()-const router = useRouter()const { investigation_id } = useParams()-async function handleNewSketch(formData: FormData) {const result = await createNewSketch(formData, investigation_id as string)if (result.success) {@@ -47,7 +45,7 @@ export default function NewSketch({ children, noDropDown = false }: { children:router.push(`/dashboard/investigations/${investigation_id}/sketches/${result.id}`)setOpen(false)} else {- toast.error("Could not create new sketch." + JSON.stringify(result))+ toast.error(result.error)}}diff --git a/flowsint-web/src/components/dashboard/recent-sketches.tsx b/flowsint-web/src/components/dashboard/recent-sketches.tsxindex 856b73b0..43581517 100644--- a/flowsint-web/src/components/dashboard/recent-sketches.tsx+++ b/flowsint-web/src/components/dashboard/recent-sketches.tsx@@ -3,7 +3,7 @@import type { Sketch } from "@/types/sketch"import { useQuery } from "@tanstack/react-query"import Link from "next/link"-import { Fingerprint, Search } from "lucide-react"+import { Fingerprint, Search, Waypoints } from "lucide-react"import { Card, CardContent } from "@/components/ui/card"import { Skeleton } from "@/components/ui/skeleton"@@ -11,6 +11,7 @@ import { formatDistanceToNow } from "date-fns"import { AvatarList } from "../avatar-list"const RecentSketches = () => {+const {data: sketches,isLoading,@@ -57,14 +58,15 @@ const RecentSketches = () => {}return (<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">+ {sketches?.length === 0 && <div className="italic opacity-60">No sketch yet.</div>}{sketches?.map((sketch: Sketch) => {return (<Link href={`/dashboard/investigations/${sketch.investigation_id}/sketches/${sketch.id}`} key={sketch.id} className="group"><Card className="bg-background shadow-xs h-full min-h-32 transition-all duration-200 hover:border-primary rounded-md"><CardContent className="p-4 relative h-full flex flex-col justify-between">- <div className="flex flex items-center gap-2 w-full">+ <div className="flex flex items-center gap-3 w-full"><div>- <Fingerprint className="h-8 w-8 text-muted-foreground opacity-60" />+ <Waypoints className="h-8 w-8 text-muted-foreground opacity-60" /></div><div className="w-full truncate"><h3 className="font-medium w-full truncate text-ellispsis transition-colors">@@ -74,7 +76,7 @@ const RecentSketches = () => {</div></div><div className="flex items-center justify-end">- <AvatarList users={sketch?.members?.map(({ profile }: { profile: { first_name: string, last_name: string, id: string } }) => ({ id: profile.id, name: `${profile.first_name} ${profile.last_name}` })) || []} size="sm" />+ <AvatarList users={sketch?.members?.map(({ profile }: { profile: { first_name: string, last_name: string, id: string } }) => ({ id: profile.id, name: `${profile.first_name} ${profile.last_name}`, owner: profile.id === sketch.owner_id })) || []} size="sm" /></div></CardContent></Card>diff --git a/flowsint-web/src/components/logo.tsx b/flowsint-web/src/components/logo.tsxdeleted file mode 100644index 2edb9731..00000000--- a/flowsint-web/src/components/logo.tsx+++ /dev/null@@ -1,10 +0,0 @@-import React from 'react'-import { HomeIcon } from 'lucide-react'-import Image from 'next/image'-const Logo = () => {- return (- <Image src="/logo.webp" height={50} width={50} alt="logo" className='w-full rounded-full max-w-[35px] max-h-[35px]' />- )-}--export default Logo\ No newline at end of filediff --git a/flowsint-web/src/components/nav-user.tsx b/flowsint-web/src/components/nav-user.tsxindex 04b20773..ffc7de10 100644--- a/flowsint-web/src/components/nav-user.tsx+++ b/flowsint-web/src/components/nav-user.tsx@@ -3,8 +3,8 @@import {BadgeCheck,Bell,- ChevronsUpDown,CreditCard,+ CrownIcon,LogOut,Sparkles,} from "lucide-react"@@ -32,14 +32,54 @@ import {import { logout } from "@/lib/actions/auth"import { ThemeSwitch } from "./theme-switch"import EnvIndicator from "./env-indicator"-+import { cn, getAvatarColor } from "@/lib/utils"+import { getInitials } from "@/lib/utils"+import { useQuery } from "@tanstack/react-query"export function NavUser({- user,+ profile_id,}: {- user: any+ profile_id: any}) {const { isMobile } = useSidebar()+ const {+ data: profile,+ isLoading,+ error,+ } = useQuery({+ queryKey: ["profiles", profile_id],+ queryFn: async () => {+ const res = await fetch(`/api/profiles/${profile_id}`)+ return res.json()+ },+ refetchOnWindowFocus: true,+ })++ if (isLoading) return++ const renderAvatar = () => {+ const name = `${profile?.first_name || "fd"} ${profile?.last_name || "fd"}`+ const avatarColor = getAvatarColor(name)+ const avatar = (+ <div className="relative">+ {isLoading ? "" :+ <Avatar+ key={profile.id}+ className={cn(+ 'h-8 w-8',+ "border-2 border-background bg-background relative",+ "transition-transform",+ "ring-0 ring-offset-0",+ )}+ >+ <AvatarImage src={profile.image} alt={``} />+ <AvatarFallback className={cn("text-xs text-white", avatarColor)}>{getInitials(name)}</AvatarFallback>+ </Avatar>}+ </div>+ )+ return avatar+ }+return (<SidebarMenu><SidebarMenuItem>@@ -47,12 +87,9 @@ export function NavUser({<DropdownMenuTrigger asChild><SidebarMenuButtonsize="lg"- className="p-0 h-auto"+ className="p-0 h-auto rounded-full cursor-pointer p-1">- <Avatar className="h-8 w-8 rounded-lg">- <AvatarImage src={user.avatar} alt={user.name} />- <AvatarFallback className="rounded-lg uppercase">{user.email[0]}</AvatarFallback>- </Avatar>+ {renderAvatar()}</SidebarMenuButton></DropdownMenuTrigger><DropdownMenuContent@@ -63,13 +100,10 @@ export function NavUser({><DropdownMenuLabel className="p-0 font-normal"><div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">- <Avatar className="h-8 w-8 rounded-lg">- <AvatarImage src={user.avatar} alt={user.name} />- <AvatarFallback className="rounded-lg">{user.email[0]}</AvatarFallback>- </Avatar>+ {renderAvatar()}<div className="grid flex-1 text-left text-sm leading-tight">- <span className="truncate font-semibold">{user.name}</span>- <span className="truncate text-xs">{user.email}</span>+ <span className="truncate font-semibold">{profile.name}</span>+ <span className="truncate text-xs">{profile.email}</span></div></div></DropdownMenuLabel>diff --git a/flowsint-web/src/components/organigrams/organigram-edge.tsx b/flowsint-web/src/components/organigrams/organigram-edge.tsxindex 8cc97d7e..ccd046ce 100644--- a/flowsint-web/src/components/organigrams/organigram-edge.tsx+++ b/flowsint-web/src/components/organigrams/organigram-edge.tsx@@ -38,7 +38,7 @@ const EditableEdge = memo((props: EdgeProps) => {setIsLoading(true)try {const { error } = await supabase- .from("relationships")+ .from("individuals_individuals").update({ relation_type: editValue }).eq("id", id.toString())const { error: error2 } = await supabasediff --git a/flowsint-web/src/components/sketches/add-contributor.tsx b/flowsint-web/src/components/sketches/add-contributor.tsxnew file mode 100644index 00000000..3583ab13--- /dev/null+++ b/flowsint-web/src/components/sketches/add-contributor.tsx@@ -0,0 +1,226 @@+"use client"++import type React from "react"++import { Dispatch, SetStateAction, useState } from "react"+import Image from "next/image"+import { Check, ChevronsUpDown, Loader2, UserCircle } from "lucide-react"+import { useQuery, useMutation } from "@tanstack/react-query"++import { Button } from "@/components/ui/button"+import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command"+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+ DialogTrigger,+} from "@/components/ui/dialog"+import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"+import { toast } from "sonner"+import { cn, getAvatarColor } from "@/lib/utils"+import { supabase } from "@/lib/supabase/client"+import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"+import { User } from "../avatar-list"++interface Profile {+ id: string+ first_name: string+ last_name: string+ email: string+ avatar_url: string | null+}++interface AddInvestigationModalProps {+ sketchId: string+ open: boolean+ setOpen: Dispatch<SetStateAction<boolean>>+}++export function AddInvestigationModal({ sketchId, open, setOpen }: AddInvestigationModalProps) {+ const [popoverOpen, setPopoverOpen] = useState(false)+ const [selectedProfile, setSelectedProfile] = useState<Profile | null>(null)+ const {+ data: profiles = [],+ isLoading,+ refetch,+ } = useQuery({+ queryKey: ["profiles"],+ queryFn: async () => {+ const response = await fetch("/api/profiles")+ if (!response.ok) {+ throw new Error("Erreur lors de la récupération des profils")+ }+ return response.json()+ },+ enabled: false, // Don't fetch on component mount, only when needed+ })++ // Mutation for adding a profile to investigation+ const mutation = useMutation({+ mutationFn: async ({ profile_id, sketch_id }: { profile_id: string; sketch_id: string }) => {+ const { error } = await supabase.from("sketches_profiles").upsert({ profile_id, sketch_id })+ if (error)+ throw (error)+ },+ onSuccess: () => {+ toast.success(`${selectedProfile?.first_name} ${selectedProfile?.last_name} a été ajouté à l'investigation`)+ setOpen(false)+ },+ onError: (e: { code: string }) => {+ if (e.code === "42501")+ return toast.error("You don't have permission to add a new collaborator.")+ return toast.error("An error occured. Try again later.")+ },+ })++ const handleOpenChange = (newOpen: boolean) => {+ setOpen(newOpen)+ if (newOpen) {+ refetch() // Fetch profiles when modal opens+ } else {+ setSelectedProfile(null)+ }+ }++ const handleSubmit = () => {+ if (!selectedProfile) return++ mutation.mutate({+ profile_id: selectedProfile.id,+ sketch_id: sketchId,+ })+ }++ return (+ <Dialog open={open} onOpenChange={handleOpenChange}>+ <DialogContent className="sm:max-w-[425px]">+ <DialogHeader>+ <DialogTitle>Ajouter un profil à l'investigation</DialogTitle>+ <DialogDescription>Sélectionnez un profil à associer à cette esquisse d'investigation.</DialogDescription>+ </DialogHeader>+ <div className="py-4">+ <Popover open={popoverOpen} onOpenChange={setPopoverOpen}>+ <PopoverTrigger asChild>+ <Button+ variant="outline"+ role="combobox"+ aria-expanded={popoverOpen}+ className="w-full justify-between"+ onClick={() => refetch()}+ disabled={isLoading}+ >+ {isLoading ? (+ <div className="flex items-center gap-2">+ <Loader2 className="h-4 w-4 animate-spin" />+ <span>Chargement des profils...</span>+ </div>+ ) : selectedProfile ? (+ <div className="flex items-center gap-2">+ {selectedProfile.avatar_url ? (+ <Image+ src={selectedProfile.avatar_url || "/placeholder.svg"}+ alt={`${selectedProfile.first_name} ${selectedProfile.last_name}`}+ width={24}+ height={24}+ className="rounded-full"+ />+ ) : (+ <UserCircle className="h-5 w-5" />+ )}+ <span>+ {selectedProfile.first_name} {selectedProfile.last_name}+ </span>+ </div>+ ) : (+ "Sélectionner un profil"+ )}+ <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />+ </Button>+ </PopoverTrigger>+ <PopoverContent className="w-[400px] p-0">+ <Command>+ <CommandInput placeholder="Rechercher un profil..." />+ <CommandList>+ <CommandEmpty>Could not find any profile.</CommandEmpty>+ <CommandGroup className="max-h-[300px] overflow-y-auto">+ {profiles.map((profile: any) => (+ <CommandItem+ key={profile.id}+ value={`${profile.first_name} ${profile.last_name} ${profile.email}`}+ onSelect={() => {+ setSelectedProfile(profile)+ setPopoverOpen(false)+ }}+ className="flex items-center gap-2 py-2"+ >+ <div className="flex items-center gap-2 flex-1">+ {/* {renderAvatar(profile)} */}+ <div className="flex flex-col">+ <span className="font-medium">+ {profile.first_name} {profile.last_name}+ </span>+ <span className="text-xs text-muted-foreground">{profile.email}</span>+ </div>+ </div>+ <Check+ className={cn(+ "ml-auto h-4 w-4",+ selectedProfile?.id === profile.id ? "opacity-100" : "opacity-0",+ )}+ />+ </CommandItem>+ ))}+ </CommandGroup>+ </CommandList>+ </Command>+ </PopoverContent>+ </Popover>+ </div>+ <DialogFooter>+ <Button onClick={handleSubmit} disabled={!selectedProfile || mutation.isPending} className="w-full">+ {mutation.isPending ? (+ <div className="flex items-center gap-2">+ <Loader2 className="h-4 w-4 animate-spin" />+ <span>Ajout en cours...</span>+ </div>+ ) : (+ "Ajouter à l'investigation"+ )}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ )+}++const getInitials = (name: string) => {+ return name+ .split(" ")+ .map((part) => part[0])+ .join("")+ .toUpperCase()+ .substring(0, 2)+}++const renderAvatar = (user: any) => {+ const avatarColor = getAvatarColor(user.email)+ const avatar = (+ <Avatar+ key={user.id}+ className={cn(+ 'h-10 w-10',+ "border-2 border-background bg-background",+ "transition-transform",+ "ring-0 ring-offset-0",+ )}+ >+ <AvatarImage src={user.image} alt={`${user.name}'s avatar`} />+ <AvatarFallback className={cn("text-xs text-white", avatarColor)}>{getInitials(user.name)}</AvatarFallback>+ </Avatar>++ )+ return avatar+}\ No newline at end of filediff --git a/flowsint-web/src/components/sketches/more-menu.tsx b/flowsint-web/src/components/sketches/more-menu.tsxindex 91e9cafd..3e685840 100644--- a/flowsint-web/src/components/sketches/more-menu.tsx+++ b/flowsint-web/src/components/sketches/more-menu.tsx@@ -7,23 +7,38 @@ import {DropdownMenuItem,} from "@/components/ui/dropdown-menu";import { Button } from "@/components/ui/button";-export default function MoreMenu() {- const { setOpenSettingsModal, handleDeleteInvestigation } = useSketchStore();-+import { AddInvestigationModal } from "./add-contributor";+import { useState } from "react";+import { Sketch } from "@/types/sketch";+export default function MoreMenu({ sketch, user_id }: { sketch: Sketch, user_id: string }) {+ const { setOpenSettingsModal, handleDeleteSketch } = useSketchStore();+ const [open, setOpen] = useState(false)+ const isOwner = sketch.owner_id == user_idreturn (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button variant="outline" size="icon" className="rounded-none border-none">- <Ellipsis className="h-4 w-4" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- {/* @ts-ignore */}- <DropdownMenuItem onClick={setOpenSettingsModal}>Settings</DropdownMenuItem>- <DropdownMenuItem onClick={handleDeleteInvestigation} className="text-red-500">- Delete- </DropdownMenuItem>- </DropdownMenuContent>- </DropdownMenu>+ <>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button variant="outline" size="icon" className="rounded-none border-none">+ <Ellipsis className="h-4 w-4" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ {isOwner &&+ <DropdownMenuItem onClick={() => setOpen(true)}>Add contributor</DropdownMenuItem>}+ {/* @ts-ignore */}+ <DropdownMenuItem onClick={setOpenSettingsModal}>Settings</DropdownMenuItem>+ {isOwner &&+ <DropdownMenuItem onClick={handleDeleteSketch} className="text-red-500">+ Delete+ </DropdownMenuItem>}+ </DropdownMenuContent>+ </DropdownMenu>+ {isOwner &&+ <AddInvestigationModal+ sketchId={sketch.id}+ setOpen={setOpen}+ open={open}+ />}+ </>);}\ No newline at end of filediff --git a/flowsint-web/src/components/sketches/new-actions.tsx b/flowsint-web/src/components/sketches/new-actions.tsxindex 8a9a0b40..89ccf1cb 100644--- a/flowsint-web/src/components/sketches/new-actions.tsx+++ b/flowsint-web/src/components/sketches/new-actions.tsx@@ -57,7 +57,7 @@ export default function NewActions({ addNodes, children }: { addNodes: any, chil.select("*").single()if (insertError) {- toast.error("Failed to create node.")+ toast.error("Failed to create node." + JSON.stringify(insertError))setLoading(false)return}diff --git a/flowsint-web/src/components/sketches/investigation-navigation.tsx b/flowsint-web/src/components/sketches/sketch-navigation.tsxsimilarity index 84%rename from flowsint-web/src/components/sketches/investigation-navigation.tsxrename to flowsint-web/src/components/sketches/sketch-navigation.tsxindex a9645a43..f36df5ba 100644--- a/flowsint-web/src/components/sketches/investigation-navigation.tsx+++ b/flowsint-web/src/components/sketches/sketch-navigation.tsx@@ -12,7 +12,7 @@ import { DownloadButton } from "../download-button"import { AvatarList } from "../avatar-list"import { Sketch } from "@/types/sketch"-function InvestigationNavigation({ investigation_id, sketch_id, sketch }: { investigation_id: string, sketch_id: string, sketch: Sketch }) {+function SketchNavigation({ investigation_id, sketch_id, sketch, user_id }: { investigation_id: string, sketch_id: string, sketch: Sketch, user_id: string }) {const pathname = usePathname()// Memoize the sections array so it doesn't get recreated on every render@@ -73,18 +73,16 @@ function InvestigationNavigation({ investigation_id, sketch_id, sketch }: { inve</div><div className="flex items-center "><div className="px-2">- <AvatarList users={sketch?.members?.map(({ profile }: { profile: { first_name: string, last_name: string, id: string } }) => ({ id: profile.id, name: `${profile.first_name} ${profile.last_name}` })) || []} />+ <AvatarList size="md" users={sketch?.members?.map(({ profile }: { profile: { first_name: string, last_name: string, id: string } }) => ({ id: profile.id, name: `${profile.first_name} ${profile.last_name}`, owner: profile.id === sketch.owner_id })) || []} /></div><DownloadButton endpoint={`/api/investigations/${investigation_id}/sketches/${sketch_id}/table`} name={investigation_id} />- <MoreMenu />+ <MoreMenu sketch={sketch} user_id={user_id} /><ScanButton /></div></div >)}-// Memoize the entire component-export const MemoizedInvestigationNavigation = memo(InvestigationNavigation);+export const MemoizedInvestigationNavigation = memo(SketchNavigation);-// For backward compatibility, you can also export the original nameexport { MemoizedInvestigationNavigation as SketchNavigation };\ No newline at end of filediff --git a/flowsint-web/src/components/sketches/sketch/nodes/node-context-menu.tsx b/flowsint-web/src/components/sketches/sketch/nodes/node-context-menu.tsxindex 0018e756..5b3637df 100644--- a/flowsint-web/src/components/sketches/sketch/nodes/node-context-menu.tsx+++ b/flowsint-web/src/components/sketches/sketch/nodes/node-context-menu.tsx@@ -164,7 +164,7 @@ const NodeContextMenu = memo(({ x, y, onClose }: NodeContextMenuProps) => {}// add individual to individualif (nodeToInsert.type === "individual" && currentNode?.data?.type === "individual") {- const { error: relationshipError } = await supabase.from("relationships").upsert({+ const { error: relationshipError } = await supabase.from("individuals_individuals").upsert({individual_a: currentNode.id,individual_b: nodeData.id,sketch_id: sketch_id,diff --git a/flowsint-web/src/components/ui/custom-edge.tsx b/flowsint-web/src/components/ui/custom-edge.tsxindex 9a1142e3..a488b0ba 100644--- a/flowsint-web/src/components/ui/custom-edge.tsx+++ b/flowsint-web/src/components/ui/custom-edge.tsx@@ -41,7 +41,7 @@ const EditableEdge = memo((props: EdgeProps) => {setIsLoading(true)try {const { error } = await supabase- .from("relationships")+ .from("individuals_individuals").update({ relation_type: editValue }).eq("id", id.toString())const { error: error2 } = await supabase@@ -53,7 +53,7 @@ const EditableEdge = memo((props: EdgeProps) => {.update({ relation_type: editValue }).eq("id", id.toString())if (error || error2 || error3) {- toast.error("An error occurred: ")+ toast.error("An error occurred.")} else {toast.success("Relation updated.")}diff --git a/flowsint-web/src/lib/actions/auth.ts b/flowsint-web/src/lib/actions/auth.tsindex a6efe9a0..9a7de8da 100644--- a/flowsint-web/src/lib/actions/auth.ts+++ b/flowsint-web/src/lib/actions/auth.ts@@ -36,40 +36,30 @@ export async function login(formData: FormData) {if (error) {return encodedRedirect("error", "/login", error.message);}- // revalidatePath('/', 'layout')- // redirect('/')+ revalidatePath('/', 'layout')+ redirect('/dashboard')}export async function signup(formData: FormData) {const supabase = await createClient()-- // type-casting here for convenience- // in practice, you should validate your inputsconst data = {email: formData.get('email') as string,password: formData.get('password') as string,}-const { error } = await supabase.auth.signUp(data)-if (error) {return encodedRedirect("error", "/login", error.message);- redirect('/error')}-revalidatePath('/', 'layout')redirect('/')}export async function logout() {const supabase = await createClient()-const { error } = await supabase.auth.signOut()-if (error) {redirect('/error')}-revalidatePath('/', 'layout')redirect('/login')}\ No newline at end of filediff --git a/flowsint-web/src/lib/actions/investigations.ts b/flowsint-web/src/lib/actions/investigations.tsindex 34422b6a..aa4ae553 100644--- a/flowsint-web/src/lib/actions/investigations.ts+++ b/flowsint-web/src/lib/actions/investigations.ts@@ -1,7 +1,7 @@"use server"import { createClient } from "../supabase/server"import { redirect } from "next/navigation"-import { revalidatePath } from "next/cache"+export const createNewInvestigation = async (formData: FormData) => {const supabase = await createClient()const { data: session, error: userError } = await supabase.auth.getUser()@@ -19,7 +19,8 @@ export const createNewInvestigation = async (formData: FormData) => {if (bucketError) throw bucketErrorreturn { success: true, id: investigation.id, path: folder.path }} catch (error) {- console.error("Error creating new investigation:", error)+ if ((error as { code?: string })?.code === "42501")+ return { success: false, error: "Missing permission to create a new investigation." }return { success: false, error: "Failed to create new investigation." }}}\ No newline at end of filediff --git a/flowsint-web/src/lib/utils.ts b/flowsint-web/src/lib/utils.tsindex e1c73568..ee897a73 100644--- a/flowsint-web/src/lib/utils.ts+++ b/flowsint-web/src/lib/utils.ts@@ -467,6 +467,16 @@ export const typeColorMap: Record<string, string> = {credential: "bg-gray-100 text-gray-800 hover:bg-gray-100/80 dark:bg-gray-800/50 dark:text-gray-300 dark:hover:bg-gray-800/60",}+export const getInitials = (name: string) => {+ return name+ .split(" ")+ .map((part) => part[0])+ .join("")+ .toUpperCase()+ .substring(0, 2)+}++export function getAvatarColor(name: string): string {const colors = ["bg-red-500",diff --git a/flowsint-web/src/store/flow-store.ts b/flowsint-web/src/store/flow-store.tsindex b5761d9e..75c89c30 100644--- a/flowsint-web/src/store/flow-store.ts+++ b/flowsint-web/src/store/flow-store.ts@@ -70,14 +70,13 @@ const createStore = (initialNodes: AppNode[] = [], initialEdges: Edge[] = []) =>try {// Batch database operations with the UI updateconst { error } = await supabase- .from("relationships")+ .from("individuals_individuals").upsert({individual_a: params.source,individual_b: params.target,sketch_id: sketch_id,relation_type: "relation"});-if (!error) {set({edges: addEdge(diff --git a/flowsint-web/src/store/sketch-store.ts b/flowsint-web/src/store/sketch-store.tsindex 5d50e77d..906f733d 100644--- a/flowsint-web/src/store/sketch-store.ts+++ b/flowsint-web/src/store/sketch-store.ts@@ -40,7 +40,7 @@ interface SketchState {// Modal HandlershandleOpenIndividualModal: (id: string) => voidsetHandleOpenIndividualModal: (handler: (id: string) => void) => void- HandleDeleteSketch: () => Promise<void>+ handleDeleteSketch: () => Promise<void>setHandleDeleteSketch: (handler: () => Promise<void>) => void// Query Hooks@@ -79,8 +79,8 @@ export const useSketchStore = create(setSketch: (sketch) => set({ sketch }),handleOpenIndividualModal: () => { },setHandleOpenIndividualModal: (handler) => set({ handleOpenIndividualModal: handler }),- HandleDeleteSketch: async () => { },- setHandleDeleteSketch: (handler) => set({ HandleDeleteSketch: handler }),+ handleDeleteSketch: async () => { },+ setHandleDeleteSketch: (handler) => set({ handleDeleteSketch: handler }),useSketchData: (investigationId: string, sketchId: string) => {const wrapRefetch = async (refetch: () => Promise<QueryObserverResult>) => {await refetch()diff --git a/flowsint-web/src/types/investigation.ts b/flowsint-web/src/types/investigation.tsindex b19741ab..90bfbcde 100644--- a/flowsint-web/src/types/investigation.ts+++ b/flowsint-web/src/types/investigation.ts@@ -8,5 +8,6 @@ export interface Investigation {created_at: stringlast_updated_at: stringowner: any+ owner_id: string,members?: any[]}\ No newline at end of filediff --git a/flowsint-web/src/types/sketch.ts b/flowsint-web/src/types/sketch.tsindex f649434a..beb20c36 100644--- a/flowsint-web/src/types/sketch.ts+++ b/flowsint-web/src/types/sketch.ts@@ -9,6 +9,7 @@ export interface Sketch {created_at: stringlast_updated_at: stringowner: any+ owner_id: string,relations?: any[]individuals?: any[]investigation?: Investigation