mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 01:06:23 +02:00
Biome: fixes for app/dashboard/search_pace_id pages
This commit is contained in:
parent
07063a1a18
commit
ecc4c11100
22 changed files with 472 additions and 480 deletions
|
|
@ -1,5 +1,57 @@
|
|||
"use client";
|
||||
|
||||
import {
|
||||
IconBrandDiscord,
|
||||
IconBrandGithub,
|
||||
IconBrandNotion,
|
||||
IconBrandSlack,
|
||||
IconBrandYoutube,
|
||||
IconLayoutKanban,
|
||||
IconTicket,
|
||||
} from "@tabler/icons-react";
|
||||
import {
|
||||
type ColumnDef,
|
||||
type ColumnFiltersState,
|
||||
flexRender,
|
||||
getCoreRowModel,
|
||||
getFacetedUniqueValues,
|
||||
getFilteredRowModel,
|
||||
getPaginationRowModel,
|
||||
getSortedRowModel,
|
||||
type PaginationState,
|
||||
type Row,
|
||||
type SortingState,
|
||||
useReactTable,
|
||||
type VisibilityState,
|
||||
} from "@tanstack/react-table";
|
||||
import { AnimatePresence, motion, type Variants } from "framer-motion";
|
||||
import {
|
||||
AlertCircle,
|
||||
ChevronDown,
|
||||
ChevronFirst,
|
||||
ChevronLast,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
ChevronUp,
|
||||
CircleAlert,
|
||||
CircleX,
|
||||
Columns3,
|
||||
File,
|
||||
FileX,
|
||||
Filter,
|
||||
Globe,
|
||||
ListFilter,
|
||||
MoreHorizontal,
|
||||
Trash,
|
||||
Webhook,
|
||||
} from "lucide-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import React, { useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import rehypeRaw from "rehype-raw";
|
||||
import rehypeSanitize from "rehype-sanitize";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import { toast } from "sonner";
|
||||
import { DocumentViewer } from "@/components/document-viewer";
|
||||
import { JsonMetadataViewer } from "@/components/json-metadata-viewer";
|
||||
import {
|
||||
|
|
@ -43,64 +95,12 @@ import {
|
|||
TableHeader,
|
||||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { useDocuments } from "@/hooks/use-documents";
|
||||
import { cn } from "@/lib/utils";
|
||||
import {
|
||||
IconBrandDiscord,
|
||||
IconBrandGithub,
|
||||
IconBrandNotion,
|
||||
IconBrandSlack,
|
||||
IconBrandYoutube,
|
||||
IconLayoutKanban,
|
||||
IconTicket,
|
||||
} from "@tabler/icons-react";
|
||||
import {
|
||||
type ColumnDef,
|
||||
type ColumnFiltersState,
|
||||
type FilterFn,
|
||||
type PaginationState,
|
||||
type Row,
|
||||
type SortingState,
|
||||
type VisibilityState,
|
||||
flexRender,
|
||||
getCoreRowModel,
|
||||
getFacetedUniqueValues,
|
||||
getFilteredRowModel,
|
||||
getPaginationRowModel,
|
||||
getSortedRowModel,
|
||||
useReactTable,
|
||||
} from "@tanstack/react-table";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import {
|
||||
AlertCircle,
|
||||
ChevronDown,
|
||||
ChevronFirst,
|
||||
ChevronLast,
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
ChevronUp,
|
||||
CircleAlert,
|
||||
CircleX,
|
||||
Columns3,
|
||||
File,
|
||||
FileX,
|
||||
Filter,
|
||||
Globe,
|
||||
ListFilter,
|
||||
MoreHorizontal,
|
||||
Trash,
|
||||
Webhook,
|
||||
} from "lucide-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import React, { useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
||||
import ReactMarkdown from "react-markdown";
|
||||
import rehypeRaw from "rehype-raw";
|
||||
import rehypeSanitize from "rehype-sanitize";
|
||||
import remarkGfm from "remark-gfm";
|
||||
import { toast } from "sonner";
|
||||
|
||||
// Define animation variants for reuse
|
||||
const fadeInScale = {
|
||||
const fadeInScale: Variants = {
|
||||
hidden: { opacity: 0, scale: 0.95 },
|
||||
visible: {
|
||||
opacity: 1,
|
||||
|
|
@ -132,19 +132,6 @@ type Document = {
|
|||
search_space_id: number;
|
||||
};
|
||||
|
||||
// Custom filter function for multi-column searching
|
||||
const multiColumnFilterFn: FilterFn<Document> = (row, columnId, filterValue) => {
|
||||
const searchableRowContent = `${row.original.title}`.toLowerCase();
|
||||
const searchTerm = (filterValue ?? "").toLowerCase();
|
||||
return searchableRowContent.includes(searchTerm);
|
||||
};
|
||||
|
||||
const statusFilterFn: FilterFn<Document> = (row, columnId, filterValue: string[]) => {
|
||||
if (!filterValue?.length) return true;
|
||||
const status = row.getValue(columnId) as string;
|
||||
return filterValue.includes(status);
|
||||
};
|
||||
|
||||
// Add document type icons mapping
|
||||
const documentTypeIcons = {
|
||||
EXTENSION: Webhook,
|
||||
|
|
@ -187,6 +174,8 @@ const columns: ColumnDef<Document>[] = [
|
|||
accessorKey: "title",
|
||||
cell: ({ row }) => {
|
||||
const Icon = documentTypeIcons[row.original.document_type];
|
||||
const title = row.getValue("title") as string;
|
||||
const truncatedTitle = title.length > 30 ? `${title.slice(0, 30)}...` : title;
|
||||
return (
|
||||
<motion.div
|
||||
className="flex items-center gap-2 font-medium"
|
||||
|
|
@ -194,8 +183,17 @@ const columns: ColumnDef<Document>[] = [
|
|||
transition={{ type: "spring", stiffness: 300 }}
|
||||
style={{ display: "flex" }}
|
||||
>
|
||||
<Icon size={16} className="text-muted-foreground shrink-0" />
|
||||
<span>{row.getValue("title")}</span>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="flex items-center gap-2">
|
||||
<Icon size={16} className="text-muted-foreground shrink-0" />
|
||||
<span>{truncatedTitle}</span>
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent>
|
||||
<p>{title}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</motion.div>
|
||||
);
|
||||
},
|
||||
|
|
@ -231,7 +229,7 @@ const columns: ColumnDef<Document>[] = [
|
|||
const title = row.getValue("title") as string;
|
||||
|
||||
// Create a truncated preview (first 150 characters)
|
||||
const previewContent = content.length > 150 ? content.substring(0, 150) + "..." : content;
|
||||
const previewContent = content.length > 150 ? `${content.substring(0, 150)}...` : content;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
|
|
@ -336,7 +334,7 @@ export default function DocumentsTable() {
|
|||
|
||||
useEffect(() => {
|
||||
if (documents) {
|
||||
setData(documents);
|
||||
setData(documents as Document[]);
|
||||
}
|
||||
}, [documents]);
|
||||
|
||||
|
|
@ -408,19 +406,19 @@ export default function DocumentsTable() {
|
|||
const values = Array.from(statusColumn.getFacetedUniqueValues().keys());
|
||||
|
||||
return values.sort();
|
||||
}, [table.getColumn("document_type")?.getFacetedUniqueValues()]);
|
||||
}, [table.getColumn]);
|
||||
|
||||
// Get counts for each status
|
||||
const statusCounts = useMemo(() => {
|
||||
const statusColumn = table.getColumn("document_type");
|
||||
if (!statusColumn) return new Map();
|
||||
return statusColumn.getFacetedUniqueValues();
|
||||
}, [table.getColumn("document_type")?.getFacetedUniqueValues()]);
|
||||
}, [table.getColumn]);
|
||||
|
||||
const selectedStatuses = useMemo(() => {
|
||||
const filterValue = table.getColumn("document_type")?.getFilterValue() as string[];
|
||||
return filterValue ?? [];
|
||||
}, [table.getColumn("document_type")?.getFilterValue()]);
|
||||
}, [table.getColumn]);
|
||||
|
||||
const handleStatusChange = (checked: boolean, value: string) => {
|
||||
const filterValue = table.getColumn("document_type")?.getFilterValue() as string[];
|
||||
|
|
@ -722,7 +720,8 @@ export default function DocumentsTable() {
|
|||
className="h-12 px-4 py-3"
|
||||
>
|
||||
{header.isPlaceholder ? null : header.column.getCanSort() ? (
|
||||
<div
|
||||
<Button
|
||||
variant="ghost"
|
||||
className={cn(
|
||||
header.column.getCanSort() &&
|
||||
"flex h-full cursor-pointer select-none items-center justify-between gap-2"
|
||||
|
|
@ -759,7 +758,7 @@ export default function DocumentsTable() {
|
|||
/>
|
||||
),
|
||||
}[header.column.getIsSorted() as string] ?? null}
|
||||
</div>
|
||||
</Button>
|
||||
) : (
|
||||
flexRender(header.column.columnDef.header, header.getContext())
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"use client";
|
||||
|
||||
import { useState, useCallback, useRef } from "react";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import { Calendar, CheckCircle2, FileType, Tag, Upload, X } from "lucide-react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useCallback, useRef, useState } from "react";
|
||||
import { useDropzone } from "react-dropzone";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { toast } from "sonner";
|
||||
import { X, Upload, Tag, CheckCircle2, Calendar, FileType } from "lucide-react";
|
||||
import { useRouter, useParams } from "next/navigation";
|
||||
import { motion, AnimatePresence } from "framer-motion";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
// Grid pattern component inspired by Aceternity UI
|
||||
function GridPattern() {
|
||||
|
|
@ -230,7 +230,7 @@ export default function FileUploader() {
|
|||
const k = 1024;
|
||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / k ** i).toFixed(2)) + " " + sizes[i];
|
||||
return `${parseFloat((bytes / k ** i).toFixed(2))} ${sizes[i]}`;
|
||||
};
|
||||
|
||||
const handleUpload = async () => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { type Tag, TagInput } from "emblor";
|
||||
import { Globe, Loader2 } from "lucide-react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
|
|
@ -13,8 +14,7 @@ import {
|
|||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { toast } from "sonner";
|
||||
import { Globe, Loader2 } from "lucide-react";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
// URL validation regex
|
||||
const urlRegex = /^(https?:\/\/)?([\da-z.-]+)\.([a-z.]{2,6})([/\w .-]*)*\/?$/;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { IconBrandYoutube } from "@tabler/icons-react";
|
||||
import { type Tag, TagInput } from "emblor";
|
||||
import { motion, type Variants } from "framer-motion";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
|
|
@ -13,9 +16,7 @@ import {
|
|||
CardHeader,
|
||||
CardTitle,
|
||||
} from "@/components/ui/card";
|
||||
import { toast } from "sonner";
|
||||
import { Youtube, Loader2 } from "lucide-react";
|
||||
import { motion } from "framer-motion";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
// YouTube video ID validation regex
|
||||
const youtubeRegex =
|
||||
|
|
@ -135,7 +136,7 @@ export default function YouTubeVideoAdder() {
|
|||
};
|
||||
|
||||
// Animation variants
|
||||
const containerVariants = {
|
||||
const containerVariants: Variants = {
|
||||
hidden: { opacity: 0 },
|
||||
visible: {
|
||||
opacity: 1,
|
||||
|
|
@ -145,7 +146,7 @@ export default function YouTubeVideoAdder() {
|
|||
},
|
||||
};
|
||||
|
||||
const itemVariants = {
|
||||
const itemVariants: Variants = {
|
||||
hidden: { y: 20, opacity: 0 },
|
||||
visible: {
|
||||
y: 0,
|
||||
|
|
@ -165,7 +166,7 @@ export default function YouTubeVideoAdder() {
|
|||
<motion.div variants={itemVariants}>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Youtube className="h-5 w-5" />
|
||||
<IconBrandYoutube className="h-5 w-5" />
|
||||
Add YouTube Videos
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
|
|
@ -282,7 +283,7 @@ export default function YouTubeVideoAdder() {
|
|||
transition={{ delay: 0.2 }}
|
||||
className="mr-2"
|
||||
>
|
||||
<Youtube className="h-4 w-4" />
|
||||
<IconBrandYoutube className="h-4 w-4" />
|
||||
</motion.span>
|
||||
Submit YouTube Videos
|
||||
</>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue