diff --git a/src/routes.js b/src/routes.js index 0105581..b6704bd 100644 --- a/src/routes.js +++ b/src/routes.js @@ -154,7 +154,6 @@ import ViewRetailDistributorPD from "./views/PrincipalDistributors/ViewRetailDis import MapRD from "./views/RetailDistributors/MapRD"; import PendingOrders from "./views/orders/pendingOrders"; import ViewInvoices from "./views/orders/viewInoices"; -import Stocks from "./views/PrincipalDistributors/Stock"; import SingleDistributorOrder from "./views/RetailDistributors/DistributorOrders"; import DistributorStocks from "./views/RetailDistributors/DistributorStock"; const routes = [ @@ -440,12 +439,6 @@ const routes = [ element: ViewRetailDistributorPD, navName: "PrincipalDistributor", }, - { - path: "/pd-stock/:id", - name: "view Stock", - element: Stocks, - navName: "PrincipalDistributor", - }, //Inventory { path: "/inventory", diff --git a/src/views/PrincipalDistributors/Stock.js b/src/views/PrincipalDistributors/Stock.js deleted file mode 100644 index cc743da..0000000 --- a/src/views/PrincipalDistributors/Stock.js +++ /dev/null @@ -1,513 +0,0 @@ -import React, { useState, useEffect, useRef, useCallback } from "react"; -import { Link, useParams } from "react-router-dom"; -import axios from "axios"; -import Button from "@material-ui/core/Button"; -import { useNavigate } from "react-router-dom"; -import { isAutheticated } from "src/auth"; -import swal from "sweetalert"; -import debounce from "lodash.debounce"; -import { Typography } from "@mui/material"; -const Stocks = () => { - const token = isAutheticated(); - const navigate = useNavigate(); - const { id } = useParams(); - const [loading, setLoading] = useState(false); - const [productsData, setProductsData] = useState([]); - const [categories, setCategories] = useState([]); - const [brands, setBrands] = useState([]); - const [user, setUser] = useState(null); - - const nameRef = useRef(); - const categoryRef = useRef(); - const brandRef = useRef(); - - const [currentPage, setCurrentPage] = useState(1); - const [itemPerPage, setItemPerPage] = useState(10); - const [totalData, setTotalData] = useState(0); - // Fetch User Details - const getUserDetails = useCallback(async () => { - try { - const response = await axios.get(`/api/v1/admin/user/${id}`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - setUser(response.data.user); - } catch (error) { - swal({ - title: "Warning", - text: error.message, - icon: "error", - button: "Close", - dangerMode: true, - }); - } - }, [id, token]); - - // Call getUserDetails on component mount - useEffect(() => { - getUserDetails(); - }, [getUserDetails]); - - const getProductsData = async () => { - setLoading(true); - try { - const response = await axios.get(`/api/pd/stock/${id}`, { - headers: { - Authorization: `Bearer ${token}`, - }, - params: { - page: currentPage, - show: itemPerPage, - name: nameRef.current?.value || "", - category: categoryRef.current?.value || "", - brand: brandRef.current?.value || "", - }, - }); - // console.log(response.data); - setProductsData(response.data?.products || []); - setTotalData(response.data?.totalProducts || 0); - } catch (err) { - const msg = err?.response?.data?.msg || "Something went wrong!"; - swal({ - title: "Error", - text: msg, - icon: "error", - button: "Retry", - dangerMode: true, - }); - } finally { - setLoading(false); - } - }; - - const getCatagories = () => { - axios - .get(`/api/category/getCategories`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - // console.log(res?.data?.categories); - setCategories(res?.data?.categories); - }); - }; - const getBrands = () => { - axios - .get(`/api/brand/getBrands`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - // console.log(res?.data?.brands); - setBrands(res?.data?.brands); - }); - }; - - const [currencyDetails, setCurrencyDetails] = useState(null); - - const getCurrency = async () => { - try { - const response = await axios.get("/api/currency/getall", { - // headers: { - // Authorization: `Bearer ${token}`, - // }, - }); - - if (response.status === 200) { - setCurrencyDetails(response?.data?.currency[0]); - } - } catch (error) { - console.log(error); - } - }; - useEffect(() => { - getCatagories(); - getCurrency(); - getBrands(); - }, []); - - useEffect(() => { - getProductsData(); - }, [itemPerPage, currentPage]); - - const debouncedSearch = useCallback( - debounce(() => { - setCurrentPage(1); - getProductsData(); - }, 500), - [] - ); - - const handleSearchChange = () => { - debouncedSearch(); - }; - return ( -
-
-
-
-
-
-
- {[ - { label: "Id", value: user?.uniqueId }, - { label: "SBU", value: user?.SBU }, - { label: "Name", value: user?.name }, - ].map((item, index) => ( - - {item.label}: - - {item.value} - - - ))} -
- - {/* Right side: Email, Mobile Number */} -
- {[ - { label: "Email", value: user?.email }, - { label: "Mobile Number", value: user?.phone }, - ].map((item, index) => ( - - {item.label}: - - {item.value} - - - ))} -
- - {/* Back Button on the right */} -
- - - -
-
- {/* Section Heading: Product Stocks */} -
-
-
- Product Stocks -
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
- - -
-
- - -
-
- - -
-
- -
- - - - - - - - - - - - - - - - {loading ? ( - - - - ) : productsData?.length > 0 ? ( - productsData?.map((product, i) => { - return ( - - - - - - - - - - - ); - }) - ) : ( - !loading && - productsData?.length === 0 && ( - - - - ) - )} - -
ImageSKUProductCategory NameBrand NamePriceAdded OnStock
- Loading... -
- {product?.image && - product?.image?.length !== 0 ? ( - <> - preview - - ) : ( -
-

No

-

image

-

uploaded!

-
- )} -
{product.SKU}{product.name} - {product.category !== "" - ? product.category - : "Category Not selected "} - - {product.brand !== "" - ? product.brand - : "Brand Not selected "} - - {currencyDetails?.CurrencySymbol} - {product?.price} - - {new Date(product.createdAt).toLocaleString( - "en-IN", - { - weekday: "short", - month: "short", - day: "numeric", - year: "numeric", - hour: "numeric", - minute: "numeric", - hour12: true, - } - )} - {product.stock}
-
No Product Available...
-
-
- -
-
-
- Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "} - {Math.min(currentPage * itemPerPage, totalData)} of{" "} - {totalData} entries -
-
- -
-
-
    -
  • - setCurrentPage((prev) => prev - 1)} - disabled={loading} - > - Previous - -
  • - - {!(currentPage - 1 < 1) && ( -
  • - - setCurrentPage((prev) => prev - 1) - } - disabled={loading} - > - {currentPage - 1} - -
  • - )} - -
  • - - {currentPage} - -
  • - - {!( - (currentPage + 1) * itemPerPage - itemPerPage > - totalData - 1 - ) && ( -
  • - { - setCurrentPage((prev) => prev + 1); - }} - disabled={loading} - > - {currentPage + 1} - -
  • - )} - -
  • - totalData - 1 - ) - ? "paginate_button page-item next" - : "paginate_button page-item next disabled" - } - > - setCurrentPage((prev) => prev + 1)} - disabled={loading} - > - Next - -
  • -
-
-
-
-
-
-
-
-
-
-
- ); -}; - -export default Stocks; diff --git a/src/views/RetailDistributors/SingleRetailDistributor.js b/src/views/RetailDistributors/SingleRetailDistributor.js index 7d03fb4..0ead6d3 100644 --- a/src/views/RetailDistributors/SingleRetailDistributor.js +++ b/src/views/RetailDistributors/SingleRetailDistributor.js @@ -87,6 +87,9 @@ useEffect(() => { + + Unique Id: {retailerDetails.uniqueId} + Trade Name: {retailerDetails.kyc.trade_name} @@ -94,13 +97,19 @@ useEffect(() => { Name: {retailerDetails.name} + Mobile Number: {retailerDetails.mobile_number} + + + Email: {retailerDetails.email} + + + + Address: {retailerDetails.kyc.address} Town/City: {retailerDetails.kyc.city} - - District: {retailerDetails.kyc.district} @@ -110,9 +119,6 @@ useEffect(() => { Pincode: {retailerDetails.kyc.pincode} - - Mobile Number: {retailerDetails.mobile_number} - Mapped Principal Distributor:{" "} {retailerDetails?.principal_distributer?.name || "Not Mapped"}