A modern platform for visual, flexible, and extensible graph-based investigations. For cybersecurity analysts and investigators.
feat: avatar list
dextmorgn54a2ad511384
diff --git a/flowsint-web/src/app/dashboard/layout.tsx b/flowsint-web/src/app/dashboard/layout.tsxindex 6b28d08e..1a8e674e 100644--- a/flowsint-web/src/app/dashboard/layout.tsx+++ b/flowsint-web/src/app/dashboard/layout.tsx@@ -34,7 +34,7 @@ const DashboardLayout = async ({<div className="flex h-12 items-center px-4"><Link href="/dashboard" className="flex items-center gap-1"><FingerprintIcon className="mr-2 h-6 w-6 text-primary" />- <h2 className="text-lg font-semibold mr-6">flowsint</h2>+ <span className='opacity-60 text-sm'>/</span></Link>{/* <Separator orientation="vertical" className="h-6" /> */}<MainNav className="mx-6" />diff --git a/flowsint-web/src/app/dashboard/page.tsx b/flowsint-web/src/app/dashboard/page.tsxindex 6ce15ff8..c0d06240 100644--- a/flowsint-web/src/app/dashboard/page.tsx+++ b/flowsint-web/src/app/dashboard/page.tsx@@ -16,7 +16,6 @@ import RecentSketches from "@/components/dashboard/recent-sketches"import NewProject from "@/components/dashboard/new-project"import { AvatarList } from "@/components/avatar-list"import { cn } from "@/lib/utils"-import DashboardLayout from "@/components/dashboard/layout"import { SubNav } from "@/components/dashboard/sub-nav"import { Card } from "@/components/ui/card"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.tsxindex 75be8f06..59c1657f 100644--- 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@@ -1,8 +1,9 @@import { InvestigationProvider } from '@/components/contexts/investigation-provider';import { createClient } from "@/lib/supabase/server";-import { redirect } from "next/navigation";+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,@@ -16,10 +17,14 @@ const DashboardLayout = async ({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} />+ <InvestigationtNavigation project_id={project_id} investigation_id={investigation_id} investigation={investigation as Investigation} /></div>{children}<ScanDrawer />diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsxindex 79603200..1db43a1f 100644--- a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsx+++ b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/page.tsx@@ -16,10 +16,6 @@ const InvestigationPage = async ({if (!user || userError) {return redirect("/login")}- const { data: investigation, error } = await supabase.from("investigations").select("id").eq("id", investigation_id).single()- if (!investigation || error) {- return notFound()- }return <DashboardClient projectId={project_id} investigationId={investigation_id} />}diff --git a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsxindex 488448f3..9ba95c79 100644--- a/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx+++ b/flowsint-web/src/app/dashboard/projects/[project_id]/investigations/[investigation_id]/table/data-table.tsx@@ -610,7 +610,6 @@ function TableCellViewer({ item, children }: { item: any, children: React.ReactN<Sheet><SheetTrigger asChild>{item.type === "social" ?-<SocialButton item={item} /> :<Button variant="link" className="w-fit px-0 text-left text-foreground"><Badge variant="secondary" className="h-7 w-7 p-0 rounded-full">diff --git a/flowsint-web/src/app/dashboard/sources/page.tsx b/flowsint-web/src/app/dashboard/sources/page.tsxnew file mode 100644index 00000000..c8331c36--- /dev/null+++ b/flowsint-web/src/app/dashboard/sources/page.tsx@@ -0,0 +1,11 @@+import React from 'react'++const SourcesPage = () => {+ return (+ <div className="w-full space-y-8 container mx-auto py-12 px-8">+ Comming soon.+ </div>+ )+}++export default SourcesPage\ No newline at end of filediff --git a/flowsint-web/src/app/login/page.tsx b/flowsint-web/src/app/login/page.tsxindex 67dcbde4..2634fe8f 100644--- a/flowsint-web/src/app/login/page.tsx+++ b/flowsint-web/src/app/login/page.tsx@@ -1,8 +1,9 @@-import { LoginForm } from "@/components/login-form"+import { Message } from "@/components/form-message"+import LoginForm from "@/components/login-form"import { createClient } from "@/lib/supabase/server"import { redirect } from "next/navigation"-export default async function Page() {+export default async function Page(props: { searchParams: Promise<Message> }) {const supabase = await createClient()const { data, error } = await supabase.auth.getUser()if (!error || data.user) {@@ -11,7 +12,7 @@ export default async function Page() {return (<div className="flex h-screen w-full items-center justify-center px-4">- <LoginForm />+ <LoginForm searchParams={props.searchParams} /></div>)}\ No newline at end of filediff --git a/flowsint-web/src/components/avatar-list.tsx b/flowsint-web/src/components/avatar-list.tsxindex 6f5e4b8a..3da04893 100644--- a/flowsint-web/src/components/avatar-list.tsx+++ b/flowsint-web/src/components/avatar-list.tsx@@ -3,7 +3,7 @@import type * as React from "react"import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"-import { cn } from "@/lib/utils"+import { cn, getAvatarColor } from "@/lib/utils"export interface User {id: string@@ -36,17 +36,17 @@ export function AvatarList({const sizeClasses = {sm: {avatar: "h-6 w-6",- container: "space-x-[-8px]",+ container: "space-x-[-7px]",more: "h-6 w-6 text-xs",},md: {avatar: "h-8 w-8",- container: "space-x-[-12px]",+ container: "space-x-[-11px]",more: "h-8 w-8 text-sm",},lg: {avatar: "h-10 w-10",- container: "space-x-[-16px]",+ container: "space-x-[-15px]",more: "h-10 w-10 text-base",},}@@ -60,19 +60,20 @@ export function AvatarList({.substring(0, 2)}- const renderAvatar = (user: User, index: number) => {+ const renderAvatar = (user: User) => {+ const avatarColor = getAvatarColor(user.name)const avatar = (<Avatarkey={user.id}className={cn(sizeClasses[size].avatar,"border-2 border-background bg-background",- "transition-transform hover:translate-y-[-4px]",+ "transition-transform","ring-0 ring-offset-0",)}><AvatarImage src={user.image} alt={`${user.name}'s avatar`} />- <AvatarFallback className="text-xs">{getInitials(user.name)}</AvatarFallback>+ <AvatarFallback className={cn("text-xs text-white", avatarColor)}>{getInitials(user.name)}</AvatarFallback></Avatar>)@@ -81,7 +82,7 @@ export function AvatarList({<TooltipProvider key={user.id} delayDuration={300}><Tooltip><TooltipTrigger asChild>{avatar}</TooltipTrigger>- <TooltipContent side="bottom" align="center">+ <TooltipContent side="bottom" align="center" className="shadow">{user.name}</TooltipContent></Tooltip>diff --git a/flowsint-web/src/components/dashboard/layout.tsx b/flowsint-web/src/components/dashboard/layout.tsxdeleted file mode 100644index 760b7013..00000000--- a/flowsint-web/src/components/dashboard/layout.tsx+++ /dev/null@@ -1,55 +0,0 @@-import React, { Fragment } from 'react'-import {- Breadcrumb,- BreadcrumbItem,- BreadcrumbLink,- BreadcrumbList,- BreadcrumbPage,- BreadcrumbSeparator,-} from "@/components/ui/breadcrumb"-import { Button } from '../ui/button'-import { BellIcon, CircleHelpIcon } from 'lucide-react'-import Link from 'next/link'-import Feedback from './feedback'--interface BreadCrumbItem {- name: string- href?: string | null- icon?: React.ReactNode-}-const DashboardLayout = ({ children, items = [] }: { children: React.ReactNode, items: BreadCrumbItem[] }) => {- return (- <>- <div className='w-full px-4 bg-sidebar sticky top-0 rounded-none shadow-none z-50 h-12 justify-between border-b flex flex-row items-center'>- <Breadcrumb>- <BreadcrumbList>- {items.map((item: BreadCrumbItem, index: number) => (- <Fragment key={index}>- <BreadcrumbItem>- {item.icon && <span className='mr-1'>{item.icon}</span>}- {item.href ?- <BreadcrumbLink asChild ><Link href={item.href}>{item.name}</Link></BreadcrumbLink>- : <BreadcrumbPage>{item.name}</BreadcrumbPage>- }- </BreadcrumbItem>- {index < items.length - 1 && (- <Fragment>- <BreadcrumbSeparator />- </Fragment>- )}- </Fragment>- ))}- </BreadcrumbList>- </Breadcrumb>- <div className='flex gap-1 items-center'>- <Feedback />- <Button variant={"ghost"} size={"icon"}><BellIcon className='h-4 w-4 opacity-60' /></Button>- <Button variant={"ghost"} size={"icon"}><CircleHelpIcon className='h-4 w-4 opacity-60' /></Button>- </div>- </div>- {children}- </>- )-}--export default DashboardLayout\ No newline at end of filediff --git a/flowsint-web/src/components/dashboard/main-nav.tsx b/flowsint-web/src/components/dashboard/main-nav.tsxindex a7858372..f37e8fe9 100644--- a/flowsint-web/src/components/dashboard/main-nav.tsx+++ b/flowsint-web/src/components/dashboard/main-nav.tsx@@ -5,39 +5,38 @@ import { cn } from "@/lib/utils"import ProjectSelector from "../investigations/project-selector"import CaseSelector from "../investigations/case-selector"import { useParams } from "next/navigation"-import { Separator } from "../ui/separator"export function MainNav({ className, ...props }: React.HTMLAttributes<HTMLElement>) {const { investigation_id, project_id } = useParams()if (project_id) return (<div className='flex gap-1 items-center p-2'>- <ProjectSelector />{investigation_id && <><span className='opacity-60'>/</span><CaseSelector /></>}+ <ProjectSelector />{investigation_id && <><span className='opacity-60 text-sm'>/</span><CaseSelector /></>}</div >)return (<nav className={cn("md:flex hidden w-full items-center space-x-4 lg:space-x-6", className)} {...props}><Link- href="/"+ href="/dashboard"className="text-sm font-medium transition-colors hover:text-primary bg-muted/50 px-3 py-1.5 rounded-md">Dashboard</Link><Link- href="/sources"+ href="/dashboard/sources"className="text-sm font-medium text-muted-foreground transition-colors hover:text-primary px-3 py-1.5 rounded-md">Sources</Link><Link- href="/analyses"+ href="/dashboard/analysis"className="text-sm font-medium text-muted-foreground transition-colors hover:text-primary px-3 py-1.5 rounded-md">Analyses</Link><Link- href="/templates"+ href="/dashboard/templates"className="text-sm font-medium text-muted-foreground transition-colors hover:text-primary px-3 py-1.5 rounded-md">Templatesdiff --git a/flowsint-web/src/components/form-message.tsx b/flowsint-web/src/components/form-message.tsxnew file mode 100644index 00000000..496f9702--- /dev/null+++ b/flowsint-web/src/components/form-message.tsx@@ -0,0 +1,24 @@+export type Message =+ | { success: string }+ | { error: string }+ | { message: string };++export function FormMessage({ message }: { message: Message }) {+ return (+ <div className="flex flex-col gap-2 w-full max-w-md text-sm">+ {"success" in message && (+ <div className="border-l-2 border px-4">+ {message.success}+ </div>+ )}+ {"error" in message && (+ <div className="text-destructive border-l-2 border-destructive px-4">+ {message.error}+ </div>+ )}+ {"message" in message && (+ <div className="border-l-2 px-4">{message.message}</div>+ )}+ </div>+ );+}\ No newline at end of filediff --git a/flowsint-web/src/components/investigations/case-selector.tsx b/flowsint-web/src/components/investigations/case-selector.tsxindex cf7ffd2c..8d6b457b 100644--- a/flowsint-web/src/components/investigations/case-selector.tsx+++ b/flowsint-web/src/components/investigations/case-selector.tsx@@ -10,7 +10,8 @@ import {SelectValue,} from "@/components/ui/select"import { Skeleton } from "@/components/ui/skeleton";-import { Waypoints } from "lucide-react";+import { WaypointsIcon } from "lucide-react";+import { Badge } from "../ui/badge";export default function CaseSelector() {const router = useRouter()@@ -27,18 +28,18 @@ export default function CaseSelector() {};return (<div className="flex items-center">- {isLoading || investigation.isLoading ? <Skeleton className="h-7 w-40 bg-foreground/10" /> :+ {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-7 rounded-sm w-full hover:bg-sidebar-accent font-medium shadow-none border-none text-ellipsis truncate gap-1">- <Waypoints className="mr-1" /> <SelectValue defaultValue={investigation?.data?.title || ""} placeholder="Select an investigation" />+ <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" key={investigation.id} value={investigation.id}>{investigation.title}</SelectItem>+ <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>+ </div >);}diff --git a/flowsint-web/src/components/investigations/investigation-navigation.tsx b/flowsint-web/src/components/investigations/investigation-navigation.tsxindex 8a9631f2..920ab913 100644--- a/flowsint-web/src/components/investigations/investigation-navigation.tsx+++ b/flowsint-web/src/components/investigations/investigation-navigation.tsx@@ -9,8 +9,10 @@ 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 }: { project_id: string, investigation_id: string }) {+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@@ -49,7 +51,7 @@ function InvestigationNavigation({ project_id, investigation_id }: { project_id:<Fragment key={section.id}>{section.disabled ?<span- className="text-muted-foreground border-b-2 border-transparent opacity-40 text-sm px-4 py-2 flex items-center gap-2">+ 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>@@ -69,7 +71,10 @@ function InvestigationNavigation({ project_id, investigation_id }: { project_id:</Fragment>))}</div>- <div className="flex items-center">+ <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 />diff --git a/flowsint-web/src/components/investigations/new-actions.tsx b/flowsint-web/src/components/investigations/new-actions.tsxindex efe6bf2e..19ca8716 100644--- a/flowsint-web/src/components/investigations/new-actions.tsx+++ b/flowsint-web/src/components/investigations/new-actions.tsx@@ -56,7 +56,6 @@ export default function NewActions({ addNodes, children }: { addNodes: any, chil.insert(dataToInsert).select("*").single()-if (insertError) {toast.error("Failed to create node.")setLoading(false)diff --git a/flowsint-web/src/components/investigations/panel-context-menu.tsx b/flowsint-web/src/components/investigations/panel-context-menu.tsxindex 6bca9723..eb094fd1 100644--- a/flowsint-web/src/components/investigations/panel-context-menu.tsx+++ b/flowsint-web/src/components/investigations/panel-context-menu.tsx@@ -26,7 +26,6 @@ export default function PanelContextMenu({ addNodes }: { addNodes: any }) {const [loading, setLoading] = useState(false)const [currentParent, setCurrentParent] = useState<ActionItem | null>(null)const [navigationHistory, setNavigationHistory] = useState<ActionItem[]>([])-const handleOpenAddNodeModal = (key: string) => {if (!nodesTypes[key as keyof typeof nodesTypes]) {toast.error("Invalid node type.")@@ -37,7 +36,6 @@ export default function PanelContextMenu({ addNodes }: { addNodes: any }) {setOpenActionDialog(false)setOpenNodeModal(true)}-const onSubmitNewNodeModal = async (e: {preventDefault: () => voidcurrentTarget: HTMLFormElement | undefined@@ -46,7 +44,6 @@ export default function PanelContextMenu({ addNodes }: { addNodes: any }) {const data = Object.fromEntries(new FormData(e.currentTarget))await handleAddNode(data)}-const handleAddNode = async (data: any) => {try {setLoading(true)@@ -56,7 +53,6 @@ export default function PanelContextMenu({ addNodes }: { addNodes: any }) {.insert(dataToInsert).select("*").single()-if (insertError) {toast.error("Failed to create node.")setLoading(false)@@ -69,8 +65,10 @@ export default function PanelContextMenu({ addNodes }: { addNodes: any }) {}const newNode = {id: nodeData.id,- type: currentNodeType.type,- data: { ...nodeData, label: data[currentNodeType.fields[0]] },+ type: "custom",+ data: {+ ...nodeData, label: data[currentNodeType.fields[0]], type: currentNodeType.type,+ },position: { x: 0, y: 0 },}addNodes(newNode)@@ -83,12 +81,10 @@ export default function PanelContextMenu({ addNodes }: { addNodes: any }) {setLoading(false)}}-const navigateToSubItems = (item: ActionItem) => {setNavigationHistory([...navigationHistory, item])setCurrentParent(item)}-const navigateBack = () => {const newHistory = [...navigationHistory]newHistory.pop()diff --git a/flowsint-web/src/components/investigations/project-selector.tsx b/flowsint-web/src/components/investigations/project-selector.tsxindex 114a1bed..85a91013 100644--- a/flowsint-web/src/components/investigations/project-selector.tsx+++ b/flowsint-web/src/components/investigations/project-selector.tsx@@ -1,5 +1,4 @@"use client"-import { useInvestigationStore } from '@/store/investigation-store';import { useParams, useRouter } from "next/navigation";import {Select,@@ -11,7 +10,7 @@ import {import { Skeleton } from "@/components/ui/skeleton";import { useQuery } from "@tanstack/react-query";import { Project } from "@/types/project";-import { FolderIcon, FolderLockIcon } from 'lucide-react';+import { Badge } from '../ui/badge';export default function ProjectSelector() {const router = useRouter()@@ -24,9 +23,6 @@ export default function ProjectSelector() {},refetchOnWindowFocus: true,})- const useInvestigationData = useInvestigationStore(- (state) => state.useInvestigationData- );const projects = data?.projects || []const handleSelectionChange = (value: string) => {@@ -34,11 +30,11 @@ export default function ProjectSelector() {};return (<div className="flex items-center">- {isLoading ? <Skeleton className="h-7 w-40 bg-foreground/10" /> :+ {isLoading ? <Skeleton className="h-8 w-40 bg-foreground/10" /> :// @ts-ignore<Select onValueChange={handleSelectionChange} defaultValue={project_id}>- <SelectTrigger className="min-w-none h-7 w-full hover:bg-sidebar-accent rounded-sm font-medium shadow-none border-none text-ellipsis truncate gap-1">- <FolderIcon className="mr-1" /><SelectValue placeholder="Select an investigation" />+ <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) => (diff --git a/flowsint-web/src/components/login-form.tsx b/flowsint-web/src/components/login-form.tsxindex 836179ce..99c74943 100644--- a/flowsint-web/src/components/login-form.tsx+++ b/flowsint-web/src/components/login-form.tsx@@ -1,12 +1,15 @@import Link from "next/link"import { Github } from "lucide-react"import { Button } from "@/components/ui/button"-import { login, signup, signInWithGithub } from "@/lib/actions/auth"+import { login, signInWithGithub } from "@/lib/actions/auth"import { Card, CardHeader, CardContent, CardFooter } from "@/components/ui/card"import { Input } from "@/components/ui/input"import { Label } from "@/components/ui/label"+import { SubmitButton } from "./submit-button"+import { FormMessage, Message } from "./form-message"-export function LoginForm() {+export default async function LoginForm(props: { searchParams: Promise<Message> }) {+ const searchParams = await props.searchParams;return (<Card className="mx-auto bg-background w-full max-w-md"><CardHeader className="space-y-1">@@ -28,9 +31,10 @@ export function LoginForm() {</div><Input id="password" name="password" type="password" placeholder="Your password" required /></div>- <Button formAction={login} type="submit" className="w-full">- Login- </Button>+ <SubmitButton pendingText="Logging in..." formAction={login} className="w-full">+ Log in+ </SubmitButton>+ <FormMessage message={searchParams} /><div className="relative"><div className="absolute inset-0 flex items-center"><span className="w-full border-t" />@@ -41,21 +45,21 @@ export function LoginForm() {</div></form><form>- <Button formAction={signInWithGithub} variant="outline" className="w-full">+ <SubmitButton pendingText="Logging in..." formAction={signInWithGithub} variant="outline" className="w-full"><Github className="mr-2 h-4 w-4" />Login with Github- </Button>+ </SubmitButton></form></CardContent>- <CardFooter className="flex justify-center">+ {/* <CardFooter className="flex justify-center"><div className="text-sm text-muted-foreground">Don't have an account?{" "}<Button variant="link" formAction={signup} className="p-0">Sign up</Button></div>- </CardFooter>+ </CardFooter> */}</Card>)}diff --git a/flowsint-web/src/components/submit-button.tsx b/flowsint-web/src/components/submit-button.tsxnew file mode 100644index 00000000..69895118--- /dev/null+++ b/flowsint-web/src/components/submit-button.tsx@@ -0,0 +1,23 @@+"use client";++import { Button } from "@/components/ui/button";+import { type ComponentProps } from "react";+import { useFormStatus } from "react-dom";++type Props = ComponentProps<typeof Button> & {+ pendingText?: string;+};++export function SubmitButton({+ children,+ pendingText = "Submitting...",+ ...props+}: Props) {+ const { pending } = useFormStatus();++ return (+ <Button disabled={pending} type="submit" aria-disabled={pending} {...props}>+ {pending ? pendingText : children}+ </Button>+ );+}\ No newline at end of filediff --git a/flowsint-web/src/lib/actions/auth.ts b/flowsint-web/src/lib/actions/auth.tsindex f8d780f5..a6efe9a0 100644--- a/flowsint-web/src/lib/actions/auth.ts+++ b/flowsint-web/src/lib/actions/auth.ts@@ -3,15 +3,19 @@import { revalidatePath } from 'next/cache'import { redirect } from 'next/navigation'import { createClient } from '@/lib/supabase/server'+import { encodedRedirect } from "@/lib/utils";export async function signInWithGithub() {const supabase = await createClient()- const { data } = await supabase.auth.signInWithOAuth({+ const { data, error } = await supabase.auth.signInWithOAuth({provider: 'github',options: {redirectTo: process.env.NEXT_PUBLIC_AUTH_REDIRECT,},})+ if (error) {+ return encodedRedirect("error", "/login", error.message);+ }if (data.url) {redirect(data.url)}@@ -30,7 +34,7 @@ export async function login(formData: FormData) {const { error } = await supabase.auth.signInWithPassword(data)if (error) {- redirect('/error')+ return encodedRedirect("error", "/login", error.message);}// revalidatePath('/', 'layout')// redirect('/')@@ -49,6 +53,7 @@ export async function signup(formData: FormData) {const { error } = await supabase.auth.signUp(data)if (error) {+ return encodedRedirect("error", "/login", error.message);redirect('/error')}diff --git a/flowsint-web/src/lib/utils.ts b/flowsint-web/src/lib/utils.tsindex 6939d986..e1c73568 100644--- a/flowsint-web/src/lib/utils.ts+++ b/flowsint-web/src/lib/utils.ts@@ -1,6 +1,7 @@import { clsx, type ClassValue } from "clsx"import { twMerge } from "tailwind-merge"import Dagre from '@dagrejs/dagre';+import { redirect } from "next/navigation";//@ts-ignoreimport * as d3 from "d3-force"@@ -464,4 +465,40 @@ export const typeColorMap: Record<string, string> = {digital_footprint: "bg-lime-100 text-lime-800 hover:bg-lime-100/80 dark:bg-lime-900/30 dark:text-lime-300 dark:hover:bg-lime-900/40",biometric: "bg-amber-100 text-amber-800 hover:bg-amber-100/80 dark:bg-amber-900/30 dark:text-amber-300 dark:hover:bg-amber-900/40",credential: "bg-gray-100 text-gray-800 hover:bg-gray-100/80 dark:bg-gray-800/50 dark:text-gray-300 dark:hover:bg-gray-800/60",+}++export function getAvatarColor(name: string): string {+ const colors = [+ "bg-red-500",+ "bg-blue-500",+ "bg-green-500",+ "bg-yellow-500",+ "bg-purple-500",+ "bg-pink-500",+ "bg-indigo-500",+ "bg-teal-500",+ "bg-orange-500",+ "bg-cyan-500",+ ]+ let hash = 0+ for (let i = 0; i < name.length; i++) {+ hash = name.charCodeAt(i) + ((hash << 5) - hash)+ }+ const index = Math.abs(hash) % colors.length+ return colors[index]+}++/**+ * Redirects to a specified path with an encoded message as a query parameter.+ * @param {('error' | 'success')} type - The type of message, either 'error' or 'success'.+ * @param {string} path - The path to redirect to.+ * @param {string} message - The message to be encoded and added as a query parameter.+ * @returns {never} This function doesn't return as it triggers a redirect.+ */+export function encodedRedirect(+ type: "error" | "success",+ path: string,+ message: string,+) {+ return redirect(`${path}?${type}=${encodeURIComponent(message)}`);}\ No newline at end of filediff --git a/flowsint-web/tailwind.config.js b/flowsint-web/tailwind.config.jsindex d8e1a676..847ca341 100644--- a/flowsint-web/tailwind.config.js+++ b/flowsint-web/tailwind.config.js@@ -73,6 +73,16 @@ module.exports = {'bg-lime-100', 'text-lime-800', 'dark:bg-lime-900/30', 'dark:text-lime-300', 'dark:hover:bg-lime-900/40','bg-amber-100', 'text-amber-800', 'dark:bg-amber-900/30', 'dark:text-amber-300', 'dark:hover:bg-amber-900/40','bg-gray-100', 'text-gray-800', 'dark:bg-gray-800/50', 'dark:text-gray-300', 'dark:hover:bg-gray-800/60',+ "bg-red-500",+ "bg-blue-500",+ "bg-green-500",+ "bg-yellow-500",+ "bg-purple-500",+ "bg-pink-500",+ "bg-indigo-500",+ "bg-teal-500",+ "bg-orange-500",+ "bg-cyan-500",],darkMode: ["class"],}