-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Amir Amiri
committed
Mar 5, 2023
1 parent
2e5fb9a
commit 717ce5d
Showing
13 changed files
with
126 additions
and
40 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
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { SpinnerContainer, SpinnerOverlay } from "./spinner.styles"; | ||
|
||
const Spinner = () => | ||
<SpinnerOverlay> | ||
<SpinnerContainer /> | ||
</SpinnerOverlay> | ||
|
||
export default Spinner; |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import styled from "styled-components"; | ||
|
||
export const SpinnerOverlay = styled.div` | ||
height: 60vh; | ||
width: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
export const SpinnerContainer = styled.div` | ||
display: inline-block; | ||
width: 50px; | ||
height: 50px; | ||
border: 3px solid rgba(195, 195, 195, 0.6); | ||
border-radius: 50%; | ||
border-top-color: #636767; | ||
animation: spin 1s ease-in-out infinite; | ||
-webkit-animation: spin 1s ease-in-out infinite; | ||
@keyframes spin { | ||
to { | ||
-webkit-transform: rotate(360deg); | ||
} | ||
} | ||
@-webkit-keyframes spin { | ||
to { | ||
-webkit-transform: rotate(360deg); | ||
} | ||
} | ||
`; |
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
10 changes: 7 additions & 3 deletions
10
src/routes/categories-preview/categories-preview.component.jsx
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
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,21 @@ | ||
import { createAction } from "../../utils/reducer/reducer.utils" | ||
import { CATEGORIES_ACTION_TYPE } from "./category.types" | ||
import { GetCategoriesAndDocuments } from '../../utils/firebase/firebase.utils'; | ||
|
||
export const setCategories = (categories) => createAction(CATEGORIES_ACTION_TYPE.SET_CATEGORIES, categories) | ||
|
||
export const setCategories = (categories) => createAction(CATEGORIES_ACTION_TYPE.SET_CATEGORIES, categories) | ||
export const fetchCategoriesStart = () => createAction(CATEGORIES_ACTION_TYPE.FETCH_CATEGORIES_START) | ||
export const fetchCategoriesSuccess = (categoriesArray) => createAction(CATEGORIES_ACTION_TYPE.FETCH_CATEGORIES_SUCCESS, categoriesArray) | ||
export const fetchCategoriesFailed = (error) => createAction(CATEGORIES_ACTION_TYPE.FETCH_CATEGORIES_FAILED, error) | ||
|
||
|
||
export const fetchCategoriesAsync = () => async (dispatch) => { | ||
dispatch(fetchCategoriesStart()) | ||
try { | ||
const categoriesArray = await GetCategoriesAndDocuments(); | ||
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
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,3 +1,6 @@ | ||
export const CATEGORIES_ACTION_TYPE = { | ||
'SET_CATEGORIES': 'category/SET_CATEGORIES' | ||
'FETCH_CATEGORIES_START': 'category/FETCH_CATEGORIES_START', | ||
'FETCH_CATEGORIES_SUCCESS': 'category/FETCH_CATEGORIES_SUCCESS', | ||
'FETCH_CATEGORIES_FAILED': 'category/FETCH_CATEGORIES_FAILED' | ||
|
||
} |
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,26 +1,22 @@ | ||
import { compose, createStore, applyMiddleware } from "redux"; | ||
import { persistStore, persistReducer } from "redux-persist"; | ||
import logger from "redux-logger"; | ||
import { rootReducer } from "./root-reducer"; | ||
import storage from "redux-persist/lib/storage"; | ||
import thunk from "redux-thunk"; | ||
|
||
|
||
const loggerMiddleware = (store) => (next) => (action) => { | ||
console.log(store) | ||
|
||
if (!action.type) { | ||
return next(action); | ||
} | ||
|
||
console.log('type', action.type) | ||
console.log('payload', action.payload) | ||
console.log('currentState', store.getState()) | ||
|
||
next(action); | ||
console.log('nextState', store.getState()) | ||
|
||
const persistConfig = { | ||
key: 'root', | ||
storage, | ||
whitelist: ['cart'] | ||
} | ||
|
||
const middleWares = [logger] | ||
const persistedReducer = persistReducer(persistConfig, rootReducer); | ||
const middleWares = [process.env.NODE_ENV === 'development' && logger, thunk].filter(Boolean) | ||
|
||
const composeEnhancer = (process.env.NODE_ENV !== 'production' && window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose; | ||
const composeEnhancers = composeEnhancer(applyMiddleware(...middleWares)) | ||
|
||
const composeEnhancers = compose(applyMiddleware(...middleWares)) | ||
export const store = createStore(persistedReducer, undefined, composeEnhancers) | ||
|
||
export const store = createStore(rootReducer, undefined, composeEnhancers) | ||
export const persistor = persistStore(store) |
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