diff --git a/src/_nav.js b/src/_nav.js
index 42636d6..5ae6421 100644
--- a/src/_nav.js
+++ b/src/_nav.js
@@ -104,6 +104,13 @@ const _nav = [
to: "/retail-distributor",
group: "RetailDistributor",
},
+ {
+ component: CNavItem,
+ name: "Opening Inventory",
+ icon: ,
+ to: "/opening-inventory",
+ group: "OpeningInventory",
+ },
{
component: CNavItem,
name: "Attendance",
@@ -118,13 +125,13 @@ const _nav = [
to: "/leaves/today",
group: "Leaves",
},
- {
- component: CNavItem,
- name: "Tasks",
- icon: ,
- to: "/task/today",
- group: "Tasks",
- },
+ // {
+ // component: CNavItem,
+ // name: "Tasks",
+ // icon: ,
+ // to: "/task/today",
+ // group: "Tasks",
+ // },
{
component: CNavItem,
name: "Inventory Data",
diff --git a/src/routes.js b/src/routes.js
index f4fd360..0cbbe0d 100644
--- a/src/routes.js
+++ b/src/routes.js
@@ -165,6 +165,7 @@ import TodayTask from "./views/Tasks/TodayTasks";
import Sales from "./views/Sales/Sales";
import SingleSales from "./views/Sales/SingleSale";
import MobileApp from "./views/configuration/MobileApp";
+import PDOpeningInventory from "./views/OpeningInventory/PDOpeningInventory";
const routes = [
//dashboard
@@ -412,7 +413,7 @@ const routes = [
navName: "Distributor",
},
{
- path: "/:distributortype/stocks/:id",
+ path: "/:distributortype/:stocks/:id",
name: " Distributor Stocks",
element: DistributorStocks,
navName: "Distributor",
@@ -662,7 +663,20 @@ const routes = [
navName: "Website Related",
},
//-------------------------------End website related routes----------------------------------
-
+//-------------------------------Opening Inventory routes----------------------------------
+{
+ path: "/opening-inventory",
+ name: "Opening Inventory",
+ element: PDOpeningInventory,
+ navName: "Opening Inventory",
+},
+{
+ path: "/opening-inventory/pd/:id",
+ name: "Opening Inventory",
+ element: PDOpeningInventory,
+ navName: "Opening Inventory",
+},
+//-------------------------------End Opening Inventory routes----------------------------------
//--------------Order Management Routes---------------------------------------
{
path: "/orders/new",
diff --git a/src/views/OpeningInventory/PDOpeningInventory.js b/src/views/OpeningInventory/PDOpeningInventory.js
new file mode 100644
index 0000000..3a3d58d
--- /dev/null
+++ b/src/views/OpeningInventory/PDOpeningInventory.js
@@ -0,0 +1,304 @@
+import React, { useState, useEffect, useRef, useCallback } from "react";
+import { Link } from "react-router-dom";
+import axios from "axios";
+import { isAutheticated } from "src/auth";
+import swal from "sweetalert";
+import debounce from "lodash.debounce";
+const PDOpeningInventory = () => {
+ const token = isAutheticated();
+ const [loading, setLoading] = useState(true);
+ const [users, setUsers] = useState([]);
+ const [totalPages, setTotalPages] = useState(1);
+ const [currentPage, setCurrentPage] = useState(1);
+ const [itemPerPage, setItemPerPage] = useState(10);
+ const [totalData, setTotalData] = useState(0);
+ const nameRef = useRef();
+ const SBURef = useRef();
+ const getUsers = async () => {
+ setLoading(true);
+ try {
+ const res = await axios.get(`/api/allpd/stock`, {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ params: {
+ page: currentPage,
+ show: itemPerPage,
+ name: nameRef.current.value,
+ SBU: SBURef.current.value,
+ },
+ });
+ // console.log(res.data);
+ setUsers(res?.data?.data);
+ setTotalData(res.data?.pagination?.totalRecords);
+ setTotalPages(res.data?.pagination?.totalPages);
+ } catch (error) {
+ swal({
+ title: error,
+ text: "please login to access the resource or refresh the page ",
+ icon: "error",
+ button: "Retry",
+ dangerMode: true,
+ });
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ useEffect(() => {
+ getUsers();
+ }, [itemPerPage, currentPage]);
+
+ const debouncedSearch = useCallback(
+ debounce(() => {
+ setCurrentPage(1);
+ getUsers();
+ }, 500),
+ []
+ );
+
+ const handleSearchChange = () => {
+ debouncedSearch();
+ };
+
+
+ return (
+
+
+
+
+
+
+
+ Principal Distributor Opening Inventory
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Unique Id |
+ SBU |
+ Name |
+ Email |
+ Mobile Nmuber |
+ Date Registered |
+
+ Opening Inventory
+ |
+
+
+
+ {loading ? (
+
+
+ Loading....
+ |
+
+ ) : users.length > 0 ? (
+ users.map((user, i) => (
+
+ {user?.userId.uniqueId} |
+ {user.userId.SBU ? user.userId.SBU : "N/A"} |
+ {user.userId.name} |
+ {user.userId.email} |
+ {user.userId.phone} |
+
+ {new Date(user.createdAt).toLocaleString(
+ "en-IN",
+ {
+ // weekday: "short",
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ // hour: "numeric",
+ // minute: "numeric",
+ // hour12: true,
+ }
+ )}
+ |
+
+
+
+
+ |
+
+ ))
+ ) : (
+
+
+ No Principal Distributor found!
+ |
+
+ )}
+
+
+
+
+
+
+
+ Showing {users?.length} of {totalData} entries
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+
+export default PDOpeningInventory;
diff --git a/src/views/RetailDistributors/DistributorStock.js b/src/views/RetailDistributors/DistributorStock.js
index f3fefbc..278017d 100644
--- a/src/views/RetailDistributors/DistributorStock.js
+++ b/src/views/RetailDistributors/DistributorStock.js
@@ -12,6 +12,7 @@ const DistributorStocks = () => {
const navigate = useNavigate();
const { id } = useParams();
const { distributortype } = useParams();
+ const { stocks } = useParams();
const [loading, setLoading] = useState(false);
const [productsData, setProductsData] = useState([]);
const [categories, setCategories] = useState([]);
@@ -159,7 +160,7 @@ const DistributorStocks = () => {
const handleCancel = () => {
navigate(
distributortype === "principaldistributor"
- ? "/principal-distributor"
+ ? stocks==="stocks"?"/principal-distributor":"/opening-inventory"
: "/retail-distributor"
);
};