import React, { useState } from 'react';
import { QuadClientEnvironment, QuadrataOnApplicationEndCallback } from '@quadrata/core-react';
import { PageKyb, QuadClientKybConfig, QuadrataKyb } from '@quadrata/kyb-react';
const quadKybConfig: QuadClientKybConfig = {
apiUrl: 'https://prod.quadrata.com/api/v1', // Testing url: https://int.quadrata.com/api/v1
environment: QuadClientEnvironment.PRODUCTION, // Use QuadClientEnvironment.SANDBOX for testing environment
protocolName: 'Your Company Name',
_debug: false, // set this to true if on a localhost domain
};
// Component
export const MyComponent: React.FC<{ accessToken: string }> = ({
accessToken,
}) => {
const [showModal, setShowModal] = useState<boolean>(false);
// Handlers
const handleOnApplicationEnd: QuadrataOnApplicationEndCallback = ({ status, error }) => {
// Application has reached an end state: completion or error
console.log('handleOnApplicationEnd:::status:::', status);
console.log('handleOnApplicationEnd:::error:::', error);
};
const handleOnHide = () => {
// do something on QuadrataKyb client hide
};
const handlePageChange = (page: PageKyb) => {
// do something on page change
};
if (!showModal) {
// Button to launch the KYB application
return (
<button
type="button"
onClick={() => setShowModal(true)}
>
Launch Quadrata
</button>
);
}
return (
<QuadrataKyb
accessToken={accessToken}
config={quadKybConfig}
onApplicationEnd={handleOnApplicationEnd}
onHide={handleOnHide}
onPageChange={handlePageChange}
/>
);
};