3.0.0 • Published 9 months ago

@creditbook/wlc-react-sdk v3.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Empower your platform with seamless financial integration using these White Label UI Components. Designed for easy customisation and seamless integration, our UI components offer: Customisation: Tailor the look and feel to match your brand. Modularity: Choose functionalities that fit your needs. Security: Industry-leading standards to protect user data. Scalability: Reliable performance for any user load. Get started today with our developer-friendly APIs and comprehensive documentation!

First install the React js sdk by running one of these command

yarn add @creditbook/wlc-react-sdk

Or

npm install @creditbook/wlc-react-sdk

import React, { useCallback, useEffect, useState } from 'react';
import './App.css';
import { LMSProvider } from '@creditbook/wlc-react-sdk';
// Custom font
import Poppins from './font/Poppins.json';

function App() {
  const [token, setToken] = useState('');

  const fetchToken = useCallback(async () => {
    // generate the token and assign to the setToken hook
  }, []);

  useEffect(() => {
    fetchToken();
  }, [fetchToken]);

  return (
    <LMSProvider
      base_url={/* provide the base url*/}
      token={token}
      info={{
        // Pass one of these information
        email: '',
        contactNumber: '',
        ntn: '',
        external_user_id: '',
      }}
      font={['Poppins']}
    >
      {/* children */}
    </LMSProvider>
  );
}

export default App;

Wrap your top level-component with LMSProvider. Note: White label component works inside LMSProvider

ParameterRequired?TypeDescription
base_urltruestringRead the doc for the base url or connect with our team (partnerships@creditbook.pk) for the base url
tokentruestringGenerate the token and pass it to the LMSProvider. Read the doc to generate the token.
infotrueInfoTypePass one of these information email, contactNumber, ntn, external_user_id. If you are new the pass one of these value with empty string like { ntn : '' }. You can set later by using useLMS() hook
themefalselight or darkYou can pass theme mode like light or dark
palettefalseTheme paletteFor more info see the theme section
fontfalsestring[]Pass font name. eg: 'Arial'. Remember if you have custom font then integrate in your project and pass the string.

Now Configuration is done. You are free to use any white label component if you business is already register.

  • RegisterFinance
  • ReviewFinance

RegisterFinance

NOTE : When navigating to the Review Finance screen, users have the opportunity to modify any relevant information before submitting it within the Review Finance component. This ensures that all details are accurate and up-to-date prior to final submission.

import React, { useState } from 'react';
import { RegisterFinance } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  return (
    <RegisterFinance
      onReview={(business: IBusiness) => console.log('business', business)}
    />
  );
};
ParameterRequired?TypeDescription
isBankRequiredfalsebooleanIf you want bank information mandatory you can pass isBankRequired={true}
onBackPressfalsefunctionit will call whenever user press back button from the navbar
onReviewfalsefunctionit will return business type object, once you successfully pass the validation

ReviewFinance

import React, { useState } from 'react';
import { ReviewFinance } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  const initialData; // you will receive initial data from register finance component. When onReview callback called.
  return (
    <ReviewFinance
      initialData={initialData}
      onSuccess={(val) => console.log('value', val)}
    />
  );
};

It will help you to register your business information with us.

ParameterRequired?TypeDescription
initialDatatrueobjectYou will receive initial data from register finance component.
onSuccessfalsefunctionit will call once user successfully register the user and it will return IBusiness object
isBankRequiredfalsefunctionIf you want bank information mandatory you can pass isBankRequired={true}
onFinishfalsefunctionit will call at the last stage of the registration

FinanceApplicationForm

import React, { useState } from 'react';
import { FinanceApplicationForm } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  return (
    <FinanceApplicationForm
      onSuccess={(loan) => console.log('loan', loan._id)}
    />
  );
};

You can apply your loan via this component

ParameterRequired?TypeDescription
onSuccessfalsefunctionit will return loan type object, once you successfully submitted your request.

RepaymentModal

import React, { useState } from 'react';
import { RepaymentModal } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  return <RepaymentModal onSuccess={(loan) => console.log('loan', loan)} />;
};
ParameterRequired?TypeDescription
loanIdtruestringonce you receive the loan object get the loan id and pass it to this component
onSuccessfalsefunctionIt will fire, whenever your request successfully saved with us.
opentruebooleanIt will set the visibility of the modal
onClosefalsefunctionIt will trigger once user clicks on the close, cancel button

SummaryCard

