Skip to content

A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.

refactor: project to investigation, investigation to sketch

dextmorgn3f8e28b01645
diff --git a/flowsint-api/app/main.py b/flowsint-api/app/main.py
index 08b151c1..d765cc43 100644
--- a/flowsint-api/app/main.py
+++ b/flowsint-api/app/main.py
@@ -8,21 +8,21 @@ app = FastAPI()
class EmailScanItem(BaseModel):
email: str
- investigation_id:str
+ sketch_id:str
@app.post("/scan/")
async def scan(item: EmailScanItem, db: Client = Depends(get_db)):
task_name = "email_scan"
task = celery_app.send_task(task_name, args=[item.email])
assert item.email is not None
- assert item.investigation_id is not None
+ assert item.sketch_id is not None
try:
response = db.table("scans").insert({
"id": task.id,
"status": "pending",
"scan_name": task_name,
"value":item.email,
- "investigation_id": item.investigation_id
+ "sketch_id": item.sketch_id
}).execute()
return {"id": task.id, "response": response}
except Exception as e:
diff --git a/flowsint-web/src/app/api/projects/[project_id]/documents/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/documents/route.ts
similarity index 80%
rename from flowsint-web/src/app/api/projects/[project_id]/documents/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/documents/route.ts
index 521f8494..028171d6 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/documents/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/documents/route.ts
@@ -2,8 +2,8 @@ import { createClient } from "@/lib/supabase/server"
import { formatFileSize } from "@/lib/utils";
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ project_id: string }> }) {
- const { project_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
+ const { investigation_id } = await params
try {
const supabase = await createClient()
const {
@@ -13,15 +13,15 @@ export async function GET(_: Request, { params }: { params: Promise<{ project_id
if (!user || userError) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
- const { data: project, error: projectError } = await supabase.from("projects")
+ const { data: investigation, error: investigationError } = await supabase.from("investigations")
.select("id")
- .eq("id", project_id)
+ .eq("id", investigation_id)
.single()
- if (!project || projectError) return NextResponse.json({ error: "Project doesn't exist." }, { status: 404 })
+ if (!investigation || investigationError) return NextResponse.json({ error: "investigation doesn't exist." }, { status: 404 })
const { data, error } = await supabase
.storage
.from("documents")
- .list(`${project_id}`, {
+ .list(`${investigation_id}`, {
sortBy: { column: "created_at", order: "desc" }
})
if (error) {
@@ -33,7 +33,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ project_id
// Récupérer les URLs publiques pour chaque fichier
const filesWithUrls = await Promise.all(
filteredData.map(async (file) => {
- const { data: urlData } = await supabase.storage.from("documents").createSignedUrl(`${project_id}/${file.name}`, 3600)
+ const { data: urlData } = await supabase.storage.from("documents").createSignedUrl(`${investigation_id}/${file.name}`, 3600)
return {
id: file.id,
name: file.name,
@@ -56,8 +56,8 @@ export async function GET(_: Request, { params }: { params: Promise<{ project_id
}
-export async function DELETE(request: Request, { params }: { params: Promise<{ project_id: string }> }) {
- const { project_id: projectId } = await params
+export async function DELETE(request: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
+ const { investigation_id: investigationId } = await params
const { searchParams } = new URL(request.url)
const fileName = searchParams.get("fileName")
if (!fileName) {
@@ -65,7 +65,7 @@ export async function DELETE(request: Request, { params }: { params: Promise<{ p
}
try {
const supabase = await createClient()
- const { error } = await supabase.storage.from("documents").remove([`${projectId}/${fileName}`])
+ const { error } = await supabase.storage.from("documents").remove([`${investigationId}/${fileName}`])
if (error) {
throw error
}
diff --git a/flowsint-web/src/app/api/projects/[project_id]/individuals/[individual_id]/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/individuals/[individual_id]/route.ts
similarity index 91%
rename from flowsint-web/src/app/api/projects/[project_id]/individuals/[individual_id]/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/individuals/[individual_id]/route.ts
index 41f57166..ce57c57d 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/individuals/[individual_id]/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/individuals/[individual_id]/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ individual_id: string, project_id: string }> }) {
- const { project_id, individual_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ individual_id: string, investigation_id: string }> }) {
+ const { investigation_id, individual_id } = await params
try {
const supabase = await createClient()
const {
diff --git a/flowsint-web/src/app/api/projects/[project_id]/organigrams/[organization_id]/sketch/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/organigrams/[organization_id]/sketch/route.ts
similarity index 100%
rename from flowsint-web/src/app/api/projects/[project_id]/organigrams/[organization_id]/sketch/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/organigrams/[organization_id]/sketch/route.ts
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/route.ts
similarity index 63%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/route.ts
index ddcdec9a..5c9eac00 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string, project_id: string }> }) {
- const { investigation_id, project_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
+ const { investigation_id } = await params
try {
const supabase = await createClient()
const {
@@ -12,11 +12,9 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
if (!user || userError) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
- const { data: investigation, error } = await supabase
- .from("investigations")
- .select("id, title, description, last_updated_at, project_id, project:projects(id, name), members:investigations_profiles(profile:profiles(id, first_name, last_name), role)")
+ 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)")
.eq("id", investigation_id)
- .eq("project_id", project_id)
.single()
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
@@ -24,7 +22,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
if (!investigation) {
return NextResponse.json({ error: "Investigation not found" }, { status: 404 })
}
- return NextResponse.json({ investigation })
+ return NextResponse.json(investigation)
} catch (error) {
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
}
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/emails/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/emails/route.ts
similarity index 86%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/emails/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/emails/route.ts
index b03739c5..663df9a7 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/emails/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/emails/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
- const { investigation_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string }> }) {
+ const { sketch_id } = await params
try {
const supabase = await createClient()
const {
@@ -17,7 +17,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
.select(`
*
`)
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/[individual_id]/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/individuals/[individual_id]/route.ts
similarity index 84%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/[individual_id]/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/individuals/[individual_id]/route.ts
index d041dd06..a858391a 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/[individual_id]/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/individuals/[individual_id]/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string, individual_id: string }> }) {
- const { investigation_id, individual_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string, individual_id: string }> }) {
+ const { sketch_id, individual_id } = await params
try {
const supabase = await createClient()
const {
@@ -17,7 +17,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
.select(`
*
`)
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
.eq("id", individual_id)
.single()
if (error) {
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/individuals/route.ts
similarity index 90%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/individuals/route.ts
index 0c5b2fa9..5f6329ac 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/individuals/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/individuals/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextRequest, NextResponse } from "next/server"
-export async function GET(request: NextRequest, { params }: { params: Promise<{ investigation_id: string }> }) {
- const { investigation_id } = await params
+export async function GET(request: NextRequest, { params }: { params: Promise<{ sketch_id: string }> }) {
+ const { sketch_id } = await params
let size = request.nextUrl.searchParams.get("size") || 10
let page = request.nextUrl.searchParams.get("page") || 1
let includeEmails = request.nextUrl.searchParams.get("includeEmails") || false
@@ -24,7 +24,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{
includePhones && "phone_numbers(phone_number)",
].filter(Boolean).join(', '), { count: "exact" })
.order("created_at", { ascending: false })
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
// .range()
if (error) {
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/ips/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/ips/route.ts
similarity index 85%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/ips/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/ips/route.ts
index ee460092..08f3334c 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/ips/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/ips/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
- const { investigation_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string }> }) {
+ const { sketch_id } = await params
try {
const supabase = await createClient()
const {
@@ -15,7 +15,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
const { data: ips, error } = await supabase
.from('ip_addresses')
.select(`*`)
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/phones/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/phones/route.ts
similarity index 85%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/phones/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/phones/route.ts
index 701278c4..3c530add 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/phones/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/phones/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
- const { investigation_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string }> }) {
+ const { sketch_id } = await params
try {
const supabase = await createClient()
const {
@@ -15,7 +15,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
const { data: phones, error } = await supabase
.from('phone_numbers')
.select(`*`)
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
diff --git a/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/route.ts
new file mode 100644
index 00000000..24749f8c
--- /dev/null
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/route.ts
@@ -0,0 +1,32 @@
+import { createClient } from "@/lib/supabase/server"
+import { NextResponse } from "next/server"
+
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string, investigation_id: string }> }) {
+ const { sketch_id, investigation_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: sketch, 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)")
+ .eq("id", sketch_id)
+ .eq("investigation_id", investigation_id)
+ .single()
+ if (error) {
+ return NextResponse.json({ error: error.message }, { status: 500 })
+ }
+ if (!sketch) {
+ return NextResponse.json({ error: "Sketch not found" }, { status: 404 })
+ }
+ return NextResponse.json({ sketch })
+ } catch (error) {
+ return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
+ }
+}
+
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/[scan_id]/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/scans/[scan_id]/route.ts
similarity index 84%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/[scan_id]/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/scans/[scan_id]/route.ts
index bd81fdb9..b1745eb6 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/[scan_id]/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/scans/[scan_id]/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string, scan_id: string }> }) {
- const { investigation_id, scan_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string, scan_id: string }> }) {
+ const { sketch_id, scan_id } = await params
try {
const supabase = await createClient()
const {
@@ -15,7 +15,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
const { data: scan, error } = await supabase
.from('scans')
.select(`*`)
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
.eq('id', scan_id)
.single()
if (error) {
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/scans/route.ts
similarity index 86%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/scans/route.ts
index 3d72c750..3751b2b7 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/scans/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/scans/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
- const { investigation_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string }> }) {
+ const { sketch_id } = await params
try {
const supabase = await createClient()
const {
@@ -15,7 +15,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
const { data: scans, error } = await supabase
.from('scans')
.select(`*`)
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
.order("created_at", { ascending: false })
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/sketch/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/sketch/route.ts
similarity index 85%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/sketch/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/sketch/route.ts
index ad17a65d..07050cbc 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/sketch/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/sketch/route.ts
@@ -2,8 +2,8 @@ import { createClient } from "@/lib/supabase/server"
import type { NodeData, EdgeData } from "@/types"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
- const { investigation_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string }> }) {
+ const { sketch_id } = await params
const supabase = await createClient()
try {
const {
@@ -14,9 +14,9 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
const { data: graphData, error: graphError } = await supabase
- .from("investigation_graph")
+ .from("sketch_graph")
.select("*")
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
.single();
if (graphError) {
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/socials/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/socials/route.ts
similarity index 86%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/socials/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/socials/route.ts
index 7c18b80d..5798f9ae 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/socials/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/socials/route.ts
@@ -1,8 +1,8 @@
import { createClient } from "@/lib/supabase/server"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
- const { investigation_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string }> }) {
+ const { sketch_id } = await params
try {
const supabase = await createClient()
const {
@@ -17,7 +17,7 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
.select(`
*
`)
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/table/route.ts b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/table/route.ts
similarity index 85%
rename from flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/table/route.ts
rename to flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/table/route.ts
index ac764114..7d96bbd1 100644
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/[investigation_id]/table/route.ts
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/[sketch_id]/table/route.ts
@@ -2,8 +2,8 @@ import { createClient } from "@/lib/supabase/server"
import type { NodeData, EdgeData } from "@/types"
import { NextResponse } from "next/server"
-export async function GET(_: Request, { params }: { params: Promise<{ investigation_id: string }> }) {
- const { investigation_id } = await params
+export async function GET(_: Request, { params }: { params: Promise<{ sketch_id: string }> }) {
+ const { sketch_id } = await params
const supabase = await createClient()
try {
const {
@@ -14,9 +14,9 @@ export async function GET(_: Request, { params }: { params: Promise<{ investigat
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
const { data: graphData, error: graphError } = await supabase
- .from("investigation_table")
+ .from("sketch_table")
.select("*")
- .eq("investigation_id", investigation_id)
+ .eq("sketch_id", sketch_id)
.single();
if (graphError) {
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.ts
new file mode 100644
index 00000000..3acdc901
--- /dev/null
+++ b/flowsint-web/src/app/api/investigations/[investigation_id]/sketches/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<{ investigation_id: string }> }) {
+ try {
+ const { investigation_id } = await params
+ 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: 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)")
+ .order("last_updated_at", { ascending: false })
+ .eq("investigation_id", investigation_id)
+ if (error) {
+ return NextResponse.json({ error: error.message }, { status: 500 })
+ }
+ return NextResponse.json(sketches)
+ } catch (error) {
+ return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
+ }
+}
+
diff --git a/flowsint-web/src/app/api/projects/route.ts b/flowsint-web/src/app/api/investigations/route.ts
similarity index 71%
rename from flowsint-web/src/app/api/projects/route.ts
rename to flowsint-web/src/app/api/investigations/route.ts
index 35b14825..29ce7e92 100644
--- a/flowsint-web/src/app/api/projects/route.ts
+++ b/flowsint-web/src/app/api/investigations/route.ts
@@ -11,12 +11,12 @@ export async function GET() {
if (!user || userError) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
- const { data: projects, error } = await supabase.from("projects")
- .select("*, investigations(*), owner:owner_id(first_name, last_name), members:projects_profiles(profile:profiles(id, first_name, last_name), role)")
+ 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)")
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
}
- return NextResponse.json({ projects })
+ return NextResponse.json({ investigations })
} catch (error) {
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
}
diff --git a/flowsint-web/src/app/api/latest-investigations/route.ts b/flowsint-web/src/app/api/latest-sketches/route.ts
similarity index 69%
rename from flowsint-web/src/app/api/latest-investigations/route.ts
rename to flowsint-web/src/app/api/latest-sketches/route.ts
index 55039002..750f70bb 100644
--- a/flowsint-web/src/app/api/latest-investigations/route.ts
+++ b/flowsint-web/src/app/api/latest-sketches/route.ts
@@ -11,14 +11,14 @@ export async function GET() {
if (!user || userError) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 })
}
- const { data: investigations, error } = await supabase.from("investigations")
- .select("id, title, description, last_updated_at, project_id, project:projects(id, name), members:investigations_profiles(profile:profiles(id, first_name, last_name), role)")
+ 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)")
.order("last_updated_at", { ascending: false })
.limit(4)
if (error) {
return NextResponse.json({ error: error.message }, { status: 500 })
}
- return NextResponse.json(investigations)
+ return NextResponse.json(sketches)
} catch (error) {
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
}
diff --git a/flowsint-web/src/app/api/projects/[project_id]/investigations/route.ts b/flowsint-web/src/app/api/projects/[project_id]/investigations/route.ts
deleted file mode 100644
index 101b4a95..00000000
--- a/flowsint-web/src/app/api/projects/[project_id]/investigations/route.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { createClient } from "@/lib/supabase/server"
-import { NextResponse } from "next/server"
-
-export async function GET(_: Request, { params }: { params: Promise<{ project_id: string }> }) {
- try {
- const { project_id } = await params
- 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: investigations, error } = await supabase.from("investigations")
- .select("id, title, description, status, project_id, last_updated_at, project:projects(id, name), members:investigations_profiles(profile:profiles(id, first_name, last_name), role)")
- .order("last_updated_at", { ascending: false })
- .eq("project_id", project_id)
- if (error) {
- return NextResponse.json({ error: error.message }, { status: 500 })
- }
- return NextResponse.json(investigations)
- } catch (error) {
- return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
- }
-}
-
diff --git a/flowsint-web/src/app/api/projects/[project_id]/route.ts b/flowsint-web/src/app/api/projects/[project_id]/route.ts
deleted file mode 100644
index a6f4fc58..00000000
--- a/flowsint-web/src/app/api/projects/[project_id]/route.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { createClient } from "@/lib/supabase/server"
-import { NextResponse } from "next/server"
-
-export async function GET(_: Request, { params }: { params: Promise<{ project_id: string }> }) {
- const { project_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: project, error } = await supabase.from("projects")
- .select("*, members:projects_profiles(profile:profiles(id, first_name, last_name), role), investigations(*, owner:owner_id(first_name, last_name), individuals(id)), owner:owner_id(first_name, last_name)")
- .eq("id", project_id)
- .single()
- if (error) {
- return NextResponse.json({ error: error.message }, { status: 500 })
- }
- if (!project) {
- return NextResponse.json({ error: "Project not found" }, { status: 404 })
- }
- return NextResponse.json(project)
- } catch (error) {
- return NextResponse.json({ error: "Internal Server Error" }, { status: 500 })
- }
-}
-
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/layout.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/layout.tsx
similarity index 50%
rename from flowsint-web/src/app/dashboard/projects/[project_id]/layout.tsx
rename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/layout.tsx
index bb241e47..03e2ff15 100644
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/layout.tsx
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/layout.tsx
@@ -1,4 +1,4 @@
-import FileUploadDialog from "@/components/projects/file-upload";
+import FileUploadDialog from "@/components/investigations/file-upload";
import { createClient } from "@/lib/supabase/server";
import { notFound } from "next/navigation";
@@ -7,12 +7,12 @@ const DashboardLayout = async ({
params
}: {
children: React.ReactNode;
- params: Promise<{ project_id: string }>
+ params: Promise<{ investigation_id: string }>
}) => {
const supabase = await createClient()
- const { project_id } = await (params)
- const { data: project, error } = await supabase.from("projects").select("id").eq("id", project_id).single()
- if (!project || error) {
+ const { investigation_id } = await (params)
+ const { data: investigation, error } = await supabase.from("investigations").select("id").eq("id", investigation_id).single()
+ if (!investigation || error) {
return notFound()
}
return (
diff --git a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/client.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/client.tsx
new file mode 100644
index 00000000..11df70e7
--- /dev/null
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/client.tsx
@@ -0,0 +1,25 @@
+"use client"
+import { useQuery } from "@tanstack/react-query"
+import OrganizationGraph from "@/components/organigrams/graph"
+import { notFound } from "next/navigation"
+interface DashboardClientProps {
+ investigationId: string
+ organizationId: string
+}
+export default function OrganigramClient({ investigationId, organizationId }: DashboardClientProps) {
+ const graphQuery = useQuery({
+ queryKey: ["investigations", [investigationId], "organigram", organizationId],
+ queryFn: async () => {
+ const res = await fetch(`/api/investigations/${investigationId}/organigrams/${organizationId}/sketch`)
+ if (!res.ok) {
+ notFound()
+ }
+ return res.json()
+ },
+ refetchOnWindowFocus: true,
+ })
+ return (
+ <OrganizationGraph graphQuery={graphQuery} />
+ )
+}
+
diff --git a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/layout.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/layout.tsx
new file mode 100644
index 00000000..12a178a7
--- /dev/null
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/layout.tsx
@@ -0,0 +1,18 @@
+import { createClient } from "@/lib/supabase/server";
+import { redirect } from "next/navigation";
+const DashboardLayout = async ({
+ children,
+}: {
+ children: React.ReactNode;
+}) => {
+ const supabase = await createClient()
+ const { data, error: userError } = await supabase.auth.getUser()
+ if (userError || !data?.user) {
+ redirect('/login')
+ }
+ return (
+ children
+ )
+}
+
+export default DashboardLayout
\ No newline at end of file
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/loading.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/loading.tsx
similarity index 100%
rename from flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/loading.tsx
rename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/loading.tsx
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/page.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/page.tsx
similarity index 73%
rename from flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/page.tsx
rename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/page.tsx
index 143a5576..4e0e675c 100644
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/page.tsx
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/organigrams/[organization_id]/page.tsx
@@ -5,10 +5,10 @@ import { createClient } from "@/lib/supabase/server"
const OrganigramPage = async ({
params,
}: {
- params: Promise<{ project_id: string, organization_id: string }>
+ params: Promise<{ investigation_id: string, organization_id: string }>
}) => {
const supabase = await createClient()
- const { project_id, organization_id } = await (params)
+ const { investigation_id, organization_id } = await (params)
const {
data: { user },
error: userError,
@@ -20,7 +20,7 @@ const OrganigramPage = async ({
if (!organization || error) {
return notFound()
}
- return <DashboardClient projectId={project_id} organizationId={organization_id} />
+ return <DashboardClient investigationId={investigation_id} organizationId={organization_id} />
}
export default OrganigramPage
diff --git a/flowsint-web/src/app/dashboard/investigations/[investigation_id]/page.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/page.tsx
new file mode 100644
index 00000000..cacf9ba3
--- /dev/null
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/page.tsx
@@ -0,0 +1,184 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Input } from "@/components/ui/input"
+import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
+import { MoreHorizontal, PlusIcon, RotateCwIcon, Search, SlidersHorizontal, Waypoints } from "lucide-react"
+import { useQuery } from "@tanstack/react-query"
+import { notFound, useParams } from "next/navigation"
+import Loader from "@/components/loader"
+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
+import { format, formatDistanceToNow } from "date-fns"
+import Link from "next/link"
+import { Sketch } from "@/types/sketch"
+import NewSketch from "@/components/dashboard/new-sketch"
+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"
+
+const DashboardPage = () => {
+ const { investigation_id } = useParams()
+ const [searchQuery, setSearchQuery] = useState("")
+
+ const { data: investigation, isLoading: isLoadingInvestigations, isRefetching: isRefetchingInvestigations, refetch: refetchSketches } = useQuery({
+ queryKey: ["dashboard", "investigation", investigation_id],
+ queryFn: async () => {
+ const res = await fetch(`/api/investigations/${investigation_id}`)
+ if (!res.ok) {
+ notFound()
+ }
+ return res.json()
+ },
+ refetchOnWindowFocus: true,
+ })
+ const {
+ data: documents, isLoading: isLoadingDocs, isRefetching: isRefetchingDocs, refetch: refetchDocs
+ } = useQuery({
+ queryKey: ["investigations", investigation_id, "documents"],
+ queryFn: async () => {
+ const res = await fetch(`/api/investigations/${investigation_id}/documents`)
+ if (!res.ok) {
+ throw new Error("Failed to fetch documents")
+ }
+ return res.json() as Promise<Document[]>
+ },
+ refetchOnWindowFocus: true,
+ enabled: !!investigation_id,
+ })
+
+ const handleRefetch = () => {
+ refetchSketches()
+ refetchDocs()
+ }
+
+ const isLoading = isLoadingDocs || isLoadingInvestigations
+ const isRefetching = isRefetchingDocs || isRefetchingInvestigations
+
+ return (
+ <>
+ <div className="sticky z-40 bg-background top-[48px] border-b">
+ <InvestigationNavigation investigation_id={investigation_id as string} />
+ </div>
+ <div className="w-full space-y-8 container mx-auto py-12 px-8">
+ <div className="flex items-center gap-2 justify-between mb-6">
+ <div className="relative w-full max-w-md">
+ <Search className="absolute left-2.5 top-2.5 h-4 w-4 bg-background text-muted-foreground" />
+ <Input
+ type="search"
+ placeholder="Search items..."
+ className="pl-8 w-full bg-background"
+ value={searchQuery}
+ onChange={(e) => setSearchQuery(e.target.value)}
+ />
+ </div>
+ <div className="flex items-center gap-2">
+ <NewSketch>
+ <Button size="sm" className="gap-2">
+ <PlusIcon className="h-4 w-4" /> New
+ </Button>
+ </NewSketch>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline" size="sm" className="gap-2">
+ <SlidersHorizontal className="h-4 w-4" />
+ <span className="hidden sm:inline">Sort by</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem>Name</DropdownMenuItem>
+ <DropdownMenuItem>Type</DropdownMenuItem>
+ <DropdownMenuItem>Date created</DropdownMenuItem>
+ <DropdownMenuItem>Date modified</DropdownMenuItem>
+ <DropdownMenuItem>Size</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <Button onClick={handleRefetch} disabled={isLoading || isRefetching} variant={"outline"} size="sm" className="gap-2">
+ <RotateCwIcon className={cn("h-4 w-4", isLoading || isRefetching && "animate-spin")} /> Refresh
+ </Button>
+ </div>
+ </div>
+ {isLoadingInvestigations ? (
+ <div className="flex justify-center items-center py-12">
+ <Loader />
+ </div>
+ ) : (
+ <Card className="border rounded-md bg-background shadow-xs">
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Name</TableHead>
+ <TableHead>Type</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">Creation</TableHead>
+ <TableHead className="w-[50px]"></TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {investigation.sketches.length === 0 && documents?.length === 0 ? (
+ <TableRow>
+ <TableCell colSpan={7} className="text-center w-full py-2 text-muted-foreground">
+ <div className="flex flex-col justify-center items-center p-3 gap-2">
+ No sketch yet or document yet.
+ <NewSketch noDropDown>
+ <Button size="sm" className="gap-2">
+ <PlusIcon className="h-4 w-4" /> Create a new sketch
+ </Button>
+ </NewSketch>
+ </div>
+ </TableCell>
+ </TableRow>
+ ) : (
+ investigation?.sketches?.map((sketch: Sketch) => (
+ <TableRow key={sketch.id}>
+ <TableCell>
+ <Link href={`/dashboard/investigations/${sketch.investigation_id}/sketches/${sketch.id}`} className="flex items-center gap-2 hover:underline">
+ <Waypoints className="h-5 w-5 text-primary" />
+ <span>{sketch.title}</span>
+ </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">
+ {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")}
+ </TableCell>
+ <TableCell>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="ghost" size="icon" className="h-8 w-8">
+ <MoreHorizontal className="h-4 w-4" />
+ <span className="sr-only">Actions</span>
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem>Open</DropdownMenuItem>
+ <DropdownMenuItem>Rename</DropdownMenuItem>
+ <DropdownMenuItem>Share</DropdownMenuItem>
+ <DropdownMenuItem className="text-destructive">Delete</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
+ ))
+ )}
+ <DocumentList refetch={refetchDocs} isLoading={isLoadingDocs} documents={documents} />
+ </TableBody>
+ </Table>
+ </Card>
+ )}
+ </div >
+ </>
+ )
+}
+
+export default DashboardPage
+
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/client.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/client.tsx
similarity index 55%
rename from flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/client.tsx
rename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/client.tsx
index cd8cd830..5b7981cd 100644
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/client.tsx
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/client.tsx
@@ -1,21 +1,19 @@
"use client"
import { useQuery } from "@tanstack/react-query"
-import InvestigationGraph from "@/components/investigations/sketch/graph"
-import LargeInvestigationGraph from '@/components/investigations/sketch/large-data-graph'
-import IndividualModal from "@/components/investigations/individual-modal"
+import InvestigationGraph from "@/components/sketches/sketch/graph"
+import LargeInvestigationGraph from '@/components/sketches/sketch/large-data-graph'
import { notFound } from "next/navigation"
import { useQueryState } from "nuqs"
-import { supabase } from "@/lib/supabase/client"
interface DashboardClientProps {
- projectId: string
investigationId: string
+ sketchId: string
}
-export default function DashboardClient({ projectId, investigationId }: DashboardClientProps) {
+export default function DashboardClient({ investigationId, sketchId }: DashboardClientProps) {
const [view, _] = useQueryState("view", { defaultValue: "flow-graph" })
const graphQuery = useQuery({
- queryKey: ["investigation", investigationId, "data"],
+ queryKey: ["investigations", investigationId, 'sketches', sketchId, "data"],
queryFn: async () => {
- const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/sketch`)
+ const res = await fetch(`/api/investigations/${investigationId}/sketches/${sketchId}/sketch`)
if (!res.ok) {
notFound()
}
@@ -30,7 +28,6 @@ export default function DashboardClient({ projectId, investigationId }: Dashboar
:
<LargeInvestigationGraph graphQuery={graphQuery} />
}
- <IndividualModal />
</>
)
}
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.tsx
new file mode 100644
index 00000000..c57bb9b6
--- /dev/null
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/layout.tsx
@@ -0,0 +1,35 @@
+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 { ScanDrawer } from '@/components/sketches/scan-drawer';
+import { Sketch } from '@/types/sketch';
+const DashboardLayout = async ({
+ children,
+ params,
+}: {
+ children: React.ReactNode;
+ params: Promise<{ investigation_id: string, sketch_id: string }>
+}) => {
+ const supabase = await createClient()
+ const { investigation_id, sketch_id } = await params
+ const { data, error: userError } = await supabase.auth.getUser()
+ 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()
+ 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} />
+ </div>
+ {children}
+ <ScanDrawer />
+ </SketchProvider>
+ )
+}
+
+export default DashboardLayout
\ No newline at end of file
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/loading.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/loading.tsx
similarity index 100%
rename from flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/loading.tsx
rename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/loading.tsx
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/map/page.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/map/page.tsx
similarity index 90%
rename from flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/map/page.tsx
rename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/map/page.tsx
index 8049bfda..9c48a8ee 100644
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/map/page.tsx
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/map/page.tsx
@@ -1,6 +1,6 @@
"use client"
-import { useState, useEffect } from "react"
+import { useState } from "react"
// @ts-ignore
import { ComposableMap, Geographies, Geography, Marker, ZoomableGroup } from "react-simple-maps"
@@ -8,16 +8,6 @@ export default function MapPage() {
const [position, setPosition] = useState({ coordinates: [0, 0], zoom: 1 })
const [dimensions, setDimensions] = useState({ width: 800, height: 450 })
- const handleZoomIn = () => {
- if (position.zoom >= 4) return
- setPosition((pos) => ({ ...pos, zoom: pos.zoom * 1.5 }))
- }
-
- const handleZoomOut = () => {
- if (position.zoom <= 1) return
- setPosition((pos) => ({ ...pos, zoom: pos.zoom / 1.5 }))
- }
-
const handleMoveEnd = (position: any) => {
setPosition(position)
}
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/page.tsx
similarity index 68%
rename from flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsx
rename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/page.tsx
index 1db43a1f..2a774f15 100644
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsx
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/page.tsx
@@ -5,10 +5,10 @@ import { createClient } from "@/lib/supabase/server"
const InvestigationPage = async ({
params,
}: {
- params: Promise<{ project_id: string, investigation_id: string }>
+ params: Promise<{ investigation_id: string, sketch_id: string }>
}) => {
const supabase = await createClient()
- const { project_id, investigation_id } = await (params)
+ const { investigation_id, sketch_id } = await (params)
const {
data: { user },
error: userError,
@@ -16,7 +16,7 @@ const InvestigationPage = async ({
if (!user || userError) {
return redirect("/login")
}
- return <DashboardClient projectId={project_id} investigationId={investigation_id} />
+ return <DashboardClient investigationId={investigation_id} sketchId={sketch_id} />
}
export default InvestigationPage
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/table/data-table.tsx
similarity index 99%
rename from flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx
rename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/table/data-table.tsx
index 9ba95c79..11e83886 100644
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/table/data-table.tsx
@@ -95,7 +95,7 @@ import { formatDistanceToNow } from "date-fns"
import { cn } from "@/lib/utils"
import { TypeBadge } from "@/components/type-badge"
import { DialogTitle } from "@radix-ui/react-dialog"
-import { MemoizedKeyValueDisplay } from "@/components/investigations/sketch/profile-panel"
+import { MemoizedKeyValueDisplay } from "@/components/sketches/sketch/profile-panel"
import { Card } from "@/components/ui/card"
import { actionItems } from "@/lib/action-items"
import { usePlatformIcons } from "@/lib/hooks/use-platform-icons"
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/page.tsx b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/table/page.tsx
similarity index 72%
rename from flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/page.tsx
rename to flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/table/page.tsx
index acf95164..805b2fc8 100644
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/page.tsx
+++ b/flowsint-web/src/app/dashboard/investigations/[investigation_id]/sketches/[sketch_id]/table/page.tsx
@@ -7,16 +7,16 @@ import { TableSkeleton } from '@/components/ui/table-skeleton'
const IndividualsPage = () => {
- const { investigation_id, project_id } = useParams()
+ const { sketch_id, investigation_id } = useParams()
const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 })
const fetchIndividuals = async () => {
- const response = await fetch(`/api/projects/${project_id}/investigations/${investigation_id}/table?page=${pagination.pageIndex + 1}&size=${pagination.pageSize}&includeEmails=true&includePhones=true`)
+ const response = await fetch(`/api/investigations/${investigation_id}/sketches/${sketch_id}/table?page=${pagination.pageIndex + 1}&size=${pagination.pageSize}&includeEmails=true&includePhones=true`)
return response.json()
}
const { data, isLoading, isError, refetch, isRefetching } = useQuery({
- queryKey: ['individuals', 'table', investigation_id, pagination.pageIndex, pagination.pageSize],
+ queryKey: ['individuals', 'table', sketch_id, pagination.pageIndex, pagination.pageSize],
queryFn: fetchIndividuals,
})
diff --git a/flowsint-web/src/app/dashboard/page.tsx b/flowsint-web/src/app/dashboard/page.tsx
index c0d06240..9e249d7a 100644
--- a/flowsint-web/src/app/dashboard/page.tsx
+++ b/flowsint-web/src/app/dashboard/page.tsx
@@ -11,9 +11,9 @@ import Loader from "@/components/loader"
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
import { format, formatDistanceToNow } from "date-fns"
import Link from "next/link"
-import { Project } from "@/types/project"
+import { Investigation } from "@/types/investigation"
import RecentSketches from "@/components/dashboard/recent-sketches"
-import NewProject from "@/components/dashboard/new-project"
+import NewInvestigation from "@/components/dashboard/new-investigation"
import { AvatarList } from "@/components/avatar-list"
import { cn } from "@/lib/utils"
import { SubNav } from "@/components/dashboard/sub-nav"
@@ -24,9 +24,9 @@ const DashboardPage = () => {
const [viewMode, setViewMode] = useState<"grid" | "list">("grid")
const { data, isLoading, refetch, isRefetching } = useQuery({
- queryKey: ["dashboard", "projects"],
+ queryKey: ["dashboard", "investigations"],
queryFn: async () => {
- const res = await fetch(`/api/projects`)
+ const res = await fetch(`/api/investigations`)
if (!res.ok || res.status === 404) {
notFound()
}
@@ -34,9 +34,9 @@ const DashboardPage = () => {
},
refetchOnWindowFocus: true,
})
- const projects = data?.projects || []
- const filteredProjects = projects.filter(
- (project: Project) => searchQuery === "" || project.name?.toLowerCase().includes(searchQuery.toLowerCase()),
+ const investigations = data?.investigations || []
+ const filteredInvestigations = investigations.filter(
+ (investigation: Investigation) => searchQuery === "" || investigation.name?.toLowerCase().includes(searchQuery.toLowerCase()),
)
return (
@@ -52,7 +52,7 @@ const DashboardPage = () => {
</div>
<Input
type="text"
- placeholder="Search investigations and projects..."
+ placeholder="Search investigations and investigations..."
className="pl-10 pr-16 py-2 h-10 text-sm bg-background"
/>
<div className="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
@@ -97,11 +97,11 @@ const DashboardPage = () => {
<List className="h-4 w-4" />
</Button>
</div>
- <NewProject>
+ <NewInvestigation>
<Button className="gap-2 h-10">
<PlusIcon className="h-4 w-4" /> New
</Button>
- </NewProject>
+ </NewInvestigation>
</div>
</div>
<div>
@@ -147,40 +147,40 @@ const DashboardPage = () => {
</TableRow>
</TableHeader>
<TableBody>
- {filteredProjects.length === 0 ? (
+ {filteredInvestigations.length === 0 ? (
<TableRow>
<TableCell colSpan={7} className="text-center py-8 text-muted-foreground">
- {searchQuery !== "" ? "No projects found" :
- <div className="flex items-center flex-col gap-3">No projects yet
- <NewProject noDropDown>
+ {searchQuery !== "" ? "No investigations found" :
+ <div className="flex items-center flex-col gap-3">No investigations yet
+ <NewInvestigation noDropDown>
<Button size="sm" className="gap-2">
- <PlusIcon className="h-4 w-4" /> Create a new project
+ <PlusIcon className="h-4 w-4" /> Create a new investigation
</Button>
- </NewProject>
+ </NewInvestigation>
</div>}
</TableCell>
</TableRow>
) : (
- filteredProjects.map((project: Project) => (
- <TableRow key={project.id}>
+ filteredInvestigations.map((investigation: Investigation) => (
+ <TableRow key={investigation.id}>
<TableCell>
- <Link href={`dashboard/projects/${project.id}`} className="flex items-center gap-2 hover:underline">
+ <Link href={`dashboard/investigations/${investigation.id}`} className="flex items-center gap-2 hover:underline">
<FolderLockIcon className="h-5 w-5 text-primary" />
- <span>{project.name}</span>
+ <span>{investigation.name}</span>
</Link>
</TableCell>
- <TableCell className="text-muted-foreground">{`${project?.owner?.first_name} ${project?.owner?.last_name}` || "You"}</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">
- {(project.investigations?.length || 0) > 0 ? `${project.investigations.length} items` : "Empty"}
+ {(investigation.sketches?.length || 0) > 0 ? `${investigation.sketches.length} items` : "Empty"}
</TableCell>
<TableCell className="hidden sm:table-cell text-muted-foreground">
- {formatDistanceToNow(new Date(project.last_updated_at), { addSuffix: true })}
+ {formatDistanceToNow(new Date(investigation.last_updated_at), { addSuffix: true })}
</TableCell>
<TableCell className="hidden sm:table-cell text-muted-foreground">
- <AvatarList users={project?.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}` })) || []} size="sm" />
</TableCell>
<TableCell className="hidden sm:table-cell text-muted-foreground">
- {format(new Date(project.created_at), "dd.MM.yyyy")}
+ {format(new Date(investigation.created_at), "dd.MM.yyyy")}
</TableCell>
<TableCell>
<DropdownMenu>
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/individuals/[individual_id]/page.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/individuals/[individual_id]/page.tsx
deleted file mode 100644
index de8fba16..00000000
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/individuals/[individual_id]/page.tsx
+++ /dev/null
@@ -1,489 +0,0 @@
-import Image from "next/image"
-import Link from "next/link"
-import {
- ArrowRight,
- Calendar,
- ExternalLink,
- CreditCard,
- User,
- Mail,
- Phone,
- Facebook,
- Instagram,
- Twitter,
- Youtube,
- Building2,
- Waypoints,
- UserIcon,
-} from "lucide-react"
-
-import { Card, CardContent, CardHeader } from "@/components/ui/card"
-import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
-import DashboardLayout from "@/components/dashboard/layout"
-
-// This is a mock type for the individual object
-// Replace with your actual type definition
-type Individual = {
- id: string
- full_name: string
- investigation: {
- title: string
- id: string,
- project: {
- name: string,
- id: string
- }
- }
- avatar: string
- email: string
- phoneNumber: string
- stats: {
- accounts: number
- names: number
- emails: number
- phoneNumbers: number
- }
- profile: {
- birthday: string
- familyStatus: string
- isJobSeeker: boolean
- education: string
- jobTitle: string
- company: string
- }
- jobHistory: Array<{
- title: string
- company: string
- logo: string
- startDate: string
- endDate: string
- }>
- scores: {
- overall: number
- phone: number
- email: number
- ipAddress: number | null
- }
- socialMedia: {
- facebook?: {
- firstSeen: string
- followersCount: number
- fullName: string
- username: string
- location: string
- profileImage?: string
- }
- instagram?: {
- firstSeen: string
- followersCount: number
- followingCount: number
- username: string
- isVerified: boolean
- probability: string
- profileImage?: string
- }
- x?: {
- firstSeen: string
- }
- youtube?: Record<string, any>
- }
-}
-
-// This would typically come from a database or API
-async function getIndividual(id: string): Promise<Individual> {
- // Mock data based on the screenshot
- return {
- id,
- full_name: "Lawrence Jackson",
- avatar: "/placeholder.svg?height=100&width=100",
- email: "[email protected]",
- phoneNumber: "+41 952 874 321",
- investigation: {
- title: "Investigation 1",
- id: "1",
- project: {
- name: "Project 1",
- id: "1"
- },
- },
- stats: {
- accounts: 24,
- names: 16,
- emails: 5,
- phoneNumbers: 2,
- },
- profile: {
- birthday: "16/02/1985",
- familyStatus: "Married",
- isJobSeeker: false,
- education: "Bachelor's Degree",
- jobTitle: "Manager",
- company: "Liberty LDA",
- },
- jobHistory: [
- {
- title: "Data Analyst",
- company: "Vertex Dynamics",
- logo: "/placeholder.svg?height=40&width=40",
- startDate: "Nov 2023",
- endDate: "Mar 2024",
- },
- {
- title: "Senior Software Engineer",
- company: "Innovatech Solutions",
- logo: "/placeholder.svg?height=40&width=40",
- startDate: "Jul 2022",
- endDate: "Nov 2023",
- },
- {
- title: "Software Engineer",
- company: "Quantum Systems",
- logo: "/placeholder.svg?height=40&width=40",
- startDate: "Feb 2021",
- endDate: "Dec 2022",
- },
- ],
- scores: {
- overall: 60,
- phone: 60,
- email: 10,
- ipAddress: null,
- },
- socialMedia: {
- facebook: {
- firstSeen: "02/07/2016, 16:42",
- followersCount: 12,
- fullName: "Lawrence Jackson",
- username: "ameliaj",
- location: "Texas, United States",
- profileImage: "/placeholder.svg?height=100&width=100",
- },
- instagram: {
- firstSeen: "02/07/2016, 16:42",
- followersCount: 650,
- followingCount: 847,
- username: "Jackson23",
- isVerified: false,
- probability: "100%",
- profileImage: "/placeholder.svg?height=100&width=100",
- },
- x: {
- firstSeen: "02/07/2016, 16:42",
- },
- youtube: {},
- },
- }
-}
-
-export default async function IndividualPage({ params }: { params: Promise<{ individual_id: string }> }) {
- const { individual_id } = await params
- const individual = await getIndividual(individual_id)
-
- return (
- <div className="min-h-screen p-6">
- <div className="max-w-7xl mx-auto my-12 space-y-6">
- {/* Header with profile info */}
- <div className="flex flex-col md:flex-row gap-6 items-start md:items-center">
- <Avatar className="w-24 h-24 rounded-full border-2">
- <AvatarImage src={individual.avatar} alt={individual.full_name} />
- <AvatarFallback className="">
- {individual.full_name
- .split(" ")
- .map((n) => n[0])
- .join("")}
- </AvatarFallback>
- </Avatar>
- <div className="space-y-4">
- <h1 className="text-3xl md:text-4xl font-bold">{individual.full_name}</h1>
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- <div className="flex items-center gap-2">
- <span className="opacity-60">Email</span>
- <span>{individual.email}</span>
- </div>
- <div className="flex items-center gap-2">
- <span className="opacity-60">Phone Number</span>
- <span>{individual.phoneNumber}</span>
- </div>
- </div>
- </div>
- </div>
-
- {/* Stats cards */}
- <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardContent className="p-4 flex justify-between items-center">
- <div className="flex items-center gap-2">
- <div className="p-2 rounded-md ">
- <CreditCard className="h-5 w-5" />
- </div>
- <span className="opacity-60">Accounts</span>
- </div>
- <div className="flex items-center gap-1">
- <span className="text-2xl font-bold">{individual.stats.accounts}</span>
- <ArrowRight className="h-4 w-4 text-gray-500" />
- </div>
- </CardContent>
- </Card>
-
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardContent className="p-4 flex justify-between items-center">
- <div className="flex items-center gap-2">
- <div className="p-2 rounded-md ">
- <User className="h-5 w-5" />
- </div>
- <span className="opacity-60">Names</span>
- </div>
- <div className="flex items-center gap-1">
- <span className="text-2xl font-bold">{individual.stats.names}</span>
- <ArrowRight className="h-4 w-4 text-gray-500" />
- </div>
- </CardContent>
- </Card>
-
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardContent className="p-4 flex justify-between items-center">
- <div className="flex items-center gap-2">
- <div className="p-2 rounded-md ">
- <Mail className="h-5 w-5" />
- </div>
- <span className="opacity-60">Emails</span>
- </div>
- <div className="flex items-center gap-1">
- <span className="text-2xl font-bold">{individual.stats.emails}</span>
- <ArrowRight className="h-4 w-4 text-gray-500" />
- </div>
- </CardContent>
- </Card>
-
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardContent className="p-4 flex justify-between items-center">
- <div className="flex items-center gap-2">
- <div className="p-2 rounded-md ">
- <Phone className="h-5 w-5" />
- </div>
- <span className="opacity-60">Phone Numbers</span>
- </div>
- <div className="flex items-center gap-1">
- <span className="text-2xl font-bold">{individual.stats.phoneNumbers}</span>
- <ArrowRight className="h-4 w-4 text-gray-500" />
- </div>
- </CardContent>
- </Card>
- </div>
-
- {/* Main content grid */}
- <div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
- {/* Profile section */}
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardHeader className="border-b pb-4">
- <h2 className="text-xl font-bold">Profile</h2>
- </CardHeader>
- <CardContent className="p-4 space-y-4">
- <div className="grid grid-cols-2 gap-y-4">
- <span className="opacity-60">Birthday</span>
- <span className="text-right">{individual.profile.birthday}</span>
-
- <span className="opacity-60">Family status</span>
- <span className="text-right">{individual.profile.familyStatus}</span>
-
- <span className="opacity-60">Is job seeker</span>
- <span className="text-right">{individual.profile.isJobSeeker ? "Yes" : "No"}</span>
-
- <span className="opacity-60">Education</span>
- <span className="text-right">{individual.profile.education}</span>
-
- <span className="opacity-60">Job title</span>
- <span className="text-right">{individual.profile.jobTitle}</span>
-
- <span className="opacity-60">Company</span>
- <span className="text-right">{individual.profile.company}</span>
- </div>
- </CardContent>
- </Card>
-
- {/* Job History section */}
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardHeader className="border-b pb-4">
- <h2 className="text-xl font-bold">Job History</h2>
- </CardHeader>
- <CardContent className="p-4 space-y-6">
- {individual.jobHistory.map((job, index) => (
- <div key={index} className="flex gap-4">
- <div className="flex-shrink-0">
- <div className="w-10 h-10 rounded-md overflow-hidden bg-sidebar shadow-none flex items-center justify-center">
- {/* <Image
- src={job.logo || "/placeholder.svg"}
- alt={job.company}
- width={40}
- height={40}
- className="object-cover"
- /> */}
- <Building2 className="h-5 w-5" />
- </div>
- </div>
- <div className="flex-1">
- <h3 className="font-medium">{job.title}</h3>
- <p className="opacity-60">{job.company}</p>
- </div>
- <div className="text-right opacity-60 text-sm">
- {job.startDate} - {job.endDate}
- </div>
- </div>
- ))}
- </CardContent>
- </Card>
- </div>
-
- {/* Social Media section */}
- <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
- {/* Facebook */}
- {individual.socialMedia.facebook && (
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardHeader className="border-b pb-4 flex flex-row justify-between items-center">
- <div className="flex items-center gap-2">
- <div className="w-8 h-8 bg-blue-600 rounded flex items-center justify-center">
- <Facebook className="h-5 w-5 text-white" />
- </div>
- <h2 className="text-xl font-bold">Facebook</h2>
- </div>
- <div className="flex items-center gap-1 text-sm opacity-60">
- <Calendar className="h-4 w-4" />
- <span>First seen {individual.socialMedia.facebook.firstSeen}</span>
- </div>
- </CardHeader>
- <CardContent className="p-4">
- <div className="flex justify-between">
- <div className="space-y-4">
- <div className="grid grid-cols-2 gap-y-4 gap-x-8">
- <span className="opacity-60">Followers count</span>
- <span>{individual.socialMedia.facebook.followersCount}</span>
-
- <span className="opacity-60">Full name</span>
- <span>{individual.socialMedia.facebook.fullName}</span>
-
- <span className="opacity-60">Username</span>
- <span>{individual.socialMedia.facebook.username}</span>
-
- <span className="opacity-60">Location</span>
- <span>{individual.socialMedia.facebook.location}</span>
- </div>
- </div>
-
- {individual.socialMedia.facebook.profileImage && (
- <div className="flex-shrink-0">
- <Image
- src={individual.socialMedia.facebook.profileImage || "/placeholder.svg"}
- alt={individual.socialMedia.facebook.fullName}
- width={100}
- height={100}
- className="rounded-md"
- />
- </div>
- )}
- </div>
- </CardContent>
- </Card>
- )}
-
- {/* Instagram */}
- {individual.socialMedia.instagram && (
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardHeader className="border-b pb-4 flex flex-row justify-between items-center">
- <div className="flex items-center gap-2">
- <div className="w-8 h-8 bg-gradient-to-tr from-purple-600 via-pink-500 to-orange-400 rounded flex items-center justify-center">
- <Instagram className="h-5 w-5 text-white" />
- </div>
- <h2 className="text-xl font-bold">Instagram</h2>
- </div>
- <Link href="#" className="text-green-500 flex items-center gap-1 text-sm">
- <span>See profile</span>
- <ExternalLink className="h-4 w-4" />
- </Link>
- </CardHeader>
- <CardContent className="p-4">
- <div className="flex justify-between">
- <div className="space-y-4">
- <div className="grid grid-cols-2 gap-y-4 gap-x-8">
- <span className="opacity-60">Followers count</span>
- <span>{individual.socialMedia.instagram.followersCount}</span>
-
- <span className="opacity-60">Following count</span>
- <span>{individual.socialMedia.instagram.followingCount}</span>
-
- <span className="opacity-60">Username</span>
- <span>{individual.socialMedia.instagram.username}</span>
-
- <span className="opacity-60">Is Verified</span>
- <span>{individual.socialMedia.instagram.isVerified ? "Yes" : "No"}</span>
-
- <span className="opacity-60">Probability</span>
- <span>{individual.socialMedia.instagram.probability}</span>
- </div>
- </div>
-
- {individual.socialMedia.instagram.profileImage && (
- <div className="flex-shrink-0">
- <Image
- src={individual.socialMedia.instagram.profileImage || "/placeholder.svg"}
- alt={individual.socialMedia.instagram.username}
- width={100}
- height={100}
- className="rounded-md"
- />
- </div>
- )}
- </div>
-
- <div className="mt-4 flex justify-end">
- <button className=" hover:bg-gray-700 text-sm px-4 py-2 rounded-md">Show more</button>
- </div>
- </CardContent>
- </Card>
- )}
-
- {/* X (Twitter) */}
- {individual.socialMedia.x && (
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardHeader className="border-b pb-4 flex flex-row justify-between items-center">
- <div className="flex items-center gap-2">
- <div className="w-8 h-8 bg-black rounded flex items-center justify-center">
- <Twitter className="h-5 w-5 text-white" />
- </div>
- <h2 className="text-xl font-bold">X</h2>
- </div>
- <Link href="#" className="text-green-500 flex items-center gap-1 text-sm">
- <span>See profile</span>
- <ExternalLink className="h-4 w-4" />
- </Link>
- </CardHeader>
- <CardContent className="p-4">
- <div className="flex items-center gap-1 text-sm opacity-60">
- <Calendar className="h-4 w-4" />
- <span>First seen {individual.socialMedia.x.firstSeen}</span>
- </div>
- </CardContent>
- </Card>
- )}
-
- {/* YouTube */}
- {individual.socialMedia.youtube && Object.keys(individual.socialMedia.youtube).length > 0 && (
- <Card className="bg-sidebar shadow-none border-border backdrop-blur">
- <CardHeader className="border-b pb-4 flex flex-row justify-between items-center">
- <div className="flex items-center gap-2">
- <div className="w-8 h-8 bg-red-600 rounded flex items-center justify-center">
- <Youtube className="h-5 w-5 text-white" />
- </div>
- <h2 className="text-xl font-bold">YouTube</h2>
- </div>
- <Link href="#" className="text-green-500 flex items-center gap-1 text-sm">
- <span>See profile</span>
- <ExternalLink className="h-4 w-4" />
- </Link>
- </CardHeader>
- </Card>
- )}
- </div>
- </div>
- </div>
- )
-}
\ No newline at end of file
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/layout.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/layout.tsx
deleted file mode 100644
index 59c1657f..00000000
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/layout.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { InvestigationProvider } from '@/components/contexts/investigation-provider';
-import { createClient } from "@/lib/supabase/server";
-import { notFound, redirect } from "next/navigation";
-import { InvestigationtNavigation } from '@/components/investigations/investigation-navigation';
-import { ScanDrawer } from '@/components/investigations/scan-drawer';
-import { Investigation } from '@/types/investigation';
-const DashboardLayout = async ({
- children,
- params,
-}: {
- children: React.ReactNode;
- params: Promise<{ project_id: string, investigation_id: string }>
-}) => {
- const supabase = await createClient()
- const { investigation_id, project_id } = await params
- const { data, error: userError } = await supabase.auth.getUser()
- if (userError || !data?.user) {
- redirect('/login')
- }
- const { data: investigation, error } = await supabase.from("investigations").select("id, members:investigations_profiles(profile:profiles(id, first_name, last_name), role)").eq("id", investigation_id).single()
- if (!investigation || error) {
- return notFound()
- }
- return (
- <InvestigationProvider>
- <div className="sticky z-40 bg-background w-full hidden md:flex top-[48px] border-b">
- <InvestigationtNavigation project_id={project_id} investigation_id={investigation_id} investigation={investigation as Investigation} />
- </div>
- {children}
- <ScanDrawer />
- </InvestigationProvider>
- )
-}
-
-export default DashboardLayout
\ No newline at end of file
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/client.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/client.tsx
deleted file mode 100644
index 539ce46d..00000000
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/client.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-"use client"
-import { useQuery } from "@tanstack/react-query"
-import OrganizationGraph from "@/components/organigrams/graph"
-import IndividualModal from "@/components/investigations/individual-modal"
-import { notFound } from "next/navigation"
-interface DashboardClientProps {
- projectId: string
- organizationId: string
-}
-export default function OrganigramClient({ projectId, organizationId }: DashboardClientProps) {
- const graphQuery = useQuery({
- queryKey: ["project", [projectId], "organigram", organizationId],
- queryFn: async () => {
- const res = await fetch(`/api/projects/${projectId}/organigrams/${organizationId}/sketch`)
- if (!res.ok) {
- notFound()
- }
- return res.json()
- },
- refetchOnWindowFocus: true,
- })
- return (
- <>
- <OrganizationGraph graphQuery={graphQuery} />
- <IndividualModal />
- </>
- )
-}
-
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/layout.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/layout.tsx
deleted file mode 100644
index f7da2be3..00000000
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/organigrams/[organization_id]/layout.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { InvestigationProvider } from '@/components/contexts/investigation-provider';
-import { SearchProvider } from '@/components/contexts/search-context';
-import { createClient } from "@/lib/supabase/server";
-import { redirect } from "next/navigation";
-import { ChatProvider } from '@/components/contexts/chatbot-context';
-import { InvestigationtNavigation } from '@/components/investigations/investigation-navigation';
-import { ScanDrawer } from '@/components/investigations/scan-drawer';
-const DashboardLayout = async ({
- children,
- params,
-}: {
- children: React.ReactNode;
- params: Promise<{ project_id: string, investigation_id: string }>
-}) => {
- const supabase = await createClient()
- const { investigation_id, project_id } = await params
- const { data, error: userError } = await supabase.auth.getUser()
- if (userError || !data?.user) {
- redirect('/login')
- }
- return (
- children
- )
-}
-
-export default DashboardLayout
\ No newline at end of file
diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/page.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/page.tsx
deleted file mode 100644
index 6115da3a..00000000
--- a/flowsint-web/src/app/dashboard/projects/[project_id]/page.tsx
+++ /dev/null
@@ -1,184 +0,0 @@
-"use client"
-
-import { useState } from "react"
-import { Button } from "@/components/ui/button"
-import { Input } from "@/components/ui/input"
-import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
-import { MoreHorizontal, PlusIcon, RotateCwIcon, Search, SlidersHorizontal, Waypoints } from "lucide-react"
-import { useQuery } from "@tanstack/react-query"
-import { notFound, useParams } from "next/navigation"
-import Loader from "@/components/loader"
-import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
-import { format, formatDistanceToNow } from "date-fns"
-import Link from "next/link"
-import { Investigation } from "@/types/investigation"
-import NewCase from "@/components/dashboard/new-sketch"
-import { DocumentList } from "@/components/projects/documents-list"
-import { cn } from "@/lib/utils"
-import { ProjectNavigation } from "@/components/investigations/project-navigation"
-import { Card } from "@/components/ui/card"
-
-const DashboardPage = () => {
- const { project_id } = useParams()
- const [searchQuery, setSearchQuery] = useState("")
-
- const { data: project, isLoading: isLoadingSketches, isRefetching: isRefetchingSketches, refetch: refetchSketches } = useQuery({
- queryKey: ["dashboard", "projects", project_id],
- queryFn: async () => {
- const res = await fetch(`/api/projects/${project_id}`)
- if (!res.ok) {
- notFound()
- }
- return res.json()
- },
- refetchOnWindowFocus: true,
- })
- const {
- data: documents, isLoading: isLoadingDocs, isRefetching: isRefetchingDocs, refetch: refetchDocs
- } = useQuery({
- queryKey: ["project", project_id, "documents"],
- queryFn: async () => {
- const res = await fetch(`/api/projects/${project_id}/documents`)
- if (!res.ok) {
- throw new Error("Failed to fetch documents")
- }
- return res.json() as Promise<Document[]>
- },
- refetchOnWindowFocus: true,
- enabled: !!project_id,
- })
-
- const handleRefetch = () => {
- refetchSketches()
- refetchDocs()
- }
-
- const isLoading = isLoadingDocs || isLoadingSketches
- const isRefetching = isRefetchingDocs || isRefetchingSketches
-
- return (
- <>
- <div className="sticky z-40 bg-background top-[48px] border-b">
- <ProjectNavigation project_id={project_id as string} />
- </div>
- <div className="w-full space-y-8 container mx-auto py-12 px-8">
- <div className="flex items-center gap-2 justify-between mb-6">
- <div className="relative w-full max-w-md">
- <Search className="absolute left-2.5 top-2.5 h-4 w-4 bg-background text-muted-foreground" />
- <Input
- type="search"
- placeholder="Search items..."
- className="pl-8 w-full bg-background"
- value={searchQuery}
- onChange={(e) => setSearchQuery(e.target.value)}
- />
- </div>
- <div className="flex items-center gap-2">
- <NewCase>
- <Button size="sm" className="gap-2">
- <PlusIcon className="h-4 w-4" /> New
- </Button>
- </NewCase>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="outline" size="sm" className="gap-2">
- <SlidersHorizontal className="h-4 w-4" />
- <span className="hidden sm:inline">Sort by</span>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem>Name</DropdownMenuItem>
- <DropdownMenuItem>Type</DropdownMenuItem>
- <DropdownMenuItem>Date created</DropdownMenuItem>
- <DropdownMenuItem>Date modified</DropdownMenuItem>
- <DropdownMenuItem>Size</DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- <Button onClick={handleRefetch} disabled={isLoading || isRefetching} variant={"outline"} size="sm" className="gap-2">
- <RotateCwIcon className={cn("h-4 w-4", isLoading || isRefetching && "animate-spin")} /> Refresh
- </Button>
- </div>
- </div>
- {isLoadingSketches ? (
- <div className="flex justify-center items-center py-12">
- <Loader />
- </div>
- ) : (
- <Card className="border rounded-md bg-background shadow-xs">
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>Name</TableHead>
- <TableHead>Type</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">Creation</TableHead>
- <TableHead className="w-[50px]"></TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {project.investigations.length === 0 && documents?.length === 0 ? (
- <TableRow>
- <TableCell colSpan={7} className="text-center w-full py-2 text-muted-foreground">
- <div className="flex flex-col justify-center items-center p-3 gap-2">
- No sketch yet or document yet.
- <NewCase noDropDown>
- <Button size="sm" className="gap-2">
- <PlusIcon className="h-4 w-4" /> Create a new sketch
- </Button>
- </NewCase>
- </div>
- </TableCell>
- </TableRow>
- ) : (
- project?.investigations?.map((investigation: Investigation) => (
- <TableRow key={investigation.id}>
- <TableCell>
- <Link href={`/dashboard/projects/${investigation.project_id}/investigations/${investigation.id}`} className="flex items-center gap-2 hover:underline">
- <Waypoints className="h-5 w-5 text-primary" />
- <span>{investigation.title}</span>
- </Link>
- </TableCell>
- <TableCell className="text-muted-foreground">{"Sketch"}</TableCell>
- <TableCell className="text-muted-foreground">{`${investigation?.owner?.first_name} ${project?.owner?.last_name}` || "You"}</TableCell>
- <TableCell className="hidden md:table-cell text-muted-foreground">
- {(investigation?.individuals?.length || 0) > 0 ? `${investigation?.individuals?.length} items` : "Empty"}
- </TableCell>
- <TableCell className="hidden sm:table-cell text-muted-foreground">
- {formatDistanceToNow(new Date(investigation.last_updated_at), { addSuffix: true })}
- </TableCell>
- <TableCell className="hidden sm:table-cell text-muted-foreground">
- {format(new Date(project.created_at), "dd/MM/yyyy")}
- </TableCell>
- <TableCell>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" size="icon" className="h-8 w-8">
- <MoreHorizontal className="h-4 w-4" />
- <span className="sr-only">Actions</span>
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuItem>Open</DropdownMenuItem>
- <DropdownMenuItem>Rename</DropdownMenuItem>
- <DropdownMenuItem>Share</DropdownMenuItem>
- <DropdownMenuItem className="text-destructive">Delete</DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </TableCell>
- </TableRow>
- ))
- )}
- <DocumentList refetch={refetchDocs} isLoading={isLoadingDocs} documents={documents} />
- </TableBody>
- </Table>
- </Card>
- )}
- </div >
- </>
- )
-}
-
-export default DashboardPage
-
diff --git a/flowsint-web/src/components/contexts/chatbot-context.tsx b/flowsint-web/src/components/contexts/chatbot-context.tsx
deleted file mode 100644
index 15ed8cea..00000000
--- a/flowsint-web/src/components/contexts/chatbot-context.tsx
+++ /dev/null
@@ -1,150 +0,0 @@
-"use client"
-
-import type React from "react"
-import { createContext, type ReactNode, useContext, useEffect, useState } from "react"
-import { useChat } from "@ai-sdk/react"
-import { Bot, User } from "lucide-react"
-import { cn } from "@/lib/utils"
-import ReactMarkdown from "react-markdown"
-import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@/components/ui/sheet"
-import { Avatar, AvatarFallback } from "@/components/ui/avatar"
-import { Card, CardContent } from "@/components/ui/card"
-import { Input } from "@/components/ui/input"
-import { Button } from "@/components/ui/button"
-import { ScrollArea } from "../ui/scroll-area"
-
-interface ChatContextType {
- open: boolean
- handleOpenChat: (content: any) => void
-}
-
-const ChatContext = createContext<ChatContextType | undefined>(undefined)
-
-interface ChatProviderProps {
- children: ReactNode
-}
-
-export const ChatProvider: React.FC<ChatProviderProps> = ({ children }) => {
- const [open, setOpen] = useState(false)
- const [context, setContext] = useState<any>(null)
- const { messages, input, handleInputChange, setInput, handleSubmit, error } = useChat()
-
- const handleOpenChat = (content: any) => {
- setContext(content)
- if (content)
- setInput(`What pattern can you extract from this person ?\n ${JSON.stringify(content)}`)
- setOpen(true)
- }
-
- return (
- <ChatContext.Provider value={{ open, handleOpenChat }}>
- {children}
- <Sheet open={open} onOpenChange={setOpen}>
- <SheetContent className={cn("w-full p-4 flex divide-y flex-col justify-between", messages?.length > 0 ? "sm:max-w-[730px]" : "sm:max-w-[480px]")}>
- <SheetHeader>
- <SheetTitle>Ask AI</SheetTitle>
- <SheetDescription>Ask AI chat bot to help you understand patterns.</SheetDescription>
- </SheetHeader>
- <ScrollArea className="flex flex-col gap-3 overflow-y-auto w-full grow">
- {messages.map((m) => (
- <div key={m.id} className="flex grow mb-2">
- <div
- className={cn(
- "flex gap-3 items-start w-full flex-row justify-start",
- )}
- >
- <Avatar className={cn("h-8 w-8")}>
- <AvatarFallback>
- {m.role === "user" ? (
- <User className="h-4 w-4" />
- ) : (
- <Bot className="h-4 w-4" />
- )}
- </AvatarFallback>
- </Avatar>
- <div className={cn("flex flex-col gap-1 w-full items-start")}>
- <Card className="bg-transparent shadow-none border-0">
- <CardContent className="p-0">
- <ReactMarkdown>{m.content}</ReactMarkdown>
- </CardContent>
- </Card>
- </div>
- </div>
- </div>
- ))}
- {error && (
- <div className="flex">
- <div className="flex gap-1 items-start justify-start w-full">
- <Avatar className="h-8 w-8 bg-red-500">
- <AvatarFallback>
- <Bot className="h-4 w-4" />
- </AvatarFallback>
- </Avatar>
- <div className="flex flex-col gap-1 items-start w-full">
- <span className="text-sm font-bold text-red-500">Error</span>
- <Card className="bg-transparent shadow-none border-0">
- <CardContent className="p-3 text-red-500">
- Oops, an error occurred. Make sure you provided a valid Mistral API key.
- </CardContent>
- </Card>
- </div>
- </div>
- </div>
- )}
- </ScrollArea>
- <form onSubmit={handleSubmit} className=" flex items-center gap-2">
- <Input
- value={input}
- onChange={handleInputChange}
- placeholder="'What pattern can you extract from those relations ?'"
- className="grow"
- />
- <div>
- <Button type="submit">
- Send
- </Button>
- </div>
- </form>
- </SheetContent>
- </Sheet>
- </ChatContext.Provider>
- )
-}
-
-export const useChatContext = (): ChatContextType => {
- const context = useContext(ChatContext)
- if (!context) {
- throw new Error("useChatContext must be used within a ChatProvider")
- }
- return context
-}
-
-interface LoadingDotsProps {
- speed?: number
- text?: string
-}
-
-const LoadingDots: React.FC<LoadingDotsProps> = ({ speed = 200, text = "Thinking" }) => {
- const [dots, setDots] = useState("")
-
- useEffect(() => {
- const interval = setInterval(() => {
- setDots((prevDots) => {
- if (prevDots.length >= 3) {
- return ""
- }
- return prevDots + "."
- })
- }, speed)
-
- return () => clearInterval(interval)
- }, [speed])
-
- return (
- <div className="flex items-center">
- <span>{text}</span>
- <span className="w-8 text-left">{dots}</span>
- </div>
- )
-}
-
diff --git a/flowsint-web/src/components/contexts/search-context.tsx b/flowsint-web/src/components/contexts/search-context.tsx
deleted file mode 100644
index d386aa00..00000000
--- a/flowsint-web/src/components/contexts/search-context.tsx
+++ /dev/null
@@ -1,134 +0,0 @@
-"use client"
-import type React from "react"
-import { createContext, useContext, type ReactNode, useState } from "react"
-import { Button } from "@/components/ui/button"
-import { Card } from "@/components/ui/card"
-import {
- Sheet,
- SheetClose,
- SheetContent,
- SheetDescription,
- SheetFooter,
- SheetHeader,
- SheetTitle,
-} from "@/components/ui/sheet"
-import { Alert, AlertDescription } from "@/components/ui/alert"
-import { InfoIcon } from "lucide-react"
-import { investigateHIBPwd } from "@/lib/actions/search"
-import Breaches from "../breach"
-import { cn } from "@/lib/utils"
-
-interface SearchContextType {
- openSearchModal: boolean
- handleOpenSearchModal: (val: string) => void
-}
-
-const SearchContext = createContext<SearchContextType | undefined>(undefined)
-
-interface SearchProviderProps {
- children: ReactNode
-}
-
-export const SearchProvider: React.FC<SearchProviderProps> = ({ children }) => {
- const [openSearchModal, setOpenSearchModal] = useState(false)
- const [value, setValue] = useState<string | null>(null)
- const [results, setResults] = useState<null | any>()
- const [isLoading, setIsLoading] = useState(false)
- const [error, setError] = useState("")
-
-
- const onSubmitNewSearch = async (e: React.FormEvent) => {
- if (!value) return setError("No value to search for.")
- e.preventDefault()
- setIsLoading(true)
- setError("")
- try {
- const data = await investigateHIBPwd(value)
- setResults(data)
- } catch (err) {
- setError(err instanceof Error ? err.message : "An error occurred.")
- } finally {
- setIsLoading(false)
- }
- }
-
- const handleOpenSearchModal = (val: string) => {
- setValue(val)
- setOpenSearchModal(true)
- }
-
- const handleCloseModal = () => {
- setValue("")
- setError("")
- setResults(null)
- setOpenSearchModal(false)
- }
-
- return (
- <SearchContext.Provider value={{ openSearchModal, handleOpenSearchModal }}>
- {children}
- <Sheet open={openSearchModal} onOpenChange={handleCloseModal}>
- <SheetContent className={cn(results ? "sm:max-w-[950px]" : "sm:max-w-[450px]", "h-screen overflow-auto")}>
- <SheetHeader>
- <SheetTitle>New search</SheetTitle>
- <SheetDescription>Make a new keyword associated research.</SheetDescription>
- </SheetHeader>
- <form onSubmit={onSubmitNewSearch} className="grow flex flex-col">
- <div className="flex flex-col grow gap-3 p-2">
- <Card className="p-4 shadow-none">
- <p>
- value: <span className="font-medium">"{value}"</span>
- </p>
- </Card>
- {error && (
- <Alert variant="destructive">
- <InfoIcon className="h-4 w-4" />
- <AlertDescription>{JSON.stringify(error)}</AlertDescription>
- </Alert>
- )}
- {results && Array.isArray(results) ? (
- <>
- <Alert variant="destructive">
- <InfoIcon className="h-4 w-4" />
- <AlertDescription>
- "{value}" has appeared in {results.length} data breach(es). Here are the infos we have:
- </AlertDescription>
- </Alert>
- <Breaches breaches={results} />
- </>
- ) : (
- results && (
- <Alert variant="default">
- <InfoIcon className="h-4 w-4" />
- <AlertDescription>{JSON.stringify(results)}</AlertDescription>
- </Alert>
- )
- )}
- </div>
- <SheetFooter className="mt-auto flex flex-row justify-end gap-2">
- <SheetClose asChild>
- <Button type="button" variant="outline">
- Close
- </Button>
- </SheetClose>
- {!results && (
- <Button disabled={isLoading} type="submit">
- {isLoading ? "Saving..." : "Save"}
- </Button>
- )}
- </SheetFooter>
- </form>
- </SheetContent>
- </Sheet>
- </SearchContext.Provider >
- )
-}
-
-export const useSearchContext = (): SearchContextType => {
- const context = useContext(SearchContext)
- if (!context) {
- throw new Error("useSearchContext must be used within a SearchProvider")
- }
- return context
-}
-
diff --git a/flowsint-web/src/components/contexts/investigation-provider.tsx b/flowsint-web/src/components/contexts/sketch-provider.tsx
similarity index 86%
rename from flowsint-web/src/components/contexts/investigation-provider.tsx
rename to flowsint-web/src/components/contexts/sketch-provider.tsx
index 898ec540..c66efa2a 100644
--- a/flowsint-web/src/components/contexts/investigation-provider.tsx
+++ b/flowsint-web/src/components/contexts/sketch-provider.tsx
@@ -1,7 +1,7 @@
"use client"
import type React from "react"
import { type ReactNode, useEffect } from "react"
-import { useInvestigationStore } from "@/store/investigation-store"
+import { useSketchStore } from "@/store/sketch-store"
import { useParams, useRouter, usePathname, useSearchParams } from "next/navigation"
import { useConfirm } from "@/components/use-confirm-dialog"
import { supabase } from "@/lib/supabase/client"
@@ -10,12 +10,12 @@ import { Button } from "@/components/ui/button"
import { Switch } from "@/components/ui/switch"
import { cn } from "@/lib/utils"
-interface InvestigationProviderProps {
+interface SketchProviderProps {
children: ReactNode
}
-export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ children }) => {
- const { investigation_id } = useParams()
+export const SketchProvider: React.FC<SketchProviderProps> = ({ children }) => {
+ const { sketch_id } = useParams()
const router = useRouter()
const pathname = usePathname()
const searchParams = useSearchParams()
@@ -26,15 +26,15 @@ export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ ch
openSettingsModal,
setOpenSettingsModal,
setHandleOpenIndividualModal,
- setHandleDeleteInvestigation,
+ setHandleDeleteSketch,
openNewNode, setOpenNewNode
- } = useInvestigationStore()
+ } = useSketchStore()
useEffect(() => {
- const handleDeleteInvestigation = async () => {
+ const handleDeleteSketch = async () => {
const confirmDelete = await confirm({
- title: "Delete investigation",
- message: "Are you really sure you want to delete this investigation ?",
+ title: "Delete sketch",
+ message: "Are you really sure you want to delete this sketch ?",
})
if (!confirmDelete) return
@@ -46,26 +46,26 @@ export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ ch
if (!confirmFinal) return
try {
const { error } = await supabase
- .from("investigations")
+ .from("Sketchs")
.update({ status: "archived" })
- .eq("id", investigation_id)
+ .eq("id", sketch_id)
if (error) throw error
router.push("/dashboard")
} catch (error) {
- console.error("Error deleting investigation:", error)
+ console.error("Error deleting sketch:", error)
}
}
- setHandleDeleteInvestigation(handleDeleteInvestigation)
+ setHandleDeleteSketch(handleDeleteSketch)
}, [
- investigation_id,
+ sketch_id,
router,
pathname,
searchParams,
confirm,
setHandleOpenIndividualModal,
- setHandleDeleteInvestigation,
+ setHandleDeleteSketch,
])
const SettingSwitch = ({
@@ -148,4 +148,4 @@ export const InvestigationProvider: React.FC<InvestigationProviderProps> = ({ ch
)
}
-export const useInvestigationContext = useInvestigationStore
\ No newline at end of file
+export const useSketchContext = useSketchStore
\ No newline at end of file
diff --git a/flowsint-web/src/components/dashboard/main-nav.tsx b/flowsint-web/src/components/dashboard/main-nav.tsx
index f37e8fe9..bade5144 100644
--- a/flowsint-web/src/components/dashboard/main-nav.tsx
+++ b/flowsint-web/src/components/dashboard/main-nav.tsx
@@ -2,16 +2,18 @@
import type React from "react"
import Link from "next/link"
import { cn } from "@/lib/utils"
-import ProjectSelector from "../investigations/project-selector"
-import CaseSelector from "../investigations/case-selector"
+import InvestigationSelector from "../investigations/investigation-selector"
+import CaseSelector from "../sketches/case-selector"
import { useParams } from "next/navigation"
export function MainNav({ className, ...props }: React.HTMLAttributes<HTMLElement>) {
- const { investigation_id, project_id } = useParams()
+ const { sketch_id, investigation_id } = useParams()
- if (project_id) return (
+ if (investigation_id) return (
<div className='flex gap-1 items-center p-2'>
- <ProjectSelector />{investigation_id && <><span className='opacity-60 text-sm'>/</span><CaseSelector /></>}
+ <InvestigationSelector />{sketch_id && <><span className='opacity-60 text-sm'>
+ /</span><CaseSelector /></>
+ }
</div >
)
diff --git a/flowsint-web/src/components/dashboard/new-project.tsx b/flowsint-web/src/components/dashboard/new-investigation.tsx
similarity index 78%
rename from flowsint-web/src/components/dashboard/new-project.tsx
rename to flowsint-web/src/components/dashboard/new-investigation.tsx
index 87b0c1b8..1dda8432 100644
--- a/flowsint-web/src/components/dashboard/new-project.tsx
+++ b/flowsint-web/src/components/dashboard/new-investigation.tsx
@@ -4,7 +4,7 @@ import type React from "react"
import { useState } from "react"
import { useRouter } from "next/navigation"
-import { createNewProject } from "@/lib/actions/projects"
+import { createNewInvestigation } from "@/lib/actions/investigations"
import { Button } from "@/components/ui/button"
import {
Dialog,
@@ -30,20 +30,20 @@ function SubmitButton() {
)
}
-export default function NewProject({ children, noDropDown }: { children: React.ReactNode, noDropDown?: boolean }) {
+export default function NewInvestigation({ children, noDropDown }: { children: React.ReactNode, noDropDown?: boolean }) {
const [open, setOpen] = useState(false)
const router = useRouter()
- async function handleNewProject(formData: FormData) {
- const result = await createNewProject(formData)
+ async function handleNewInvestigation(formData: FormData) {
+ const result = await createNewInvestigation(formData)
if (result.success) {
- toast.success("New project created.")
+ toast.success("New investigation created.")
if (result.path)
toast.success("New storage bucket created.")
- router.push(`/dashboard/projects/${result.id}`)
+ router.push(`/dashboard/investigations/${result.id}`)
setOpen(false)
} else {
- toast.error("Could not create new project.")
+ toast.error("Could not create new investigation.")
}
}
@@ -53,13 +53,13 @@ export default function NewProject({ children, noDropDown }: { children: React.R
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
- <DialogTitle>New project</DialogTitle>
- <DialogDescription>Create a new blank project.</DialogDescription>
+ <DialogTitle>New investigation</DialogTitle>
+ <DialogDescription>Create a new blank investigation.</DialogDescription>
</DialogHeader>
- <form action={handleNewProject}>
+ <form action={handleNewInvestigation}>
<div className="grid gap-4 py-4">
<div className="grid gap-2">
- <Label htmlFor="name">Project name</Label>
+ <Label htmlFor="name">investigation name</Label>
<Input id="name" name="name" placeholder="Suspicion de fraude" required />
</div>
<div className="grid gap-2">
@@ -88,7 +88,7 @@ export default function NewProject({ children, noDropDown }: { children: React.R
<DropdownMenuTrigger asChild>{children}</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onSelect={() => setOpen(true)}>
- New project
+ New investigation
<span className="ml-auto text-xs text-muted-foreground">⌘ E</span>
</DropdownMenuItem>
</DropdownMenuContent>
@@ -96,13 +96,13 @@ export default function NewProject({ children, noDropDown }: { children: React.R
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent className="sm:max-w-[425px]">
<DialogHeader>
- <DialogTitle>New project</DialogTitle>
- <DialogDescription>Create a new blank project.</DialogDescription>
+ <DialogTitle>New investigation</DialogTitle>
+ <DialogDescription>Create a new blank investigation.</DialogDescription>
</DialogHeader>
- <form action={handleNewProject}>
+ <form action={handleNewInvestigation}>
<div className="grid gap-4 py-4">
<div className="grid gap-2">
- <Label htmlFor="name">Project name</Label>
+ <Label htmlFor="name">investigation name</Label>
<Input id="name" name="name" placeholder="Suspicion de fraude" required />
</div>
<div className="grid gap-2">
diff --git a/flowsint-web/src/components/dashboard/new-sketch.tsx b/flowsint-web/src/components/dashboard/new-sketch.tsx
index ef848b72..bd294e2e 100644
--- a/flowsint-web/src/components/dashboard/new-sketch.tsx
+++ b/flowsint-web/src/components/dashboard/new-sketch.tsx
@@ -4,7 +4,7 @@ import type React from "react"
import { useState } from "react"
import { useParams, useRouter } from "next/navigation"
-import { createNewCase } from "@/lib/actions/investigations"
+import { createNewSketch } from "@/lib/actions/sketches"
import { Button } from "@/components/ui/button"
import {
Dialog,
@@ -19,7 +19,7 @@ import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { useFormStatus } from "react-dom"
import { toast } from "sonner"
-import { useProjectStore } from "@/store/project-store"
+import { useInvestigationStore } from "@/store/project-store"
function SubmitButton() {
const { pending } = useFormStatus()
@@ -32,19 +32,19 @@ function SubmitButton() {
)
}
-export default function NewCase({ children, noDropDown = false }: { children: React.ReactNode, noDropDown?: boolean }) {
+export default function NewSketch({ children, noDropDown = false }: { children: React.ReactNode, noDropDown?: boolean }) {
const [open, setOpen] = useState(false)
- const { setOpenUploadModal } = useProjectStore()
+ const { setOpenUploadModal } = useInvestigationStore()
const router = useRouter()
- const { project_id } = useParams()
+ const { investigation_id } = useParams()
- async function handleNewCase(formData: FormData) {
- const result = await createNewCase(formData, project_id as string)
+ async function handleNewSketch(formData: FormData) {
+ const result = await createNewSketch(formData, investigation_id as string)
if (result.success) {
toast.success("New sketch created.")
- router.push(`/dashboard/projects/${project_id}/investigations/${result.id}`)
+ router.push(`/dashboard/investigations/${investigation_id}/sketches/${result.id}`)
setOpen(false)
} else {
toast.error("Could not create new sketch." + JSON.stringify(result))
@@ -60,7 +60,7 @@ export default function NewCase({ children, noDropDown = false }: { children: Re
<DialogTitle>New sketch</DialogTitle>
<DialogDescription>Create a new blank sketch.</DialogDescription>
</DialogHeader>
- <form action={handleNewCase}>
+ <form action={handleNewSketch}>
<div className="grid gap-4 py-4">
<div className="grid gap-2">
<Label htmlFor="title">Investigation name</Label>
@@ -107,7 +107,7 @@ export default function NewCase({ children, noDropDown = false }: { children: Re
<DialogTitle>New sketch</DialogTitle>
<DialogDescription>Create a new blank sketch.</DialogDescription>
</DialogHeader>
- <form action={handleNewCase}>
+ <form action={handleNewSketch}>
<div className="grid gap-4 py-4">
<div className="grid gap-2">
<Label htmlFor="title">Investigation name</Label>
diff --git a/flowsint-web/src/components/dashboard/recent-sketches.tsx b/flowsint-web/src/components/dashboard/recent-sketches.tsx
index 859979d8..856b73b0 100644
--- a/flowsint-web/src/components/dashboard/recent-sketches.tsx
+++ b/flowsint-web/src/components/dashboard/recent-sketches.tsx
@@ -1,6 +1,6 @@
"use client"
-import type { Investigation } from "@/types/investigation"
+import type { Sketch } from "@/types/sketch"
import { useQuery } from "@tanstack/react-query"
import Link from "next/link"
import { Fingerprint, Search } from "lucide-react"
@@ -12,13 +12,13 @@ import { AvatarList } from "../avatar-list"
const RecentSketches = () => {
const {
- data: investigations,
+ data: sketches,
isLoading,
error,
} = useQuery({
- queryKey: ["dashboard", "investigations"],
+ queryKey: ["dashboard", "sketches"],
queryFn: async () => {
- const res = await fetch(`/api/latest-investigations`)
+ const res = await fetch(`/api/latest-sketches`)
return res.json()
},
refetchOnWindowFocus: true,
@@ -28,9 +28,9 @@ const RecentSketches = () => {
return (
<div className="flex flex-col items-center justify-center p-8 text-center rounded-lg border border-dashed">
<Search className="h-10 w-10 text-muted-foreground mb-2" />
- <h3 className="text-lg font-semibold">Error loading investigations</h3>
+ <h3 className="text-lg font-semibold">Error loading sketches.</h3>
<p className="text-sm text-muted-foreground">
- There was a problem loading your investigations. Please try again.
+ There was a problem loading your sketches. Please try again.
</p>
</div>
)
@@ -57,9 +57,9 @@ const RecentSketches = () => {
}
return (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
- {investigations?.map((investigation: Investigation) => {
+ {sketches?.map((sketch: Sketch) => {
return (
- <Link href={`/dashboard/projects/${investigation.project_id}/investigations/${investigation.id}`} key={investigation.id} className="group">
+ <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">
@@ -68,13 +68,13 @@ const RecentSketches = () => {
</div>
<div className="w-full truncate">
<h3 className="font-medium w-full truncate text-ellispsis transition-colors">
- {investigation?.project?.name}<span className="mx-1 opacity-40 text-sm">/</span>{investigation.title}
+ {sketch?.investigation?.name}<span className="mx-1 opacity-40 text-sm">/</span>{sketch.title}
</h3>
- <span className="text-xs opacity-60">Last updated {formatDistanceToNow(investigation.last_updated_at, { addSuffix: true })}</span>
+ <span className="text-xs opacity-60">Last updated {formatDistanceToNow(sketch.last_updated_at, { addSuffix: true })}</span>
</div>
</div>
<div className="flex items-center justify-end">
- <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={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" />
</div>
</CardContent>
</Card>
diff --git a/flowsint-web/src/components/dashboard/search-palette.tsx b/flowsint-web/src/components/dashboard/search-palette.tsx
deleted file mode 100644
index 09e46010..00000000
--- a/flowsint-web/src/components/dashboard/search-palette.tsx
+++ /dev/null
@@ -1,113 +0,0 @@
-"use client"
-
-import { useState, useCallback, useEffect, SetStateAction } from 'react'
-// @ts-ignore
-import debounce from "lodash.debounce"
-import { Search, UserIcon } from 'lucide-react'
-// @ts-ignore
-import Highlighter from "react-highlight-words"
-import { useSearchResults } from '@/lib/hooks/investigation/use-search-results'
-import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"
-import { Input } from "@/components/ui/input"
-import { Button } from "@/components/ui/button"
-import { ScrollArea } from "@/components/ui/scroll-area"
-import { useFlowStore } from '@/store/flow-store'
-import { cn } from '@/lib/utils'
-import Loader from '../loader'
-
-const SearchModal = ({ investigation_id }: { investigation_id: string }) => {
- const [search, setSearch] = useState("")
- const [open, setOpen] = useState(false)
- const { setCurrentNode } = useFlowStore()
- const {
- results,
- error,
- isLoading,
- refetch,
- } = useSearchResults(search, investigation_id)
-
- const changeHandler = (event: { target: { value: SetStateAction<string> } }) => {
- setSearch(event.target.value)
- refetch && refetch()
- }
- const debouncedChangeHandler = useCallback(debounce(changeHandler, 300), [])
-
- const handleClose = () => {
- setSearch('')
- setOpen(false)
- }
-
- useEffect(() => {
- const handleKeyPress = (event: KeyboardEvent) => {
- if (event.ctrlKey && event.key === 'k') {
- setOpen(true)
- }
- }
- window.addEventListener('keydown', handleKeyPress)
- return () => {
- window.removeEventListener('keydown', handleKeyPress)
- }
- }, [])
-
- const SearchItem = ({ item }: any) => (
- <li
- className={cn(
- "hover:bg-sidebar-accent rounded-md text-sidebar-accent-foreground/90 hover:text-sidebar-accent-foreground text-sm",
- "bg-sidebar-accent text-sidebar-accent-foreground",
- )}
- key={item.id}
- >
- <button
- onClick={() => { setCurrentNode(item.id); setOpen(false) }}
- className="flex items-center p-1 px-4 w-full gap-2"
- >
- <UserIcon className="h-3 w-3 opacity-60" />
- <Highlighter
- highlightClassName="bg-primary/60"
- searchWords={[search]}
- autoEscape={true}
- textToHighlight={item.full_name}
- />
- </button>
- </li >
- )
-
- return (
- <>
- <Dialog open={open} onOpenChange={handleClose}>
- <Button variant="outline" size="icon" onClick={() => setOpen(true)}>
- <Search className="h-4 w-4" />
- </Button>
- <DialogContent className="min-h-none">
- <DialogHeader>
- <DialogTitle>Search</DialogTitle>
- <DialogDescription>
- Find the profile you're looking for.
- </DialogDescription>
- </DialogHeader>
- <div className="space-y-4">
- <Input
- defaultValue={search}
- onChange={debouncedChangeHandler}
- placeholder="Your search here…"
- />
- <div className='w-full relative text-center flex flex-col items-center justify-center gap-2'>
- {error && <p className="text-red-500">An error occurred.</p>}
- {isLoading && <div><Loader /> Loading..</div>}
- {results?.length === 0 && <p>No results found for "{search}".</p>}
- {results && results?.length !== 0 && <ScrollArea className="h-[60vh] w-full rounded-md border p-4">
- <ul className='space-y-2'>
- {!error && !isLoading && Array.isArray(results) && results?.map((item) => (
- <SearchItem key={item.id} item={item} />
- ))}
- </ul>
- </ScrollArea>}
- </div>
- </div>
- </DialogContent>
- </Dialog>
- </>
- )
-}
-
-export default SearchModal
diff --git a/flowsint-web/src/components/investigations/case-selector.tsx b/flowsint-web/src/components/investigations/case-selector.tsx
deleted file mode 100644
index 8d6b457b..00000000
--- a/flowsint-web/src/components/investigations/case-selector.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-"use client"
-import { useInvestigations } from "@/lib/hooks/investigation/investigation";
-import { useInvestigationStore } from '@/store/investigation-store';
-import { useParams, useRouter } from "next/navigation";
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select"
-import { Skeleton } from "@/components/ui/skeleton";
-import { WaypointsIcon } from "lucide-react";
-import { Badge } from "../ui/badge";
-
-export default function CaseSelector() {
- const router = useRouter()
- const { investigation_id, project_id } = useParams()
- const useInvestigationData = useInvestigationStore(
- (state) => state.useInvestigationData
- );
- const { investigations, isLoading } = useInvestigations(project_id as string)
- const { investigation } = useInvestigationData(project_id as string, investigation_id as string);
-
- const handleSelectionChange = (value: string) => {
- value === "overview" ? router.push(`/dashboard/projects/${project_id}`) :
- router.push(`/dashboard/projects/${project_id}/investigations/${value}`);
- };
- return (
- <div className="flex items-center">
- {isLoading || investigation.isLoading ? <Skeleton className="h-8 w-40 bg-foreground/10" /> :
- <Select onValueChange={handleSelectionChange} defaultValue={investigation?.data.id}>
- <SelectTrigger className="min-w-none h-8 rounded-sm w-full hover:bg-sidebar-accent font-medium shadow-none border-none text-ellipsis truncate gap-1">
- <SelectValue defaultValue={investigation?.data?.title || ""} placeholder="Select an investigation" />
- </SelectTrigger>
- <SelectContent>
- <SelectItem className="text-ellipsis truncate" value={"overview"}>{"Overview"}</SelectItem>
- {investigations?.map((investigation) => (
- <SelectItem className="text-ellipsis truncate items-center" key={investigation.id} value={investigation.id}>{investigation.title} <Badge variant={"outline"} className="ml-1 rounded-full shadow-none !flex items-center gap-1"><WaypointsIcon className="!h-3 !w-3" />Sketch</Badge></SelectItem>
- ))}
- </SelectContent>
- </Select >}
- </div >
- );
-}
diff --git a/flowsint-web/src/components/projects/documents-list.tsx b/flowsint-web/src/components/investigations/documents-list.tsx
similarity index 97%
rename from flowsint-web/src/components/projects/documents-list.tsx
rename to flowsint-web/src/components/investigations/documents-list.tsx
index 56079e66..f9ed1911 100644
--- a/flowsint-web/src/components/projects/documents-list.tsx
+++ b/flowsint-web/src/components/investigations/documents-list.tsx
@@ -23,7 +23,7 @@ const icons: Record<string, JSX.Element> = {
}
export function DocumentList({ documents, isLoading, refetch }: { documents: any[] | undefined, isLoading: boolean, refetch: () => void }) {
- const { project_id } = useParams<{ project_id: string }>()
+ const { investigation_id } = useParams<{ investigation_id: string }>()
const [searchQuery, setSearchQuery] = useState("")
const [previewUrl, setPreviewUrl] = useState<string | null>(null)
const [previewType, setPreviewType] = useState<string | null>(null)
@@ -63,7 +63,7 @@ export function DocumentList({ documents, isLoading, refetch }: { documents: any
const deleteFile = async (fileName: string) => {
if (!await confirm({ title: `Are you sure you want to delete ${fileName}?`, message: "This action is irreversible." })) return
try {
- const res = await fetch(`/api/projects/${project_id}/documents?fileName=${encodeURIComponent(fileName)}`, {
+ const res = await fetch(`/api/investigations/${investigation_id}/documents?fileName=${encodeURIComponent(fileName)}`, {
method: "DELETE",
})
if (!res.ok) {
diff --git a/flowsint-web/src/components/projects/file-upload.tsx b/flowsint-web/src/components/investigations/file-upload.tsx
similarity index 97%
rename from flowsint-web/src/components/projects/file-upload.tsx
rename to flowsint-web/src/components/investigations/file-upload.tsx
index ed9e02aa..5daafa74 100644
--- a/flowsint-web/src/components/projects/file-upload.tsx
+++ b/flowsint-web/src/components/investigations/file-upload.tsx
@@ -18,7 +18,7 @@ import {
DialogTitle,
} from "@/components/ui/dialog"
import { Progress } from "@/components/ui/progress"
-import { useProjectStore } from "@/store/project-store"
+import { useInvestigationStore } from "@/store/project-store"
import { toast } from "sonner"
import { useParams, useRouter } from "next/navigation"
@@ -32,8 +32,8 @@ interface FileWithStatus {
}
export default function FileUploadDialog() {
- const { project_id } = useParams()
- const { openUploadModal: open, setOpenUploadModal: setOpen } = useProjectStore()
+ const { investigation_id } = useParams()
+ const { openUploadModal: open, setOpenUploadModal: setOpen } = useInvestigationStore()
const router = useRouter()
const [files, setFiles] = useState<FileWithStatus[]>([])
const [isDragging, setIsDragging] = useState(false)
@@ -90,7 +90,7 @@ export default function FileUploadDialog() {
try {
const file = files[i].file
const safeName = sanitize(file.name)
- const filePath = `${project_id}/${safeName}`
+ const filePath = `${investigation_id}/${safeName}`
// Upload file to Supabase
const { error } = await supabase.storage.from("documents").upload(filePath, file)
// Simulate progress tracking (if needed)
diff --git a/flowsint-web/src/components/investigations/individual-modal.tsx b/flowsint-web/src/components/investigations/individual-modal.tsx
deleted file mode 100644
index 4e588389..00000000
--- a/flowsint-web/src/components/investigations/individual-modal.tsx
+++ /dev/null
@@ -1,672 +0,0 @@
-"use client"
-
-import type React from "react"
-import { useEffect, useState } from "react"
-import { useIndividual } from "@/lib/hooks/individuals/use-individual"
-import { useEmailsAndBreaches } from "@/lib/hooks/individuals/use-emails-breaches"
-import { useRelations } from "@/lib/hooks/individuals/use-relations"
-import { usePlatformIcons } from "@/lib/hooks/use-platform-icons"
-import { supabase } from "@/lib/supabase/client"
-import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogTitle } from "@/components/ui/dialog"
-import { Button } from "@/components/ui/button"
-import { Input } from "@/components/ui/input"
-import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
-import { Badge } from "@/components/ui/badge"
-import { Alert, AlertDescription } from "@/components/ui/alert"
-import { Card, CardContent } from "@/components/ui/card"
-import { Pencil, X, Plus, Trash2, Building2, Mail, MapPin, Phone, Briefcase, ExternalLink } from "lucide-react"
-import Breaches from "../breach"
-import { useQueryState } from "nuqs"
-import { Progress } from "@/components/ui/progress"
-
-const IndividualModal = () => {
- const [individualId, setIndividualId] = useQueryState("individual_id")
- const { individual, isLoading } = useIndividual(individualId)
- const { emails, isLoading: isLoadingEmails } = useEmailsAndBreaches(individualId)
- const platformsIcons = usePlatformIcons()
- const { relations, isLoading: isLoadingRelations } = useRelations(individualId)
- const [editMode, setEditMode] = useState(false)
- const [image, setImage] = useState<string | null>("")
- const [phones, setPhones] = useState([""])
- const [accounts, setAccounts] = useState([""])
- const [ips, setIps] = useState([""])
-
- useEffect(() => {
- setPhones(individual?.phone_numbers?.map(({ phone_number }: any) => phone_number) || [""])
- setIps(individual?.ip_addresses?.map(({ ip_address }: any) => ip_address) || [""])
- setAccounts(individual?.social_accounts || [""])
- setImage(individual?.image_url)
- }, [individual])
-
- const handleCloseModal = () => {
- setEditMode(false)
- setIndividualId(null)
- }
-
- const handleSave = async (event: React.FormEvent<HTMLFormElement>) => {
- event.preventDefault()
- const formData = new FormData(event.currentTarget)
- const formContent = Object.fromEntries(formData.entries())
- const { data } = await supabase
- .from("individuals")
- .update({ ...formContent, birth_date: null })
- .eq("id", individualId)
- .select("image_url")
- .single()
- setImage(data?.image_url)
- setEditMode(false)
- }
-
- const handleAddField = (setter: React.Dispatch<React.SetStateAction<string[]>>) => {
- setEditMode(true)
- setter((prev) => [...prev, ""])
- }
-
- const handleRemoveField = (index: number, setter: React.Dispatch<React.SetStateAction<string[]>>) => {
- setter((prev) => prev.filter((_, i) => i !== index))
- }
-
- const handleFieldChange = (index: number, value: string, setter: React.Dispatch<React.SetStateAction<string[]>>) => {
- setter((prev) => prev.map((item, i) => (i === index ? value : item)))
- }
-
- if (!isLoading && !individual) {
- return (
- <Dialog open={Boolean(individualId)} onOpenChange={handleCloseModal}>
- <DialogContent>
- <DialogTitle>No data</DialogTitle>
- <DialogDescription>No data found for this individual.</DialogDescription>
- <DialogFooter>
- <Button variant="outline" onClick={handleCloseModal}>
- Close
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- )
- }
-
- return (
- <Dialog open={Boolean(individualId)} onOpenChange={handleCloseModal}>
- <DialogContent className="sm:max-w-[90vw] max-h-[90vh] p-0 bg-background overflow-y-auto">
- <div className="h-full flex flex-col">
- <div className="flex justify-between sticky top-0 items-center p-4 border-b">
- <DialogTitle className="text-xl font-bold">{individual?.full_name || "User Profile"}</DialogTitle>
- <div className="flex items-center gap-2 mr-12">
- <Button
- variant="ghost"
- type="button"
- onClick={() => setEditMode(!editMode)}
- aria-label={editMode ? "Cancel edit" : "Edit profile"}
- className="text-zinc-400 flex hover:text-white hover:bg-zinc-800"
- >
- {editMode ? <>Close <X className="h-4 w-4" /></> : <>Edit <Pencil className="h-4 w-4" /></>}
- </Button>
- {/* <Button
- variant="ghost"
- size="icon"
- onClick={handleCloseModal}
- className="text-zinc-400 hover:text-white hover:bg-zinc-800"
- >
- <X className="h-4 w-4" />
- </Button> */}
- </div>
- </div>
-
- <div className="flex-1 overflow-y-auto p-6">
- <form className="flex flex-col gap-6" onSubmit={handleSave}>
- <div className="flex flex-col md:flex-row gap-6">
- {/* Left column - Profile image and basic info */}
- <div className="flex flex-col gap-4 md:w-1/3">
- <div className="flex flex-col items-center gap-4 rounded-xl p-6">
- <Avatar className="h-32 w-32 border-2">
- <AvatarImage src={image || undefined} alt={individual?.full_name} />
- <AvatarFallback className="bg-zinc-800 text-2xl">
- {individual?.full_name?.[0] || "?"}
- </AvatarFallback>
- </Avatar>
- <div className="text-center">
- <h2 className="text-xl font-bold">{individual?.full_name}</h2>
- {individual?.job_title && <p className="text-zinc-400">{individual.job_title}</p>}
- </div>
-
- <div className="w-full space-y-4 mt-2">
- {individual?.email && (
- <div className="flex items-center gap-3 text-sm">
- <Mail className="h-4 w-4" />
- <span className="">{individual.email}</span>
- </div>
- )}
-
- {phones[0] && (
- <div className="flex items-center gap-3 text-sm">
- <Phone className="h-4 w-4" />
- <span className="">{phones[0]}</span>
- </div>
- )}
-
- {individual?.location && (
- <div className="flex items-center gap-3 text-sm">
- <MapPin className="h-4 w-4" />
- <span className="">{individual.location}</span>
- </div>
- )}
-
- {individual?.company && (
- <div className="flex items-center gap-3 text-sm">
- <Building2 className="h-4 w-4" />
- <span className="">{individual.company}</span>
- </div>
- )}
- </div>
- </div>
-
- <div className="bg-background rounded-xl p-6">
- <h3 className="text-lg font-semibold mb-4">Profile</h3>
- <div className="space-y-3">
- {individual?.birth_date && (
- <div className="flex justify-between">
- <span className="text-zinc-400">Birthday</span>
- <span>{individual.birth_date}</span>
- </div>
- )}
-
- {individual?.family_status && (
- <div className="flex justify-between">
- <span className="text-zinc-400">Family status</span>
- <span>{individual.family_status}</span>
- </div>
- )}
-
- {individual?.education && (
- <div className="flex justify-between">
- <span className="text-zinc-400">Education</span>
- <span>{individual.education}</span>
- </div>
- )}
-
- {individual?.job_title && (
- <div className="flex justify-between">
- <span className="text-zinc-400">Job title</span>
- <span>{individual.job_title}</span>
- </div>
- )}
-
- {individual?.company && (
- <div className="flex justify-between">
- <span className="text-zinc-400">Company</span>
- <span>{individual.company}</span>
- </div>
- )}
- </div>
- </div>
-
- {/* Score card */}
- <div className="bg-background rounded-xl p-6">
- <div className="flex items-center justify-between mb-4">
- <h3 className="text-lg font-semibold">Overall score</h3>
- <div className="relative h-16 w-16">
- <div className="absolute inset-0 flex items-center justify-center">
- <span className="text-xl font-bold">60</span>
- </div>
- <svg className="h-full w-full" viewBox="0 0 36 36">
- <path
- d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
- fill="none"
- stroke="#444"
- strokeWidth="2"
- />
- <path
- d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
- fill="none"
- stroke="url(#gradient)"
- strokeWidth="2"
- strokeDasharray="60, 100"
- />
- <defs>
- <linearGradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">
- <stop offset="0%" stopColor="#4ade80" />
- <stop offset="100%" stopColor="#facc15" />
- </linearGradient>
- </defs>
- </svg>
- </div>
- </div>
-
- <div className="space-y-3">
- <div className="space-y-1">
- <div className="flex justify-between text-sm">
- <span className="text-zinc-400">Phone score</span>
- <span>60</span>
- </div>
- <Progress value={60} className="h-1.5 bg-zinc-800" />
- </div>
-
- <div className="space-y-1">
- <div className="flex justify-between text-sm">
- <span className="text-zinc-400">Email score</span>
- <span>10</span>
- </div>
- <Progress value={10} className="h-1.5 bg-zinc-800" />
- </div>
-
- <div className="space-y-1">
- <div className="flex justify-between text-sm">
- <span className="text-zinc-400">IP address score</span>
- <span>—</span>
- </div>
- <Progress value={0} className="h-1.5 bg-zinc-800" />
- </div>
- </div>
- </div>
- </div>
-
- {/* Right column - Tabs content */}
- <div className="flex-1">
- <Tabs defaultValue="overview" className="w-full">
- <TabsList className="w-full justify-start p-1 rounded-lg mb-4">
- <TabsTrigger
- value="overview"
- className="data-[state=active]:bg-zinc-800 data-[state=active]:text-white"
- >
- Overview
- </TabsTrigger>
- <TabsTrigger
- value="social_account"
- className="data-[state=active]:bg-zinc-800 data-[state=active]:text-white"
- >
- Social accounts
- <Badge variant={accounts?.length > 0 ? "default" : "outline"} className="ml-1 bg-zinc-700">
- {accounts?.length || 0}
- </Badge>
- </TabsTrigger>
- <TabsTrigger
- value="emails"
- className="data-[state=active]:bg-zinc-800 data-[state=active]:text-white"
- >
- Emails
- <Badge variant={emails?.length > 0 ? "default" : "outline"} className="ml-1 bg-zinc-700">
- {emails?.length || 0}
- </Badge>
- </TabsTrigger>
- <TabsTrigger
- value="phone_numbers"
- className="data-[state=active]:bg-zinc-800 data-[state=active]:text-white"
- >
- Phone numbers
- <Badge variant={phones?.length > 0 ? "default" : "outline"} className="ml-1 bg-zinc-700">
- {phones?.length || 0}
- </Badge>
- </TabsTrigger>
- <TabsTrigger
- value="ip_addresses"
- className="data-[state=active]:bg-zinc-800 data-[state=active]:text-white"
- >
- IP addresses
- <Badge variant={ips?.length > 0 ? "default" : "outline"} className="ml-1 bg-zinc-700">
- {ips?.length || 0}
- </Badge>
- </TabsTrigger>
- <TabsTrigger
- value="relations"
- className="data-[state=active]:bg-zinc-800 data-[state=active]:text-white"
- >
- Relations
- <Badge variant={relations?.length > 0 ? "default" : "outline"} className="ml-1 bg-zinc-700">
- {relations?.length || 0}
- </Badge>
- </TabsTrigger>
- </TabsList>
-
- <div className="bg-background rounded-xl p-6">
- <TabsContent value="overview">
- {editMode ? (
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- {individual &&
- Object.keys(individual)
- .filter((key) => typeof individual[key] !== "object" || !Array.isArray(individual[key]))
- .map((key) => (
- <div key={key} className="flex flex-col gap-1">
- <label className="text-zinc-400 capitalize-first">{key}</label>
- <Input
- type={key === "birth_date" ? "date" : "text"}
- defaultValue={individual[key]}
- placeholder={key}
- name={key}
- disabled={key === "id" || key === "investigation_id" || !editMode}
- className="bg-zinc-800 text-white"
- />
- </div>
- ))}
- </div>
- ) : (
- <div className="space-y-6">
- {/* Job History */}
- <div>
- <h3 className="text-lg font-semibold mb-4">Job History</h3>
- <div className="space-y-4">
- <div className="flex gap-4 items-start">
- <div className="bg-blue-500/20 p-2 rounded-md">
- <Briefcase className="h-5 w-5 text-blue-500" />
- </div>
- <div className="flex-1">
- <div className="flex justify-between">
- <div>
- <h4 className="font-medium">Data Analyst</h4>
- <p className="text-zinc-400 text-sm">Vertex Dynamics</p>
- </div>
- <span className="text-zinc-400 text-sm">Nov 2023 - Mar 2024</span>
- </div>
- </div>
- </div>
-
- <div className="flex gap-4 items-start">
- <div className="bg-yellow-500/20 p-2 rounded-md">
- <Briefcase className="h-5 w-5 text-yellow-500" />
- </div>
- <div className="flex-1">
- <div className="flex justify-between">
- <div>
- <h4 className="font-medium">Senior Software Engineer</h4>
- <p className="text-zinc-400 text-sm">Innovatech Solutions</p>
- </div>
- <span className="text-zinc-400 text-sm">Jul 2022 - Nov 2023</span>
- </div>
- </div>
- </div>
-
- <div className="flex gap-4 items-start">
- <div className="bg-green-500/20 p-2 rounded-md">
- <Briefcase className="h-5 w-5 text-green-500" />
- </div>
- <div className="flex-1">
- <div className="flex justify-between">
- <div>
- <h4 className="font-medium">Software Engineer</h4>
- <p className="text-zinc-400 text-sm">Quantum Systems</p>
- </div>
- <span className="text-zinc-400 text-sm">Feb 2021 - Dec 2022</span>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- )}
- </TabsContent>
-
- <TabsContent value="social_account">
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- {accounts.length === 0 && (
- <p className="italic text-zinc-400 text-sm col-span-full">
- No account registered. Click on edit to add one.
- </p>
- )}
-
- {accounts.map((account: any, index) => (
- <Card key={index} className="bg-zinc-800 p-4">
- <CardContent className="flex items-center gap-3 p-0">
- <Avatar className="h-10 w-10 bg-zinc-700">
- {/* @ts-ignore */}
- <AvatarImage src={platformsIcons[account?.platform]?.icon} />
- <AvatarFallback className="bg-zinc-700 ">
- {account?.platform?.[0] || "?"}
- </AvatarFallback>
- </Avatar>
- <div className="overflow-hidden">
- <p className="text-sm font-semibold">{account?.platform}</p>
- <p className="text-sm font-bold">
- {account?.username || <span className="italic font-light">No username</span>}
- </p>
- <a
- href={account?.profile_url}
- className="text-sm text-blue-400 hover:underline truncate block flex items-center gap-1"
- >
- {account?.profile_url}
- <ExternalLink className="h-3 w-3" />
- </a>
- </div>
-
- {editMode && (
- <Button
- variant="ghost"
- size="icon"
- onClick={() => handleRemoveField(index, setAccounts)}
- className="ml-auto text-zinc-400 hover:text-white hover:bg-zinc-700"
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- )}
- </CardContent>
- </Card>
- ))}
-
- {editMode && (
- <Button
- onClick={() => handleAddField(setAccounts)}
- variant="outline"
- className="border-dashed hover:border-zinc-500 bg-transparent text-zinc-400 hover:text-white hover:bg-zinc-800"
- >
- <Plus className="mr-2 h-4 w-4" /> Add account
- </Button>
- )}
- </div>
- </TabsContent>
-
- <TabsContent value="emails">
- <div className="space-y-4">
- {emails.length === 0 && (
- <p className="italic text-zinc-400 text-sm">
- No email registered. Click on edit to add one.
- </p>
- )}
-
- {emails.map((email: any, index: number) => (
- <div key={index} className="space-y-2">
- <Alert
- variant={email.breaches.length > 0 ? "destructive" : "default"}
- className={
- email.breaches.length > 0
- ? "bg-red-950/50 border-red-900 text-red-200"
- : "bg-zinc-800"
- }
- >
- <AlertDescription className="flex items-center gap-2">
- <Mail className="h-4 w-4" />
- <span className="font-bold">{email.email}</span>{" "}
- {email.breaches.length === 0
- ? " is not yet involved in a data breach."
- : ` was involved in ${email.breaches.length} data breach(es).`}
- </AlertDescription>
- </Alert>
- <Breaches breaches={email.breaches} />
- </div>
- ))}
- </div>
- </TabsContent>
-
- <TabsContent value="phone_numbers">
- <div className="space-y-4">
- {phones.length === 0 && (
- <p className="italic text-zinc-400 text-sm">
- No phone number registered. Click on edit to add one.
- </p>
- )}
-
- {phones.map((phone, index) => (
- <div key={index} className="flex items-center gap-2">
- <div className="bg-zinc-800 border rounded-md p-3 flex items-center gap-3 flex-1">
- <Phone className="h-4 w-4 text-zinc-400" />
- {editMode ? (
- <Input
- value={phone}
- onChange={(e) => handleFieldChange(index, e.target.value, setPhones)}
- placeholder="Phone Number"
- type="tel"
- className="bg-transparent border-0 p-0 h-auto focus-visible:ring-0 focus-visible:ring-offset-0"
- />
- ) : (
- <span>{phone}</span>
- )}
- </div>
-
- {editMode && (
- <Button
- variant="ghost"
- size="icon"
- onClick={() => handleRemoveField(index, setPhones)}
- className="text-zinc-400 hover:text-white hover:bg-zinc-800"
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- )}
- </div>
- ))}
-
- {editMode && (
- <Button
- onClick={() => handleAddField(setPhones)}
- variant="outline"
- className="border-dashed hover:border-zinc-500 bg-transparent text-zinc-400 hover:text-white hover:bg-zinc-800"
- >
- <Plus className="mr-2 h-4 w-4" /> Add Phone
- </Button>
- )}
- </div>
- </TabsContent>
-
- <TabsContent value="ip_addresses">
- <div className="space-y-4">
- {ips.length === 0 && (
- <p className="italic text-zinc-400 text-sm">
- No IP address registered. Click on edit to add one.
- </p>
- )}
-
- {ips.map((ip, index) => (
- <div key={index} className="flex items-center gap-2">
- <div className="bg-zinc-800 border rounded-md p-3 flex items-center gap-3 flex-1">
- <svg
- className="h-4 w-4 text-zinc-400"
- viewBox="0 0 24 24"
- fill="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <path
- d="M12 2L2 7L12 12L22 7L12 2Z"
- stroke="currentColor"
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- <path
- d="M2 17L12 22L22 17"
- stroke="currentColor"
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- <path
- d="M2 12L12 17L22 12"
- stroke="currentColor"
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- />
- </svg>
- {editMode ? (
- <Input
- value={ip}
- onChange={(e) => handleFieldChange(index, e.target.value, setIps)}
- placeholder="IP address"
- type="text"
- className="bg-transparent border-0 p-0 h-auto focus-visible:ring-0 focus-visible:ring-offset-0"
- />
- ) : (
- <span>{ip}</span>
- )}
- </div>
-
- {editMode && (
- <Button
- variant="ghost"
- size="icon"
- onClick={() => handleRemoveField(index, setIps)}
- className="text-zinc-400 hover:text-white hover:bg-zinc-800"
- >
- <Trash2 className="h-4 w-4" />
- </Button>
- )}
- </div>
- ))}
-
- {editMode && (
- <Button
- onClick={() => handleAddField(setIps)}
- variant="outline"
- className="border-dashed hover:border-zinc-500 bg-transparent text-zinc-400 hover:text-white hover:bg-zinc-800"
- >
- <Plus className="mr-2 h-4 w-4" /> Add IP address
- </Button>
- )}
- </div>
- </TabsContent>
-
- <TabsContent value="relations">
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
- {relations.length === 0 && (
- <p className="italic text-zinc-400 text-sm col-span-full">
- No relation registered. Click on edit to add one.
- </p>
- )}
-
- {relations.map((relation) => (
- <Card
- key={relation.id}
- className="bg-zinc-800 p-4 hover:bg-zinc-750 transition-colors cursor-pointer"
- onClick={() => setIndividualId(relation.id)}
- >
- <CardContent className="flex items-center gap-3 p-0">
- <Avatar className="h-10 w-10 border">
- <AvatarImage src={relation?.image_url} alt={relation.full_name} />
- <AvatarFallback className="bg-zinc-700 ">
- {relation.full_name?.[0] || "?"}
- </AvatarFallback>
- </Avatar>
- <div>
- <p className="font-semibold">{relation.full_name}</p>
- <p className="text-sm text-zinc-400">{relation.relation_type}</p>
- </div>
- </CardContent>
- </Card>
- ))}
- </div>
- </TabsContent>
- </div>
- </Tabs>
- </div>
- </div>
- {editMode && (
- <DialogFooter>
- <Button
- variant="outline"
- onClick={() => setEditMode(false)}
- className="bg-transparent hover:bg-zinc-800 hover:text-white"
- >
- Cancel
- </Button>
- <Button type="submit" className="bg-blue-600 hover:bg-blue-700 text-white">
- Save Changes
- </Button>
- </DialogFooter>
- )}
- </form>
- </div>
- </div>
- </DialogContent>
- </Dialog>
- )
-}
-
-export default IndividualModal
diff --git a/flowsint-web/src/components/investigations/investigation-navigation.tsx b/flowsint-web/src/components/investigations/investigation-navigation.tsx
index 920ab913..a1f8d212 100644
--- a/flowsint-web/src/components/investigations/investigation-navigation.tsx
+++ b/flowsint-web/src/components/investigations/investigation-navigation.tsx
@@ -1,90 +1,65 @@
"use client"
import { cn } from "@/lib/utils"
-import { Users, TimerIcon, MapIcon, WaypointsIcon, TablePropertiesIcon } from 'lucide-react'
+import { Eye, Users, Camera, Settings, Waypoints } from "lucide-react"
import Link from "next/link"
import { usePathname } from "next/navigation"
-import { Fragment, memo, useMemo } from "react"
-import MoreMenu from "./more-menu"
-import { ScanButton } from "./scans-drawer/scan-button"
-import { Badge } from "../ui/badge"
-import { DownloadButton } from "../download-button"
-import { AvatarList } from "../avatar-list"
-import { Investigation } from "@/types/investigation"
-function InvestigationNavigation({ project_id, investigation_id, investigation }: { project_id: string, investigation_id: string, investigation: Investigation }) {
- const pathname = usePathname()
- // Memoize the sections array so it doesn't get recreated on every render
- const sections = useMemo(() => [
+export function InvestigationNavigation({ investigation_id }: { investigation_id: string }) {
+ const pathname = usePathname()
+ const sections = [
{
- id: "sketch",
- name: "Sketch",
- href: `/dashboard/projects/${project_id}/investigations/${investigation_id}`,
- icon: WaypointsIcon
+ id: "overview",
+ name: "Overview",
+ href: `/dashboard/investigations/${investigation_id}`,
+ icon: Eye,
+ count: 18,
},
{
- id: "table",
- name: "Table",
- href: `/dashboard/projects/${project_id}/investigations/${investigation_id}/table`,
- icon: TablePropertiesIcon,
+ id: "sketches",
+ name: "Sketches",
+ href: `/dashboard/investigations/${investigation_id}?filter=sketch`,
+ icon: Waypoints,
+ count: 24,
},
{
- id: "map",
- name: "Map",
- href: `/dashboard/projects/${project_id}/investigations/${investigation_id}/map`,
- icon: MapIcon,
+ id: "documents",
+ name: "Documents",
+ href: `/dashboard/investigations/${investigation_id}?filter=document`,
+ icon: Camera,
+ count: 6,
},
{
- id: "timeline",
- name: "Timeline",
- href: `/dashboard/projects/${project_id}/investigations/${investigation_id}/timeline`,
- icon: TimerIcon,
- "disabled": true,
- }
- ], [project_id, investigation_id]);
+ id: "configurations",
+ name: "Configurations",
+ href: `/dashboard/investigations/${investigation_id}/settings`,
+ icon: Settings,
+ count: null,
+ },
+ ]
return (
- <div className="flex items-center justify-between w-full">
- <div className="flex overflow-auto">
- {sections.map((section) => (
- <Fragment key={section.id}>
- {section.disabled ?
- <span
- className="text-muted-foreground border-b-2 border-transparent opacity-40 text-sm px-4 py-2.5 flex items-center gap-2">
- <section.icon className="h-4 w-4" />
- <span>{section.name}</span>
- <Badge variant={"outline"}>Soon</Badge>
- </span> :
- <Link
- href={section?.href || ""}
- className={cn(
- "flex items-center text-sm gap-2 border-b-2 border-transparent px-4 py-2 transition-colors",
- section?.href == pathname
- ? "bg-accent text-accent-foreground border-b-primary"
- : "text-muted-foreground hover:text-foreground hover:bg-accent/50",
- )}
- >
- <section.icon className="h-4 w-4" />
- <span>{section.name}</span>
- </Link>}
- </Fragment>
- ))}
- </div>
- <div className="flex items-center ">
- <div className="px-2">
- <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}` })) || []} />
- </div>
- <DownloadButton endpoint={`/api/projects/${project_id}/investigations/${investigation_id}/table`} name={project_id} />
- <MoreMenu />
- <ScanButton />
- </div>
- </div >
+ <div className="flex overflow-auto">
+ {sections.map((section) => (
+ <Link
+ key={section.id}
+ href={section?.href || ""}
+ className={cn(
+ "flex items-center text-sm gap-2 px-4 py-2 transition-colors",
+ section?.href == pathname
+ ? "bg-accent text-accent-foreground"
+ : "text-muted-foreground hover:text-foreground hover:bg-accent/50",
+ )}
+ >
+ <section.icon className="h-4 w-4" />
+ <span>{section.name}</span>
+ {section.count !== null && (
+ <span className="ml-1 rounded-full bg-primary/10 px-2 py-0.5 text-xs">{section.count}</span>
+ )}
+ </Link>
+ ))}
+ </div>
)
}
-// Memoize the entire component
-export const MemoizedInvestigationNavigation = memo(InvestigationNavigation);
-
-// For backward compatibility, you can also export the original name
-export { MemoizedInvestigationNavigation as InvestigationtNavigation };
\ No newline at end of file
diff --git a/flowsint-web/src/components/investigations/project-selector.tsx b/flowsint-web/src/components/investigations/investigation-selector.tsx
similarity index 70%
rename from flowsint-web/src/components/investigations/project-selector.tsx
rename to flowsint-web/src/components/investigations/investigation-selector.tsx
index 85a91013..15a9119b 100644
--- a/flowsint-web/src/components/investigations/project-selector.tsx
+++ b/flowsint-web/src/components/investigations/investigation-selector.tsx
@@ -9,36 +9,36 @@ import {
} from "@/components/ui/select"
import { Skeleton } from "@/components/ui/skeleton";
import { useQuery } from "@tanstack/react-query";
-import { Project } from "@/types/project";
+import { Investigation } from "@/types/investigation";
import { Badge } from '../ui/badge';
-export default function ProjectSelector() {
+export default function InvestigationSelector() {
const router = useRouter()
- const { project_id } = useParams()
+ const { investigation_id } = useParams()
const { data, isLoading } = useQuery({
- queryKey: ["dashboard", "projects"],
+ queryKey: ["dashboard", "investigations"],
queryFn: async () => {
- const res = await fetch(`/api/projects`)
+ const res = await fetch(`/api/investigations`)
return res.json()
},
refetchOnWindowFocus: true,
})
- const projects = data?.projects || []
+ const investigations = data?.investigations || []
const handleSelectionChange = (value: string) => {
- router.push(`/dashboard/projects/${value}`);
+ router.push(`/dashboard/investigations/${value}`);
};
return (
<div className="flex items-center">
{isLoading ? <Skeleton className="h-8 w-40 bg-foreground/10" /> :
// @ts-ignore
- <Select onValueChange={handleSelectionChange} defaultValue={project_id}>
+ <Select onValueChange={handleSelectionChange} defaultValue={investigation_id}>
<SelectTrigger className="min-w-none h-8 w-full hover:bg-sidebar-accent rounded-sm font-medium shadow-none border-none text-ellipsis truncate gap-1">
<SelectValue placeholder="Select an investigation" /><Badge variant="outline" className="ml-1 rounded-full shadow-none">Case</Badge>
</SelectTrigger>
<SelectContent>
- {projects?.map((project: Project) => (
- <SelectItem className="text-ellipsis truncate" key={project.id} value={project.id}>{project.name}</SelectItem>
+ {investigations?.map((investigation: Investigation) => (
+ <SelectItem className="text-ellipsis truncate" key={investigation.id} value={investigation.id}>{investigation.name}</SelectItem>
))}
</SelectContent>
</Select >}
diff --git a/flowsint-web/src/components/investigations/project-navigation.tsx b/flowsint-web/src/components/investigations/project-navigation.tsx
deleted file mode 100644
index 23d4ae6c..00000000
--- a/flowsint-web/src/components/investigations/project-navigation.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-"use client"
-
-import { cn } from "@/lib/utils"
-import { Eye, Users, Camera, Settings, Waypoints } from "lucide-react"
-import Link from "next/link"
-import { usePathname } from "next/navigation"
-
-
-export function ProjectNavigation({ project_id }: { project_id: string }) {
- const pathname = usePathname()
- const sections = [
- {
- id: "overview",
- name: "Overview",
- href: `/dashboard/projects/${project_id}`,
- icon: Eye,
- count: 18,
- },
- {
- id: "sketches",
- name: "Sketches",
- href: `/dashboard/projects/${project_id}?filter=sketch`,
- icon: Waypoints,
- count: 24,
- },
- {
- id: "documents",
- name: "Documents",
- href: `/dashboard/projects/${project_id}?filter=document`,
- icon: Camera,
- count: 6,
- },
- {
- id: "configurations",
- name: "Configurations",
- href: `/dashboard/projects/${project_id}/settings`,
- icon: Settings,
- count: null,
- },
- ]
-
- return (
- <div className="flex overflow-auto">
- {sections.map((section) => (
- <Link
- key={section.id}
- href={section?.href || ""}
- className={cn(
- "flex items-center text-sm gap-2 px-4 py-2 transition-colors",
- section?.href == pathname
- ? "bg-accent text-accent-foreground"
- : "text-muted-foreground hover:text-foreground hover:bg-accent/50",
- )}
- >
- <section.icon className="h-4 w-4" />
- <span>{section.name}</span>
- {section.count !== null && (
- <span className="ml-1 rounded-full bg-primary/10 px-2 py-0.5 text-xs">{section.count}</span>
- )}
- </Link>
- ))}
- </div>
- )
-}
-
diff --git a/flowsint-web/src/components/organigrams/graph.tsx b/flowsint-web/src/components/organigrams/graph.tsx
index 40088c73..817289a5 100644
--- a/flowsint-web/src/components/organigrams/graph.tsx
+++ b/flowsint-web/src/components/organigrams/graph.tsx
@@ -24,18 +24,18 @@ import {
WaypointsIcon,
} from "lucide-react"
import { useTheme } from "next-themes"
-import NewActions from "../investigations/new-actions"
+import NewActions from "../sketches/new-actions"
import { useParams } from "next/navigation"
import { Tooltip, TooltipContent } from "@/components/ui/tooltip"
import { Button } from "@/components/ui/button"
import { TooltipTrigger } from "@radix-ui/react-tooltip"
import { cn } from "@/lib/utils"
-import { useInvestigationStore } from "@/store/investigation-store"
+import { useSketchStore } from "@/store/sketch-store"
import { useFlowStore } from "@/store/flow-store"
import Loader from "@/components/loader"
import { useQueryState } from "nuqs"
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from "@/components/ui/context-menu"
-import PanelContextMenu from "../investigations/panel-context-menu"
+import PanelContextMenu from "../sketches/panel-context-menu"
import { memo } from "react"
import { shallow } from "zustand/shallow"
import { TooltipProvider } from "@/components/ui/tooltip"
@@ -46,8 +46,8 @@ import {
} from "@/components/ui/resizable"
import { Dialog, DialogTrigger } from "@/components/ui/dialog"
import FullscreenButton from "@/components/full-screen-button"
-import ProfilePanel from "../investigations/sketch/profile-panel"
-import NodesPanel from "../investigations/sketch/nodes-panel"
+import ProfilePanel from "../sketches/sketch/profile-panel"
+import NodesPanel from "../sketches/sketch/nodes-panel"
import OrganigramNode from "./organigram-node"
import OrganigramEdge from './organigram-edge'
const nodeTypes = {
@@ -171,8 +171,8 @@ const FlowControls = memo(({
const LayoutFlow = memo(({ refetch, theme }: any) => {
const { fitView, zoomIn, zoomOut, addNodes, getNode, setCenter, getNodes } = useReactFlow();
- const { investigation_id } = useParams();
- const showMiniMap = useInvestigationStore(state => state.settings.showMiniMap);
+ const { sketch_id } = useParams();
+ const showMiniMap = useSketchStore(state => state.settings.showMiniMap);
const [_, setView] = useQueryState("view", { defaultValue: "flow-graph" });
// Use a ref for context menu state to avoid re-renders on position changes
@@ -242,8 +242,8 @@ const LayoutFlow = memo(({ refetch, theme }: any) => {
}, [currentNode?.id]); // Only depend on currentNode.id, not the whole object
const handleConnect = useCallback(
- (params: any) => onConnect(params, investigation_id),
- [onConnect, investigation_id]
+ (params: any) => onConnect(params, sketch_id),
+ [onConnect, sketch_id]
);
const handleNodeContextMenu = useCallback(
diff --git a/flowsint-web/src/components/sketches/case-selector.tsx b/flowsint-web/src/components/sketches/case-selector.tsx
new file mode 100644
index 00000000..bf18b278
--- /dev/null
+++ b/flowsint-web/src/components/sketches/case-selector.tsx
@@ -0,0 +1,45 @@
+"use client"
+import { useSketches } from "@/lib/hooks/sketches";
+import { useSketchStore } from '@/store/sketch-store';
+import { useParams, useRouter } from "next/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select"
+import { Skeleton } from "@/components/ui/skeleton";
+import { WaypointsIcon } from "lucide-react";
+import { Badge } from "../ui/badge";
+
+export default function CaseSelector() {
+ const router = useRouter()
+ const { sketch_id, investigation_id } = useParams()
+ const useSketchData = useSketchStore(
+ (state) => state.useSketchData
+ );
+ const { sketches, isLoading } = useSketches(investigation_id as string)
+ const { sketch } = useSketchData(investigation_id as string, sketch_id as string);
+
+ const handleSelectionChange = (value: string) => {
+ value === "overview" ? router.push(`/dashboard/investigations/${investigation_id}`) :
+ router.push(`/dashboard/investigations/${investigation_id}/sketches/${value}`);
+ };
+ return (
+ <div className="flex items-center">
+ {isLoading || sketch.isLoading ? <Skeleton className="h-8 w-40 bg-foreground/10" /> :
+ <Select onValueChange={handleSelectionChange} defaultValue={sketch?.data?.id}>
+ <SelectTrigger className="min-w-none h-8 rounded-sm w-full hover:bg-sidebar-accent font-medium shadow-none border-none text-ellipsis truncate gap-1">
+ <SelectValue defaultValue={sketch?.data?.title || ""} placeholder="Select an investigation" />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem className="text-ellipsis truncate" value={"overview"}>{"Overview"}</SelectItem>
+ {sketches?.map((sketch) => (
+ <SelectItem className="text-ellipsis truncate items-center" key={sketch.id} value={sketch.id}>{sketch.title} <Badge variant={"outline"} className="ml-1 rounded-full shadow-none !flex items-center gap-1"><WaypointsIcon className="!h-3 !w-3" />Sketch</Badge></SelectItem>
+ ))}
+ </SelectContent>
+ </Select >}
+ </div >
+ );
+}
diff --git a/flowsint-web/src/components/sketches/investigation-navigation.tsx b/flowsint-web/src/components/sketches/investigation-navigation.tsx
new file mode 100644
index 00000000..a9645a43
--- /dev/null
+++ b/flowsint-web/src/components/sketches/investigation-navigation.tsx
@@ -0,0 +1,90 @@
+"use client"
+
+import { cn } from "@/lib/utils"
+import { Users, TimerIcon, MapIcon, WaypointsIcon, TablePropertiesIcon } from 'lucide-react'
+import Link from "next/link"
+import { usePathname } from "next/navigation"
+import { Fragment, memo, useMemo } from "react"
+import MoreMenu from "./more-menu"
+import { ScanButton } from "./scans-drawer/scan-button"
+import { Badge } from "../ui/badge"
+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 }) {
+ const pathname = usePathname()
+
+ // Memoize the sections array so it doesn't get recreated on every render
+ const sections = useMemo(() => [
+ {
+ id: "sketch",
+ name: "Sketch",
+ href: `/dashboard/investigations/${investigation_id}/sketches/${sketch_id}`,
+ icon: WaypointsIcon
+ },
+ {
+ id: "table",
+ name: "Table",
+ href: `/dashboard/investigations/${investigation_id}/sketches/${sketch_id}/table`,
+ icon: TablePropertiesIcon,
+ },
+ {
+ id: "map",
+ name: "Map",
+ href: `/dashboard/investigations/${investigation_id}/sketches/${sketch_id}/map`,
+ icon: MapIcon,
+ },
+ {
+ id: "timeline",
+ name: "Timeline",
+ href: `/dashboard/investigations/${investigation_id}/sketches/${sketch_id}/timeline`,
+ icon: TimerIcon,
+ "disabled": true,
+ }
+ ], [investigation_id, sketch_id]);
+
+ return (
+ <div className="flex items-center justify-between w-full">
+ <div className="flex overflow-auto">
+ {sections.map((section) => (
+ <Fragment key={section.id}>
+ {section.disabled ?
+ <span
+ className="text-muted-foreground border-b-2 border-transparent opacity-40 text-sm px-4 py-2.5 flex items-center gap-2">
+ <section.icon className="h-4 w-4" />
+ <span>{section.name}</span>
+ <Badge variant={"outline"}>Soon</Badge>
+ </span> :
+ <Link
+ href={section?.href || ""}
+ className={cn(
+ "flex items-center text-sm gap-2 border-b-2 border-transparent px-4 py-2 transition-colors",
+ section?.href == pathname
+ ? "bg-accent text-accent-foreground border-b-primary"
+ : "text-muted-foreground hover:text-foreground hover:bg-accent/50",
+ )}
+ >
+ <section.icon className="h-4 w-4" />
+ <span>{section.name}</span>
+ </Link>}
+ </Fragment>
+ ))}
+ </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}` })) || []} />
+ </div>
+ <DownloadButton endpoint={`/api/investigations/${investigation_id}/sketches/${sketch_id}/table`} name={investigation_id} />
+ <MoreMenu />
+ <ScanButton />
+ </div>
+ </div >
+ )
+}
+
+// Memoize the entire component
+export const MemoizedInvestigationNavigation = memo(InvestigationNavigation);
+
+// For backward compatibility, you can also export the original name
+export { MemoizedInvestigationNavigation as SketchNavigation };
\ No newline at end of file
diff --git a/flowsint-web/src/components/investigations/more-menu.tsx b/flowsint-web/src/components/sketches/more-menu.tsx
similarity index 91%
rename from flowsint-web/src/components/investigations/more-menu.tsx
rename to flowsint-web/src/components/sketches/more-menu.tsx
index 7d1c450a..91e9cafd 100644
--- a/flowsint-web/src/components/investigations/more-menu.tsx
+++ b/flowsint-web/src/components/sketches/more-menu.tsx
@@ -1,5 +1,5 @@
import { Ellipsis } from "lucide-react";
-import { useInvestigationStore } from '@/store/investigation-store';
+import { useSketchStore } from '@/store/sketch-store';
import {
DropdownMenu,
DropdownMenuTrigger,
@@ -8,7 +8,7 @@ import {
} from "@/components/ui/dropdown-menu";
import { Button } from "@/components/ui/button";
export default function MoreMenu() {
- const { setOpenSettingsModal, handleDeleteInvestigation } = useInvestigationStore();
+ const { setOpenSettingsModal, handleDeleteInvestigation } = useSketchStore();
return (
<DropdownMenu>
diff --git a/flowsint-web/src/components/investigations/new-actions.tsx b/flowsint-web/src/components/sketches/new-actions.tsx
similarity index 97%
rename from flowsint-web/src/components/investigations/new-actions.tsx
rename to flowsint-web/src/components/sketches/new-actions.tsx
index 19ca8716..8a9a0b40 100644
--- a/flowsint-web/src/components/investigations/new-actions.tsx
+++ b/flowsint-web/src/components/sketches/new-actions.tsx
@@ -12,15 +12,15 @@ import { Alert, AlertTitle, AlertDescription } from "../ui/alert"
import { Badge } from "../ui/badge"
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle } from "../ui/dialog"
import { actionItems, type ActionItem } from "@/lib/action-items"
-import { useInvestigationStore } from "@/store/investigation-store"
+import { useSketchStore } from "@/store/sketch-store"
import { Card, CardContent } from "@/components/ui/card"
import { AnimatePresence, motion } from "framer-motion"
export default function NewActions({ addNodes, children }: { addNodes: any, children: React.ReactNode }) {
- const { investigation_id } = useParams()
+ const { sketch_id } = useParams()
const [openAddNodeModal, setOpenNodeModal] = useState(false)
const [openActionDialog, setOpenActionDialog] = useState(false)
- const { setCurrentNode } = useInvestigationStore((state) => state)
+ const { setCurrentNode } = useSketchStore((state) => state)
const [currentNodeType, setCurrentNodeType] = useState<any | null>(null)
const [error, setError] = useState<string | null>(null)
const [loading, setLoading] = useState(false)
@@ -50,7 +50,7 @@ export default function NewActions({ addNodes, children }: { addNodes: any, chil
const handleAddNode = async (data: any) => {
try {
setLoading(true)
- const dataToInsert = { ...data, investigation_id }
+ const dataToInsert = { ...data, sketch_id }
const { data: nodeData, error: insertError } = await supabase
.from(currentNodeType.table)
.insert(dataToInsert)
diff --git a/flowsint-web/src/components/investigations/panel-context-menu.tsx b/flowsint-web/src/components/sketches/panel-context-menu.tsx
similarity index 97%
rename from flowsint-web/src/components/investigations/panel-context-menu.tsx
rename to flowsint-web/src/components/sketches/panel-context-menu.tsx
index eb094fd1..34ead18b 100644
--- a/flowsint-web/src/components/investigations/panel-context-menu.tsx
+++ b/flowsint-web/src/components/sketches/panel-context-menu.tsx
@@ -12,15 +12,15 @@ import { Alert, AlertTitle, AlertDescription } from "../ui/alert"
import { Badge } from "../ui/badge"
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle } from "../ui/dialog"
import { actionItems, type ActionItem } from "@/lib/action-items"
-import { useInvestigationStore } from "@/store/investigation-store"
+import { useSketchStore } from "@/store/sketch-store"
import { Card, CardContent } from "@/components/ui/card"
import { AnimatePresence, motion } from "framer-motion"
export default function PanelContextMenu({ addNodes }: { addNodes: any }) {
- const { investigation_id } = useParams()
+ const { sketch_id } = useParams()
const [openAddNodeModal, setOpenNodeModal] = useState(false)
const [_, setOpenActionDialog] = useState(false)
- const { setCurrentNode } = useInvestigationStore((state) => state)
+ const { setCurrentNode } = useSketchStore((state) => state)
const [currentNodeType, setCurrentNodeType] = useState<any | null>(null)
const [error, setError] = useState<string | null>(null)
const [loading, setLoading] = useState(false)
@@ -47,7 +47,7 @@ export default function PanelContextMenu({ addNodes }: { addNodes: any }) {
const handleAddNode = async (data: any) => {
try {
setLoading(true)
- const dataToInsert = { ...data, investigation_id }
+ const dataToInsert = { ...data, sketch_id }
const { data: nodeData, error: insertError } = await supabase
.from(currentNodeType.table)
.insert(dataToInsert)
diff --git a/flowsint-web/src/components/investigations/scan-drawer.tsx b/flowsint-web/src/components/sketches/scan-drawer.tsx
similarity index 98%
rename from flowsint-web/src/components/investigations/scan-drawer.tsx
rename to flowsint-web/src/components/sketches/scan-drawer.tsx
index 0c00bf70..cb5b5c95 100644
--- a/flowsint-web/src/components/investigations/scan-drawer.tsx
+++ b/flowsint-web/src/components/sketches/scan-drawer.tsx
@@ -54,16 +54,16 @@ export type Scan = {
}
export function ScanDrawer() {
- const { project_id, investigation_id } = useParams()
+ const { investigation_id, sketch_id } = useParams()
const [scanId, setScanId] = useQueryState("scan_id")
const [open, setOpen] = useState(Boolean(scanId))
const [searchQuery, setSearchQuery] = useState("")
const [viewMode, setViewMode] = useState<"grid" | "table">("table")
const { data: currentScan = null, isLoading } = useQuery({
- queryKey: ["projects", project_id, "investigations", investigation_id, "scans", scanId],
+ queryKey: ["projects", investigation_id, "investigations", sketch_id, "scans", scanId],
queryFn: async (): Promise<Scan | null> => {
- const res = await fetch(`/api/projects/${project_id}/investigations/${investigation_id}/scans/${scanId}`)
+ const res = await fetch(`/api/investigations/${investigation_id}/sketches/${sketch_id}/scans/${scanId}`)
if (!res.ok) {
return null
}
diff --git a/flowsint-web/src/components/investigations/scans-drawer/scan-button.tsx b/flowsint-web/src/components/sketches/scans-drawer/scan-button.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/scans-drawer/scan-button.tsx
rename to flowsint-web/src/components/sketches/scans-drawer/scan-button.tsx
diff --git a/flowsint-web/src/components/investigations/scans-drawer/scan-table.tsx b/flowsint-web/src/components/sketches/scans-drawer/scan-table.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/scans-drawer/scan-table.tsx
rename to flowsint-web/src/components/sketches/scans-drawer/scan-table.tsx
diff --git a/flowsint-web/src/components/investigations/sketch/floating-connection.tsx b/flowsint-web/src/components/sketches/sketch/floating-connection.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/sketch/floating-connection.tsx
rename to flowsint-web/src/components/sketches/sketch/floating-connection.tsx
diff --git a/flowsint-web/src/components/investigations/sketch/graph.tsx b/flowsint-web/src/components/sketches/sketch/graph.tsx
similarity index 97%
rename from flowsint-web/src/components/investigations/sketch/graph.tsx
rename to flowsint-web/src/components/sketches/sketch/graph.tsx
index 41de8d89..d33910fb 100644
--- a/flowsint-web/src/components/investigations/sketch/graph.tsx
+++ b/flowsint-web/src/components/sketches/sketch/graph.tsx
@@ -31,7 +31,7 @@ import { Tooltip, TooltipContent } from "@/components/ui/tooltip"
import { Button } from "@/components/ui/button"
import { TooltipTrigger } from "@radix-ui/react-tooltip"
import { cn } from "@/lib/utils"
-import { useInvestigationStore } from "@/store/investigation-store"
+import { useSketchStore } from "@/store/sketch-store"
import { useFlowStore } from "@/store/flow-store"
import Loader from "@/components/loader"
import { useQueryState } from "nuqs"
@@ -174,8 +174,8 @@ const FlowControls = memo(({
const LayoutFlow = memo(({ refetch, theme }: any) => {
const { fitView, zoomIn, zoomOut, addNodes, getNode, setCenter, getNodes } = useReactFlow();
- const { investigation_id } = useParams();
- const showMiniMap = useInvestigationStore(state => state.settings.showMiniMap);
+ const { sketch_id } = useParams();
+ const showMiniMap = useSketchStore(state => state.settings.showMiniMap);
const [_, setView] = useQueryState("view", { defaultValue: "flow-graph" });
// Use a ref for context menu state to avoid re-renders on position changes
@@ -245,8 +245,8 @@ const LayoutFlow = memo(({ refetch, theme }: any) => {
}, [currentNode?.id]); // Only depend on currentNode.id, not the whole object
const handleConnect = useCallback(
- (params: any) => onConnect(params, investigation_id),
- [onConnect, investigation_id]
+ (params: any) => onConnect(params, sketch_id),
+ [onConnect, sketch_id]
);
const handleNodeContextMenu = useCallback(
diff --git a/flowsint-web/src/components/investigations/sketch/large-data-graph.tsx b/flowsint-web/src/components/sketches/sketch/large-data-graph.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/sketch/large-data-graph.tsx
rename to flowsint-web/src/components/sketches/sketch/large-data-graph.tsx
diff --git a/flowsint-web/src/components/investigations/sketch/nodes-panel.tsx b/flowsint-web/src/components/sketches/sketch/nodes-panel.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/sketch/nodes-panel.tsx
rename to flowsint-web/src/components/sketches/sketch/nodes-panel.tsx
diff --git a/flowsint-web/src/components/investigations/sketch/nodes/custom-node.tsx b/flowsint-web/src/components/sketches/sketch/nodes/custom-node.tsx
similarity index 93%
rename from flowsint-web/src/components/investigations/sketch/nodes/custom-node.tsx
rename to flowsint-web/src/components/sketches/sketch/nodes/custom-node.tsx
index 8472cef5..c75aa78a 100644
--- a/flowsint-web/src/components/investigations/sketch/nodes/custom-node.tsx
+++ b/flowsint-web/src/components/sketches/sketch/nodes/custom-node.tsx
@@ -10,13 +10,13 @@ import {
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip-node";
-import { useInvestigationStore } from '@/store/investigation-store';
+import { useSketchStore } from '@/store/sketch-store';
import { useFlowStore } from '@/store/flow-store';
export default memo(({ data, selected }: any) => {
const item = useMemo(() => (actionItems as any).find((a: any) => a.type === data.type), [data?.type]);
const Icon = item?.icon || QuestionMarkIcon;
- const showNodeLabel = useInvestigationStore(state => state.settings.showNodeLabel);
+ const showNodeLabel = useSketchStore(state => state.settings.showNodeLabel);
const currentNodeId = useFlowStore(state => state.currentNode?.id,
(prev, next) => prev === next);
diff --git a/flowsint-web/src/components/investigations/sketch/nodes/node-context-menu.tsx b/flowsint-web/src/components/sketches/sketch/nodes/node-context-menu.tsx
similarity index 97%
rename from flowsint-web/src/components/investigations/sketch/nodes/node-context-menu.tsx
rename to flowsint-web/src/components/sketches/sketch/nodes/node-context-menu.tsx
index 65588d85..0018e756 100644
--- a/flowsint-web/src/components/investigations/sketch/nodes/node-context-menu.tsx
+++ b/flowsint-web/src/components/sketches/sketch/nodes/node-context-menu.tsx
@@ -38,7 +38,7 @@ interface NodeContextMenuProps {
const NodeContextMenu = memo(({ x, y, onClose }: NodeContextMenuProps) => {
const { currentNode, setCurrentNode } = useFlowStore()
const { addNodes, addEdges, setNodes, setEdges } = useReactFlow()
- const { investigation_id } = useParams()
+ const { sketch_id } = useParams()
const [openAddNodeModal, setOpenNodeModal] = useState(false)
const [error, setError] = useState<null | string>(null)
const [openNote, setOpenNote] = useState(false)
@@ -52,7 +52,7 @@ const NodeContextMenu = memo(({ x, y, onClose }: NodeContextMenuProps) => {
if (!currentNode && currentNode?.data && !currentNode?.data?.email) return toast.error("No email found.")
if (!await confirm({ title: "Email scan", message: "This scan will look for some socials that the email might be associated with. The list is not exhaustive and might return false positives." })) return
// @ts-ignore
- toast.promise(checkEmail(currentNode?.data?.email, investigation_id), {
+ toast.promise(checkEmail(currentNode?.data?.email, sketch_id), {
loading: "Loading...",
success: () => {
return `Scan on ${currentNode?.data?.email} has been launched.`
@@ -68,7 +68,7 @@ const NodeContextMenu = memo(({ x, y, onClose }: NodeContextMenuProps) => {
)
},
})
- }, [currentNode, investigation_id])
+ }, [currentNode, sketch_id])
const handleDuplicateNode = async () => {
if (!currentNode) return
@@ -147,7 +147,7 @@ const NodeContextMenu = memo(({ x, y, onClose }: NodeContextMenuProps) => {
setLoading(false)
return
}
- const dataToInsert = { ...data, investigation_id: investigation_id }
+ const dataToInsert = { ...data, sketch_id: sketch_id }
if (!["individual", "organization"].includes(nodeToInsert.type)) {
const tp = currentNode?.data?.type === "individual" ? "individual_id" : "organization_id"
dataToInsert[tp] = currentNode.id
@@ -167,7 +167,7 @@ const NodeContextMenu = memo(({ x, y, onClose }: NodeContextMenuProps) => {
const { error: relationshipError } = await supabase.from("relationships").upsert({
individual_a: currentNode.id,
individual_b: nodeData.id,
- investigation_id: investigation_id,
+ sketch_id: sketch_id,
relation_type: "relation",
})
if (relationshipError) {
@@ -179,7 +179,7 @@ const NodeContextMenu = memo(({ x, y, onClose }: NodeContextMenuProps) => {
const { error: relationshipError } = await supabase.from("organizations_individuals").upsert({
individual_id: nodeData.id,
organization_id: currentNode.id,
- investigation_id: investigation_id,
+ sketch_id: sketch_id,
relation_type: "employee",
})
if (relationshipError) {
@@ -191,7 +191,7 @@ const NodeContextMenu = memo(({ x, y, onClose }: NodeContextMenuProps) => {
const { error: relationshipError } = await supabase.from("organizations_individuals").upsert({
individual_id: currentNode.id,
organization_id: nodeData.id,
- investigation_id: investigation_id,
+ sketch_id: sketch_id,
relation_type: "employee",
})
if (relationshipError) {
@@ -203,7 +203,7 @@ const NodeContextMenu = memo(({ x, y, onClose }: NodeContextMenuProps) => {
const { error: relationshipError } = await supabase.from("organizations_organizations").upsert({
organization_a: currentNode.id,
organization_b: nodeData.id,
- investigation_id: investigation_id,
+ sketch_id: sketch_id,
})
if (relationshipError) {
toast.error("Error creating new relation.")
diff --git a/flowsint-web/src/components/investigations/sketch/nodes/node-notes-editor.tsx b/flowsint-web/src/components/sketches/sketch/nodes/node-notes-editor.tsx
similarity index 95%
rename from flowsint-web/src/components/investigations/sketch/nodes/node-notes-editor.tsx
rename to flowsint-web/src/components/sketches/sketch/nodes/node-notes-editor.tsx
index b926a879..7ff124c9 100644
--- a/flowsint-web/src/components/investigations/sketch/nodes/node-notes-editor.tsx
+++ b/flowsint-web/src/components/sketches/sketch/nodes/node-notes-editor.tsx
@@ -17,7 +17,7 @@ import {
} from "@/components/ui/dialog"
import { useQuery } from "@tanstack/react-query"
import { useParams } from "next/navigation"
-import { Individual } from "@/types/investigation"
+import { Individual } from "@/types/sketch"
import Loader from "../../../loader"
interface NoteEditorModalProps {
@@ -27,12 +27,12 @@ interface NoteEditorModalProps {
}
export function NodeNotesEditor({ openNote, setOpenNote, individualId }: NoteEditorModalProps) {
- const { investigation_id, project_id } = useParams()
+ const { sketch_id, investigation_id } = useParams()
const [isSaving, setIsSaving] = useState(false)
const { data: individual = null, isLoading, error } = useQuery({
- queryKey: ["investigations", investigation_id, "individuals", individualId],
+ queryKey: ["investigations", sketch_id, "individuals", individualId],
queryFn: async (): Promise<Individual | null> => {
- const res = await fetch(`/api/projects/${project_id}/investigations/${investigation_id}/individuals/${individualId}`)
+ const res = await fetch(`/api/investigations/${investigation_id}/sketches/${sketch_id}/individuals/${individualId}`)
if (!res.ok) {
return null
}
diff --git a/flowsint-web/src/components/investigations/sketch/profile-panel.tsx b/flowsint-web/src/components/sketches/sketch/profile-panel.tsx
similarity index 92%
rename from flowsint-web/src/components/investigations/sketch/profile-panel.tsx
rename to flowsint-web/src/components/sketches/sketch/profile-panel.tsx
index 5f8236cf..8bc3f601 100644
--- a/flowsint-web/src/components/investigations/sketch/profile-panel.tsx
+++ b/flowsint-web/src/components/sketches/sketch/profile-panel.tsx
@@ -18,7 +18,7 @@ import {
import { useConfirm } from "@/components/use-confirm-dialog"
import Link from "next/link"
export default function ProfilePanel({ data, type }: { data: any, type: string }) {
- const { investigation_id, project_id } = useParams()
+ const { sketch_id, investigation_id } = useParams()
const { confirm } = useConfirm()
const handleCheckEmail = useCallback(async () => {
@@ -26,7 +26,7 @@ export default function ProfilePanel({ data, type }: { data: any, type: string }
if (!data && data?.email) return toast.error("No email found.")
if (!await confirm({ title: "Email scan", message: "This scan will look for some socials that the email might be associated with. The list is not exhaustive and might return false positives." })) return
// @ts-ignore
- toast.promise(checkEmail(data?.email, investigation_id), {
+ toast.promise(checkEmail(data?.email, sketch_id), {
loading: "Loading...",
success: () => {
return `Scan on ${data?.email} has been launched.`
@@ -42,7 +42,7 @@ export default function ProfilePanel({ data, type }: { data: any, type: string }
)
},
})
- }, [data, investigation_id])
+ }, [data, sketch_id])
return (
<div className=" overflow-y-auto overflow-x-hidden h-full">
@@ -50,7 +50,7 @@ export default function ProfilePanel({ data, type }: { data: any, type: string }
<h1 className="text-md font-semibold truncate">{data?.label}</h1>
<div className="flex items-center gap-2">
{data?.type === "organization" ?
- <Link href={`/dashboard/projects/${project_id}/organigrams/${data.id}`}>
+ <Link href={`/dashboard/investigations/${investigation_id}/organigrams/${data.id}`}>
<Button
className="relative min-w-[80px] h-8 overflow-hidden truncate bg-gradient-to-r from-purple-600 to-indigo-400 hover:from-purple-700 hover:to-indigo-500 transition-all duration-300 px-6 py-2 text-white border-none font-medium rounded-full"
>
@@ -97,7 +97,7 @@ function KeyValueDisplay({ data, className }: KeyValueDisplayProps) {
return (
<div className={cn("w-full border-collapse", className)}>
{data && Object.entries(data)
- .filter(([key]) => !["id", "individual_id", "investigation_id", "group_id", "forceToolbarVisible"].includes(key))
+ .filter(([key]) => !["id", "individual_id", "sketch_id", "group_id", "forceToolbarVisible"].includes(key))
.map(([key, value], index) => {
const val = Array.isArray(value) ? `${value.length} items` : value?.toString() || null
const display = (typeof val === "string" && val.startsWith("https://")) ? <a href={val} className="underline text-primary" target="_blank">{val}</a> : val
diff --git a/flowsint-web/src/components/investigations/sketch/search-email.tsx b/flowsint-web/src/components/sketches/sketch/search-email.tsx
similarity index 80%
rename from flowsint-web/src/components/investigations/sketch/search-email.tsx
rename to flowsint-web/src/components/sketches/sketch/search-email.tsx
index 72444966..f2e5e093 100644
--- a/flowsint-web/src/components/investigations/sketch/search-email.tsx
+++ b/flowsint-web/src/components/sketches/sketch/search-email.tsx
@@ -2,15 +2,15 @@ import { Button } from '@/components/ui/button'
import React, { useCallback } from 'react'
import { toast } from 'sonner'
import { checkEmail } from '@/lib/actions/search'
-const SearchEmail = ({ investigation_id, email }: { investigation_id: string, email: string }) => {
+const SearchEmail = ({ sketch_id, email }: { sketch_id: string, email: string }) => {
const [disabled, setDisabled] = React.useState(false)
const handleCheckEmail = useCallback(() => {
// @ts-ignore
setDisabled(true)
- if (!investigation_id && !email) return
+ if (!sketch_id && !email) return
// @ts-ignore
- toast.promise(checkEmail(email, investigation_id), {
+ toast.promise(checkEmail(email, sketch_id), {
loading: "Loading...",
success: () => {
setDisabled(false)
@@ -28,7 +28,7 @@ const SearchEmail = ({ investigation_id, email }: { investigation_id: string, em
)
},
})
- }, [email, investigation_id])
+ }, [email, sketch_id])
return (
<Button disabled={disabled} onClick={handleCheckEmail}>Search socials</Button>
)
diff --git a/flowsint-web/src/components/investigations/sketch/simple-floating-edge.tsx b/flowsint-web/src/components/sketches/sketch/simple-floating-edge.tsx
similarity index 100%
rename from flowsint-web/src/components/investigations/sketch/simple-floating-edge.tsx
rename to flowsint-web/src/components/sketches/sketch/simple-floating-edge.tsx
diff --git a/flowsint-web/src/lib/actions/investigations.ts b/flowsint-web/src/lib/actions/investigations.ts
index dde18981..34422b6a 100644
--- a/flowsint-web/src/lib/actions/investigations.ts
+++ b/flowsint-web/src/lib/actions/investigations.ts
@@ -2,24 +2,24 @@
import { createClient } from "../supabase/server"
import { redirect } from "next/navigation"
import { revalidatePath } from "next/cache"
-
-export async function createNewCase(formData: FormData, project_id: string) {
+export const createNewInvestigation = async (formData: FormData) => {
const supabase = await createClient()
const { data: session, error: userError } = await supabase.auth.getUser()
if (userError || !session?.user) {
redirect('/login')
}
const data = {
- title: formData.get("title"),
+ name: formData.get("name"),
description: formData.get("description"),
}
try {
- const { data: investigation, error } = await supabase.from("investigations").insert({ ...data, owner_id: session?.user?.id, project_id }).select("id").single()
+ const { data: investigation, error } = await supabase.from("investigations").insert({ ...data, owner_id: session?.user?.id }).select("id").single()
if (error) throw error
- revalidatePath("/")
- return { success: true, id: investigation.id }
+ const { data: folder, error: bucketError } = await supabase.storage.from('documents').upload(`${investigation.id}/placeholder`, '')
+ if (bucketError) throw bucketError
+ return { success: true, id: investigation.id, path: folder.path }
} catch (error) {
- console.error("Error creating new case:", error)
- return { success: false, error: "Failed to create new case" }
+ console.error("Error creating new investigation:", error)
+ return { success: false, error: "Failed to create new investigation." }
}
-}
+}
\ No newline at end of file
diff --git a/flowsint-web/src/lib/actions/projects.ts b/flowsint-web/src/lib/actions/projects.ts
deleted file mode 100644
index 7d59fde5..00000000
--- a/flowsint-web/src/lib/actions/projects.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-"use server"
-import { createClient } from "../supabase/server"
-import { redirect } from "next/navigation"
-import { revalidatePath } from "next/cache"
-export const createNewProject = async (formData: FormData) => {
- const supabase = await createClient()
- const { data: session, error: userError } = await supabase.auth.getUser()
- if (userError || !session?.user) {
- redirect('/login')
- }
- const data = {
- name: formData.get("name"),
- description: formData.get("description"),
- }
- try {
- const { data: project, error } = await supabase.from("projects").insert({ ...data, owner_id: session?.user?.id }).select("id").single()
- if (error) throw error
- const { data: folder, error: bucketError } = await supabase.storage.from('documents').upload(`${project.id}/placeholder`, '')
- if (bucketError) throw bucketError
- return { success: true, id: project.id, path: folder.path }
- } catch (error) {
- console.error("Error creating new project:", error)
- return { success: false, error: "Failed to create new project." }
- }
-}
\ No newline at end of file
diff --git a/flowsint-web/src/lib/hooks/individuals/use-emails-breaches.ts b/flowsint-web/src/lib/hooks/individuals/use-emails-breaches.ts
deleted file mode 100644
index 245b26b8..00000000
--- a/flowsint-web/src/lib/hooks/individuals/use-emails-breaches.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { supabase } from "@/lib/supabase/client"
-import { useQuery } from "@supabase-cache-helpers/postgrest-swr"
-
-export function useEmailsAndBreaches(individualId: string | null | undefined) {
- const { data: emails, error } = useQuery(
- individualId ? supabase.from("individuals").select(`*, emails(*)`).eq("id", individualId).single() : null,
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- },
- )
-
- const emailAddresses = emails?.emails?.map(({ email }: { email: string }) => email) || []
-
- const { data: breaches, error: breachesError, mutate } = useQuery(
- emailAddresses.length > 0
- ? supabase.from("accounts_breaches").select(`account, breach:breach_id(raw_content)`).in("account", emailAddresses)
- : null,
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- },
- )
-
- const formattedData = emailAddresses.map((email: string) => ({
- email,
- breaches: breaches?.filter((breach: any) => breach.account === email).map((breach: any) => breach.breach.raw_content) || [],
- }))
-
- const isLoading = !emails && !error
-
- return {
- emails: formattedData,
- isLoading,
- refetch: mutate,
- error: error || breachesError,
- }
-}
-
diff --git a/flowsint-web/src/lib/hooks/individuals/use-individual.ts b/flowsint-web/src/lib/hooks/individuals/use-individual.ts
deleted file mode 100644
index 03d9dcb7..00000000
--- a/flowsint-web/src/lib/hooks/individuals/use-individual.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { supabase } from "@/lib/supabase/client";
-import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
-
-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(*)
- `)
- .eq("id", individualId)
- .single() : null,
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- return {
- individual: individual || null,
- isLoading,
- refetch: mutate,
- error: error
- };
-}
-
diff --git a/flowsint-web/src/lib/hooks/individuals/use-relations.ts b/flowsint-web/src/lib/hooks/individuals/use-relations.ts
deleted file mode 100644
index e05c5909..00000000
--- a/flowsint-web/src/lib/hooks/individuals/use-relations.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { supabase } from "@/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/flowsint-web/src/lib/hooks/investigation/investigation.ts b/flowsint-web/src/lib/hooks/investigation/investigation.ts
deleted file mode 100644
index 78df521b..00000000
--- a/flowsint-web/src/lib/hooks/investigation/investigation.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { supabase } from "@/lib/supabase/client";
-import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
-
-export function useInvestigations(project_id: string) {
- const { data: investigations, count, mutate, isLoading, error } = useQuery(
- supabase
- .from('investigations')
- .select('id, title, description')
- .eq("project_id", project_id)
- .order("last_updated_at", { ascending: false }),
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
-
- return { investigations, count, isLoading, refetch: mutate, error };
-}
-
-export function useInvestigation(investigationId: string | string[] | undefined) {
- if (!investigationId) return { investigation: null }
- const { data: investigation, mutate, isLoading, error } = useQuery(
- supabase
- .from('investigations')
- .select('id, title, description')
- .eq("id", investigationId)
- .single(),
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- return { investigation: investigation ?? null, isLoading, refetch: mutate, error };
-}
\ No newline at end of file
diff --git a/flowsint-web/src/lib/hooks/investigation/use-emails.tsx b/flowsint-web/src/lib/hooks/investigation/use-emails.tsx
deleted file mode 100644
index 872b70b7..00000000
--- a/flowsint-web/src/lib/hooks/investigation/use-emails.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import { supabase } from "@/lib/supabase/client";
-import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
-
-export function useEmails(investigationId: string | null | undefined) {
- const { data: emails, mutate, isLoading, error } = useQuery(Boolean(investigationId) ?
- supabase
- .from('emails')
- .select(`
- *
- `)
- .eq("investigation_id", investigationId)
- : null,
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- return {
- emails: emails || null,
- isLoading,
- refetch: mutate,
- error: error
- };
-}
-
diff --git a/flowsint-web/src/lib/hooks/investigation/use-individuals.tsx b/flowsint-web/src/lib/hooks/investigation/use-individuals.tsx
deleted file mode 100644
index e74a1cbe..00000000
--- a/flowsint-web/src/lib/hooks/investigation/use-individuals.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import { supabase } from "@/lib/supabase/client";
-import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
-
-export function useIndividuals(investigationId: string | null | undefined) {
- const { data: individuals, mutate, isLoading, error } = useQuery(Boolean(investigationId) ?
- supabase
- .from('individuals')
- .select(`
- *
- `)
- .eq("investigation_id", investigationId)
- : null,
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- return {
- individuals: individuals || null,
- isLoading,
- refetch: mutate,
- error: error
- };
-}
-
diff --git a/flowsint-web/src/lib/hooks/investigation/use-phones.tsx b/flowsint-web/src/lib/hooks/investigation/use-phones.tsx
deleted file mode 100644
index 36cc49d4..00000000
--- a/flowsint-web/src/lib/hooks/investigation/use-phones.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import { supabase } from "@/lib/supabase/client";
-import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
-
-export function usePhones(investigationId: string | null | undefined) {
- const { data: phones, mutate, isLoading, error } = useQuery(Boolean(investigationId) ?
- supabase
- .from('phone_numbers')
- .select(`
- *
- `)
- .eq("investigation_id", investigationId)
- : null,
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- return {
- phones: phones || null,
- isLoading,
- refetch: mutate,
- error: error
- };
-}
-
diff --git a/flowsint-web/src/lib/hooks/investigation/use-search-results.tsx b/flowsint-web/src/lib/hooks/investigation/use-search-results.tsx
deleted file mode 100644
index 56bc29b9..00000000
--- a/flowsint-web/src/lib/hooks/investigation/use-search-results.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { supabase } from "@/lib/supabase/client";
-import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
-
-export function useSearchResults(search: string | undefined, investigationId: string | string[] | undefined) {
- const { data: results, count, mutate, isLoading, error } = useQuery(search ?
- supabase
- .from('individuals')
- .select('*')
- .eq("investigation_id", investigationId)
- .ilike('full_name', `%${search}%`) : null,
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- if (error) throw error
-
- return { results, count, isLoading, refetch: mutate, error };
-}
\ No newline at end of file
diff --git a/flowsint-web/src/lib/hooks/investigation/use-socials.ts b/flowsint-web/src/lib/hooks/investigation/use-socials.ts
deleted file mode 100644
index f3afe6a0..00000000
--- a/flowsint-web/src/lib/hooks/investigation/use-socials.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { supabase } from "@/lib/supabase/client";
-import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
-
-export function useSocials(investigationId: string | null | undefined) {
- const { data: socials, mutate, isLoading, error } = useQuery(Boolean(investigationId) ?
- supabase
- .from('social_accounts')
- .select(`
- *
- `)
- .eq("investigation_id", investigationId)
- : null,
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- return {
- socials: socials || null,
- isLoading,
- refetch: mutate,
- error: error
- };
-}
-
diff --git a/flowsint-web/src/lib/hooks/investigation/usernames.tsx b/flowsint-web/src/lib/hooks/investigation/usernames.tsx
deleted file mode 100644
index 6d383c9e..00000000
--- a/flowsint-web/src/lib/hooks/investigation/usernames.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { supabase } from "@/lib/supabase/client";
-import { useQuery } from "@supabase-cache-helpers/postgrest-swr";
-
-export function useUsernames(investigationId: string | string[] | undefined) {
- if (!investigationId) return { usernames: [] }
- const { data: usernames, count, mutate, isLoading, error } = useQuery(
- supabase
- .from('social_accounts')
- .select('id, username')
- .eq("investigation_id", investigationId)
- .not('username', 'is', null)
- .neq('username', ''),
- {
- revalidateOnFocus: false,
- revalidateOnReconnect: false,
- }
- );
- if (error) throw error
-
- return { usernames, count, isLoading, refetch: mutate, error };
-}
\ No newline at end of file
diff --git a/flowsint-web/src/store/flow-store.ts b/flowsint-web/src/store/flow-store.ts
index 0c870952..b5761d9e 100644
--- a/flowsint-web/src/store/flow-store.ts
+++ b/flowsint-web/src/store/flow-store.ts
@@ -37,7 +37,7 @@ export type AppState = {
setEdges: (edges: Edge[]) => void;
highlightPath: (selectedNode: Node | null) => void;
onLayout: (layout: string, fitView: () => void) => void,
- onConnect: (params: any, investigation_id?: string) => Promise<void>;
+ onConnect: (params: any, sketch_id?: string) => Promise<void>;
onNodeClick: (_: React.MouseEvent, node: Node) => void;
onPaneClick: (_: React.MouseEvent) => void,
setCurrentNode: (node: object | null) => void;
@@ -65,8 +65,8 @@ const createStore = (initialNodes: AppNode[] = [], initialEdges: Edge[] = []) =>
setCurrentNode: (node: Partial<Node> | null) => {
set({ currentNode: node });
},
- onConnect: async (params: any, investigation_id?: string) => {
- if (!investigation_id) return;
+ onConnect: async (params: any, sketch_id?: string) => {
+ if (!sketch_id) return;
try {
// Batch database operations with the UI update
const { error } = await supabase
@@ -74,7 +74,7 @@ const createStore = (initialNodes: AppNode[] = [], initialEdges: Edge[] = []) =>
.upsert({
individual_a: params.source,
individual_b: params.target,
- investigation_id: investigation_id,
+ sketch_id: sketch_id,
relation_type: "relation"
});
diff --git a/flowsint-web/src/store/investigation-store.ts b/flowsint-web/src/store/investigation-store.ts
deleted file mode 100644
index aad5756f..00000000
--- a/flowsint-web/src/store/investigation-store.ts
+++ /dev/null
@@ -1,219 +0,0 @@
-"use client"
-
-import { create } from "zustand"
-import { persist, createJSONStorage } from "zustand/middleware"
-import { useQuery, type QueryObserverResult } from "@tanstack/react-query"
-import type { Investigation, Individual, Email, Phone, Social, IP, Relation, Address } from "@/types/investigation"
-
-// Define a generic type for query results
-interface QueryResult<T> {
- data: T
- isLoading: boolean
- refetch: () => Promise<void>
-}
-
-// Define the return type for useInvestigationData
-interface InvestigationData {
- investigation: QueryResult<Investigation>
- individuals: QueryResult<Individual[]>
- emails: QueryResult<Email[]>
- phones: QueryResult<Phone[]>
- socials: QueryResult<Social[]>
- ips: QueryResult<IP[]>
- addresses: QueryResult<Address[]>
- relations: QueryResult<Relation[]>
-}
-
-interface InvestigationState {
- // UI State
- filters: any
- settings: {
- showNodeLabel: boolean
- showEdgeLabel: boolean
- showMiniMap: boolean
- showCopyIcon: boolean
- showNodeToolbar: boolean
- }
- openSettingsModal: boolean
- currentNode: any
- panelOpen: boolean
- openNewNode: boolean,
- investigation: Investigation | null
- isRefetching: boolean
-
- // UI Actions
- setFilters: (filters: any) => void
- setSettings: (settings: any) => void
- setOpenSettingsModal: (open: boolean) => void
- setOpenNewNode: (open: boolean) => void
- setCurrentNode: (node: any) => void
- setPanelOpen: (open: boolean) => void
- setInvestigation: (investigation: Investigation | null) => void
-
- // Modal Handlers
- handleOpenIndividualModal: (id: string) => void
- setHandleOpenIndividualModal: (handler: (id: string) => void) => void
- handleDeleteInvestigation: () => Promise<void>
- setHandleDeleteInvestigation: (handler: () => Promise<void>) => void
-
- // Query Hooks
- useInvestigationData: (projectId: string, investigationId: string) => InvestigationData & {
- refetchAll: () => Promise<void>
- }
-}
-
-const isServer = typeof window === "undefined"
-
-export const useInvestigationStore = create(
- persist<InvestigationState>(
- (set, get) => ({
- // UI State
- filters: {},
- settings: {
- showNodeLabel: true,
- showEdgeLabel: true,
- showMiniMap: true,
- showCopyIcon: true,
- showNodeToolbar: true,
- },
- openSettingsModal: false,
- currentNode: null,
- openNewNode: false,
- panelOpen: false,
- investigation: null,
- isRefetching: false,
- // UI Actions
- setFilters: (filters) => set({ filters }),
- setSettings: (settings) => set({ settings }),
- setOpenSettingsModal: (open) => set({ openSettingsModal: open }),
- setOpenNewNode: (open) => set({ openNewNode: open }),
- setCurrentNode: (node) => set({ currentNode: node }),
- setPanelOpen: (open) => set({ panelOpen: open }),
- setInvestigation: (investigation) => set({ investigation }),
- handleOpenIndividualModal: () => { },
- setHandleOpenIndividualModal: (handler) => set({ handleOpenIndividualModal: handler }),
- handleDeleteInvestigation: async () => { },
- setHandleDeleteInvestigation: (handler) => set({ handleDeleteInvestigation: handler }),
- useInvestigationData: (projectId: string, investigationId: string) => {
- const wrapRefetch = async (refetch: () => Promise<QueryObserverResult>) => {
- await refetch()
- }
-
- const investigationQuery = useQuery<Investigation>({
- queryKey: ["projects", projectId, "investigation", investigationId, 'investigation'],
- queryFn: async () => {
- const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}`)
- if (!res.ok) throw new Error("Failed to fetch investigation")
- const data = await res.json()
- return data.investigation as Investigation
- },
- })
-
- const individualsQuery = useQuery<Individual[]>({
- queryKey: ["projects", projectId, "investigation", investigationId, "individuals"],
- queryFn: async () => {
- const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/individuals`)
- if (!res.ok) throw new Error("Failed to fetch individuals")
- const data = await res.json()
- return data.individuals
- },
- })
-
- const emailsQuery = useQuery<Email[]>({
- queryKey: ["projects", projectId, "investigation", investigationId, "emails"],
- queryFn: async () => {
- const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/emails`)
- if (!res.ok) throw new Error("Failed to fetch emails")
- const data = await res.json()
- return data.emails
- },
- })
-
- const phonesQuery = useQuery<Phone[]>({
- queryKey: ["projects", projectId, "investigation", investigationId, "phones"],
- queryFn: async () => {
- const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/phones`)
- if (!res.ok) throw new Error("Failed to fetch phones")
- const data = await res.json()
- return data.phones
- },
- })
-
- const socialsQuery = useQuery<Social[]>({
- queryKey: ["investigation", investigationId, "socials"],
- queryFn: async () => {
- const res = await fetch(`/api/projects/${projectId}/investigations/${investigationId}/socials`)
- if (!res.ok) throw new Error("Failed to fetch socials")
- const data = await res.json()
- return data.socials
- },
- })
-
- const refetchAll = async () => {
- set({ isRefetching: true })
- try {
- await Promise.all([
- individualsQuery.refetch(),
- emailsQuery.refetch(),
- phonesQuery.refetch(),
- socialsQuery.refetch(),
- ])
- } finally {
- set({ isRefetching: false })
- }
- }
-
- return {
- investigation: {
- data: investigationQuery.data as Investigation,
- isLoading: investigationQuery.isLoading,
- refetch: () => wrapRefetch(investigationQuery.refetch),
- },
- individuals: {
- data: individualsQuery.data ?? [],
- isLoading: individualsQuery.isLoading,
- refetch: () => wrapRefetch(individualsQuery.refetch),
- },
- emails: {
- data: emailsQuery.data ?? [],
- isLoading: emailsQuery.isLoading,
- refetch: () => wrapRefetch(emailsQuery.refetch),
- },
- phones: {
- data: phonesQuery.data ?? [],
- isLoading: phonesQuery.isLoading,
- refetch: () => wrapRefetch(phonesQuery.refetch),
- },
- socials: {
- data: socialsQuery.data ?? [],
- isLoading: socialsQuery.isLoading,
- refetch: () => wrapRefetch(socialsQuery.refetch),
- },
- ips: {
- data: [],
- isLoading: false,
- refetch: async () => { },
- },
- addresses: {
- data: [],
- isLoading: false,
- refetch: async () => { },
- },
- relations: {
- data: [],
- isLoading: false,
- refetch: async () => { },
- },
- refetchAll,
- }
- },
- }),
- {
- name: "investigation-storage",
- storage: createJSONStorage(() => (isServer ? localStorage : localStorage)),
- partialize: (state) => ({
- ...state,
- }),
- },
- )
-)
\ No newline at end of file
diff --git a/flowsint-web/src/store/project-store.ts b/flowsint-web/src/store/project-store.ts
index 40e2b4ce..9b53435d 100644
--- a/flowsint-web/src/store/project-store.ts
+++ b/flowsint-web/src/store/project-store.ts
@@ -5,7 +5,7 @@ interface ProjectState {
setOpenUploadModal: (isOpen: boolean) => void;
}
-export const useProjectStore = create<ProjectState>((set) => ({
+export const useInvestigationStore = create<ProjectState>((set) => ({
openUploadModal: false,
setOpenUploadModal: (isOpen) => set({ openUploadModal: isOpen }),
}));
diff --git a/flowsint-web/src/store/sketch-store.ts b/flowsint-web/src/store/sketch-store.ts
new file mode 100644
index 00000000..5d50e77d
--- /dev/null
+++ b/flowsint-web/src/store/sketch-store.ts
@@ -0,0 +1,116 @@
+"use client"
+
+import { create } from "zustand"
+import { persist, createJSONStorage } from "zustand/middleware"
+import { useQuery, type QueryObserverResult } from "@tanstack/react-query"
+import type { Sketch } from "@/types/sketch"
+
+interface QueryResult<T> {
+ data: T
+ isLoading: boolean
+ refetch: () => Promise<void>
+}
+interface SketchResults {
+ sketch: QueryResult<Sketch>
+}
+interface SketchState {
+ filters: any
+ settings: {
+ showNodeLabel: boolean
+ showEdgeLabel: boolean
+ showMiniMap: boolean
+ showCopyIcon: boolean
+ showNodeToolbar: boolean
+ }
+ openSettingsModal: boolean
+ currentNode: any
+ panelOpen: boolean
+ openNewNode: boolean,
+ sketch: Sketch | null
+ isRefetching: boolean
+
+ setFilters: (filters: any) => void
+ setSettings: (settings: any) => void
+ setOpenSettingsModal: (open: boolean) => void
+ setOpenNewNode: (open: boolean) => void
+ setCurrentNode: (node: any) => void
+ setPanelOpen: (open: boolean) => void
+ setSketch: (sketch: Sketch | null) => void
+
+ // Modal Handlers
+ handleOpenIndividualModal: (id: string) => void
+ setHandleOpenIndividualModal: (handler: (id: string) => void) => void
+ HandleDeleteSketch: () => Promise<void>
+ setHandleDeleteSketch: (handler: () => Promise<void>) => void
+
+ // Query Hooks
+ useSketchData: (investigationId: string, sketchId: string) => SketchResults & {
+ refetchAll: () => Promise<void>
+ }
+}
+
+const isServer = typeof window === "undefined"
+
+export const useSketchStore = create(
+ persist<SketchState>(
+ (set, get) => ({
+ // UI State
+ filters: {},
+ settings: {
+ showNodeLabel: true,
+ showEdgeLabel: true,
+ showMiniMap: true,
+ showCopyIcon: true,
+ showNodeToolbar: true,
+ },
+ openSettingsModal: false,
+ currentNode: null,
+ openNewNode: false,
+ panelOpen: false,
+ sketch: null,
+ isRefetching: false,
+ // UI Actions
+ setFilters: (filters) => set({ filters }),
+ setSettings: (settings) => set({ settings }),
+ setOpenSettingsModal: (open) => set({ openSettingsModal: open }),
+ setOpenNewNode: (open) => set({ openNewNode: open }),
+ setCurrentNode: (node) => set({ currentNode: node }),
+ setPanelOpen: (open) => set({ panelOpen: open }),
+ setSketch: (sketch) => set({ sketch }),
+ handleOpenIndividualModal: () => { },
+ setHandleOpenIndividualModal: (handler) => set({ handleOpenIndividualModal: handler }),
+ HandleDeleteSketch: async () => { },
+ setHandleDeleteSketch: (handler) => set({ HandleDeleteSketch: handler }),
+ useSketchData: (investigationId: string, sketchId: string) => {
+ const wrapRefetch = async (refetch: () => Promise<QueryObserverResult>) => {
+ await refetch()
+ }
+ const sketchQuery = useQuery<Sketch>({
+ queryKey: ["investigations", investigationId, "sketches", sketchId],
+ queryFn: async () => {
+ const res = await fetch(`/api/investigations/${investigationId}/sketches/${sketchId}`)
+ if (!res.ok) throw new Error("Failed to fetch sketch.")
+ const data = await res.json()
+ return data.sketch as Sketch
+ },
+ })
+ return {
+ sketch: {
+ data: sketchQuery.data as Sketch,
+ isLoading: sketchQuery.isLoading,
+ refetch: () => wrapRefetch(sketchQuery.refetch),
+ },
+ refetchAll: () => wrapRefetch(sketchQuery.refetch),
+
+ }
+ },
+ }),
+ {
+ name: "sketch-storage",
+ storage: typeof window !== 'undefined' ? createJSONStorage(() => localStorage) : undefined,
+ partialize: (state) => ({
+ ...state,
+ }),
+ },
+ )
+)
\ No newline at end of file
diff --git a/flowsint-web/src/types/investigation.ts b/flowsint-web/src/types/investigation.ts
index 1f404873..b19741ab 100644
--- a/flowsint-web/src/types/investigation.ts
+++ b/flowsint-web/src/types/investigation.ts
@@ -1,55 +1,12 @@
-import { Project } from "./project"
+import { Sketch } from "./sketch"
export interface Investigation {
id: string
- title: string
+ name: string
description: string
- status?: string
- priority?: string
+ sketches: Sketch[]
created_at: string
last_updated_at: string
owner: any
- relations?: any[]
- individuals?: any[]
- project?: Project
- project_id: string
members?: any[]
-}
-export interface Individual {
- id: string
- full_name: string
-}
-
-export interface Email {
- id: string
- email: string
-}
-
-export interface Phone {
- id: string,
- phone_number: string
-}
-
-export interface Social {
- id: string
- profile_url: string
- username: string
- platform: string
-}
-
-export interface IP {
- id: string
- ip_address: string
-}
-
-export interface Address {
- id: string
- address: string
- city: string
- country: string
- zip: string
-}
-
-export interface Relation {
- id: string
}
\ No newline at end of file
diff --git a/flowsint-web/src/types/project.ts b/flowsint-web/src/types/project.ts
deleted file mode 100644
index a58c3eac..00000000
--- a/flowsint-web/src/types/project.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { Investigation } from "./investigation"
-
-export interface Project {
- id: string
- name: string
- description: string
- investigations: Investigation[]
- created_at: string
- last_updated_at: string
- owner: any
- members?: any[]
-}
\ No newline at end of file
diff --git a/flowsint-web/src/types/sketch.ts b/flowsint-web/src/types/sketch.ts
new file mode 100644
index 00000000..f649434a
--- /dev/null
+++ b/flowsint-web/src/types/sketch.ts
@@ -0,0 +1,55 @@
+import { Investigation } from "./investigation"
+
+export interface Sketch {
+ id: string
+ title: string
+ description: string
+ status?: string
+ priority?: string
+ created_at: string
+ last_updated_at: string
+ owner: any
+ relations?: any[]
+ individuals?: any[]
+ investigation?: Investigation
+ investigation_id: string
+ members?: any[]
+}
+export interface Individual {
+ id: string
+ full_name: string
+}
+
+export interface Email {
+ id: string
+ email: string
+}
+
+export interface Phone {
+ id: string,
+ phone_number: string
+}
+
+export interface Social {
+ id: string
+ profile_url: string
+ username: string
+ platform: string
+}
+
+export interface IP {
+ id: string
+ ip_address: string
+}
+
+export interface Address {
+ id: string
+ address: string
+ city: string
+ country: string
+ zip: string
+}
+
+export interface Relation {
+ id: string
+}
\ No newline at end of file
diff --git a/flowsint-web/tsconfig.json b/flowsint-web/tsconfig.json
index c2556ed9..8db84a97 100644
--- a/flowsint-web/tsconfig.json
+++ b/flowsint-web/tsconfig.json
@@ -23,6 +23,6 @@
"@/*": ["./src/*"]
}
},
- "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", "src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/page.tss"],
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "../../ReconOps/src/lib/utils.ts", "src/components/sketches/collide.js", "src/lib/utils/flow.js", "src/app/dashboard/investigations/[investigation_id]/sketch/[sketch_id]/table/page.tss"],
"exclude": ["node_modules"]
}