mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-15 18:25:18 +02:00
feat: migrate deleteconnector handler
This commit is contained in:
parent
68fe4daea1
commit
6913a7b59f
1 changed files with 6 additions and 5 deletions
|
|
@ -16,6 +16,7 @@ import { useParams, useRouter } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { deleteConnectorMutationAtom } from "@/atoms/connectors/connector-mutation.atoms";
|
||||||
import { connectorsAtom } from "@/atoms/connectors/connector-query.atoms";
|
import { connectorsAtom } from "@/atoms/connectors/connector-query.atoms";
|
||||||
import { activeSearchSpaceIdAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
import { activeSearchSpaceIdAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
||||||
import {
|
import {
|
||||||
|
|
@ -89,8 +90,10 @@ export default function ConnectorsPage() {
|
||||||
|
|
||||||
const { data: connectors = [], isLoading, error } = useAtomValue(connectorsAtom);
|
const { data: connectors = [], isLoading, error } = useAtomValue(connectorsAtom);
|
||||||
|
|
||||||
// Keep old hook for mutations (will migrate later)
|
const { mutateAsync: deleteConnector } = useAtomValue(deleteConnectorMutationAtom);
|
||||||
const { deleteConnector, indexConnector, updateConnector } = useSearchSourceConnectors(
|
|
||||||
|
// Keep old hook for other mutations (will migrate later)
|
||||||
|
const { indexConnector, updateConnector } = useSearchSourceConnectors(
|
||||||
true,
|
true,
|
||||||
parseInt(searchSpaceId)
|
parseInt(searchSpaceId)
|
||||||
);
|
);
|
||||||
|
|
@ -126,11 +129,9 @@ export default function ConnectorsPage() {
|
||||||
if (connectorToDelete === null) return;
|
if (connectorToDelete === null) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await deleteConnector(connectorToDelete);
|
await deleteConnector({ id: connectorToDelete });
|
||||||
toast.success(t("delete_success"));
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error deleting connector:", error);
|
console.error("Error deleting connector:", error);
|
||||||
toast.error(t("delete_failed"));
|
|
||||||
} finally {
|
} finally {
|
||||||
setConnectorToDelete(null);
|
setConnectorToDelete(null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue