1.0.5 • Published 2 years ago

@centic-io/scoring-modal v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Centic Scoring modal

React modal for calculating custom wallet score.

Installation

npm install @centic-io/scoring-modal

Usage

Setup the Scoring context

Wrap your app inside ScoringContextProvider with the api key created and the score model ID you choose (only use credit score type model). API Key can be created here

import { ScoringContextProvider } from  "@centic-io/scoring-modal";

export const App = () => {
	return (
 	<ScoringContextProvider  apiKey="your api key" scoreId="score model ID">
		<YourApp />
	</ScoringContextProvider>
  );
};

Start calculating the score

The score calculator model can be invoked by calling the start() function provided in useScoringContext hook. The score calculated will be saved within the score key provided in the hook.

import  React, { useEffect } from  "react";
import { useScoringContext } from  "@centic-io/scoring-modal";

function  Page() {
	const { start, score } =  useScoringContext();
	useEffect(() => {
		if (score) {
			console.log(`Your score: ${score}`);
		}
	}, [score]);
	return  <button  onClick={start}>Calculate credit score</button>;
}
export default Page;