-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from Chamindu36/dev
[T18] Add redux-async libraries to handle fetching of categories
- Loading branch information
Showing
8 changed files
with
65 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
// parserOptions: { | ||
// parser: '@babel/eslint-parser', | ||
// requireConfigFile: false, // <== ADD THIS | ||
// ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features | ||
// sourceType: 'module' // Allows for the use of imports | ||
// } | ||
|
||
parserOptions: { | ||
parser: '@babel/eslint-parser', | ||
requireConfigFile: false, // <== ADD THIS | ||
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features | ||
sourceType: 'module' // Allows for the use of imports | ||
parser: '@babel/eslint-parser'; | ||
requireConfigFile: false; // <== ADD THIS | ||
ecmaVersion: 2018; // Allows for the parsing of modern ECMAScript features | ||
sourceType: 'module' // Allows for the use of imports | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,28 @@ | ||
import CATEGORIES_ACTION_TYPES from './category.types'; | ||
import { createAction } from '../../utils/reducer/reducer.utils'; | ||
|
||
import { getCategoriesAndDocuments } from '../../utils/firebase/firebase.utils'; | ||
|
||
export const setCategories = (categoriesArray) => | ||
createAction(CATEGORIES_ACTION_TYPES.SET_CATEGORIES, categoriesArray); | ||
|
||
export const fetchCategoriesStart = () => | ||
createAction(CATEGORIES_ACTION_TYPES.FETCH_CATEGORY_START); | ||
|
||
export const fetchCategoriesSuccess = (categoriesArray) => | ||
createAction(CATEGORIES_ACTION_TYPES.FETCH_CATEGORY_SUCCESS, categoriesArray); | ||
|
||
export const fetchCategoriesFailed = (error) => | ||
createAction(CATEGORIES_ACTION_TYPES.FETCH_CATEGORY_FAILURE, error); | ||
|
||
// Actual thunk async call to handle fetch | ||
export const fetchCategoriesAsync = () => async (dispatch) => { | ||
dispatch(fetchCategoriesStart()); | ||
try { | ||
const categoriesArray = await getCategoriesAndDocuments('categories'); | ||
|
||
dispatch(fetchCategoriesSuccess(categoriesArray)); | ||
} catch (error) { | ||
dispatch(fetchCategoriesFailed(error)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
const CATEGORIES_ACTION_TYPES = { | ||
SET_CATEGORIES: 'categories/SET_CATEGORIES', | ||
FETCH_CATEGORY_START: 'categories/FETCH_CATEGORY_START', | ||
FETCH_CATEGORY_SUCCESS: 'categories/FETCH_CATEGORY_SUCCESS', | ||
FETCH_CATEGORY_FAILURE: 'categories/FETCH_CATEGORY_FAILURE', | ||
}; | ||
|
||
export default CATEGORIES_ACTION_TYPES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters