mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-10 20:35:17 +02:00
fix: minor type adjustments and cleanup
- Added missing Document type export - Fixed typeCounts usage in DocumentsTable - Minor formatting adjustments in DocumentsDataTable
This commit is contained in:
parent
ede7020b61
commit
55502579e1
3 changed files with 9 additions and 11 deletions
|
|
@ -6,7 +6,7 @@ import { useTranslations } from "next-intl";
|
|||
import { useCallback, useEffect, useId, useMemo, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useAtomValue, useSetAtom } from "jotai";
|
||||
import { useAtomValue } from "jotai";
|
||||
import { documentsApiService } from "@/lib/apis/documents-api.service";
|
||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||
import { documentTypeCountsAtom } from "@/atoms/documents/document-query.atoms";
|
||||
|
|
@ -15,7 +15,7 @@ import { deleteDocumentMutationAtom } from "@/atoms/documents/document-mutation.
|
|||
import { DocumentsFilters } from "./components/DocumentsFilters";
|
||||
import { DocumentsTableShell, type SortKey } from "./components/DocumentsTableShell";
|
||||
import { PaginationControls } from "./components/PaginationControls";
|
||||
import type { ColumnVisibility, Document } from "./components/types";
|
||||
import type { ColumnVisibility } from "./components/types";
|
||||
import { DocumentTypeEnum } from "@/contracts/types/document.types";
|
||||
|
||||
function useDebounced<T>(value: T, delay = 250) {
|
||||
|
|
@ -48,9 +48,7 @@ export default function DocumentsTable() {
|
|||
const [sortDesc, setSortDesc] = useState(false);
|
||||
const [selectedIds, setSelectedIds] = useState<Set<number>>(new Set());
|
||||
const {data: typeCounts} = useAtomValue(documentTypeCountsAtom) ;
|
||||
|
||||
// Set up the delete mutation
|
||||
const deleteDocumentMutation = useSetAtom(deleteDocumentMutationAtom);
|
||||
const {mutateAsync : deleteDocumentMutation} = useAtomValue(deleteDocumentMutationAtom);
|
||||
|
||||
// Build query parameters for fetching documents
|
||||
const queryParams = useMemo(
|
||||
|
|
@ -138,7 +136,7 @@ export default function DocumentsTable() {
|
|||
const deleteDocument = useCallback(
|
||||
async (id: number) => {
|
||||
try {
|
||||
await deleteDocumentMutation([{ id }]);
|
||||
await deleteDocumentMutation({ id });
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Failed to delete document:", error);
|
||||
|
|
@ -158,7 +156,7 @@ export default function DocumentsTable() {
|
|||
const results = await Promise.all(
|
||||
Array.from(selectedIds).map(async (id) => {
|
||||
try {
|
||||
await deleteDocumentMutation([{ id }]);
|
||||
await deleteDocumentMutation({ id });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -32,10 +32,9 @@ import {
|
|||
TableRow,
|
||||
} from "@/components/ui/table";
|
||||
import { getConnectorIcon } from "@/contracts/enums/connectorIcons";
|
||||
import { type Document, type DocumentType } from "@/hooks/use-documents";
|
||||
import { documentsApiService } from "@/lib/apis/documents-api.service";
|
||||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||
import { DocumentTypeEnum } from "@/contracts/types/document.types";
|
||||
import { Document, DocumentTypeEnum } from "@/contracts/types/document.types";
|
||||
import { useAtomValue } from "jotai";
|
||||
import { documentTypeCountsAtom } from "@/atoms/documents/document-query.atoms";
|
||||
|
||||
|
|
@ -110,8 +109,8 @@ const columns: ColumnDef<Document>[] = [
|
|||
cell: ({ row }) => {
|
||||
const type = row.getValue("document_type") as DocumentType;
|
||||
return (
|
||||
<div className="flex items-center gap-2" title={type}>
|
||||
<span className="text-primary">{getConnectorIcon(type)}</span>
|
||||
<div className="flex items-center gap-2" title={String(type)}>
|
||||
<span className="text-primary">{getConnectorIcon(String(type))}</span>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -161,6 +161,7 @@ export const deleteDocumentResponse = z.object({
|
|||
message: z.literal("Document deleted successfully"),
|
||||
});
|
||||
|
||||
export type Document = z.infer<typeof document>
|
||||
export type GetDocumentsRequest = z.infer<typeof getDocumentsRequest>;
|
||||
export type GetDocumentsResponse = z.infer<typeof getDocumentsResponse>;
|
||||
export type GetDocumentRequest = z.infer<typeof getDocumentRequest>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue