import React, { useState, useEffect, useCallback, useContext } from 'react'; import { Row, Col, Container, Form, InputGroup, Image, Card, Button, Alert, } from 'react-bootstrap'; import { apiFetch, getApiEndpoint } from '../../utils/helpers'; import { ClientContext } from '../../contexts/clientProvider'; function Imports() { const client = useContext(ClientContext); const [imports, setImports] = useState(null); const [pages, setPages] = useState(0); const [count, setCount] = useState(0); const [input, setInput] = useState(''); const [loading, setLoading] = useState(false); const fetchImports = useCallback( async (page: number = 1, search: string = null) => { try { setLoading(true); const data = await apiFetch( '/meta/imports/all?page=' + page + (search ? '&search=' + search : ''), { method: 'GET', } ); const { imports, pages, count } = data; setImports(imports); setPages(pages); setCount(count); } catch (err) { throw new Error( "The data you're trying to fetch is undefined!" ); } finally { setLoading(false); } }, [] ); useEffect(() => { if (!client.loaded) return; if (client?.controller?.apiAccess) fetchImports(); }, [fetchImports, client]); return (

Imports{' '} {count}

Here are all the imports which have been picked up by InfinityMint are being used in your projects

{client?.controller?.apiAccess ? ( <> Search Term { if (e.key === 'Enter') { if (input === '') return; fetchImports(0, input); } }} onChange={(e) => { setInput(e.target.value); if (e.target.value === '') fetchImports(); }} aria-describedby="basic-addon3" /> {Object.keys(imports || {}).map((importName) => { let importFile = imports[importName]; let extensions = [ '.png', '.jpg', '.jpeg', '.gif', '.svg', '.bmp', ]; return ( {importFile.base}