import React, { useState } from 'react';
import { SummaryCard } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  const { userDetail } = useLMS();

  return (
    <SummaryCard
      onClick={() => {
        /* Write your business logic, eg: navigate to the other screen */
      }}
    />
  );
};
ParameterRequired?TypeDescription
onClickfalsefunctionIt will call whenever user click on Apply for financing

LoanDetails

import React, { useState } from 'react';
import { LoanDetails } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  const { userDetail } = useLMS();

  return (
    <LoanDetails
      loanId={'65d8c8034a5df5b079172dec'} // pass your loanId
      onRecordClick={() => {
        // do something
      }}
      isRepayment={false}
    />
  );
};
ParameterRequired?TypeDescription
loanIdtruestringPass the loan id to see the loan details
isRepaymentfalsebooleanpass if you want default tab selected to "Repayment"
onRecordClickfalsefunctionit will call whenever user clicks on Record payments button

Banner

import React, { useState } from 'react';
import { Banner } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  const { userDetail } = useLMS();

  return (
    <Banner
      onClick={() => {}}
      onClose={() => {
        // it will fire whenever user click on the close icon
      }}
    />
  );
};
ParameterRequired?TypeDescription
onClickfalsefunctionit will fire whenever user clicks on the button, it will return type and contractUrl.Available types: REGISTER_FOR_FINANCINGREVIEW_SIGN_CONTRACTREGISTER_AGAINAPPLY_FINANCING
onClosefalsefunctionIt will call when user click on the close icon

LoanList

import React, { useState } from 'react';
import { Banner } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  const { userDetail } = useLMS();

  return (
    <LoanList
      onRecordPaymentClick={(loan) => {
        // it will return you selected loan
      }}
      onViewClick={(type, loan) => {
        // it will return you type : 'LOAN'|'APPLICATION' and selected loan detail
      }}
      tableMaxHeight={300}
    />
  );
};
ParameterRequired?TypeDescription
onRecordPaymentClickfalsefunctionIt will return you selected loan
onViewClickfalsefunctionit will return you type : LOAN or APPLICATION and selected loan
tableMaxHeightfalsenumberTable max height for both Loan and Application

Profile

import React, { useState } from 'react';
import { Profile } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  return <Profile />;
};

RequestEdit

import React, { useState } from 'react';
import { RequestEdit } from '@creditbook/wlc-react-sdk';

export const Component = () => {
  return <RequestEdit />;
};

Hooks

useLMS()

const { TOKEN, BASE_URL, axiosInstance, EMAIL, setEmail, userDetail } = useLMS()

NameDescription
TOKENIt will return current token
BASE_URLIt will return current base url
axiosInstanceYou can use use axiosInstance, if you wanna call the server directly
EMAILIt will return current email
setEmailif you wanna change the email you can call this function. setEmail('abc@gmail.com')
userDetailit will return IBusiness type object. IBusiness - current user status

Theme

Default Palette

