import { createRoot } from 'react-dom/client'; import React, { useState } from 'react'; // @ts-expect-error this stopped working in typescript 5.0+ import { useConnect } from '@pay-api/connect-sdk'; // eslint-disable-line import/no-unresolved // import { useConnect } from '../src/index'; // for local testing export const App = () => { const [authorizationCode, setAuthorizationCode] = useState( null ); const [state, setState] = useState(); const onSuccess = ({ authorizationCode, state, }: { authorizationCode: string; state?: string; }): void => { setAuthorizationCode(authorizationCode); if (state) setState(state); }; const onError = ({ errorMessage }: { errorMessage: string }) => console.error({ errorMessage }); const onClose = () => console.log('User exited Connect'); const { open } = useConnect({ clientId: 'D3FD062B-1EAD4E14-9E74328C-7F530826', scopes: [ '/2023-03-01/payroll/employees', '/2023-03-01/payroll/payruns', '/2023-03-01/payroll/payruns/:payrun_id', ], mode: 'payroll', // provider: 'brightpay connect', // optional param, will skip the provider selector page if set // sandbox: true, // if this flag is enabled, `provider` needs to be `provider: sandbox` above // state: '00000000-0000-0000-0000-000000000000', // optional - usually your internal identifier of a customer onSuccess, onError, onClose, }); return (

Authorization Code: {authorizationCode}

State (optional): {state}

); }; const container = document.getElementById('root'); const root = createRoot(container!); // eslint-disable-line @typescript-eslint/no-non-null-assertion root.render( );