From c855c124e1cca6395d3d834a82a4edb57126a8a4 Mon Sep 17 00:00:00 2001 From: dextmorgn Date: Mon, 17 Feb 2025 11:44:56 +0100 Subject: [PATCH] feat: custom node card --- src/components/contexts/chatbot-context.tsx | 4 +- .../investigations/current-node-card.tsx | 89 +++++++++++++++++++ src/components/investigations/graph.tsx | 16 ++-- .../investigations/nodes/social.tsx | 2 +- 4 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 src/components/investigations/current-node-card.tsx diff --git a/src/components/contexts/chatbot-context.tsx b/src/components/contexts/chatbot-context.tsx index 3dd00cc..b5d8b62 100644 --- a/src/components/contexts/chatbot-context.tsx +++ b/src/components/contexts/chatbot-context.tsx @@ -63,7 +63,7 @@ export const ChatProvider: React.FC = ({ children }) => {
- + {m.content} @@ -82,7 +82,7 @@ export const ChatProvider: React.FC = ({ children }) => {
Error - + Oops, an error occurred. Make sure you provided a valid Mistral API key. diff --git a/src/components/investigations/current-node-card.tsx b/src/components/investigations/current-node-card.tsx new file mode 100644 index 0000000..4aeb9d2 --- /dev/null +++ b/src/components/investigations/current-node-card.tsx @@ -0,0 +1,89 @@ +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" +import { Button } from "@/components/ui/button" +import { Card, CardContent, CardHeader } from "@/components/ui/card" +import { Phone, User2, XIcon } from "lucide-react" +import { useState } from "react" +import { useInvestigationContext } from "../contexts/investigation-provider" + +interface PhoneNumber { + id: string + country: string | null + phone_number: string + individual_id: string + investigation_id: string +} + +interface Individual { + id: string + investigation_id: string + full_name: string + birth_date: string | null + gender: string + nationality: string + notes: string + image_url: string + ip_addresses: string[] + phone_numbers: PhoneNumber[] +} + +interface CurrentNodeProps { + individual: Partial +} + +export default function CurrentNode({ individual }: CurrentNodeProps) { + const { handleOpenIndividualModal } = useInvestigationContext() + const [show, setShow] = useState(true) + if (!show) return + return ( + +
+ +
+
+
+ + + + {individual?.full_name?.[0]} + + +
+
+ +

{individual.full_name}

+

{individual.notes || No notes.}

+
+ + {individual?.phone_numbers && individual?.phone_numbers?.length > 0 && ( +
+ + {individual?.phone_numbers?.map((phone) => ( + {phone.phone_number} + ))} +
+ )} +
+ + {/* */} +
+
+
+

Nationality

+

{individual.nationality || "N/A"}

+
+
+

Gender

+

{individual.gender || "N/A"}

+
+
+

IPs

+

{individual?.ip_addresses?.length}

+
+
+
+
+ ) +} diff --git a/src/components/investigations/graph.tsx b/src/components/investigations/graph.tsx index 85f43b9..cd4272d 100644 --- a/src/components/investigations/graph.tsx +++ b/src/components/investigations/graph.tsx @@ -30,6 +30,7 @@ import { Card } from '@/components/ui/card'; import { cn } from '@/lib/utils'; import { useInvestigationContext } from '@/components/contexts/investigation-provider'; import { useFlowStore } from '../contexts/use-flow-store'; +import CurrentNode from './current-node-card'; const edgeTypes = { "custom": FloatingEdge @@ -139,12 +140,15 @@ const LayoutFlow = ({ theme }: { theme: ColorMode }) => {
- {currentNode && ( - - <> - {getNode(currentNode)?.data?.label} - - + {currentNode && getNode(currentNode) && ( + getNode(currentNode)?.type === "individual" ? + // @ts-ignore + : + + <> + {getNode(currentNode)?.data.label} + + )}
diff --git a/src/components/investigations/nodes/social.tsx b/src/components/investigations/nodes/social.tsx index 9c6e959..ff1f4bb 100644 --- a/src/components/investigations/nodes/social.tsx +++ b/src/components/investigations/nodes/social.tsx @@ -79,7 +79,7 @@ function SocialNode({ data }: any) { - handleOpenSearchModal(data.email)}> + handleOpenSearchModal(data.label)}> Launch search