diff --git a/src/_nav.js b/src/_nav.js
index 69db563..95574c7 100644
--- a/src/_nav.js
+++ b/src/_nav.js
@@ -6,6 +6,7 @@ import {
cilBell,
cilCalculator,
cilChartPie,
+ cilClipboard,
cilCommand,
cilCursor,
cilDrop,
@@ -38,7 +39,12 @@ const _nav = [
},
-
+ {
+ component: CNavItem,
+ name: 'Products',
+ icon: ,
+ to: '/products',
+ },
{
component: CNavItem,
name: 'Temples',
diff --git a/src/index.js b/src/index.js
index 62a8094..bc52aee 100644
--- a/src/index.js
+++ b/src/index.js
@@ -12,7 +12,7 @@ import axios from 'axios'
const setupAxios = () => {
axios.defaults.baseURL = 'https://atpapi.checkapp.one'
- //axios.defaults.baseURL = 'http://localhost:5000'
+ // axios.defaults.baseURL = 'http://localhost:5000'
axios.defaults.headers = {
'Cache-Control': 'no-cache,no-store',
'Pragma': 'no-cache',
diff --git a/src/routes.js b/src/routes.js
index fa3f33a..c8cae34 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -26,6 +26,7 @@ import Login from './views/pages/login/Login'
import Temples from './views/Temples/Temples'
import AddTemple from './views/Temples/AddTemple'
import EditTemple from './views/Temples/EditTemple'
+import Products from './views/Products/Products'
const routes = [
@@ -33,6 +34,13 @@ const routes = [
{ path: '/change_password', name: 'Change Password', element: Change_Password },
{ path: '/profile/edit', name: 'Edit Profile', element: EditProfile },
// { path: '/profile', name: 'Profile', element: Profile },
+
+
+ //Product
+ { path: '/products', name: 'products', element: Products },
+ { path: '/product/add', name: 'Add products', element: AddTemple },
+ { path: '/products/edit/:id', name: 'Edit products', element: EditTemple },
+
//Temple
{ path: '/temples', name: 'Temples', element: Temples },
{ path: '/temple/add', name: 'Add Temple', element: AddTemple },
diff --git a/src/views/Products/AddProduct.js b/src/views/Products/AddProduct.js
new file mode 100644
index 0000000..0b04d79
--- /dev/null
+++ b/src/views/Products/AddProduct.js
@@ -0,0 +1 @@
+rafce
diff --git a/src/views/Products/Products.js b/src/views/Products/Products.js
new file mode 100644
index 0000000..441f730
--- /dev/null
+++ b/src/views/Products/Products.js
@@ -0,0 +1,384 @@
+import React, { useState, useEffect } from 'react'
+import { Link } from 'react-router-dom'
+import Button from '@material-ui/core/Button'
+import { useNavigate } from 'react-router-dom'
+import axios from 'axios'
+import { isAutheticated } from 'src/auth'
+
+const Products = () => {
+ const token = isAutheticated()
+ const navigate = useNavigate()
+ const [loading, setLoading] = useState(true)
+ const [success, setSuccess] = useState(true)
+ const [productsData, setProductsData] = useState([])
+
+ const [currentPage, setCurrentPage] = useState(1)
+ const [itemPerPage, setItemPerPage] = useState(10)
+ const [showData, setShowData] = useState(productsData)
+
+ const handleShowEntries = (e) => {
+ setCurrentPage(1)
+ setItemPerPage(e.target.value)
+ }
+
+ const getProductsData = async () => {
+ axios
+ .get(`/api/product`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ .then((res) => {
+ setProductsData(res.data?.data)
+ setLoading(false)
+ })
+ .catch((err) => {
+ setLoading(false)
+ })
+ }
+
+ useEffect(() => {
+ getProductsData()
+ }, [success])
+
+ useEffect(() => {
+ const loadData = () => {
+ const indexOfLastPost = currentPage * itemPerPage
+ const indexOfFirstPost = indexOfLastPost - itemPerPage
+ setShowData(productsData.slice(indexOfFirstPost, indexOfLastPost))
+ }
+ loadData()
+ }, [currentPage, itemPerPage, productsData])
+
+ const handleDelete = (id) => {
+ swal({
+ title: 'Are you sure?',
+ icon: 'error',
+ buttons: { Yes: { text: 'Yes', value: true }, Cancel: { text: 'Cancel', value: 'cancel' } },
+ }).then((value) => {
+ if (value === true) {
+ axios
+ .delete(`/api/product/${id}`, {
+ headers: {
+ 'Access-Control-Allow-Origin': '*',
+ Authorization: `Bearer ${token}`,
+ },
+ })
+ .then((res) => {
+ setSuccess((prev) => !prev)
+ })
+ .catch((err) => {
+ swal({
+ title: 'Warning',
+ text: 'Something went wrong!',
+ icon: 'error',
+ button: 'Retry',
+ dangerMode: true,
+ })
+ })
+ }
+ })
+ }
+
+ return (
+
+
+
+
+
+
+
+ Products
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Product Name |
+ Category |
+ Preview |
+ Master Price |
+ Added On |
+ Actions |
+
+
+
+ {!loading && showData.length === 0 && (
+
+
+ No Data Available
+ |
+
+ )}
+ {loading ? (
+
+
+ Loading...
+ |
+
+ ) : (
+ showData.map((product, i) => {
+ return (
+
+ {product.name} |
+ {product.category?.name} |
+
+ {product?.images && (
+ <>
+
+ >
+ )}
+ |
+ ₹ {product.master_price} |
+
+ {new Date(product.createdAt).toLocaleString('en-IN', {
+ weekday: 'short',
+ month: 'short',
+ day: 'numeric',
+ year: 'numeric',
+ hour: 'numeric',
+ minute: 'numeric',
+ hour12: true,
+ })}
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+ )
+ })
+ )}
+
+
+
+
+
+
+
+ Showing {currentPage * itemPerPage - itemPerPage + 1} to{' '}
+ {Math.min(currentPage * itemPerPage, productsData.length)} of{' '}
+ {productsData.length} entries
+
+
+
+
+
+
+ -
+ setCurrentPage((prev) => prev - 1)}
+ >
+ Previous
+
+
+
+ {!(currentPage - 1 < 1) && (
+ -
+ setCurrentPage((prev) => prev - 1)}
+ >
+ {currentPage - 1}
+
+
+ )}
+
+ -
+
+ {currentPage}
+
+
+
+ {!(
+ (currentPage + 1) * itemPerPage - itemPerPage >
+ productsData.length - 1
+ ) && (
+ -
+ {
+ setCurrentPage((prev) => prev + 1)
+ }}
+ >
+ {currentPage + 1}
+
+
+ )}
+
+ -
+ productsData.length - 1
+ )
+ ? 'paginate_button page-item next'
+ : 'paginate_button page-item next disabled'
+ }
+ >
+ setCurrentPage((prev) => prev + 1)}
+ >
+ Next
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default Products