amcat4api v0.1.3
amcat4api
This repository contains components for amcat4 authentication
The query components can be viewed by running the App, which just shows the login screen (and prints Amcat class in console)
npm install
npm start
The components to be used in amcat4client can then be exported in src/lib/index.js, and published to NPM. (don't forget to increment version)
npm run build_npm
npm publish
To install from npm
npm i amcat4api
Components
The key components are Login and Index. Login creates a login screen, and can be passed a setstate to get an AmCAT API connection class. Index creates a dropdown for selecting and index, and can include buttons for creating and deleting indices.
This simple example should say it all:
const App = () => {
import {Login, Index} from amcat4api
const [amcat, setAmcat] = useState(null);
const [index, setIndex] = useState();
return (
<Container style={{ marginTop: "50px" }}>
<Login onLogin={setAmcat} />
<Index amcat={amcat} index={index} setIndex={setIndex} canCreate canDelete />
</Container>
);
};
Some of the underlying components are also exported. Without being too specific: Amcat, getToken, IndexCreate and IndexDelete.