Skip to content
Snippets Groups Projects
roles.ts 490 B
Newer Older
  • Learn to ignore specific revisions
  • This file handles actions for the roles redux state
    */
    
    
    Carl Schönfelder's avatar
    Carl Schönfelder committed
    import axios from 'axios'
    import { AppDispatch } from './../store'
    import Types from './types'
    
    
    /** Get all roles and dispatch action to save them to roles state */
    
    Carl Schönfelder's avatar
    Carl Schönfelder committed
    export const getRoles = () => async (dispatch: AppDispatch) => {
      await axios
    
        .get('/api/misc/roles')
    
    Carl Schönfelder's avatar
    Carl Schönfelder committed
        .then((res) => {
          dispatch({
            type: Types.SET_ROLES,
            payload: res.data.items,
          })
        })
        .catch((err) => console.log(err))
    }