A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat: highlight relations and node
dextmorgn8e973a1279c7
diff --git a/package.json b/package.jsonindex ea0b2f37..e32ef233 100644--- a/package.json+++ b/package.json@@ -36,7 +36,7 @@"clsx": "2.1.1","d3-force": "^3.0.0","d3-quadtree": "^3.0.1",- "framer-motion": "11.13.1",+ "framer-motion": "^12.3.1","intl-messageformat": "^10.5.0","lucide-react": "^0.474.0","next": "15.1.6",diff --git a/src/app/investigations/[investigation_id]/data.js b/src/app/investigations/[investigation_id]/data.jsnew file mode 100644index 00000000..4fa52055--- /dev/null+++ b/src/app/investigations/[investigation_id]/data.js@@ -0,0 +1,26 @@+export const usernames = [+ "@cyberwarrior",+ "@net_hunter",+ "@reconmaster",+ "@pentest_guru",+ "@osint_seeker",+ "@hash_cracker"+]++export const countries = [+ "France",+ "Germany",+ "United States",+ "Netherlands",+ "Canada",+ "Sweden"+]++export const settings = [+ "socials",+ "emails",+ "ips",+ "account",+ "address",+ "relations"+]diff --git a/src/app/investigations/[investigation_id]/layout.tsx b/src/app/investigations/[investigation_id]/layout.tsxindex 3b0b5289..e3cbb9e6 100644--- a/src/app/investigations/[investigation_id]/layout.tsx+++ b/src/app/investigations/[investigation_id]/layout.tsx@@ -1,7 +1,9 @@+import DisplaySelector from '@/src/components/investigations/display-selector';import { InvestigationProvider } from '@/src/components/investigations/investigation-provider';import InvestigationLayout from '@/src/components/investigations/layout';import { getInvestigation } from '@/src/lib/actions/investigations';-+import { Text } from '@radix-ui/themes';+import { usernames, countries, settings } from './data.js'const DashboardLayout = async ({children,params,@@ -12,9 +14,21 @@ const DashboardLayout = async ({const { investigation_id } = await (params)const { investigation, error } = await getInvestigation(investigation_id)if (error) return <div>An error occured.</div>++ const Left = () => (+ <div className='flex flex-col gap-2'>+ <Text size={"2"}>Display</Text>+ <DisplaySelector values={settings} />+ <Text size={"2"}>Countries</Text>+ <DisplaySelector values={countries} />+ <Text size={"2"}>Usernames</Text>+ <DisplaySelector values={usernames} />++ </div>+ )return (<InvestigationProvider>- <InvestigationLayout investigation={investigation}>+ <InvestigationLayout left={<Left />} investigation={investigation}>{children}</InvestigationLayout></InvestigationProvider>diff --git a/src/components/investigations/display-selector.tsx b/src/components/investigations/display-selector.tsxnew file mode 100644index 00000000..efff1a77--- /dev/null+++ b/src/components/investigations/display-selector.tsx@@ -0,0 +1,100 @@+"use client"++import { useState } from "react"+import { motion, AnimatePresence } from "framer-motion"+import { Check } from 'lucide-react'++export default function DisplaySelector({ values }: { values: string[] }) {+ const [selected, setSelected] = useState<string[]>([])++ const toggleSelect = (val: string) => {+ setSelected((prev) =>+ prev.includes(val) ? prev.filter((c) => c !== val) : [...prev, val]+ )+ }++ return (+ <div className="">+ <motion.div+ className="flex flex-wrap gap-1 overflow-visible"+ layout+ transition={{+ type: "spring",+ stiffness: 500,+ damping: 30,+ mass: 0.5,+ }}+ >+ {values.map((value: string) => {+ const isSelected = selected.includes(value)+ return (+ <motion.button+ key={value}+ onClick={() => toggleSelect(value)}+ layout+ initial={false}+ animate={{+ backgroundColor: isSelected ? "#2a1711" : "rgba(39, 39, 42, 0.5)",+ }}+ whileHover={{+ backgroundColor: isSelected ? "#2a1711" : "rgba(39, 39, 42, 0.8)",+ }}+ whileTap={{+ backgroundColor: isSelected ? "#1f1209" : "rgba(39, 39, 42, 0.9)",+ }}+ transition={{+ type: "spring",+ stiffness: 500,+ damping: 30,+ mass: 0.5,+ backgroundColor: { duration: 0.1 },+ }}+ className={`+ inline-flex items-center px-2 py-1 rounded-full text-xs font-medium+ whitespace-nowrap overflow-hidden ring-1 ring-inset+ ${isSelected+ ? "text-[#ff9066] ring-[hsla(0,0%,100%,0.12)]"+ : "text-zinc-400 ring-[hsla(0,0%,100%,0.06)]"}+ `}+ >+ <motion.div+ className="relative flex items-center"+ animate={{+ width: isSelected ? "auto" : "100%",+ paddingRight: isSelected ? "1rem" : "0",+ }}+ transition={{+ ease: [0.175, 0.885, 0.32, 1.275],+ duration: 0.3,+ }}+ >+ <span>{value}</span>+ <AnimatePresence>+ {isSelected && (+ <motion.span+ initial={{ scale: 0, opacity: 0 }}+ animate={{ scale: 1, opacity: 1 }}+ exit={{ scale: 0, opacity: 0 }}+ transition={{+ type: "spring",+ stiffness: 500,+ damping: 30,+ mass: 0.5+ }}+ className="absolute right-0"+ >+ <div className="w-3 h-3 rounded-full bg-[#ff9066] flex items-center justify-center">+ <Check className="w-2 h-2 text-[#2a1711]" strokeWidth={1.5} />+ </div>+ </motion.span>+ )}+ </AnimatePresence>+ </motion.div>+ </motion.button>+ )+ })}+ </motion.div>+ </div>+ )+}+diff --git a/src/components/investigations/graph.tsx b/src/components/investigations/graph.tsxindex 4fec00fe..09a88622 100644--- a/src/components/investigations/graph.tsx+++ b/src/components/investigations/graph.tsx@@ -12,6 +12,8 @@ import {addEdge,ColorMode,MiniMap,+ Node,+ Edge} from '@xyflow/react';import '@xyflow/react/dist/style.css';import { supabase } from '@/src/lib/supabase/client';@@ -21,13 +23,15 @@ import CustomEdge from './custom-edge';import IpNode from './nodes/ip_address';import EmailNode from './nodes/email';import SocialNode from './nodes/social'+import AddressNode from './nodes/physical_address'import { AlignCenterHorizontal, AlignCenterVertical, MaximizeIcon, RotateCcwIcon, ZoomInIcon, ZoomOutIcon } from 'lucide-react';import { useTheme } from 'next-themes';import NewActions from './new-actions';import { IconButton, Tooltip, Spinner } from '@radix-ui/themes';-import { usePathname, useSearchParams, useRouter } from 'next/navigation';+import { isNode, isEdge, getIncomers, getOutgoers } from "@xyflow/react";+import { EdgeBase } from '@xyflow/system';-const nodeTypes = { individual: IndividualNode, phone: PhoneNode, ip: IpNode, email: EmailNode, social: SocialNode };+const nodeTypes = { individual: IndividualNode, phone: PhoneNode, ip: IpNode, email: EmailNode, social: SocialNode, address: AddressNode };const edgeTypes = {'custom': CustomEdge,};@@ -61,22 +65,136 @@ const getLayoutedElements = (nodes: any[], edges: any[], options: { direction: a};const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any, initialEdges: any, theme: ColorMode }) => {- const { fitView, zoomIn, zoomOut, addNodes } = useReactFlow();+ const { fitView, zoomIn, zoomOut, addNodes, getNodes, getEdges } = useReactFlow();const [nodes, setNodes, onNodesChange] = useNodesState(initialNodes);const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);- const router = useRouter()- const pathname = usePathname()- const searchParams = useSearchParams()const ref = useRef(null);- const createQueryString = useCallback(- (name: string, value: string) => {- const params = new URLSearchParams(searchParams.toString())- params.set(name, value)+ const getAllIncomers = useCallback((node: any, nodes: any[], edges: EdgeBase[], prevIncomers = []) => {+ const incomers = getIncomers(node, nodes, edges);+ const result = incomers.reduce(+ (memo, incomer) => {+ memo.push(incomer);+ //@ts-ignore+ if ((prevIncomers.findIndex(n => n.id == incomer.id) == -1)) {+ prevIncomers.push(incomer as never);- return params.toString()+ getAllIncomers(incomer, nodes, edges, prevIncomers).forEach((foundNode: { id: any; }) => {+ memo.push(foundNode);+ //@ts-ignore+ if ((prevIncomers.findIndex(n => n.id == foundNode.id) == -1)) {+ prevIncomers.push(incomer as never);++ }+ });+ }+ return memo;+ },+ []+ );+ return result;+ }, [])++ const getAllOutgoers = useCallback((node: any, nodes: any[], edges: EdgeBase[], prevOutgoers: any = []) => {+ const outgoers = getOutgoers(node, nodes, edges);+ return outgoers.reduce(+ (memo, outgoer) => {+ memo.push(outgoer);+ if ((prevOutgoers.findIndex((n: any) => n.id == outgoer.id) == -1)) {+ prevOutgoers.push(outgoer);+ getAllOutgoers(outgoer, nodes, edges, prevOutgoers).forEach((foundNode: { id: any; }) => {+ memo.push(foundNode);+ if ((prevOutgoers.findIndex((n: any) => n.id == foundNode.id) == -1)) {+ prevOutgoers.push(foundNode);+ }+ });+ }+ return memo;+ },+ []+ )+ }, [])++ const highlightPath = useCallback(+ (selectedNode: Node | null) => {+ if (!selectedNode) {+ setNodes((nodes) =>+ nodes.map((node) => ({+ ...node,+ style: { ...node.style, opacity: 1 },+ })),+ )+ setEdges((edges) =>+ edges.map((edge) => ({+ ...edge,+ animated: false,+ style: { ...edge.style, stroke: "#b1b1b7", opacity: 1 },+ })),+ )+ return+ }+ const nodes = getNodes()+ const edges = getEdges()+ const allIncomers = getIncomers(selectedNode, nodes, edges)+ const allOutgoers = getOutgoers(selectedNode, nodes, edges)+ const incomerIds = new Set(allIncomers.map((node) => node.id))+ const outgoerIds = new Set(allOutgoers.map((node) => node.id))+ setNodes((prevNodes) =>+ prevNodes.map((node) => {+ const highlight = node.id === selectedNode.id || incomerIds.has(node.id) || outgoerIds.has(node.id)+ return {+ ...node,+ disabled: !highlight,+ draggable: highlight,+ style: {+ ...node.style,+ opacity: highlight ? 1 : 0.25,+ },+ }+ }),+ )+ setEdges((prevEdges) =>+ prevEdges.map((edge) => {+ const animated =+ incomerIds.has(edge.source) && (incomerIds.has(edge.target) || selectedNode.id === edge.target)+ return {+ ...edge,+ animated,+ style: {+ ...edge.style,+ stroke: animated ? "#3030e6" : "#b1b1b7",+ opacity: animated ? 1 : 0.25,+ },+ }+ }),+ )},- [searchParams]+ [getNodes, getEdges, setNodes, setEdges],)++ const resetNodeStyles = useCallback(() => {+ setNodes((nodes) =>+ nodes.map((node) => ({+ ...node,+ disabled: false,+ draggable: true,+ style: {+ ...node.style,+ opacity: 1,+ },+ })),+ )+ setEdges((edges) =>+ edges.map((edge) => ({+ ...edge,+ animated: false, // Désactive l'animation+ style: {+ ...edge.style,+ stroke: "#b1b1b7",+ opacity: 1,+ },+ })),+ )+ }, [setNodes, setEdges])const onLayout = useCallback((direction: any) => {const layouted = getLayoutedElements(nodes, edges, { direction });@@ -90,7 +208,6 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,);const onConnect = useCallback(async (params: any) => {- console.log(params)await supabase.from("relationships").insert({ individual_a: params.source, individual_b: params.target, relation_type: "relation" })setEdges((els) => addEdge({ ...params, label: "relation", type: "custom" }, els))@@ -98,13 +215,25 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,[setEdges],);++ const onNodeClick = useCallback(+ (_: React.MouseEvent, node: Node) => {+ highlightPath(node)+ },+ [highlightPath],+ )++ const onPaneClick = useCallback(+ () => {+ resetNodeStyles()+ },+ [resetNodeStyles],+ )+useEffect(() => {onLayout('LR')}, [initialEdges])- const handleOpenIndividualModal = (id: string) => router.push(pathname + '?' + createQueryString('individual_id', id))--return (<div className='h-[calc(100vh_-_48px)]'><ReactFlow@@ -115,10 +244,8 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,onNodesChange={onNodesChange}onEdgesChange={onEdgesChange}onConnect={onConnect}- onNodeClick={(_, node) => {- if (node.type !== "individual") return- handleOpenIndividualModal(node.id);- }}+ onNodeClick={onNodeClick}+ onPaneClick={onPaneClick}fitViewproOptions={{hideAttribution: true@@ -168,7 +295,7 @@ const LayoutFlow = ({ initialNodes, initialEdges, theme }: { initialNodes: any,</Tooltip></Panel><Background />- <MiniMap />+ <MiniMap pannable /></ReactFlow></div>);diff --git a/src/components/investigations/individual-modal.tsx b/src/components/investigations/individual-modal.tsxindex 4535cf6b..e1ef6fa9 100644--- a/src/components/investigations/individual-modal.tsx+++ b/src/components/investigations/individual-modal.tsx@@ -14,33 +14,43 @@ import {Avatar,Tabs,IconButton,+ Text,+ Spinner,+ Badge,+ Grid,+ Link,} from "@radix-ui/themes"import { usePathname, useRouter, useSearchParams } from "next/navigation"import { useIndividual } from "@/src/lib/hooks/use-individual"import { Pencil1Icon, Cross2Icon, PlusIcon, TrashIcon } from "@radix-ui/react-icons"-import social from "./nodes/social"+import { useRelations } from "@/src/lib/hooks/use-relations"+import { useInvestigationContext } from "./investigation-provider"+import { usePlatformIcons } from "@/src/lib/hooks/use-platform-icons"const IndividualModal = () => {const router = useRouter()const pathname = usePathname()const searchParams = useSearchParams()const individual_id = searchParams.get("individual_id")+ const { handleOpenIndividualModal } = useInvestigationContext()const { individual, isLoading } = useIndividual(individual_id)+ const platformsIcons = usePlatformIcons("medium")+ const { relations, isLoading: isLoadingRelations } = useRelations(individual_id)const [editMode, setEditMode] = useState(false)const [emails, setEmails] = useState([""])const [phones, setPhones] = useState([""])const [accounts, setAccounts] = useState([""])- const [ipAddresses, setIpAddresses] = useState([""])+ const [ips, setIps] = useState([""])- console.log(individual)useEffect(() => {setEmails(individual?.emails.map(({ email }: any) => email) || [""])setPhones(individual?.phone_numbers.map(({ phone_number }: any) => phone_number) || [""])- setIpAddresses(individual?.ip_addresses.map(({ ip_address }: any) => ip_address) || [""])- setAccounts(individual?.social_accounts.map(({ username }: any) => username) || [""])+ setIps(individual?.ip_addresses.map(({ ip_address }: any) => ip_address) || [""])+ setAccounts(individual?.social_accounts || [""])}, [individual])const handleCloseModal = () => {+ setEditMode(false)router.push(pathname)}@@ -50,12 +60,14 @@ const IndividualModal = () => {const formContent = Object.fromEntries(formData.entries())formContent.emails = emails as anyformContent.phones = phones as any- formContent.ip_addresses = ipAddresses as any+ formContent.ip_addresses = ips as any+ formContent.accounts = accounts as anyalert(JSON.stringify(formContent, null, 2))setEditMode(false)}const handleAddField = (setter: React.Dispatch<React.SetStateAction<string[]>>) => {+ setEditMode(true)setter((prev) => [...prev, ""])}@@ -87,10 +99,10 @@ const IndividualModal = () => {return (<Dialog.Root open={Boolean(individual_id)} onOpenChange={handleCloseModal}>- <Dialog.Content style={{ maxWidth: "900px", width: "90vw" }} minHeight={"80vh"}>+ <Dialog.Content style={{ maxWidth: "1200px", width: "90vw" }} minHeight={"80vh"}><Skeleton loading={isLoading}><form className="flex flex-col gap-3 justify-between h-full" onSubmit={handleSave}>- <Flex direction="column" gap="4">+ <Flex direction="column" gap="4" flexGrow="0"><Flex justify="between" align="center"><Dialog.Title>User Profile</Dialog.Title><IconButton@@ -106,6 +118,7 @@ const IndividualModal = () => {<Flex direction={"column"}><Avatarsize="9"+ src={individual?.image_url}fallback={individual?.full_name?.[0] || "?"}radius="full"/>@@ -119,20 +132,31 @@ const IndividualModal = () => {<Tabs.Root defaultValue="overview"><Tabs.List><Tabs.Trigger value="overview">Overview</Tabs.Trigger>- <Tabs.Trigger value="social_account">Social accounts</Tabs.Trigger>- <Tabs.Trigger value="emails">Emails</Tabs.Trigger>- <Tabs.Trigger value="phone_numbers">Phone numbers</Tabs.Trigger>- <Tabs.Trigger value="ip_addresses">IP addresses</Tabs.Trigger>+ <Tabs.Trigger value="social_account">Social accounts<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={accounts?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{accounts?.length}</Badge></Spinner></Tabs.Trigger>+ <Tabs.Trigger value="emails">Emails<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={emails?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{emails?.length}</Badge></Spinner></Tabs.Trigger>+ <Tabs.Trigger value="phone_numbers">Phone numbers<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={phones?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{phones?.length}</Badge></Spinner></Tabs.Trigger>+ <Tabs.Trigger value="ip_addresses">IP addresses<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={ips?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{ips?.length}</Badge></Spinner></Tabs.Trigger>+ <Tabs.Trigger value="relations">Relations<Spinner className="ml-1" loading={isLoadingRelations}><Badge color={relations?.length > 0 ? "indigo" : "gray"} radius="full" className="ml-1">{relations?.length}</Badge></Spinner></Tabs.Trigger></Tabs.List><Box pt="3"><Tabs.Content value="overview"><Flex direction="column" gap="3">- <TextField.Root- defaultValue={individual?.full_name}- placeholder="Full Name"- name="full_name"- disabled={!editMode}- />+ {individual && Object.keys(individual).filter((key) => typeof individual[key] !== "object" || !Array.isArray(individual[key])).map((key) => (+ <Flex key={key} direction="column" gap="1">+ <label className="capitalize-first">{key}</label>+ <TextField.Root+ defaultValue={individual[key]}+ placeholder={key}+ name={key}+ disabled={!editMode}+ />+ </Flex>+ ))}+ </Flex>+ </Tabs.Content>+ <Tabs.Content value="emails">+ <Flex direction="column" gap="3" maxWidth={"420px"}>+ {emails.length === 0 && <Text className="italic opacity-60 text-sm">No email registered. Click on edit to add one.</Text>}{emails.map((email: string | number | undefined, index: React.Key | null | undefined) => (<Flex key={index} gap="2" align="center"><TextField.Root@@ -160,6 +184,42 @@ const IndividualModal = () => {<PlusIcon /> Add Email</Button>)}+ </Flex>+ </Tabs.Content>+ <Tabs.Content value="social_account">+ <Grid columns="3" gap="3" width="auto">+ {accounts.length === 0 && <Text className="italic opacity-60 text-sm">No account registered. Click on edit to add one.</Text>}+ {accounts.map((account: any, index) => (+ <Badge className="!p-3 cursor-pointer" color="gray" radius="large" key={index} asChild size="1">+ <Flex gap="3" align="center" direction={"row"} className="w-full">+ {/* @ts-ignore */}+ <Avatar size="3" radius="full" color={platformsIcons[account?.platform]?.color || "amber"} fallback={platformsIcons[account?.platform]?.icon || "?"} />+ <Box width={"80%"}>+ <Text as="div" size="1" weight="bold">+ {account?.platform}+ </Text>+ <Text as="div" size="2" weight="bold">+ {account?.username || <span className="italic font-light">No username</span>}+ </Text>+ <Link href={account?.profile_url} size="2" className="!max-w-full" color="indigo">+ <Text as="div" truncate>+ {account?.profile_url}+ </Text>+ </Link>+ </Box>+ </Flex>+ </Badge>+ ))}+ {editMode && (+ <Button type="button" onClick={() => handleAddField(setAccounts)} variant="soft">+ <PlusIcon /> Add account+ </Button>+ )}+ </Grid>+ </Tabs.Content>+ <Tabs.Content value="phone_numbers">+ <Flex direction="column" gap="3" maxWidth={"420px"}>+ {phones.length === 0 && <Text className="italic opacity-60 text-sm">No phone number registered. Click on edit to add one.</Text>}{phones.map((phone, index) => (<Flex key={index} gap="2" align="center"><TextField.Root@@ -189,31 +249,25 @@ const IndividualModal = () => {)}</Flex></Tabs.Content>- <Tabs.Content value="social_account">+ <Tabs.Content value="ip_addresses"><Flex direction="column" gap="3">- <TextField.Root- defaultValue={individual?.username}- placeholder="Username"- name="username"- disabled={!editMode}- />- {editMode && (- <TextField.Root placeholder="New Password" name="new_password" type="password" />- )}- {accounts.map((account, index) => (+ {ips.length === 0 && <Text className="italic opacity-60 text-sm">No IP address registered. Click on edit to add one.</Text>}+ {ips.map((ip, index) => (<Flex key={index} gap="2" align="center"><TextField.Root- value={account}- onChange={(e) => handleFieldChange(index, e.target.value, setAccounts)}- placeholder="Social account"+ value={ip}+ onChange={(e) => handleFieldChange(index, e.target.value, setIps)}+ placeholder="IP address"+ type="text"disabled={!editMode}style={{ flexGrow: 1 }}/>{editMode && (<IconButton+ type="button"variant="ghost"- onClick={() => handleRemoveField(index, setAccounts)}- aria-label="Remove social account"+ onClick={() => handleRemoveField(index, setIps)}+ aria-label="Remove ip"><TrashIcon /></IconButton>@@ -221,44 +275,31 @@ const IndividualModal = () => {</Flex>))}{editMode && (- <Button type="button" onClick={() => handleAddField(setIpAddresses)} variant="soft">- <PlusIcon /> Add IP Address+ <Button type="button" onClick={() => handleAddField(setIps)} variant="soft">+ <PlusIcon /> Add IP address</Button>)}</Flex></Tabs.Content>-- <Tabs.Content value="emails">- <Flex direction="column" gap="3">- <TextField.Root- defaultValue={individual?.language}- placeholder="Preferred Language"- name="language"- disabled={!editMode}- />- <TextField.Root- defaultValue={individual?.timezone}- placeholder="Timezone"- name="timezone"- disabled={!editMode}- />- </Flex>- </Tabs.Content>- <Tabs.Content value="phone_numbers">- <Flex direction="column" gap="3">- <TextField.Root- defaultValue={individual?.language}- placeholder="Preferred Language"- name="language"- disabled={!editMode}- />- <TextField.Root- defaultValue={individual?.timezone}- placeholder="Timezone"- name="timezone"- disabled={!editMode}- />- </Flex>+ <Tabs.Content value="relations">+ <Grid columns="3" gap="3" width="auto">+ {relations.length === 0 && <Text className="italic opacity-60 text-sm">No relation registered. Click on edit to add one.</Text>}+ {relations.map((relation) => (+ <Badge className="!p-3 cursor-pointer" color="gray" radius="large" key={relation.id} onClick={() => handleOpenIndividualModal(relation.id)} asChild size="1">+ <Flex gap="3" align="center" direction={"row"} className="w-full">+ <Avatar src={relation?.image_url} size="3" radius="full" fallback={relation.full_name[0]} color="indigo" />+ <Box>+ <Text as="div" size="2" weight="bold">+ {relation.full_name}+ </Text>+ <Text as="div" size="2" color="gray">+ {relation.relation_type}+ </Text>+ </Box>+ </Flex>+ </Badge>+ ))}+ </Grid></Tabs.Content></Box></Tabs.Root>diff --git a/src/components/investigations/investigation-provider.tsx b/src/components/investigations/investigation-provider.tsxindex c386a79d..5e1e2369 100644--- a/src/components/investigations/investigation-provider.tsx+++ b/src/components/investigations/investigation-provider.tsx@@ -1,11 +1,10 @@"use client"-import useLocalStorage from "@/src/lib/use-local-storage";-import React, { createContext, useContext, ReactNode, useState } from "react";+import useLocalStorage from "@/src/lib/hooks/use-local-storage";+import React, { createContext, useContext, ReactNode, useState, useCallback } from "react";import { Button, Dialog, Flex, Switch } from "@radix-ui/themes";-import { useParams } from "next/navigation";+import { useParams, useRouter, usePathname, useSearchParams } from "next/navigation";import { Investigation } from "@/src/types/investigation";import { useInvestigation } from "@/src/lib/hooks/investigation";-import { supabase } from "@/src/lib/supabase/client";import { ThemeSwitch } from "../theme-switch";interface InvestigationContextType {@@ -16,6 +15,7 @@ interface InvestigationContextType {setOpenSettingsModal: any,investigation: Investigation | null,isLoadingInvestigation: boolean | undefined,+ handleOpenIndividualModal: any}const InvestigationContext = createContext<InvestigationContextType | undefined>(undefined);@@ -24,23 +24,30 @@ interface InvestigationProviderProps {}export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ children }) => {- const [filters, setFilters] = useLocalStorage('filters', {});const { investigation_id } = useParams()+ const router = useRouter()+ const pathname = usePathname()+ const searchParams = useSearchParams()+ const [filters, setFilters] = useLocalStorage('filters', {});const { investigation, isLoading: isLoadingInvestigation } = useInvestigation(investigation_id)const [openSettingsModal, setOpenSettingsModal] = useState(false)+const [settings, setSettings] = useLocalStorage('settings', {showNodeLabel: true,showEdgeLabel: true});- const handleDeleteNode = async (id: string) => {- await supabase.from("individuals").delete().eq("id", id)- .then(({ data, error }) => {- if (error)- alert('an error occured.')- return data- })- }+ const createQueryString = useCallback(+ (name: string, value: string) => {+ const params = new URLSearchParams(searchParams.toString())+ params.set(name, value)++ return params.toString()+ },+ [searchParams]+ )+ const handleOpenIndividualModal = (id: string) => router.push(pathname + '?' + createQueryString('individual_id', id))+const SettingSwitch = ({ setting, value, title, description }: { setting: string, value: boolean, title: string, description: string }) => (<div className="flex items-center justify-between gap-4">@@ -54,7 +61,7 @@ export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ ch</div>)return (- <InvestigationContext.Provider value={{ filters, setFilters, settings, setSettings, setOpenSettingsModal, investigation, isLoadingInvestigation }}>+ <InvestigationContext.Provider value={{ filters, setFilters, settings, setSettings, setOpenSettingsModal, investigation, isLoadingInvestigation, handleOpenIndividualModal }}>{children}<Dialog.Root open={openSettingsModal}><Dialog.Content maxWidth="450px">@@ -64,7 +71,7 @@ export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ ch</Dialog.Description><Flex direction="column" gap="3"><SettingSwitch setting={"showNodeLabel"} value={settings.showNodeLabel} title={"Show labels on nodes"} description={"Displays the labels on the nodes, like username or avatar."} />- <SettingSwitch setting={"showEdgeLabel"} value={settings.showEdgeLabel} title={"Show labels on edeges"} description={"Displays the labels on the edges, like relation type."} />+ <SettingSwitch setting={"showEdgeLabel"} value={settings.showEdgeLabel} title={"Show labels on edges"} description={"Displays the labels on the edges, like relation type."} /><div className="flex items-center justify-between gap-4"><div className="flex flex-col gap-1"><p className="font-medium">Theme</p>@@ -74,7 +81,6 @@ export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ ch</div><ThemeSwitch /></div>-</Flex><Flex gap="3" mt="4" justify="end"><Dialog.Close onClick={() => setOpenSettingsModal(false)}>diff --git a/src/components/investigations/layout.tsx b/src/components/investigations/layout.tsxindex fa36916a..adfa14d8 100644--- a/src/components/investigations/layout.tsx+++ b/src/components/investigations/layout.tsx@@ -8,10 +8,12 @@ import NewCase from '../dashboard/new-case';const InvestigationLayout = ({children,- investigation+ investigation,+ left}: {children: React.ReactNode;- investigation: Investigation+ investigation: Investigation,+ left: React.ReactNode;}) => {return (<div className='h-screen w-screen flex'>@@ -20,10 +22,9 @@ const InvestigationLayout = ({<div className='w-full rounded-none shadow-none h-12 border-b border-gray-400/20 flex items-center flex-row justify-end p-2'><NewCase /></div>- <div className='p-3'>+ <div className='p-3 grow overflow-y-auto'><div className="flex flex-col">- <p className="text-md">{investigation.title}</p>- <p className="text-sm opacity-60">{investigation.description}</p>+ {left}</div></div></div>diff --git a/src/components/investigations/nodes/email.tsx b/src/components/investigations/nodes/email.tsxindex dfd47766..74dca620 100644--- a/src/components/investigations/nodes/email.tsx+++ b/src/components/investigations/nodes/email.tsx@@ -19,7 +19,7 @@ function EmailNode({ data }: any) {<Card><Inset><Flex className='items-center p-0'>- <Badge className='!h-[24px] !rounded-r-none'>+ <Badge color='green' className='!h-[24px] !rounded-r-none'><AtSignIcon className='h-3 w-3' /></Badge><Box className='p-1'>@@ -31,7 +31,7 @@ function EmailNode({ data }: any) {</Inset></Card>:- <Tooltip content={data.username || data.profile_url}>+ <Tooltip content={data.label}><button className='!rounded-full border-transparent'><Avatarsize="1"diff --git a/src/components/investigations/nodes/individual.tsx b/src/components/investigations/nodes/individual.tsxindex 2799a5c8..bd837f37 100644--- a/src/components/investigations/nodes/individual.tsx+++ b/src/components/investigations/nodes/individual.tsx@@ -1,24 +1,25 @@"use client"-import React, { memo, useCallback } from 'react';+import React, { memo } from 'react';import { Handle, Position } from '@xyflow/react';import { useInvestigationContext } from '../investigation-provider';-import { Avatar, Card, Box, Flex, Text, ContextMenu, Spinner, Badge, Tooltip } from '@radix-ui/themes';-import { AtSignIcon, CameraIcon, FacebookIcon, InstagramIcon, LocateIcon, MessageCircleDashedIcon, PhoneIcon, SendIcon, UserIcon } from 'lucide-react';+import { Avatar, Card, Box, Flex, Text, ContextMenu, Spinner, Badge, Tooltip, Code } from '@radix-ui/themes';+import { AtSignIcon, CameraIcon, FacebookIcon, InstagramIcon, LocateIcon, MessageCircleDashedIcon, PhoneIcon, SendIcon, UserIcon, MapPinHouseIcon } from 'lucide-react';import { NodeProvider, useNodeContext } from './node-context';import { cn } from '@/utils';-function Custom({ data }: any) {- const { settings } = useInvestigationContext()+function Custom(props: any) {+ const { settings, handleOpenIndividualModal } = useInvestigationContext()const { setOpenAddNodeModal, handleDuplicateNode, handleDeleteNode, loading } = useNodeContext()-+ const { data } = propsreturn (<><ContextMenu.Root>- <ContextMenu.Trigger>+ <ContextMenu.Trigger onContextMenu={(e) => { e.stopPropagation() }}><Box className={cn(loading ? "!opacity-40" : "!opacity-100")}>{settings.showNodeLabel ?- <Card className='!py-1'>+ <Card onDoubleClick={() => handleOpenIndividualModal(data.id)} className='!py-1'><Flex gap="2" align="center"><Avatar+ color='gray'size="2"src={data?.image_url}radius="full"@@ -36,7 +37,7 @@ function Custom({ data }: any) {</Flex></Card> :<Tooltip content={data.full_name}>- <button className='!rounded-full border-transparent'>+ <button onDoubleClick={() => handleOpenIndividualModal(data.id)} className='!rounded-full border-transparent'><Avatarsize="3"src={data?.image_url}@@ -61,24 +62,25 @@ function Custom({ data }: any) {<ContextMenu.Sub><ContextMenu.SubTrigger >New</ContextMenu.SubTrigger><ContextMenu.SubContent>- <ContextMenu.Item onClick={() => setOpenAddNodeModal("individuals")}><UserIcon className='h-4 w-4' /> New relation</ContextMenu.Item>- <ContextMenu.Item onClick={() => setOpenAddNodeModal("phone_numbers", data.id)}><PhoneIcon className='h-4 w-4' />Phone number</ContextMenu.Item>- <ContextMenu.Item onClick={() => setOpenAddNodeModal("emails", data.id)}><AtSignIcon className='h-4 w-4' />Email address</ContextMenu.Item>- <ContextMenu.Item onClick={() => setOpenAddNodeModal("ip_addresses", data.id)}><LocateIcon className='h-4 w-4' />IP address</ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "individuals")}><UserIcon className='h-4 w-4' /> New relation</ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "phone_numbers", data.id)}><PhoneIcon className='h-4 w-4' />Phone number</ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "physical_addresses", data.id)}><MapPinHouseIcon className='h-4 w-4' />Physical address</ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "emails", data.id)}><AtSignIcon className='h-4 w-4' />Email address</ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "ip_addresses", data.id)}><LocateIcon className='h-4 w-4' />IP address</ContextMenu.Item><ContextMenu.Sub><ContextMenu.SubTrigger >Social account</ContextMenu.SubTrigger><ContextMenu.SubContent>- <ContextMenu.Item onClick={() => setOpenAddNodeModal("social_accounts_facebook", data.id)}><FacebookIcon className='h-4 w-4' />Facebook</ContextMenu.Item>- <ContextMenu.Item onClick={() => setOpenAddNodeModal("social_accounts_instagram", data.id)}><InstagramIcon className='h-4 w-4' />Instagram</ContextMenu.Item>- <ContextMenu.Item onClick={() => setOpenAddNodeModal("social_accounts_telegram", data.id)}><SendIcon className='h-4 w-4' />Telegram</ContextMenu.Item>- <ContextMenu.Item onClick={() => setOpenAddNodeModal("social_accounts_signal", data.id)}><MessageCircleDashedIcon className='h-4 w-4' />Signal</ContextMenu.Item>- <ContextMenu.Item onClick={() => setOpenAddNodeModal("social_accounts_snapchat", data.id)}><CameraIcon className='h-4 w-4' />Snapchat</ContextMenu.Item>- <ContextMenu.Item disabled onClick={() => setOpenAddNodeModal("social_accounts_coco", data.id)}>Coco <Badge radius='full'>soon</Badge></ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "social_accounts_facebook", data.id)}><FacebookIcon className='h-4 w-4' />Facebook</ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "social_accounts_instagram", data.id)}><InstagramIcon className='h-4 w-4' />Instagram</ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "social_accounts_telegram", data.id)}><SendIcon className='h-4 w-4' />Telegram</ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "social_accounts_signal", data.id)}><MessageCircleDashedIcon className='h-4 w-4' />Signal</ContextMenu.Item>+ <ContextMenu.Item onClick={(e) => setOpenAddNodeModal(e, "social_accounts_snapchat", data.id)}><CameraIcon className='h-4 w-4' />Snapchat</ContextMenu.Item>+ <ContextMenu.Item disabled onClick={(e) => setOpenAddNodeModal(e, "social_accounts_coco", data.id)}>Coco <Badge radius='full'>soon</Badge></ContextMenu.Item></ContextMenu.SubContent></ContextMenu.Sub></ContextMenu.SubContent></ContextMenu.Sub>- <ContextMenu.Item>View and edit</ContextMenu.Item>+ <ContextMenu.Item onClick={() => handleOpenIndividualModal(data.id)}>View and edit</ContextMenu.Item><ContextMenu.Item onClick={handleDuplicateNode}>Duplicate</ContextMenu.Item><ContextMenu.Separator /><ContextMenu.Item onClick={handleDeleteNode} shortcut="⌘ ⌫" color="red">diff --git a/src/components/investigations/nodes/ip_address.tsx b/src/components/investigations/nodes/ip_address.tsxindex b9094fde..51008e76 100644--- a/src/components/investigations/nodes/ip_address.tsx+++ b/src/components/investigations/nodes/ip_address.tsx@@ -20,7 +20,7 @@ function Custom({ data }: any) {<Card><Inset><Flex className='items-center p-0'>- <Badge className='!h-[24px] !rounded-r-none'>+ <Badge color='orange' className='!h-[24px] !rounded-r-none'><LocateIcon className='h-3 w-3' /></Badge><Box className='p-1'>diff --git a/src/components/investigations/nodes/node-context.tsx b/src/components/investigations/nodes/node-context.tsxindex bb235508..380304c7 100644--- a/src/components/investigations/nodes/node-context.tsx+++ b/src/components/investigations/nodes/node-context.tsx@@ -1,9 +1,10 @@"use client"import React, { createContext, useContext, ReactNode, useState, useCallback } from "react";-import { Button, Dialog, Flex, Text, TextField } from "@radix-ui/themes";+import { Button, Callout, Dialog, Flex, Text, TextField } from "@radix-ui/themes";import { useParams } from "next/navigation";import { supabase } from "@/src/lib/supabase/client";import { useNodeId, useReactFlow } from "@xyflow/react";+import { InfoCircledIcon } from "@radix-ui/react-icons";interface NodeContextType {setOpenAddNodeModal: any,@@ -22,6 +23,7 @@ const nodesTypes = {"social_accounts_telegram": { table: "social_accounts", type: "social", fields: ["profile_url", "username", "platform:telegram"] },"social_accounts_snapchat": { table: "social_accounts", type: "social", fields: ["profile_url", "username", "platform:snapchat"] },"social_accounts_signal": { table: "social_accounts", type: "social", fields: ["profile_url", "username", "platform:signal"] },+ "physical_addresses": { table: "physical_addresses", type: "address", fields: ["address", "city", "country", "zip"] },}const NodeContext = createContext<NodeContextType | undefined>(undefined);@@ -34,50 +36,44 @@ export const NodeProvider: React.FC<NodeProviderProps> = (props: any) => {const { addNodes, addEdges, setNodes, setEdges } = useReactFlow();const { investigation_id } = useParams()const [openAddNodeModal, setOpenNodeModal] = useState(false)+ const [error, setError] = useState<null | string>(null)const [loading, setLoading] = useState(false)const [nodeType, setnodeType] = useState<any | null>(null)const nodeId = useNodeId();- const setOpenAddNodeModal = (tableName: string) => {+ const returnError = (message: string) => {+ setLoading(false)+ setError(message)+ return+ }++ const setOpenAddNodeModal = (e: { stopPropagation: () => void; }, tableName: string) => {+ e.stopPropagation()// @ts-ignoreif (!nodesTypes[tableName]) return// @ts-ignoresetnodeType(nodesTypes[tableName])+ setError(null)setOpenNodeModal(true)}const onSubmitNewNodeModal = async (e: { preventDefault: () => void; currentTarget: HTMLFormElement | undefined; }) => {e.preventDefault();const data = Object.fromEntries(new FormData(e.currentTarget));- const newNodeId = crypto.randomUUID()- addNodes({- id: newNodeId,- type: nodeType.type,- data: { ...data, label: data[nodeType.fields[0]] },- position: { x: -100, y: -100 }- });- if (nodeId)- addEdges({- source: nodeId,- target: newNodeId,- type: 'custom',- id: `${nodeId}-${newNodeId}`.toString(),- label: nodeType.type,- });- await handleAddNode({ ...data, id: newNodeId });+ await handleAddNode(data);};const handleAddNode = async (data: any) => {setLoading(true)- if (!nodeId) return alert("No node detected.")- const dataToInsert = { ...data, investigation_id, }+ if (!nodeId) return returnError("No node detected.")+ const dataToInsert = { ...data, investigation_id }if (nodeType.table !== "individuals")dataToInsert["individual_id"] = nodeIdconst node = await supabase.from(nodeType.table).insert(dataToInsert).select("*").single().then(({ data, error }) => {if (error)- console.log(error)+ returnError(error.details)return data})if (!node) return@@ -88,13 +84,29 @@ export const NodeProvider: React.FC<NodeProviderProps> = (props: any) => {investigation_id: investigation_id}).then(({ error }) => console.log(error))- await supabase.from("relationships").insert({+ await supabase.from("relationships").upsert({individual_a: nodeId,individual_b: node.id,relation_type: "relation"- }).then(({ error }) => console.log(error))+ }).then(({ error }) => { if (error) returnError(error.details) }+ )}+ addNodes({+ id: node.id,+ type: nodeType.type,+ data: { ...node, label: data[nodeType.fields[0]] },+ position: { x: 0, y: 0 }+ });+ if (nodeId)+ addEdges({+ source: nodeId,+ target: node.id,+ type: 'custom',+ id: `${nodeId}-${node.id}`.toString(),+ label: nodeType.type === "individual" ? "relation" : nodeType.type,+ });setLoading(false)+ setError(null)setOpenNodeModal(false)}@@ -109,7 +121,7 @@ export const NodeProvider: React.FC<NodeProviderProps> = (props: any) => {.insert({ full_name: data.full_name }).select("*").single()- if (insertError) throw error+ if (insertError) returnError(insertError.details)addNodes({id: node.id,type: "individual",@@ -138,7 +150,6 @@ export const NodeProvider: React.FC<NodeProviderProps> = (props: any) => {<Flex direction="column" gap="3">{nodeType?.fields.map((field: any, i: number) => {const [key, value] = field.split(":")- console.log(Boolean(value))return (<label key={i}><Text as="div" size="2" mb="1" weight="bold">@@ -146,7 +157,7 @@ export const NodeProvider: React.FC<NodeProviderProps> = (props: any) => {</Text><TextField.RootdefaultValue={value || ""}- disabled={Boolean(value)}+ // disabled={Boolean(value)}name={key}placeholder={`Your value here (${key})`}/>@@ -154,15 +165,21 @@ export const NodeProvider: React.FC<NodeProviderProps> = (props: any) => {)})}</Flex>+ {error && <Callout.Root className="mt-4" color="red">+ <Callout.Icon>+ <InfoCircledIcon />+ </Callout.Icon>+ <Callout.Text>+ {error}+ </Callout.Text>+ </Callout.Root>}<Flex gap="3" mt="4" justify="end"><Dialog.Close><Button variant="soft" color="gray">Cancel</Button></Dialog.Close>- <Dialog.Close>- <Button loading={loading} type="submit">Save</Button>- </Dialog.Close>+ <Button loading={loading} type="submit">Save</Button></Flex></form></Dialog.Content>diff --git a/src/components/investigations/nodes/phone.tsx b/src/components/investigations/nodes/phone.tsxindex 7308b388..a7c7c3c5 100644--- a/src/components/investigations/nodes/phone.tsx+++ b/src/components/investigations/nodes/phone.tsx@@ -20,7 +20,7 @@ function Custom({ data }: any) {<Card><Inset><Flex className='items-center p-0'>- <Badge className='!h-[24px] !rounded-r-none'>+ <Badge color='violet' className='!h-[24px] !rounded-r-none'><PhoneIcon className='h-3 w-3' /></Badge><Box className='p-1'>diff --git a/src/components/investigations/nodes/physical_address.tsx b/src/components/investigations/nodes/physical_address.tsxnew file mode 100644index 00000000..8c3e6951--- /dev/null+++ b/src/components/investigations/nodes/physical_address.tsx@@ -0,0 +1,70 @@+"use client"+import React, { memo } from 'react';+import { Handle, Position } from '@xyflow/react';+import { Card, Box, Text, ContextMenu, Badge, Flex, Inset, Tooltip, Avatar } from '@radix-ui/themes';+import { NodeProvider, useNodeContext } from './node-context';+import { MapPinHouseIcon } from 'lucide-react';+import { cn } from '@/utils';+import { useInvestigationContext } from '../investigation-provider';++function AddressNode({ data }: any) {+ const { handleDeleteNode, loading } = useNodeContext()+ const { settings } = useInvestigationContext()+ return (+ <ContextMenu.Root>+ <ContextMenu.Trigger>+ <Box className={cn(loading ? "!opacity-40" : "!opacity-100")}>+ {settings.showNodeLabel ?+ <Card>+ <Inset>+ <Flex className='items-center p-0'>+ <Badge color='ruby' className='!h-[24px] !rounded-r-none'>+ <MapPinHouseIcon className='h-3 w-3' />+ </Badge>+ <Box className='p-1'>+ <Text as="div" size="1" weight="regular">+ {data.label}+ </Text>+ </Box>+ </Flex>+ </Inset>+ </Card>+ :+ <Tooltip content={data.label}>+ <button className='!rounded-full border-transparent'>+ <Avatar+ size="1"+ src={data?.image_url}+ radius="full"+ /* @ts-ignore */+ fallback={<MapPinHouseIcon className='h-3 w-3' />}+ />+ </button>+ </Tooltip>}+ <Handle+ type="target"+ position={Position.Top}+ className="w-16 !bg-teal-500"+ />+ </Box>++ </ContextMenu.Trigger>+ <ContextMenu.Content>+ <ContextMenu.Item shortcut="⌘ C">Copy content</ContextMenu.Item>+ <ContextMenu.Item shortcut="⌘ D">Duplicate</ContextMenu.Item>+ <ContextMenu.Separator />+ <ContextMenu.Item onClick={handleDeleteNode} shortcut="⌘ ⌫" color="red">+ Delete+ </ContextMenu.Item>+ </ContextMenu.Content>+ </ContextMenu.Root>+ );+}++const MemoizedNode = (props: any) => (+ <NodeProvider>+ <AddressNode {...props} />+ </NodeProvider>+);++export default memo(MemoizedNode);\ No newline at end of filediff --git a/src/components/investigations/nodes/social.tsx b/src/components/investigations/nodes/social.tsxindex f497552d..cb8004e2 100644--- a/src/components/investigations/nodes/social.tsx+++ b/src/components/investigations/nodes/social.tsx@@ -1,23 +1,16 @@"use client"-import React, { memo, useMemo } from 'react';+import React, { memo } from 'react';import { Handle, Position } from '@xyflow/react';import { Card, Box, Text, ContextMenu, Flex, Inset, Badge, Tooltip, Avatar } from '@radix-ui/themes';import { NodeProvider, useNodeContext } from './node-context';-import { CameraIcon, FacebookIcon, InstagramIcon, MessageCircleDashedIcon, SendIcon } from 'lucide-react';import { cn } from '@/utils';import { useInvestigationContext } from '../investigation-provider';+import { usePlatformIcons } from '@/src/lib/hooks/use-platform-icons';function Custom({ data }: any) {const { handleDeleteNode, loading } = useNodeContext()const { settings } = useInvestigationContext()-- const platformsIcons = useMemo(() => ({- "facebook": <FacebookIcon className='h-3 w-3' />,- "instagram": <InstagramIcon className='h-3 w-3' />,- "telegram": <SendIcon className='h-3 w-3' />,- "signal": <MessageCircleDashedIcon className='h-3 w-3' />,- "snapchat": <CameraIcon className='h-3 w-3' />- }), [])+ const platformsIcons = usePlatformIcons()return (<><ContextMenu.Root>@@ -27,12 +20,14 @@ function Custom({ data }: any) {<Card><Inset><Flex className='items-center p-0'>- <Badge className='!h-[24px] !rounded-r-none'>+ {/* @ts-ignore */}+ <Badge color={platformsIcons?.[data?.platform]?.color as any || "amber"}+ className='!h-[24px] !rounded-r-none'>{/* @ts-ignore */}- {platformsIcons[data.platform]}+ {platformsIcons?.[data?.platform]?.icon || "?"}</Badge><Box maxWidth={"20px"} className='!max-w-[240px] p-1'>- <Text as="div" size="1" weight="medium" color='blue' className='truncate text-ellipsis underline'>+ <Text as="div" size="1" weight="medium">{data.username || data.profile_url}</Text></Box>@@ -44,10 +39,12 @@ function Custom({ data }: any) {<button className='!rounded-full border-transparent'><Avatarsize="1"+ /* @ts-ignore */+ color={platformsIcons?.[data?.platform]?.color || "amber"}src={data?.image_url}radius="full"/* @ts-ignore */- fallback={platformsIcons[data.platform]}+ fallback={platformsIcons?.[data?.platform]?.icon || "?"}/></button></Tooltip>}diff --git a/src/lib/actions/investigations.ts b/src/lib/actions/investigations.tsindex 15ba62e7..6b615d70 100644--- a/src/lib/actions/investigations.ts+++ b/src/lib/actions/investigations.ts@@ -40,7 +40,7 @@ export async function getInvestigationData(investigationId: string): Promise<{ nconst supabase = await createClient();let { data: individuals, error: indError } = await supabase.from('individuals')- .select('*, ip_addresses(*), phone_numbers(*), social_accounts(*), emails(*)')+ .select('*, ip_addresses(*), phone_numbers(*), social_accounts(*), emails(*), physical_addresses(*)').eq('investigation_id', investigationId);if (indError) throw notFound();@@ -143,6 +143,22 @@ export async function getInvestigationData(investigationId: string): Promise<{ nlabel: 'IP',});});++ ind.physical_addresses?.forEach((address: any) => {+ nodes.push({+ id: address.id.toString(),+ type: 'address',+ data: { ...address, label: [address.address, address.city, address.country].join(", ") },+ position: { x: 100, y: 100 }+ });+ edges.push({+ source: individualId,+ target: address.id.toString(),+ type: 'custom',+ id: `${individualId}-${address.id}`.toString(),+ label: 'address',+ });+ });});relations.forEach(({ individual_a, individual_b, relation_type, confidence_level }) => {edges.push({diff --git a/src/lib/hooks/use-individual.ts b/src/lib/hooks/use-individual.tsindex a523c162..0bcd3604 100644--- a/src/lib/hooks/use-individual.ts+++ b/src/lib/hooks/use-individual.ts@@ -5,7 +5,13 @@ export function useIndividual(individualId: string | null | undefined) {const { data: individual, mutate, isLoading, error } = useQuery(Boolean(individualId) ?supabase.from('individuals')- .select('*, ip_addresses(*), phone_numbers(*), social_accounts(*), emails(*)')+ .select(`+ *,+ ip_addresses(*),+ phone_numbers(*),+ social_accounts(*),+ emails(*)+ `).eq("id", individualId).single() : null,{@@ -13,5 +19,11 @@ export function useIndividual(individualId: string | null | undefined) {revalidateOnReconnect: false,});- return { individual: individual ?? null, isLoading, refetch: mutate, error };-}\ No newline at end of file+ return {+ individual: individual || null,+ isLoading,+ refetch: mutate,+ error: error+ };+}+diff --git a/src/lib/use-local-storage.ts b/src/lib/hooks/use-local-storage.tssimilarity index 100%rename from src/lib/use-local-storage.tsrename to src/lib/hooks/use-local-storage.tsdiff --git a/src/lib/hooks/use-platform-icons.tsx b/src/lib/hooks/use-platform-icons.tsxnew file mode 100644index 00000000..31d57583--- /dev/null+++ b/src/lib/hooks/use-platform-icons.tsx@@ -0,0 +1,24 @@+import { useMemo } from "react"+import { CameraIcon, FacebookIcon, InstagramIcon, MessageCircleDashedIcon, SendIcon } from 'lucide-react';++export const usePlatformIcons = (size = "small") => {+ const className = size === "small" ? 'h-3 w-3' : 'h-5 w-5'+ const platformsIcons = useMemo(() => ({+ "facebook": {+ icon: <FacebookIcon className={className} />, color: "indigo"+ },+ "instagram": {+ icon: <InstagramIcon className={className} />, color: "plum"+ },+ "telegram": {+ icon: <SendIcon className={className} />, color: "cyan"+ },+ "signal": {+ icon: <MessageCircleDashedIcon className={className} />, color: "blue"+ },+ "snapchat": {+ icon: <CameraIcon className={className} />, color: "yellow"+ },+ }), [])+ return platformsIcons+}\ No newline at end of filediff --git a/src/lib/hooks/use-relations.ts b/src/lib/hooks/use-relations.tsnew file mode 100644index 00000000..9e060a79--- /dev/null+++ b/src/lib/hooks/use-relations.ts@@ -0,0 +1,36 @@+import { supabase } from "@/src/lib/supabase/client";+import { useQuery } from "@supabase-cache-helpers/postgrest-swr";++export function useRelations(individualId: string | null | undefined) {+ const { data: individuals, mutate, isLoading, error } = useQuery(+ Boolean(individualId)+ ? supabase+ .from("relationships")+ .select(`+ id,+ individual_a(id, full_name, image_url),+ individual_b(id, full_name, image_url),+ relation_type,+ confidence_level+ `)+ .or(`individual_a.eq.${individualId},individual_b.eq.${individualId}`)+ : null,+ {+ revalidateOnFocus: false,+ revalidateOnReconnect: false,+ }+ );+ const relations = individuals+ ? individuals.map((rel: { individual_a: any, individual_b: any, relation_type: string }) => {+ return rel.individual_a?.id === individualId+ ? { ...rel.individual_b, relation_type: rel.relation_type }+ : { ...rel.individual_a, relation_type: rel.relation_type }+ }).filter(Boolean)+ : [];+ return {+ relations,+ isLoading,+ refetch: mutate,+ error+ };+}diff --git a/tsconfig.json b/tsconfig.jsonindex d8bf2be0..cd00fda5 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -23,6 +23,6 @@"@/*": ["./*"]}},- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "../../ReconOps/src/lib/utils.ts", "src/components/investigations/collide.js"],+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "../../ReconOps/src/lib/utils.ts", "src/components/investigations/collide.js", "src/lib/utils/flow.js"],"exclude": ["node_modules"]}diff --git a/yarn.lock b/yarn.lockindex 139b9d48..30fa8ad5 100644--- a/yarn.lock+++ b/yarn.lock@@ -5374,13 +5374,13 @@ fraction.js@^4.3.7:resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.7.tgz#06ca0085157e42fda7f9e726e79fefc4068840f7"integrity sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==- version "11.13.1"- resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-11.13.1.tgz#f15ca61c2b77067f4c7bc75833adae711fbef1fe"- integrity sha512-F40tpGTHByhn9h3zdBQPcEro+pSLtzARcocbNqAyfBI+u9S+KZuHH/7O9+z+GEkoF3eqFxfvVw0eBDytohwqmQ==+framer-motion@^12.3.1:+ version "12.3.1"+ resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-12.3.1.tgz#041be06a3e1041cf6820a0895b704e8ea588e3df"+ integrity sha512-Br4a2YhdeEvdzMDX8ToVO+/Jbqm2Loo/8rMjizX1nejjBvRJGMfz+NW1qBo4WCHF26uIdES5MBztUlB4pIyfqQ==dependencies:- motion-dom "^11.13.0"- motion-utils "^11.13.0"+ motion-dom "^12.0.0"+ motion-utils "^12.0.0"tslib "^2.4.0"fs.realpath@^1.0.0:@@ -6042,17 +6042,17 @@ minimist@^1.2.0, minimist@^1.2.6:resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==-motion-dom@^11.13.0:- version "11.18.1"- resolved "https://registry.yarnpkg.com/motion-dom/-/motion-dom-11.18.1.tgz#e7fed7b7dc6ae1223ef1cce29ee54bec826dc3f2"- integrity sha512-g76KvA001z+atjfxczdRtw/RXOM3OMSdd1f4DL77qCTF/+avrRJiawSG4yDibEQ215sr9kpinSlX2pCTJ9zbhw==+motion-dom@^12.0.0:+ version "12.0.0"+ resolved "https://registry.yarnpkg.com/motion-dom/-/motion-dom-12.0.0.tgz#7045c63642eecbcc04c40b4457ebb07b3c2b3d0c"+ integrity sha512-CvYd15OeIR6kHgMdonCc1ihsaUG4MYh/wrkz8gZ3hBX/uamyZCXN9S9qJoYF03GqfTt7thTV/dxnHYX4+55vDg==dependencies:- motion-utils "^11.18.1"+ motion-utils "^12.0.0"-motion-utils@^11.13.0, motion-utils@^11.18.1:- version "11.18.1"- resolved "https://registry.yarnpkg.com/motion-utils/-/motion-utils-11.18.1.tgz#671227669833e991c55813cf337899f41327db5b"- integrity sha512-49Kt+HKjtbJKLtgO/LKj9Ld+6vw9BjH5d9sc40R/kVyH8GLAXgT42M2NnuPcJNuA3s9ZfZBUcwIgpmZWGEE+hA==+motion-utils@^12.0.0:+ version "12.0.0"+ resolved "https://registry.yarnpkg.com/motion-utils/-/motion-utils-12.0.0.tgz#fabf79f4f1c818720a1b70f615e2a1768f396ac0"+ integrity sha512-MNFiBKbbqnmvOjkPyOKgHUp3Q6oiokLkI1bEwm5QA28cxMZrv0CbbBGDNmhF6DIXsi1pCQBSs0dX8xjeER1tmA==mri@^1.2.0:version "1.2.0"