diff --git a/src/redux/actions/config.js b/src/redux/actions/config.js new file mode 100644 index 0000000..5308980 --- /dev/null +++ b/src/redux/actions/config.js @@ -0,0 +1,10 @@ +import proxy from "../proxy"; + +const config = { + getBottomNavigation: + (data = {}) => + async (dispatch) => + await proxy.get("config/bottomNavigations", data, { dispatch }), +}; + +export default config; diff --git a/src/redux/actions/index.js b/src/redux/actions/index.js index f95dc9e..01859a6 100644 --- a/src/redux/actions/index.js +++ b/src/redux/actions/index.js @@ -16,4 +16,5 @@ export { default as transport } from "./transport"; export { default as activation } from "./activation"; export { default as form } from "./form"; export { default as comment } from "./comment"; -export { default as vote } from "./vote"; \ No newline at end of file +export { default as vote } from "./vote"; +export { default as config } from "./config"; \ No newline at end of file diff --git a/src/redux/reducers/config.js b/src/redux/reducers/config.js new file mode 100644 index 0000000..880bc55 --- /dev/null +++ b/src/redux/reducers/config.js @@ -0,0 +1,25 @@ +const initialState = { + loading: false, + error: null, + bottomNavigations: null, +}; + +export default function config(state = initialState, action) { + let { type, data } = action; + switch (type) { + case "config/bottomNavigations": + console.log(data); + return { + ...state, + loading: false, + bottomNavigations: data, + error: null, + }; + case "config/loading": + return { ...state, loading: true }; + case "config/error": + return { ...state, loading: false, error: data.message }; + default: + return state; + } +} \ No newline at end of file diff --git a/src/redux/reducers/index.js b/src/redux/reducers/index.js index fa70dad..8369fa4 100644 --- a/src/redux/reducers/index.js +++ b/src/redux/reducers/index.js @@ -15,4 +15,5 @@ export { default as transport } from "./transport"; export { default as activation } from "./activation"; export { default as form } from "./form"; export { default as comment } from "./comment"; -export { default as vote } from "./vote"; \ No newline at end of file +export { default as vote } from "./vote"; +export { default as config } from "./config"; \ No newline at end of file diff --git a/src/screens/Products/components/Header.js b/src/screens/Products/components/Header.js index 95fc3f8..aa8682c 100644 --- a/src/screens/Products/components/Header.js +++ b/src/screens/Products/components/Header.js @@ -19,7 +19,7 @@ const Header = ({ setFilterOptions, filterOptions, levels, productTypes }) => { value={filterOptions.search} /> - {/* @@ -38,7 +38,7 @@ const Header = ({ setFilterOptions, filterOptions, levels, productTypes }) => { : setFilterOptions({ ...filterOptions, [name]: null }) } options={Object.values(levels)} - width={"100%"} + width={"48%"} name="grade" /> diff --git a/src/screens/Splash/index.js b/src/screens/Splash/index.js index f4a6a4d..29bd8d6 100644 --- a/src/screens/Splash/index.js +++ b/src/screens/Splash/index.js @@ -9,7 +9,13 @@ import { } from "react-native"; import AsyncStorage from "@react-native-async-storage/async-storage"; import { connect } from "react-redux"; -import { blog, book, userProduct, publicApi } from "../../redux/actions"; +import { + blog, + book, + userProduct, + publicApi, + config, +} from "../../redux/actions"; import { useIsFocused } from "@react-navigation/native"; import Logo from "../../assets/images/logo.png"; @@ -30,6 +36,8 @@ function Splash({ userProducts, getUserProducts, setIsDark, + getBottomNavigation, + bottomNavigation, }) { const isFocused = useIsFocused(); const [out, setOut] = React.useState(false); @@ -63,12 +71,14 @@ function Splash({ routes: [{ name: "Login" }], }); } else { - if (blogs.length === 0) { + if (!blogs.length) { getBlogs(); - } else if (books.length === 0) { + } else if (!books.length) { getBooks({ vod: true }); - } else if (userProducts.length === 0) { + } else if (!userProducts.length) { getUserProducts(); + } else if (!bottomNavigation) { + getBottomNavigation(); } else { setOutHandler(true); navigation.reset({ @@ -78,7 +88,7 @@ function Splash({ } } } - }, [isLogin, books, userProducts, blogs]); + }, [isLogin, books, userProducts, blogs, bottomNavigation]); // if (isFocused && out) { // setOutHandler(false); @@ -139,6 +149,7 @@ const mapStateToProps = (state) => ({ books: state.book.list, userProducts: state.userProduct.list, theme: state.publicApi.theme, + bottomNavigation: state.config.bottomNavigation, }); const mapDispatchToProps = { @@ -146,6 +157,7 @@ const mapDispatchToProps = { getBooks: book.list, getUserProducts: userProduct.list, setIsDark: publicApi.setIsDark, + getBottomNavigation: config.getBottomNavigation, }; export default connect(mapStateToProps, mapDispatchToProps)(Splash);