const palette = {
  primary: {
    '50': '#EBF5FF',
    '100': '#CCE5FF',
    '200': '#99CCFF',
    '300': '#66B2FF',
    '400': '#3399FF',
    '500': '#007FFF',
    '600': '#0066CC',
    '700': '#004C99',
    '800': '#004C99',
    '900': '#003A75',
    main: '#007FFF',
    light: '#66B2FF',
    dark: '#004C99',
    contrastText: '#fff',
  },
  secondary: {
    '50': '#F3F6F9',
    '100': '#E5EAF2',
    '200': '#DAE2ED',
    '300': '#C7D0DD',
    '400': '#B0B8C4',
    '500': '#9DA8B7',
    '600': '#6B7A90',
    '700': '#434D5B',
    '800': '#303740',
    '900': '#1C2025',
    main: '#DAE0E7',
    contrastText: '#2F3A46',
    light: 'rgb(225, 230, 235)',
    dark: 'rgb(152, 156, 161)',
  },
  divider: '#E5EAF2',
  primaryDark: {
    '50': '#EAEDF1',
    '100': '#DAE0E7',
    '200': '#ACBAC8',
    '300': '#7B91A7',
    '400': '#4B5E71',
    '500': '#3B4A59',
    '600': '#2F3A46',
    '700': '#1F262E',
    '800': '#141A1F',
    '900': '#101418',
    main: '#7B91A7',
  },
  common: { black: '#0B0D0E', white: '#fff' },
  text: {
    primary: '#1C2025',
    secondary: '#434D5B',
    tertiary: '#6B7A90',
    disabled: 'rgba(0, 0, 0, 0.38)',
  },
  grey: {
    '50': '#F3F6F9',
    '100': '#E5EAF2',
    '200': '#DAE2ED',
    '300': '#C7D0DD',
    '400': '#B0B8C4',
    '500': '#9DA8B7',
    '600': '#6B7A90',
    '700': '#434D5B',
    '800': '#303740',
    '900': '#1C2025',
    main: '#E5EAF2',
    contrastText: '#6B7A90',
    A100: '#f5f5f5',
    A200: '#eeeeee',
    A400: '#bdbdbd',
    A700: '#616161',
  },
  error: {
    '50': '#FFF0F1',
    '100': '#FFDBDE',
    '200': '#FFBDC2',
    '300': '#FF99A2',
    '400': '#FF7A86',
    '500': '#FF505F',
    '600': '#EB0014',
    '700': '#C70011',
    '800': '#94000D',
    '900': '#570007',
    main: '#EB0014',
    light: '#FF99A2',
    dark: '#C70011',
    contrastText: '#fff',
  },
  success: {
    '50': '#E9FBF0',
    '100': '#C6F6D9',
    '200': '#9AEFBC',
    '300': '#6AE79C',
    '400': '#3EE07F',
    '500': '#21CC66',
    '600': '#1DB45A',
    '700': '#1AA251',
    '800': '#178D46',
    '900': '#0F5C2E',
    main: '#1AA251',
    light: '#6AE79C',
    dark: '#1AA251',
    contrastText: '#fff',
  },
  warning: {
    '50': '#FFF9EB',
    '100': '#FFF3C1',
    '200': '#FFECA1',
    '300': '#FFDC48',
    '400': '#F4C000',
    '500': '#DEA500',
    '600': '#D18E00',
    '700': '#AB6800',
    '800': '#8C5800',
    '900': '#5A3600',
    main: '#DEA500',
    light: '#FFDC48',
    dark: '#AB6800',
    contrastText: 'rgba(0, 0, 0, 0.87)',
  },
  gradients: {
    lightGrayRadio:
      'radial-gradient(50% 50% at 50% 50%, #F0F7FF 0%, rgba(240, 247, 255, 0.05) 100%)',
    stylizedRadio:
      'linear-gradient(rgba(255 255 255 / 0.3), rgba(255 255 255 / 0.3)), linear-gradient(254.86deg, rgba(194, 224, 255, 0.12) 0%, rgba(194, 224, 255, 0.12) 0%, rgba(255, 255, 255, 0.3) 49.98%, rgba(240, 247, 255, 0.3) 100.95%)',
    linearSubtle:
      'linear-gradient(to top right, rgba(235, 245, 255, 0.3) 40%, rgba(243, 246, 249, 0.2) 100%)',
  },
  info: {
    main: '#0288d1',
    light: '#03a9f4',
    dark: '#01579b',
    contrastText: '#fff',
  },
  contrastThreshold: 3,
  tonalOffset: 0.2,
  background: { paper: '#fff', default: '#fff' },
  action: {
    active: 'rgba(0, 0, 0, 0.54)',
    hover: 'rgba(0, 0, 0, 0.04)',
    hoverOpacity: 0.04,
    selected: 'rgba(0, 0, 0, 0.08)',
    selectedOpacity: 0.08,
    disabled: 'rgba(0, 0, 0, 0.26)',
    disabledBackground: 'rgba(0, 0, 0, 0.12)',
    disabledOpacity: 0.38,
    focus: 'rgba(0, 0, 0, 0.12)',
    focusOpacity: 0.12,
    activatedOpacity: 0.12,
  },
};
3.0.0

9 months ago

2.0.37

1 year ago

2.0.38

1 year ago

2.0.39

1 year ago

2.0.48

1 year ago

2.0.49

1 year ago

2.0.46

1 year ago

2.0.47

1 year ago

2.0.45

1 year ago

2.0.42

1 year ago

2.0.43

1 year ago

2.0.40

1 year ago

2.0.41

1 year ago

1.0.37

1 year ago

1.0.38

1 year ago

2.0.59

12 months ago

2.0.57

12 months ago

2.0.58

12 months ago

2.0.55

12 months ago

2.0.53

12 months ago

2.0.54

12 months ago

2.0.51

12 months ago

2.0.52

12 months ago

2.0.50

1 year ago

2.0.60

12 months ago

1.0.29

1 year ago

1.0.33

1 year ago

1.0.31

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.25-test

1 year ago

1.0.25-test-1

1 year ago

1.0.26

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.22

1 year ago

1.0.23

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago