States and Selectors

|-/redux
    |
    |-/payroll
        |- index.ts
        |- payrollSlice.ts
        |- payrollThunks.ts
Initial State
payrollSlice.ts
initialState: SliceState = {
  accountsCompleteData: {
    accountsList: [],
    meta: {
      count: null,
      next_cursor: null,
    },
  },
  accountJobsData: {
    data: [],
    meta: {
      count: null,
      next_cursor: null,
    },
  },
  accountPaystubsData: {
    data: [],
    meta: {
      count: null,
      next_cursor: null,
      refreshed_at: null,
    },
  },
  isLoadingAccountsUserData: false,
};
Selectors
  • getAccountsComplete: This selector gets the complete list of the accounts of the user.

  • getAccountsNextCursor: This selector helps with the pagination of the accounts list.

  • getIsLoadingAccountsUserData: This selector helps to know when data related to the payroll flow is loading.

  • getAccountJobs: This selector gets the list of the movements of the current account.

  • getJobsCursor: This selector helps with the pagination of the jobs list.

  • getAccountPaystubs: This selector gets the list of the receipts of the current account.

  • getPaystubsCursor: This selector helps with the pagination of the receipts list.

How to get the user accounts?

Invoke fetchUserAccounts from LinkerStudio/modules/payroll/common/redux/payroll using the hook useAppDispatch from LinkerStudio/core/hooks

import {useAppDispatch} from 'LinkerStudio/core/hooks';

const dispatch = useAppDispatch();

dispatch(fetchUserAccounts(params));

How to get movements?

Invoke fetchJobs and fetchMoreJobs from LinkerStudio/modules/payroll/common/redux/payroll using the hook useAppDispatch from LinkerStudio/core/hooks

import {useAppDispatch} from 'LinkerStudio/core/hooks';

const dispatch = useAppDispatch();

dispatch(fetchJobs());
dispatch(fetchMoreJobs(params));

Where params are:

cursor: string; // Used for fetchMoreJobs

How to get receipts?

Invoke fetchPaystubs and fetchMorePaystubs from LinkerStudio/modules/payroll/common/redux/payroll using the hook useAppDispatch from LinkerStudio/core/hooks

import {useAppDispatch} from 'LinkerStudio/core/hooks';

const dispatch = useAppDispatch();

dispatch(fetchPaystubs(params));
dispatch(fetchMorePaystubs(params));

Where params are:

dateFrom: Date;
dateTo: Date;
cursor: string; // Used for fetchMorePaystubs

Last updated