/* eslint-disable */ import { useEffect, useState } from "react"; import { useAxios } from "@/lib/hooks"; import { useEventTracking } from "@/services/analytics/useEventTracking"; import { useTranslation } from "react-i18next"; import { useSupabase } from "../../../lib/context/SupabaseProvider"; interface DocumentDataProps { documentName: string; } // eslint-disable-next-line @typescript-eslint/no-explicit-any type DocumentDetails = any; //TODO: review this component logic, types and purposes const DocumentData = ({ documentName }: DocumentDataProps): JSX.Element => { const { session } = useSupabase(); const { axiosInstance } = useAxios(); const { track } = useEventTracking(); const { t } = useTranslation(["translation", "explore"]); const [documents, setDocuments] = useState([]); const [loading, setLoading] = useState(false); if (!session) { throw new Error(t("sessionNotFound", { ns: "explore" })); } useEffect(() => { const fetchDocuments = async () => { setLoading(true); void track("GET_DOCUMENT_DETAILS"); try { const res = await axiosInstance.get<{ documents: DocumentDetails[] }>( `/explore/${documentName}/` ); setDocuments(res.data.documents); } catch (error) { setDocuments([]); console.error(error); } setLoading(false); }; fetchDocuments(); }, [axiosInstance, documentName]); function Data() { return (

{documentName}

{documents.length > 0 ? ( <>

{t("chunkNumber", { quantity: documents.length, ns: "explore" })}

{Object.entries(documents[0]).map(([key, value]) => { if (value && typeof value === "object") return; return (

{key.replaceAll("_", " ")}

{String(value || t("notAvailable", { ns: "explore" }))}
); })}
) : (

{t("notAvailable", { ns: "explore" })}

)}
); } if (loading) { return
{t("loading")}
; } else { return ; } }; export default DocumentData;