Products.js
76 lines
| 1 | /** |
| 2 | * External Dependencies |
| 3 | */ |
| 4 | import { Box, Heading, SimpleGrid, Stack } from "@chakra-ui/react"; |
| 5 | import { __ } from "@wordpress/i18n"; |
| 6 | import React, { useContext, useEffect } from "react"; |
| 7 | |
| 8 | /** |
| 9 | * Internal Dependencies |
| 10 | */ |
| 11 | import { PLUGINS, THEMES } from "../../Constants/Products"; |
| 12 | import ProductCard from "./components/ProductCard"; |
| 13 | import DashboardContext from "./../../context/DashboardContext"; |
| 14 | import { actionTypes } from "../../reducers/DashboardReducer"; |
| 15 | |
| 16 | const Products = () => { |
| 17 | const { plugins, themes } = |
| 18 | typeof _EVF_DASHBOARD_ !== "undefined" && _EVF_DASHBOARD_; |
| 19 | const [{ pluginsStatus, themesStatus }, dispatch] = |
| 20 | useContext(DashboardContext); |
| 21 | useEffect(() => { |
| 22 | dispatch( |
| 23 | { |
| 24 | type: actionTypes.GET_PLUGINS_STATUS, |
| 25 | pluginsStatus: plugins, |
| 26 | }, |
| 27 | { |
| 28 | type: actionTypes.GET_THEMES_STATUS, |
| 29 | themeStatus: themes, |
| 30 | } |
| 31 | ); |
| 32 | }, [pluginsStatus, themesStatus]); |
| 33 | return ( |
| 34 | <Stack my="8" mx="6"> |
| 35 | <Box> |
| 36 | <Heading size="md" fontSize="xl" fontWeight="semibold" mb="8"> |
| 37 | {__("Plugins", "everest-forms")} |
| 38 | </Heading> |
| 39 | <SimpleGrid |
| 40 | columns={{ base: 1, md: 2, lg: 3, xl: 4 }} |
| 41 | spacing="5" |
| 42 | > |
| 43 | {PLUGINS.map((plugin) => ( |
| 44 | <ProductCard |
| 45 | key={plugin.slug} |
| 46 | {...plugin} |
| 47 | pluginsStatus={pluginsStatus} |
| 48 | themesStatus={themesStatus} |
| 49 | /> |
| 50 | ))} |
| 51 | </SimpleGrid> |
| 52 | </Box> |
| 53 | <Box> |
| 54 | <Heading size="md" fontSize="xl" fontWeight="semibold" my="8"> |
| 55 | {__("Themes", "everest-forms")} |
| 56 | </Heading> |
| 57 | <SimpleGrid |
| 58 | columns={{ base: 1, md: 2, lg: 3, xl: 4 }} |
| 59 | spacing="5" |
| 60 | > |
| 61 | {THEMES.map((theme) => ( |
| 62 | <ProductCard |
| 63 | key={theme.slug} |
| 64 | {...theme} |
| 65 | pluginsStatus={pluginsStatus} |
| 66 | themesStatus={themesStatus} |
| 67 | /> |
| 68 | ))} |
| 69 | </SimpleGrid> |
| 70 | </Box> |
| 71 | </Stack> |
| 72 | ); |
| 73 | }; |
| 74 | |
| 75 | export default Products; |
| 76 |