diff --git a/admin/src/api/explorer-api.js b/admin/src/api/explorer-api.js
deleted file mode 100644
index bbec9d0..0000000
--- a/admin/src/api/explorer-api.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { request } from "@strapi/helper-plugin";
-
-const explorerRequests = {
- getContentTypes: async () => {
- return await request("/content-type-explorer/get-content-types", {
- method: "GET",
- });
- },
-};
-
-export default explorerRequests;
diff --git a/admin/src/pages/HomePage/index.js b/admin/src/pages/HomePage/index.js
index 8787f82..49f9b10 100644
--- a/admin/src/pages/HomePage/index.js
+++ b/admin/src/pages/HomePage/index.js
@@ -1,28 +1,39 @@
-/*
- *
- * HomePage
- *
- */
-
import React, { useCallback, useEffect, useMemo, useState } from "react";
+import { useFetchClient } from "@strapi/helper-plugin";
import { HeaderLayout, Icon, LinkButton } from "@strapi/design-system";
-import explorerRequests from "../../api/explorer-api";
+// import explorerRequests from "../../api/explorer-api";
import { Question, Search, Drag } from "@strapi/icons";
import { useTheme } from "styled-components";
-import { SmartBezierEdge, SmartStepEdge, SmartStraightEdge } from "@tisoap/react-flow-smart-edge";
+import {
+ SmartBezierEdge,
+ SmartStepEdge,
+ SmartStraightEdge,
+} from "@tisoap/react-flow-smart-edge";
import CustomNode from "../../components/CustomNode";
-import { createEdegs, createNodes, updateEdges, updateNodes } from "../../utils/dataUtils";
-import { Background, ControlButton, Controls, ReactFlow, useEdgesState, useNodesState } from "reactflow";
+import {
+ createEdegs,
+ createNodes,
+ updateEdges,
+ updateNodes,
+} from "../../utils/dataUtils";
+import {
+ Background,
+ ControlButton,
+ Controls,
+ ReactFlow,
+ useEdgesState,
+ useNodesState,
+} from "reactflow";
import { getBackgroundColor } from "../../utils/themeUtils";
-import "reactflow/dist/style.css";
import OptionsBar from "../../components/OptionsBar";
+
+import "reactflow/dist/style.css";
import "./styles.css";
const HomePage = () => {
const theme = useTheme();
-
+ const { get } = useFetchClient();
const [contentTypes, setContentTypes] = useState([]);
-
const [options, setOptions] = useState({
snapToGrid: false,
showTypes: true,
@@ -57,19 +68,25 @@ const HomePage = () => {
const [nodes, setNodes, onNodesChange] = useNodesState([]);
const [edges, setEdges, onEdgesChange] = useEdgesState([]);
- const onConnect = useCallback((params) => setEdges((eds) => addEdge(params, eds)), [setEdges]);
+ const onConnect = useCallback(
+ (params) => setEdges((eds) => addEdge(params, eds)),
+ [setEdges]
+ );
// get (and filter) content-types
useEffect(() => {
const fetchData = async () => {
- let allTypes = await explorerRequests.getContentTypes();
- if (!options.showAdminTypes) {
- allTypes = allTypes.filter((x) => !x.name.startsWith("admin::"));
- }
- if (!options.showPluginTypes) {
- allTypes = allTypes.filter((x) => !x.name.startsWith("plugin::"));
- }
- setContentTypes(allTypes);
+ const data = await get(`/strapi-content-type-explorer/get-types`);
+ // console.log("fetching data");
+ // let allTypes = await explorerRequests.getContentTypes();
+ console.log("Data is", data);
+ // if (!options.showAdminTypes) {
+ // allTypes = allTypes.filter((x) => !x.name.startsWith("admin::"));
+ // }
+ // if (!options.showPluginTypes) {
+ // allTypes = allTypes.filter((x) => !x.name.startsWith("plugin::"));
+ // }
+ // setContentTypes(allTypes);
};
fetchData();
@@ -93,7 +110,13 @@ const HomePage = () => {
useEffect(() => {
let newNodes = updateNodes(nodes, options);
setNodes(newNodes);
- }, [setNodes, options.showTypes, options.showIcons, options.showRelationsOnly, options.showDefaultFields]);
+ }, [
+ setNodes,
+ options.showTypes,
+ options.showIcons,
+ options.showRelationsOnly,
+ options.showDefaultFields,
+ ]);
return (
<>
@@ -110,7 +133,10 @@ const HomePage = () => {
}
/>
-