From 67928e0cb7eb1c7e61dd709c8c894563c8eae31a Mon Sep 17 00:00:00 2001 From: Sibunnayak Date: Fri, 12 Jul 2024 15:48:02 +0530 Subject: [PATCH] blogs,salescoordinator,settings and product managment fixed --- package.json | 4 +- src/_nav.js | 290 +--- src/index.js | 3 +- src/routes.js | 262 +--- src/views/Banner/banner.js | 707 ---------- src/views/Charts/CityRevenue.js | 200 --- src/views/Charts/OrderDaywise.js | 195 --- src/views/Charts/ProductRevenue.js | 213 --- src/views/Charts/RevenueCharts.js | 199 --- src/views/Charts/Staterevenue.js | 200 --- src/views/Charts/UserChart.js | 200 --- .../ContactRequests/AddContactRequest.js | 221 --- src/views/ContactRequests/ContactRequests.js | 338 ----- src/views/CustomerSupport/CloseRequestView.js | 207 --- .../CustomerSupport/EmailCMS/EmailCms.js | 111 -- .../EmailCMS/RegistrationEmail.js | 207 --- src/views/CustomerSupport/MessageList.js | 32 - src/views/CustomerSupport/SupportReply.js | 346 ----- src/views/CustomerSupport/SupportRequest.js | 428 ------ .../CustomerSupport/SupportRequestClosed.js | 379 ----- src/views/Home/editPanel1.js | 394 ------ src/views/Home/editPanel2.js | 409 ------ src/views/Home/editPanel3.js | 407 ------ src/views/Home/editPanel4.js | 402 ------ src/views/Home/home.js | 165 --- src/views/Images/ShopImage.js | 706 ---------- src/views/Patients/Patient.js | 650 --------- src/views/Patients/ViewPatient.js | 263 ---- .../PointOfSale/AddressSelectionModal.js | 77 - src/views/PointOfSale/Pos.js | 1242 ----------------- .../Productcomponents/ProductDetails.js | 2 +- src/views/Products/ViewProduct.js | 2 +- .../SalesCoOrdinators/AddSalesCoOrdinator.js | 189 +++ .../SalesCoOrdinators/EditSalesCoOrdinator.js | 395 ++++++ .../SalesCoOrdinators/SalesCoOrdinator.js | 428 ++++++ src/views/configuration/Currency.js | 190 +-- src/views/configuration/Logo.js | 17 +- src/views/configuration/Web_Images.js | 423 ------ src/views/configuration/tax/Addtax.js | 6 +- src/views/configuration/tax/Edittax.js | 4 +- src/views/configuration/tax/Tax.js | 4 +- src/views/orders/POSViewOrders.js | 945 ------------- src/views/orders/PrintOrderDetails.js | 2 +- 43 files changed, 1175 insertions(+), 10889 deletions(-) delete mode 100644 src/views/Banner/banner.js delete mode 100644 src/views/Charts/CityRevenue.js delete mode 100644 src/views/Charts/OrderDaywise.js delete mode 100644 src/views/Charts/ProductRevenue.js delete mode 100644 src/views/Charts/RevenueCharts.js delete mode 100644 src/views/Charts/Staterevenue.js delete mode 100644 src/views/Charts/UserChart.js delete mode 100644 src/views/ContactRequests/AddContactRequest.js delete mode 100644 src/views/ContactRequests/ContactRequests.js delete mode 100644 src/views/CustomerSupport/CloseRequestView.js delete mode 100644 src/views/CustomerSupport/EmailCMS/EmailCms.js delete mode 100644 src/views/CustomerSupport/EmailCMS/RegistrationEmail.js delete mode 100644 src/views/CustomerSupport/MessageList.js delete mode 100644 src/views/CustomerSupport/SupportReply.js delete mode 100644 src/views/CustomerSupport/SupportRequest.js delete mode 100644 src/views/CustomerSupport/SupportRequestClosed.js delete mode 100644 src/views/Home/editPanel1.js delete mode 100644 src/views/Home/editPanel2.js delete mode 100644 src/views/Home/editPanel3.js delete mode 100644 src/views/Home/editPanel4.js delete mode 100644 src/views/Home/home.js delete mode 100644 src/views/Images/ShopImage.js delete mode 100644 src/views/Patients/Patient.js delete mode 100644 src/views/Patients/ViewPatient.js delete mode 100644 src/views/PointOfSale/AddressSelectionModal.js delete mode 100644 src/views/PointOfSale/Pos.js create mode 100644 src/views/SalesCoOrdinators/AddSalesCoOrdinator.js create mode 100644 src/views/SalesCoOrdinators/EditSalesCoOrdinator.js create mode 100644 src/views/SalesCoOrdinators/SalesCoOrdinator.js delete mode 100644 src/views/configuration/Web_Images.js delete mode 100644 src/views/orders/POSViewOrders.js diff --git a/package.json b/package.json index 3ad9df3..9602544 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@mui/material": "^5.11.12", "@reduxjs/toolkit": "^1.9.2", "axios": "^0.25.0", - "bootstrap": "^5.1.3", + "bootstrap": "^5.3.3", "chart.js": "^4.4.2", "country-state-city": "^3.2.1", "draft-js": "^0.11.7", @@ -56,7 +56,7 @@ "prop-types": "^15.7.2", "quill": "^1.3.7", "react": "18.0.0", - "react-bootstrap": "^2.7.0", + "react-bootstrap": "^2.10.4", "react-chartjs-2": "^5.2.0", "react-datepicker": "^4.25.0", "react-dom": "^18.0.0", diff --git a/src/_nav.js b/src/_nav.js index 445e5c5..222d86a 100644 --- a/src/_nav.js +++ b/src/_nav.js @@ -46,58 +46,6 @@ const _nav = [ group: "Customers", }, - // { - // component: CNavGroup, - // name: "Charts", - // icon: , - // group: "", - - // items: [ - // { - // component: CNavItem, - // name: "new user day wise", - // icon: , - // to: "/new-user-day-wise", - // group: "Charts", - // }, - // { - // component: CNavItem, - // name: "Revenue By Product", - // icon: , - // to: "/revenue-by-product", - // group: "Charts", - // }, - // { - // component: CNavItem, - // name: "Revenue By State", - // icon: , - // to: "/revenue-by-state", - // group: "Charts", - // }, - // { - // component: CNavItem, - // name: "Revenue By City", - // icon: , - // to: "/revenue-by-city", - // group: "Charts", - // }, - // { - // component: CNavItem, - // name: "Orders (Day Wise)", - // icon: , - // to: "/orders-day-wise", - // group: "Charts", - // }, - // { - // component: CNavItem, - // name: "Revenue (Day Wise)", - // icon: , - // to: "/revenue-day-wise", - // group: "Charts", - // }, - // ], - // }, - { component: CNavGroup, name: "Product Management", @@ -121,84 +69,84 @@ const _nav = [ }, { component: CNavItem, - name: "VAT", + name: "GST", icon: , - to: "/vat", + to: "/tax", group: "Product Management", }, ], }, { component: CNavItem, - name: "Patients", + name: "SalesCoOrdinator", icon: , - to: "/patients", - group: "Patients", + to: "/salescoordinators", + group: "SalesCoOrdinator", }, - // { - // component: CNavGroup, - // name: "Orders", - // icon: , - // group: "", + { + component: CNavGroup, + name: "Orders", + icon: , + group: "", - // items: [ - // { - // component: CNavItem, - // name: "New", - // icon: , - // to: "/orders/new", - // group: "Orders", - // }, - // // { - // // component: CNavItem, - // // name: "Paid", - // // icon: , - // // to: "/orders/returned", - // // }, - // { - // component: CNavItem, - // name: "Processing", - // icon: , - // to: "/orders/processing", - // group: "Orders", - // }, - // { - // component: CNavItem, - // name: "Dispatched", - // icon: , - // to: "/orders/dispatched", - // group: "Orders", - // }, - // { - // component: CNavItem, - // name: "Delivered", - // icon: , - // to: "/orders/delivered", - // group: "Orders", - // }, - // { - // component: CNavItem, - // name: "Cancelled", - // icon: , - // to: "/orders/cancelled", - // group: "Orders", - // }, - // { - // component: CNavItem, - // name: "In Store Cash Orders", - // icon: , - // to: "/inStoreCashOrders/new", - // group: "Orders", - // }, - // { - // component: CNavItem, - // name: "In Store QRCode Orders", - // icon: , - // to: "/InStoreQRCodeOrders/new", - // group: "Orders", - // }, - // ], - // }, + items: [ + { + component: CNavItem, + name: "New", + icon: , + to: "/orders/new", + group: "Orders", + }, + // { + // component: CNavItem, + // name: "Paid", + // icon: , + // to: "/orders/returned", + // }, + { + component: CNavItem, + name: "Processing", + icon: , + to: "/orders/processing", + group: "Orders", + }, + { + component: CNavItem, + name: "Dispatched", + icon: , + to: "/orders/dispatched", + group: "Orders", + }, + { + component: CNavItem, + name: "Delivered", + icon: , + to: "/orders/delivered", + group: "Orders", + }, + { + component: CNavItem, + name: "Cancelled", + icon: , + to: "/orders/cancelled", + group: "Orders", + }, + { + component: CNavItem, + name: "In Store Cash Orders", + icon: , + to: "/inStoreCashOrders/new", + group: "Orders", + }, + { + component: CNavItem, + name: "In Store QRCode Orders", + icon: , + to: "/InStoreQRCodeOrders/new", + group: "Orders", + }, + ], + }, { component: CNavGroup, name: "Settings", @@ -206,41 +154,6 @@ const _nav = [ group: "", items: [ - { - component: CNavItem, - name: "Banner", - icon: , - to: "/banner", - group: "Settings", - }, - // { - // component: CNavItem, - // name: "Register Image", - // icon: , - // to: "/registerImage", - // group: "Settings", - // }, - // { - // component: CNavItem, - // name: "Login Image", - // icon: , - // to: "/loginImage", - // group: "Settings", - // }, - // { - // component: CNavItem, - // name: "Shop Page Image", - // icon: , - // to: "/shopImage", - // group: "Settings", - // }, - { - component: CNavItem, - name: "Web Images", - icon: , - to: "/web_images", - group: "Settings", - }, // { // component: CNavItem, // name: "Testimonials", @@ -248,13 +161,6 @@ const _nav = [ // to: "/testimonials", // group: "Website Related", // }, - // { - // component: CNavItem, - // name: "Contact Requests", - // icon: , - // to: "/contact/request", - // group: "Website Related", - // }, // { // component: CNavItem, @@ -314,13 +220,6 @@ const _nav = [ to: "/copyright/message", group: "Settings", }, - { - component: CNavItem, - name: "Home", - icon: , - to: "/home", - group: "Settings", - }, ], }, // { @@ -358,43 +257,14 @@ const _nav = [ // ], // }, // //Affiliate end - // { - // component: CNavGroup, - // name: "Customer Service", - // icon: , - // group: "", - - // items: [ - // { - // component: CNavItem, - // name: "Customer Support", - // icon: , - // to: "/support/request", - // group: "Customer Service", - // }, - // { - // component: CNavItem, - // name: "Contact Requests", - // icon: , - // to: "/contact/request", - // group: "Customer Service", - // }, - // // { - // // component: CNavItem, - // // name: "Email CMS", - // // icon: , - // // to: "/email-cms", - // // }, - // ], - // }, - // //Blog start - // { - // component: CNavItem, - // name: "Blog", - // icon: , - // to: "/blogs", - // group: "Blog", - // }, + //Blog start + { + component: CNavItem, + name: "Blog", + icon: , + to: "/blogs", + group: "Blog", + }, // // Employee // { // component: CNavItem, @@ -403,14 +273,6 @@ const _nav = [ // to: "/employee", // group: "Employees & Access", // }, - // //Point of Sale start - // { - // component: CNavItem, - // name: "Point of Sale", - // icon: , - // to: "/pos", - // group: "Point of Sale", - // }, // { // component: CNavGroup, // name: "Blog", diff --git a/src/index.js b/src/index.js index a5e4809..b47a948 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ import "bootstrap/dist/css/bootstrap.min.css"; import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css"; import "react-app-polyfill/stable"; import "core-js"; +import 'bootstrap/dist/css/bootstrap.min.css'; import React from "react"; import ReactDOM from "react-dom"; import App from "./App"; @@ -14,7 +15,7 @@ import { cibGmail } from "@coreui/icons"; import { createRoot } from "react-dom/client"; const setupAxios = () => { - //axios.defaults.baseURL = "http://localhost:5000"; + // axios.defaults.baseURL = "http://localhost:5000"; axios.defaults.baseURL = "https://cheminova-api-2.onrender.com"; axios.defaults.headers = { diff --git a/src/routes.js b/src/routes.js index ff4451a..6852fc2 100644 --- a/src/routes.js +++ b/src/routes.js @@ -22,7 +22,6 @@ import Socialmedia from "./views/configuration/Socialmedia.js"; import Address from "./views/configuration/Address.js"; import Logo from "./views/configuration/Logo.js"; import Login from "./views/pages/login/Login"; -import Web_Images from "./views/configuration/Web_Images"; // Appointments import Appointments from "./views/Appointments/Appointments"; @@ -42,7 +41,6 @@ import DispatchedOrders from "./views/orders/DispatchedOrders.js"; import DeliveredOrders from "./views/orders/DeliveredOrders.js"; import CancelledOrders from "./views/orders/CancelledOrders.js"; import ReturnedOrders from "./views/orders/ReturnedOrders.js"; -import ViewOdr from "./views/orders/ViewOdr"; import AddOrder from "./views/orders/AddOrder"; //Taxes import Tax from "./views/configuration/tax/Tax"; @@ -57,8 +55,6 @@ import AddInformations from "./views/Informations/AddInformations"; import ApplicationName from "./views/configuration/ApplicationName"; import CopyrightMessage from "./views/configuration/CopyrightMessage"; -import ContactRequests from "./views/ContactRequests/ContactRequests"; -import AddContactRequest from "./views/ContactRequests/AddContactRequest"; import AddSeoRequest from "./views/seo/AddSeoRequest"; @@ -97,10 +93,8 @@ import EditAboutUs from "./views/Content/editAboutUs"; // import AddUserAddress from "./views/customerDetails/addUserAddress"; import viewDetails from "./views/customerDetails/viewDetails"; import Design from "./views/Design/design"; -import Banners from "./views/Banner/banner"; import RegisterImage from "./views/Images/RegisterImage"; import LoginImage from "./views/Images/LoginImage"; -import ShopImage from "./views/Images/ShopImage"; //Affiliate import Coupons from "./views/Affiliate/Coupons"; import Affiliates from "./views/Affiliate/Affiliates"; @@ -111,10 +105,6 @@ import EditCoupon from "./views/Affiliate/EditCoupon"; import PayAffiliate from "./views/Affiliate/PayAffiliate"; import AffiliateHistory from "./views/Affiliate/AffiliateHistory"; import CouponHistory from "./views/Affiliate/CouponHistory"; -import SupportRequest from "./views/CustomerSupport/SupportRequest"; -import SupportReply from "./views/CustomerSupport/SupportReply"; -import SupportRequestClosed from "./views/CustomerSupport/SupportRequestClosed"; -import CloseRequestView from "./views/CustomerSupport/CloseRequestView"; import EditTestimonial from "./views/Testimonials/EditTestimonial"; //Blogs import Blogs from "./views/Blog/Blogs"; @@ -122,37 +112,22 @@ import CreateBlog from "./views/Blog/CreateBlog"; import users from "./views/Users/users"; import UpdateBlog from "./views/Blog/EditBlog"; import ViewBlog from "./views/Blog/ViewBlog"; -import Home from "./views/Home/home"; -import EditPanel1 from "./views/Home/editPanel1"; -import EditPanel2 from "./views/Home/editPanel2"; -import EditPanel3 from "./views/Home/editPanel3"; -import Editpanel4 from "./views/Home/editPanel4"; import CustomerTable from "./views/customerDetails/customerTable"; import SingleUserAllDetails from "./views/customerDetails/singleUserAllDetails"; -import Charts from "./views/Charts/RevenueCharts"; -import UserCharts from "./views/Charts/UserChart"; -import ProductrevenueCharts from "./views/Charts/ProductRevenue"; -import StateRevenueCharts from "./views/Charts/Staterevenue"; -import CityRevenueCharts from "./views/Charts/CityRevenue"; + import { element } from "prop-types"; -import OrderdayChart from "./views/Charts/OrderDaywise"; -import RevenueCharts from "./views/Charts/RevenueCharts"; import AddCustomer from "./views/customerDetails/addCustomer"; -import Pos from "./views/PointOfSale/Pos"; import InStoreCashOrders from "./views/orders/InStoreCashOrders"; -import POSViewOrders from "./views/orders/POSViewOrders"; + import InStoreQRCodeOrders from "./views/orders/InStoreQRCodeOrders"; -import EmailCms from "./views/CustomerSupport/EmailCMS/EmailCms"; -import RegistrationEmail from "./views/CustomerSupport/EmailCMS/RegistrationEmail"; import Employee from "./views/EmployeeAccess/Employee"; import AddEmployee from "./views/EmployeeAccess/addEmployee"; import EditEmployee from "./views/EmployeeAccess/editEmployee"; -import ExportToExcel from "./views/exportExcel"; import Currency from "./views/configuration/Currency"; -import Patient from "./views/Patients/Patient"; -import ViewPatient from "./views/Patients/ViewPatient"; +import SalesCoOrdinator from "./views/SalesCoOrdinators/SalesCoOrdinator"; +import EditSalesCoOrdinator from "./views/SalesCoOrdinators/EditSalesCoOrdinator"; +import AddSalesCoOrdinator from "./views/SalesCoOrdinators/AddSalesCoOrdinator"; const routes = [ - // { path: "/", exact: true, name: "Home", navName: "" }, //dashboard { path: "/dashboard", name: "Dashboard", element: Dashboard, navName: "" }, @@ -169,44 +144,6 @@ const routes = [ navName: "", }, // { path: '/profile', name: 'Profile', element: Profile }, - //------------------Charts Routes------------------------------------ - { - path: "/new-user-day-wise", - name: "new user day wise", - element: UserCharts, - navName: "Charts", - }, - { - path: "/revenue-by-product", - name: "Revenue By Product", - element: ProductrevenueCharts, - navName: "Charts", - }, - { - path: "/revenue-by-state", - name: "Revenue By State", - element: StateRevenueCharts, - navName: "Charts", - }, - { - path: "/revenue-by-city", - name: "Revenue By City", - element: CityRevenueCharts, - navName: "Charts", - }, - { - path: "/orders-day-wise", - name: "Orders (Day Wise)", - element: OrderdayChart, - navName: "Charts", - }, - { - path: "/revenue-day-wise", - name: "Revenue (Day Wise)", - element: RevenueCharts, - navName: "Charts", - }, - //------------------ End Charts Routes------------------------------------ //-----------------------Product Management Routes------------------------------------------------ { path: "/products", @@ -240,20 +177,26 @@ const routes = [ }, { - path: "//patient/view/:id", - name: "View Patient", - element: ViewPatient, - navName: "Patients", + path: "/salescoordinator/edit/:id", + name: "Edit SalesCoOrdinator", + element: EditSalesCoOrdinator, + navName: "SalesCoOrdinators", }, { - path: "/patients", - name: "Patients", - element: Patient, - navName: "Patients", + path: "/salescoordinators", + name: "SalesCoOrdinators", + element: SalesCoOrdinator, + navName: "SalesCoOrdinators", + }, + { + path: "/salescoordinator/add", + name: "Add SalesCoOrdinators", + element: AddSalesCoOrdinator, + navName: "SalesCoOrdinators", }, //Gst tax { - path: "/vat", + path: "/tax", name: "Tax Rates", element: Tax, navName: "Product Management", @@ -383,70 +326,11 @@ const routes = [ // }, // { path: '/franchisee/view/:id', name: 'view franchisee', element: ViewFra }, - //Contact Requests - // ----------------Customer Service Routes------------------------------- - { - path: "/contact/request", - name: "Customer Service", - element: ContactRequests, - navName: "Customer Service", - }, - { - path: "/contact/request/new", - name: "Customer Service", - element: AddContactRequest, - navName: "Customer Service", - }, - //Support Requests - { - path: "/email-cms", - name: "CustomerSupport Requests", - element: EmailCms, - navName: "Customer Service", - }, - { - path: "/email-cms/registration-email", - name: "CustomerSupport Requests", - element: RegistrationEmail, - navName: "Customer Service", - }, - - { - path: "/support/request", - name: "Customer Service", - element: SupportRequest, - navName: "Customer Service", - }, - { - path: "/support/request/closed", - name: "Customer Service", - element: SupportRequestClosed, - navName: "Customer Service", - }, - { - path: "/support/request/closed/:ticketID", - name: "Customer Service", - element: CloseRequestView, - navName: "Customer Service", - }, - { - path: "/support/request/reply/:ticketID", - name: "Customer Service", - element: SupportReply, - navName: "Customer Service", - }, - // ---------------- End Customer Service Routes------------------------------- // { path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint }, //Complaints //-------------------------------website related routes---------------------------------- - { - path: "/banner", - name: "Banners", - element: Banners, - navName: "Website Related", - }, { path: "/registerImage", name: "RegisterImage", @@ -454,24 +338,12 @@ const routes = [ navName: "Website Related", }, - { - path: "/web_images", - name: "Web Images", - element: Web_Images, - navName: "Settings", - }, { path: "/loginImage", name: "LoginImage", element: LoginImage, navName: "Website Related", }, - { - path: "/shopImage", - name: "ShopImage", - element: ShopImage, - navName: "Website Related", - }, { path: "/testimonials", name: "Testimonials", @@ -547,47 +419,8 @@ const routes = [ element: EditAboutUs, navName: "Website Related", }, - // Home Pannel website - { - path: "/home", - name: "Home", - element: Home, - navName: "Website Related", - }, - { - path: "/home/panel-1", - name: "EditPanel1", - element: EditPanel1, - navName: "Website Related", - }, - { - path: "/home/panel-2", - name: "EditPanel2", - element: EditPanel2, - navName: "Website Related", - }, - { - path: "/home/panel-3", - name: "EditPanel3", - element: EditPanel3, - navName: "Website Related", - }, - { - path: "/home/panel-4", - name: "EditPanel4", - element: Editpanel4, - navName: "Website Related", - }, //-------------------------------End website related routes---------------------------------- - //informations - // { path: "/informations", name: "Informations", element: Informations }, - // { - // path: "/information/new", - // name: "Add Informations", - // element: AddInformations, - // }, - //--------------Order Management Routes--------------------------------------- { path: "/orders/new", @@ -656,12 +489,6 @@ const routes = [ element: InStoreQRCodeOrders, navName: "Orders", }, - { - path: "/inStoreOrders/:status/:id", - name: "View In Store Cash Orders", - element: POSViewOrders, - navName: "Orders", - }, //-------------- End Order Management Routes--------------------------------------- //----------Point of sale orders Routes----------------------- @@ -670,37 +497,6 @@ const routes = [ //------------settings------------------------// - // { path: "/policies", name: "Policies", element: Policies }, - - // { path: "/purpose", name: "Purpose", element: Purpose }, - // { path: "/purpose/add", name: "Add Purpose", element: AddPurpose }, - // //languge - - // { path: "/languages", name: "languages", element: Languages }, - // { path: "/language/add", name: "Add languages", element: AddLanguage }, - // { path: "/language/edit/:id", name: "Edit languages", element: EditLanguage }, - //business Type - - // { path: "/business_type", name: "business", element: BusinessType }, - // { - // path: "/business_type/add", - // name: "Add business", - // element: AddBusinessType, - // }, - // { - // path: "/business_type/edit/:id", - // name: "Edit business", - // element: EditBusinessType, - // }, - - //purpose - - // { path: "/purpose", name: "purpose", element: Purpose }, - // { path: "/purpose/add", name: "Add purpose", element: AddPurpose }, - // { path: "/purpose/edit/:id", name: "Edit purpose", element: EditPurpose }, - - //languge - //-----------------Configuration Routes----------------------------------- { path: "/socialmedia", @@ -834,24 +630,6 @@ const routes = [ element: EditEmployee, navName: "Employees & Access", }, - // ------------------------ End Employee Routes----------------------- - - //---------Point of Sale Section Routes------------------------ - { - path: "/pos", - name: "Point of Sale", - element: Pos, - navName: "Point of Sale", - }, - - // Export to excel - { - path: "/exp", - name: "Point of Sale", - element: ExportToExcel, - navName: "Point of Sale", - }, - //--------- End Point of Sale Section Routes------------------------ ]; export default routes; diff --git a/src/views/Banner/banner.js b/src/views/Banner/banner.js deleted file mode 100644 index 7e12ff4..0000000 --- a/src/views/Banner/banner.js +++ /dev/null @@ -1,707 +0,0 @@ -import React, { useState, useEffect } from "react"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -import { - Button, - Box, - IconButton, - Modal, - Pagination, - TextField, - Typography, -} from "@mui/material"; -import CloseIcon from "@mui/icons-material/Close"; -import { ClipLoader } from "react-spinners"; -import swal from "sweetalert"; -import CloudUploadIcon from "@mui/icons-material/CloudUpload"; -import DeleteSharpIcon from "@mui/icons-material/DeleteSharp"; - -const style = { - position: "absolute", - top: "50%", - left: "50%", - transform: "translate(-50%, -50%)", - width: 400, - bgcolor: "background.paper", - borderRadius: "0.5rem", - boxShadow: 24, - width: "500px", -}; - -const Banners = () => { - const token = isAutheticated(); - const [loading, setLoading] = useState(true); - const [updating, setUpdating] = useState(true); // for loading state - // const [isUpdate, setIsUpdate] = useState(false); // for edit state - const [saveLoding, setSaveLoading] = useState(true); - const [edit, setEdit] = useState(false); - const [bannerName, setBannerName] = useState(""); - const [bannerImage, setBannerImage] = useState(""); - const [error, setError] = useState(""); - const [bannerId, setBannerId] = useState(""); - const [banner, setBanner] = useState([]); - const [itemPerPage, setItemPerPage] = useState(10); - const [page, setPage] = useState(1); - const [open, setOpen] = useState(false); - const [olderBannerName, setOlderBaannerName] = useState(""); - const [olderImage, setOlderImage] = useState(""); - - const handleOpen = () => setOpen(true); - const handleClose = () => { - setOpen(false); - // setUpdating(false); - setEdit(false); - - setBannerName(""); - setBannerId(""); - setOlderImage(""); - setBannerImage(""); - }; - - const getBanner = async () => { - try { - const response = await axios.get("/api/banner/getBanners", { - // headers: { - // Authorization: `Bearer ${token}`, - // }, - }); - - if (response.status === 200) { - setBanner(response?.data?.banners); - setLoading(false); - } - } catch (error) { - swal({ - title: error, - text: " please login to access the resource ", - icon: "error", - button: "Retry", - dangerMode: true, - }); - } - }; - - useEffect(() => { - getBanner(); - }, []); - // }, [token, banner]); - - const handleEditClick = (_id, bannerName, bannerImage) => { - setOpen(true); - setOlderImage(bannerImage); - setBannerName(bannerName); - setBannerId(_id); - setOlderBaannerName(bannerName); - setEdit(true); - // setUpdating(false); - }; - const bannerNamesArray = []; - const setBannerNamesArray = () => { - banner && - banner.map((banner) => { - bannerNamesArray.push(banner.bannerName.toLowerCase()); - }); - }; - setBannerNamesArray(); - - const handleUpdate = () => { - const filteredArrayNames = bannerNamesArray.filter( - (item) => item !== olderBannerName.toLowerCase() - ); - console.log(filteredArrayNames, "filter"); - const bannerExits = filteredArrayNames.includes(bannerName.toLowerCase()); - if (bannerExits) { - swal({ - title: "Warning", - text: "Banner already exists ", - icon: "error", - button: "Retry", - dangerMode: true, - }); - return; - } - - if (!bannerName || (!bannerImage && !olderImage)) { - swal({ - title: "Warning", - text: "Please fill all the required fields!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - return; - } - setUpdating(false); - const formData = new FormData(); - formData.append("bannerName", bannerName); - - formData.append("bannerImage", bannerImage); - - formData.append("olderImage", JSON.stringify(olderImage)); - - axios - .patch(`/api/banner/update/${bannerId}`, formData, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - // setUpdating(true); - // setIsUpdate(false); - handleClose(); - setBannerId(""); - setBannerName(""); - setBannerImage(""); - setOlderImage(""); - setUpdating(true); - setEdit(false); - swal({ - title: "Congratulations!!", - text: "The banner was updated successfully!", - icon: "success", - button: "OK", - }); - // getCategories(); // Refresh the category list after updating - }) - .catch((err) => { - swal({ - title: "Sorry, please try again", - text: err, - icon: "error", - button: "Retry", - dangerMode: true, - }); - setUpdating(true); - }); - }; - - 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/banner/delete/${_id}`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - swal({ - title: "Congratulations!!", - text: "The banner was deleted successfully!", - icon: "success", - button: "OK", - }); - // getCategories(); // Refresh the category list after deleting - }) - .catch((err) => { - swal({ - title: "", - text: "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - }); - }; - - const handleSaveBanner = async () => { - const bannerExits = bannerNamesArray.includes(bannerName.toLowerCase()); - if (bannerExits) { - swal({ - title: "Warning", - text: "Banner Already exits.", - icon: "error", - button: "Retry", - dangerMode: true, - }); - return; - } - if (!bannerName || !bannerImage) { - swal({ - title: "Warning", - text: "Please fill all the required fields!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - return; - } - setSaveLoading(false); - setLoading(true); - const formData = new FormData(); - formData.append("bannerName", bannerName); - formData.append("bannerImage", bannerImage); - - axios - .post("/api/banner/add", formData, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/formdata", - }, - }) - .then((response) => { - if (response.status === 201) { - setOpen(false); - setLoading(false); - setSaveLoading(true); - setBannerName(""); - setBannerImage(""); - setOlderImage(""); - swal({ - title: "Added", - text: "New Banner added successfully!", - icon: "success", - button: "OK", - }); - // getCategories(); // Refresh the category list after adding - } - }) - .catch((error) => { - setSaveLoading(true); - swal({ - title: error, - text: "something went wrong", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - }; - const getPageCount = () => { - return Math.max(1, Math.ceil(banner.length / itemPerPage)); - }; - - const handleFileChange = (e) => { - const files = e.target.files[0]; - - // Check file types and append to selectedFiles - const allowedTypes = ["image/jpeg", "image/png", "image/jpg"]; - if (allowedTypes.includes(files.type)) { - setBannerImage(files); - } - }; - const handeldeleteImage = () => { - setBannerImage(""); - }; - return ( -
-
-
-
-
-
-
- Banners -
- -
- - - - - - Banner Name - - handleClose()}> - - - -
- - setBannerName( - e.target.value.charAt(0).toUpperCase() + - e.target.value.slice(1) - ) - } - /> - {bannerName ? ( - <> - - {25 - bannerName.length} characters left - - - ) : ( - <> - )} - - - - {bannerImage && ( - - bannerImage - handeldeleteImage()} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - /> - - )} - {olderImage && ( - - bannerImage - setOlderImage("")} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - /> - - )} - - - {error &&

{error}

} -

- Upload jpg, jpeg and png only* -

- - - {!edit && ( - - )} - {edit && ( - - )} - - -
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
- -
- - - - - - - - - - - - - {!loading && banner.length === 0 && ( - - - - )} - {loading ? ( - - - - ) : ( - banner && - banner - .slice( - (`${page}` - 1) * itemPerPage, - `${page}` * itemPerPage - ) - .map((item, i) => ( - - - - - - - )) - )} - -
Image Banner NameActionDimension
-
No Data Available
-
- Loading... -
- -
{}
-
-
{item.bannerName}
-
- - - 1600 x 900 pixels
-
- -
- setPage(value)} - /> -
-
-
-
-
-
-
-
- ); -}; - -export default Banners; diff --git a/src/views/Charts/CityRevenue.js b/src/views/Charts/CityRevenue.js deleted file mode 100644 index 27ea992..0000000 --- a/src/views/Charts/CityRevenue.js +++ /dev/null @@ -1,200 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { isAutheticated } from "src/auth"; -import axios from "axios"; -import { Bar } from "react-chartjs-2"; -import { - Chart as ChartJS, - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend, -} from "chart.js"; - -ChartJS.register( - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend -); - -const CityRevenueCharts = () => { - const token = isAutheticated(); - const [ordersData, setOrdersData] = useState([]); - const [filteredOrders, setFilteredOrders] = useState([]); - const [selectedYear, setSelectedYear] = useState(new Date().getFullYear()); - const [selectedMonth, setSelectedMonth] = useState(new Date().getMonth() + 1); - - useEffect(() => { - function getOrder() { - axios - .get(`/api/order/getAll/`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - setOrdersData(res.data.order); - // console.log(res.data.order); - }) - .catch((err) => { - console.log(err); - }); - } - getOrder(); - }, []); - - useEffect(() => { - // Filter orders based on selected year and month - const filtered = ordersData.filter((order) => { - const createdAt = new Date(order.createdAt); - return ( - createdAt.getFullYear() === selectedYear && - createdAt.getMonth() + 1 === selectedMonth - ); - }); - // Sort filtered orders by date in ascending order - filtered.sort((a, b) => { - const dateA = new Date(a.createdAt); - const dateB = new Date(b.createdAt); - return dateA - dateB; - }); - setFilteredOrders(filtered); - }, [ordersData, selectedYear, selectedMonth]); // Update filtered orders when orders data, year, or month changes - - const uniquecity = [ - ...new Set( - filteredOrders.map((item) => item.shippingInfo.city) - ), - ]; -// console.log(uniquecity); -// console.log(filteredOrders); - // Prepare data for chart - const data = { - labels: uniquecity, // Use unique product names as labels - datasets: [ - { - label: "Total Amount", - data: uniquecity.map((city) => { - // Sum total amounts for each date - return filteredOrders - .filter((order) => order.shippingInfo.city.includes(city)) - .reduce((total, order) => total + order.total_amount, 0); - }), - backgroundColor: "rgba(43, 63, 229, 0.8)", - borderRadius: 5, - }, - ], - }; - - const options = { - responsive: true, - plugins: { - legend: { - display: false, - }, - title: { - display: true, - text: "Revenue Chart", - }, - }, - scales: { - x: { - title: { - display: true, - text: "City", - }, - }, - y: { - beginAtZero: true, - title: { - display: true, - text: "Total Amount", - }, - ticks: { - stepSize: 1, // Adjust step size as needed - }, - }, - }, - }; - - // Convert month number to string - const monthToString = (monthNumber) => { - const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - ]; - return months[monthNumber - 1]; - }; - - // Determine the lowest year found in the ordersData - const lowestYear = Math.min( - ...ordersData.map((order) => new Date(order.createdAt).getFullYear()) - ); - - // Generate an array of years from the lowest year to the current year - const years = Array.from( - { length: new Date().getFullYear() - lowestYear + 1 }, - (_, index) => lowestYear + index - ); - - return ( - <> -
-
- - -
-
- - -
-
-
- {filteredOrders.length === 0 ? ( -

No data available

- ) : ( -
- -
- )} -
- - ); -}; - -export default CityRevenueCharts; diff --git a/src/views/Charts/OrderDaywise.js b/src/views/Charts/OrderDaywise.js deleted file mode 100644 index 26b048c..0000000 --- a/src/views/Charts/OrderDaywise.js +++ /dev/null @@ -1,195 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { isAutheticated } from "src/auth"; -import axios from "axios"; -import { Bar } from "react-chartjs-2"; -import { - Chart as ChartJS, - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend, -} from "chart.js"; - -ChartJS.register( - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend -); - -const OrderdayChart = () => { - const token = isAutheticated(); - const [ordersData, setOrdersData] = useState([]); - const [filteredOrders, setFilteredOrders] = useState([]); - const [selectedYear, setSelectedYear] = useState(new Date().getFullYear()); - const [selectedMonth, setSelectedMonth] = useState(new Date().getMonth() + 1); - - useEffect(() => { - function getOrder() { - axios - .get(`/api/order/getAll/`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - setOrdersData(res.data.order); - }) - .catch((err) => { - console.log(err); - }); - } - getOrder(); - }, [token]); - - useEffect(() => { - // Filter orders based on selected year and month - const filtered = ordersData.filter((order) => { - const createdAt = new Date(order.createdAt); - return ( - createdAt.getFullYear() === selectedYear && - createdAt.getMonth() + 1 === selectedMonth - ); - }); - // Sort filtered orders by date in ascending order - filtered.sort((a, b) => { - const dateA = new Date(a.createdAt); - const dateB = new Date(b.createdAt); - return dateA - dateB; - }); - setFilteredOrders(filtered); - }, [ordersData, selectedYear, selectedMonth]); // Update filtered orders when orders data, year, or month changes - - // Extract unique dates from filtered orders - const uniqueDates = Array.from( - new Set(filteredOrders.map((order) => order.createdAt.split("T")[0])) - ); - - // Prepare data for chart - const data = { - labels: uniqueDates, - datasets: [ - { - label: "Total Orders", - data: uniqueDates.map((date) => { - // Count total orders for each date - return filteredOrders.filter((order) => order.createdAt.includes(date)).length; - }), - backgroundColor: "rgba(43, 63, 229, 0.8)", - borderRadius: 5, - }, - ], - }; - - const options = { - responsive: true, - plugins: { - legend: { - display: false, - }, - title: { - display: true, - text: "Revenue Order", - }, - }, - scales: { - x: { - title: { - display: true, - text: "Date", - }, - }, - y: { - beginAtZero: true, - title: { - display: true, - text: "Orders", - }, - ticks: { - stepSize: 1, // Adjust step size as needed - }, - }, - }, - }; - - // Convert month number to string - const monthToString = (monthNumber) => { - const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - ]; - return months[monthNumber - 1]; - }; - - // Determine the lowest year found in the ordersData - const lowestYear = Math.min( - ...ordersData.map((order) => new Date(order.createdAt).getFullYear()) - ); - - // Generate an array of years from the lowest year to the current year - const years = Array.from( - { length: new Date().getFullYear() - lowestYear + 1 }, - (_, index) => lowestYear + index - ); - - return ( - <> -
-
- - -
-
- - -
-
-
- {filteredOrders.length === 0 ? ( -

No data available

- ) : ( -
- -
- )} -
- - ); -}; - -export default OrderdayChart; diff --git a/src/views/Charts/ProductRevenue.js b/src/views/Charts/ProductRevenue.js deleted file mode 100644 index dcf8e0e..0000000 --- a/src/views/Charts/ProductRevenue.js +++ /dev/null @@ -1,213 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { isAutheticated } from "src/auth"; -import axios from "axios"; -import { Bar } from "react-chartjs-2"; -import { - Chart as ChartJS, - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend, -} from "chart.js"; - -ChartJS.register( - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend -); - -const ProductrevenueCharts = () => { - const token = isAutheticated(); - const [ordersData, setOrdersData] = useState([]); - const [filteredOrders, setFilteredOrders] = useState([]); - const [selectedYear, setSelectedYear] = useState(new Date().getFullYear()); - const [selectedMonth, setSelectedMonth] = useState(new Date().getMonth() + 1); - - useEffect(() => { - function getOrder() { - axios - .get(`/api/order/getAll/`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - setOrdersData(res.data.order); - // console.log(res.data.order); - }) - .catch((err) => { - console.log(err); - }); - } - getOrder(); - }, []); - - useEffect(() => { - // Filter orders based on selected year and month - const filtered = ordersData.filter((order) => { - const createdAt = new Date(order.createdAt); - return ( - createdAt.getFullYear() === selectedYear && - createdAt.getMonth() + 1 === selectedMonth - ); - }); - // Sort filtered orders by date in ascending order - filtered.sort((a, b) => { - const dateA = new Date(a.createdAt); - const dateB = new Date(b.createdAt); - return dateA - dateB; - }); - setFilteredOrders(filtered); - }, [ordersData, selectedYear, selectedMonth]); // Update filtered orders when orders data, year, or month changes - - // Extract unique products from filtered orders - const uniqueProducts = [ - ...new Set( - filteredOrders.flatMap((order) => - order.orderItems.map((item) => item.name) - ) - ), - ]; -// console.log(uniqueProducts); -// console.log(filteredOrders); - // Prepare data for chart - const data = { - labels: uniqueProducts, // Use unique product names as labels - datasets: [ - { - label: "Total Amount", - data: uniqueProducts.map((product) => - filteredOrders.reduce((total, order) => { - // Find the order item for the current product - const orderItem = order.orderItems.find( - (item) => item.name === product - ); - if (orderItem) { - // If the order item exists, add its total amount to the total for this product - return total + orderItem. - product_Subtotal; - } else { - // If the order item does not exist, return the current total - return total; - } - }, 0) - ), - backgroundColor: "rgba(43, 63, 229, 0.8)", - borderRadius: 5, - }, - ], - }; - - const options = { - responsive: true, - plugins: { - legend: { - display: false, - }, - title: { - display: true, - text: "Revenue Chart", - }, - }, - scales: { - x: { - title: { - display: true, - text: "Product", - }, - }, - y: { - beginAtZero: true, - title: { - display: true, - text: "Total Amount", - }, - ticks: { - stepSize: 1, // Adjust step size as needed - }, - }, - }, - }; - - // Convert month number to string - const monthToString = (monthNumber) => { - const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - ]; - return months[monthNumber - 1]; - }; - - // Determine the lowest year found in the ordersData - const lowestYear = Math.min( - ...ordersData.map((order) => new Date(order.createdAt).getFullYear()) - ); - - // Generate an array of years from the lowest year to the current year - const years = Array.from( - { length: new Date().getFullYear() - lowestYear + 1 }, - (_, index) => lowestYear + index - ); - - return ( - <> -
-
- - -
-
- - -
-
-
- {filteredOrders.length === 0 ? ( -

No data available

- ) : ( -
- -
- )} -
- - ); -}; - -export default ProductrevenueCharts; diff --git a/src/views/Charts/RevenueCharts.js b/src/views/Charts/RevenueCharts.js deleted file mode 100644 index 4a4a88f..0000000 --- a/src/views/Charts/RevenueCharts.js +++ /dev/null @@ -1,199 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { isAutheticated } from "src/auth"; -import axios from "axios"; -import { Bar } from "react-chartjs-2"; -import { - Chart as ChartJS, - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend, -} from "chart.js"; - -ChartJS.register( - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend -); - -const RevenueCharts = () => { - const token = isAutheticated(); - const [ordersData, setOrdersData] = useState([]); - const [filteredOrders, setFilteredOrders] = useState([]); - const [selectedYear, setSelectedYear] = useState(new Date().getFullYear()); - const [selectedMonth, setSelectedMonth] = useState(new Date().getMonth() + 1); - - useEffect(() => { - function getOrder() { - axios - .get(`/api/order/getAll/`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - setOrdersData(res.data.order); - // console.log(res.data.order); - }) - .catch((err) => { - console.log(err); - }); - } - getOrder(); - }, []); - - useEffect(() => { - // Filter orders based on selected year and month - const filtered = ordersData.filter((order) => { - const createdAt = new Date(order.createdAt); - return ( - createdAt.getFullYear() === selectedYear && - createdAt.getMonth() + 1 === selectedMonth - ); - }); - // Sort filtered orders by date in ascending order - filtered.sort((a, b) => { - const dateA = new Date(a.createdAt); - const dateB = new Date(b.createdAt); - return dateA - dateB; - }); - setFilteredOrders(filtered); - }, [ordersData, selectedYear, selectedMonth]); // Update filtered orders when orders data, year, or month changes - - // Extract unique dates from filtered orders - const uniqueDates = Array.from( - new Set(filteredOrders.map((order) => order.createdAt.split("T")[0])) - ); - // console.log(uniqueDates); - // console.log(filteredOrders); - // Prepare data for chart - const data = { - labels: uniqueDates, - datasets: [ - { - label: "Total Amount", - data: uniqueDates.map((date) => { - // Sum total amounts for each date - return filteredOrders - .filter((order) => order.createdAt.includes(date)) - .reduce((total, order) => total + order.total_amount, 0); - }), - backgroundColor: "rgba(43, 63, 229, 0.8)", - borderRadius: 5, - }, - ], - }; - - const options = { - responsive: true, - plugins: { - legend: { - display: false, - }, - title: { - display: true, - text: "Revenue Chart", - }, - }, - scales: { - x: { - title: { - display: true, - text: "Date", - }, - }, - y: { - beginAtZero: true, - title: { - display: true, - text: "Total Amount", - }, - ticks: { - stepSize: 1000, // Adjust step size as needed - }, - }, - }, - }; - - // Convert month number to string - const monthToString = (monthNumber) => { - const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - ]; - return months[monthNumber - 1]; - }; - - // Determine the lowest year found in the ordersData - const lowestYear = Math.min( - ...ordersData.map((order) => new Date(order.createdAt).getFullYear()) - ); - - // Generate an array of years from the lowest year to the current year - const years = Array.from( - { length: new Date().getFullYear() - lowestYear + 1 }, - (_, index) => lowestYear + index - ); - - return ( - <> -
-
- - -
-
- - -
-
-
- {filteredOrders.length === 0 ? ( -

No data available

- ) : ( -
- -
- )} -
- - ); -}; - -export default RevenueCharts; diff --git a/src/views/Charts/Staterevenue.js b/src/views/Charts/Staterevenue.js deleted file mode 100644 index 3becaf4..0000000 --- a/src/views/Charts/Staterevenue.js +++ /dev/null @@ -1,200 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { isAutheticated } from "src/auth"; -import axios from "axios"; -import { Bar } from "react-chartjs-2"; -import { - Chart as ChartJS, - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend, -} from "chart.js"; - -ChartJS.register( - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend -); - -const StateRevenueCharts = () => { - const token = isAutheticated(); - const [ordersData, setOrdersData] = useState([]); - const [filteredOrders, setFilteredOrders] = useState([]); - const [selectedYear, setSelectedYear] = useState(new Date().getFullYear()); - const [selectedMonth, setSelectedMonth] = useState(new Date().getMonth() + 1); - - useEffect(() => { - function getOrder() { - axios - .get(`/api/order/getAll/`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - setOrdersData(res.data.order); - // console.log(res.data.order); - }) - .catch((err) => { - console.log(err); - }); - } - getOrder(); - }, []); - - useEffect(() => { - // Filter orders based on selected year and month - const filtered = ordersData.filter((order) => { - const createdAt = new Date(order.createdAt); - return ( - createdAt.getFullYear() === selectedYear && - createdAt.getMonth() + 1 === selectedMonth - ); - }); - // Sort filtered orders by date in ascending order - filtered.sort((a, b) => { - const dateA = new Date(a.createdAt); - const dateB = new Date(b.createdAt); - return dateA - dateB; - }); - setFilteredOrders(filtered); - }, [ordersData, selectedYear, selectedMonth]); // Update filtered orders when orders data, year, or month changes - - const uniquestate = [ - ...new Set( - filteredOrders.map((item) => item.shippingInfo.state) - ), - ]; -// console.log(uniquestate); -// console.log(filteredOrders); - // Prepare data for chart - const data = { - labels: uniquestate, // Use unique product names as labels - datasets: [ - { - label: "Total Amount", - data: uniquestate.map((state) => { - // Sum total amounts for each date - return filteredOrders - .filter((order) => order.shippingInfo.state.includes(state)) - .reduce((total, order) => total + order.total_amount, 0); - }), - backgroundColor: "rgba(43, 63, 229, 0.8)", - borderRadius: 5, - }, - ], - }; - - const options = { - responsive: true, - plugins: { - legend: { - display: false, - }, - title: { - display: true, - text: "Revenue Chart", - }, - }, - scales: { - x: { - title: { - display: true, - text: "State", - }, - }, - y: { - beginAtZero: true, - title: { - display: true, - text: "Total Amount", - }, - ticks: { - stepSize: 1, // Adjust step size as needed - }, - }, - }, - }; - - // Convert month number to string - const monthToString = (monthNumber) => { - const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - ]; - return months[monthNumber - 1]; - }; - - // Determine the lowest year found in the ordersData - const lowestYear = Math.min( - ...ordersData.map((order) => new Date(order.createdAt).getFullYear()) - ); - - // Generate an array of years from the lowest year to the current year - const years = Array.from( - { length: new Date().getFullYear() - lowestYear + 1 }, - (_, index) => lowestYear + index - ); - - return ( - <> -
-
- - -
-
- - -
-
-
- {filteredOrders.length === 0 ? ( -

No data available

- ) : ( -
- -
- )} -
- - ); -}; - -export default StateRevenueCharts; diff --git a/src/views/Charts/UserChart.js b/src/views/Charts/UserChart.js deleted file mode 100644 index 60fbcc9..0000000 --- a/src/views/Charts/UserChart.js +++ /dev/null @@ -1,200 +0,0 @@ -import React, { useEffect, useState } from "react"; -import { isAutheticated } from "src/auth"; -import axios from "axios"; -import { Bar } from "react-chartjs-2"; -import { - Chart as ChartJS, - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend, -} from "chart.js"; - -ChartJS.register( - CategoryScale, - LinearScale, - BarElement, - Title, - Tooltip, - Legend -); - -const UserCharts = () => { - const token = isAutheticated(); - const [userData, setUsers] = useState([]); - const [filteredUsers, setfilteredUsers] = useState([]); - const [selectedYear, setSelectedYear] = useState(new Date().getFullYear()); - const [selectedMonth, setSelectedMonth] = useState(new Date().getMonth() + 1); - - useEffect(() => { - function getOrder() { - axios - .get(`/api/v1/admin/users`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - setUsers(res.data.users); - // console.log(res.data.users); - }) - .catch((err) => { - console.log(err); - }); - } - getOrder(); - }, []); - - useEffect(() => { - // Filter orders based on selected year and month - const filtered = userData.filter((order) => { - const createdAt = new Date(order.createdAt); - return ( - createdAt.getFullYear() === selectedYear && - createdAt.getMonth() + 1 === selectedMonth - ); - }); - // Sort filtered orders by date in ascending order - filtered.sort((a, b) => { - const dateA = new Date(a.createdAt); - const dateB = new Date(b.createdAt); - return dateA - dateB; - }); - setfilteredUsers(filtered); - }, [userData, selectedYear, selectedMonth]); // Update filtered orders when orders data, year, or month changes - - // Extract unique dates from filtered orders - const uniqueDates = Array.from( - new Set(filteredUsers.map((order) => order.createdAt.split("T")[0])) - ); - // console.log(uniqueDates); - // console.log(filteredUsers); - // Prepare data for chart - const data = { - labels: uniqueDates, - datasets: [ - { - label: "No of Amounts", - data: uniqueDates.map((date) => { - // Sum total amounts for each date - return filteredUsers - .filter((order) => order.createdAt.includes(date)) - .length; - }), - backgroundColor: "rgba(43, 63, 229, 0.8)", - borderRadius: 5, - }, - ], - }; - - const options = { - responsive: true, - plugins: { - legend: { - display: false, - }, - title: { - display: true, - text: "User Chart", - }, - }, - scales: { - x: { - title: { - display: true, - text: "Date", - }, - }, - y: { - beginAtZero: true, - title: { - display: true, - text: "No of Users", - }, - ticks: { - stepSize: 1, // Adjust step size as needed - }, - }, - }, - }; - - // Convert month number to string - const monthToString = (monthNumber) => { - const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - ]; - return months[monthNumber - 1]; - }; - - // Determine the lowest year found in the userData - const lowestYear = Math.min( - ...userData.map((order) => new Date(order.createdAt).getFullYear()) - ); - - // Generate an array of years from the lowest year to the current year - const years = Array.from( - { length: new Date().getFullYear() - lowestYear + 1 }, - (_, index) => lowestYear + index - ); - - return ( - <> -
-
- - -
-
- - -
-
-
- {filteredUsers.length === 0 ? ( -

No data available

- ) : ( -
- -
- )} -
- - ); -}; - -export default UserCharts; - diff --git a/src/views/ContactRequests/AddContactRequest.js b/src/views/ContactRequests/AddContactRequest.js deleted file mode 100644 index f31add7..0000000 --- a/src/views/ContactRequests/AddContactRequest.js +++ /dev/null @@ -1,221 +0,0 @@ -import React, { useEffect, useState } from "react"; -import Button from "@material-ui/core/Button"; -import { Link, useNavigate } from "react-router-dom"; -import swal from "sweetalert"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -// import { WebsiteURL } from '../WebsiteURL' - -const AddContactRequest = () => { - const token = isAutheticated(); - const navigate = useNavigate(); - const [data, setData] = useState({ - name: "", - EmailOrMobile: "", - message: "", - }); - - const [loading, setLoading] = useState(false); - - const handleChange = (e) => { - setData((prev) => ({ ...prev, [e.target.id]: e.target.value })); - }; - - const handleSubmit = () => { - if ( - data.name.trim() === "" || - data.EmailOrMobile.trim() === "" || - data.message.trim() === "" - ) { - swal({ - title: "Warning", - text: "Fill all mandatory fields", - icon: "error", - button: "Close", - dangerMode: true, - }); - return; - } - setLoading(true); - const formData = new FormData(); - formData.set("name", data.name); - formData.set("EmailOrMobile", data.EmailOrMobile); - - formData.set("message", data.message); - - axios - .post(`/api/contact/request/new/`, formData, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/formdata", - "Access-Control-Allow-Origin": "*", - }, - }) - .then((res) => { - swal({ - title: "Added", - text: "Contact Requests added successfully!", - icon: "success", - button: "ok", - }); - setLoading(false); - navigate("/contact/request", { replace: true }); - }) - .catch((err) => { - setLoading(false); - const message = err.response?.data?.message || "Something went wrong!"; - swal({ - title: "Warning", - text: message, - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - }; - - return ( -
-
-
-
-
- New Contact Request -
-
-

-
- -
- - - - -
-
-
-
-
-
-
-
-
- - handleChange(e)} - /> - {data.name ? ( - <> - - {25 - data.name.length} characters left - - - ) : ( - <> - )}{" "} -
-
- - handleChange(e)} - /> - {data.EmailOrMobile ? ( - <> - - {25 - data.EmailOrMobile.length} characters left - - - ) : ( - <> - )}{" "} -
- -
- - - - {data.message ? ( - <> - - {500 - data.message.length} characters left - - - ) : ( - <> - )} -
- - {/*
- -
- -
*/} -
-
-
-
-
- ); -}; - -export default AddContactRequest; diff --git a/src/views/ContactRequests/ContactRequests.js b/src/views/ContactRequests/ContactRequests.js deleted file mode 100644 index 469a076..0000000 --- a/src/views/ContactRequests/ContactRequests.js +++ /dev/null @@ -1,338 +0,0 @@ - -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 ContactRequests = () => { - const token = isAutheticated() - const navigate = useNavigate() - const [loading, setLoading] = useState(true) - const [success, setSuccess] = useState(true) - const [ContactRequestsData, setContactRequestsData] = useState([]) - - const [currentPage, setCurrentPage] = useState(1) - const [itemPerPage, setItemPerPage] = useState(10) - const [showData, setShowData] = useState(ContactRequestsData) - - const handleShowEntries = (e) => { - setCurrentPage(1) - setItemPerPage(e.target.value) - } - - - - const getContactRequestsData = async () => { - axios - .get(`/api/contact/request/getAll/`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - console.log(res.data) - setContactRequestsData(res.data?.contactRequest) - setLoading(false) - }) - .catch((err) => { - setLoading(false) - }) - } - - useEffect(() => { - getContactRequestsData() - }, [success]) - - useEffect(() => { - const loadData = () => { - const indexOfLastPost = currentPage * itemPerPage - const indexOfFirstPost = indexOfLastPost - itemPerPage - setShowData(ContactRequestsData.slice(indexOfFirstPost, indexOfLastPost)) - } - loadData() - }, [currentPage, itemPerPage, ContactRequestsData]) - - 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/delete/${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 ( -
-
-
-
-
-
-
- Contact Requests -
- -
- -
-
-
-
- -
-
-
-
-
-
-
- -
-
-
- -
- - - - - - - - - - - - - - - {/* */} - - - - {!loading && showData.length === 0 && ( - - - - )} - {loading ? ( - - - - ) : ( - showData.map((product, i) => { - return ( - - - - - - - - - {/* */} - - - ) - }) - )} - -
NameEmail/MobileMessageDate & TimeAction
-
No Data Available
-
- Loading... -
{product.name}{product.EmailOrMobile}{product.message} - {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, ContactRequestsData.length)} of{' '} - {ContactRequestsData.length} entries -
-
- -
-
-
    -
  • - setCurrentPage((prev) => prev - 1)} - > - Previous - -
  • - - {!(currentPage - 1 < 1) && ( -
  • - setCurrentPage((prev) => prev - 1)} - > - {currentPage - 1} - -
  • - )} - -
  • - - {currentPage} - -
  • - - {!( - (currentPage + 1) * itemPerPage - itemPerPage > - ContactRequestsData.length - 1 - ) && ( -
  • - { - setCurrentPage((prev) => prev + 1) - }} - > - {currentPage + 1} - -
  • - )} - -
  • - ContactRequestsData.length - 1 - ) - ? 'paginate_button page-item next' - : 'paginate_button page-item next disabled' - } - > - setCurrentPage((prev) => prev + 1)} - > - Next - -
  • -
-
-
-
-
-
-
-
-
-
-
- ) -} - -export default ContactRequests diff --git a/src/views/CustomerSupport/CloseRequestView.js b/src/views/CustomerSupport/CloseRequestView.js deleted file mode 100644 index 078346a..0000000 --- a/src/views/CustomerSupport/CloseRequestView.js +++ /dev/null @@ -1,207 +0,0 @@ -import React, { useEffect, useState } from "react"; -// import Button from "@material-ui/core/Button"; -import { Link, useNavigate } from "react-router-dom"; -import swal from "sweetalert"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -import { Button, ImageList, InputLabel, ImageListItem } from "@mui/material"; -import MessageList from "./MessageList"; -import { useParams } from "react-router-dom"; -import { useDispatch, useSelector } from "react-redux"; - -const CloseRequestView = () => { - // Assuming you have the following ticket details - const { ticketID } = useParams(); - const token = isAutheticated(); - const navigate = useNavigate(); - - const [loading, setLoading] = useState(false); - // error****************************please check - const [ticketDetails, setticketDetails] = useState(null); - - // const dispatch = useDispatch(); - // const tickets = useSelector((state) => state.ticket.ticket); - // useEffect(() => { - // dispatch(getTicketItem()); - // }, [dispatch]); - - // console.log(tickets); - // geting data from backend************ - - // const dispatch = useDispatch(); - // const tickets = useSelector((state) => state.ticket.ticket); - // useEffect(() => { - // dispatch(getTicketItem()); - // }, [dispatch]); - - // console.log(tickets); - // useEffect(() => { - // const foundTicket = tickets.find((ticket) => ticket.ticketId === ticketID); - // // console.log(foundTicket); - // setticketDetails(foundTicket); - // }, [ticketID]); - // console.log(ticketID); - // ***************** - // geting data from backend************ - const getSupportTicketDetails = async () => { - // console.log(ticketID); - axios - .get(`/api/support/getOne/${ticketID}`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - // console.log(res?.data); - // setticketDetails(res.data?.support); - // setTicket(res.data?.support); - console.log(res.data?.support); - getuserName(res.data?.support); - // setLoading(false); - }) - .catch((error) => { - swal({ - title: error, - text: "please login to access the resource or refresh the page ", - icon: "error", - button: "Retry", - dangerMode: true, - }); - // setLoading(false); - }); - }; - // ************************************ - const getuserName = async (ticket) => { - try { - const userId = ticket.addedBy; - let resp = await axios.get(`/api/v1/admin/user/${userId}`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - console.log(resp?.data?.user?.name); - const userName = resp?.data?.user?.name; - const userMailId = resp?.data?.user?.email; - // console.log(userName); - // Update support ticket with user name - const ticketWithUserName = { - ...ticket, - userName: userName, - userMailId: userMailId, - }; - setticketDetails(ticketWithUserName); - } catch (error) { - // Handle errors - } - }; - - React.useEffect(() => { - getSupportTicketDetails(); - }, []); - // ***************** - - return ( -
-
-
-
-
- View Request -
-
-

-
-
- -
-
-
-
-
-
-
-
-
- - Ticket ID: {ticketDetails?.ticketId} - - - User ID: {ticketDetails?.addedBy} - - - User Name: {ticketDetails?.userName} - - - User MailId: {ticketDetails?.userMailId} - - - Date and Time: {ticketDetails?.createdOn} - - - Subject: {ticketDetails?.subject} - - - Description:{" "} - {ticketDetails?.description - ? ticketDetails?.description - : "No Description"} - -
-
- {ticketDetails?.image?.length > 0 && ( -
- - Image: - - - {ticketDetails?.image?.map((item) => ( - - {item.title - - ))} - -
- )} -
-
- {ticketDetails && ( - - )} -
- - {/* *************** */} -
-
-
-
-
- ); -}; - -export default CloseRequestView; diff --git a/src/views/CustomerSupport/EmailCMS/EmailCms.js b/src/views/CustomerSupport/EmailCMS/EmailCms.js deleted file mode 100644 index dfb2489..0000000 --- a/src/views/CustomerSupport/EmailCMS/EmailCms.js +++ /dev/null @@ -1,111 +0,0 @@ -import { - Button, - Paper, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, - Typography, -} from "@mui/material"; -import React from "react"; -import { Link } from "react-router-dom"; - -export default function EmailCms() { - const pages = [ - { - name: "New user registration", - action: "Edit", - path: "/email-cms/registration-email", - }, - { - name: "Forgot Password", - action: "Edit", - path: "#", - }, - { - name: "Change Password Notification ", - action: "Edit", - path: "#", - }, - { - name: "New Order", - action: "Edit", - path: "#", - }, - { - name: "Order - Processing", - action: "Edit", - path: "#", - }, - { - name: "Order - Dispatched", - action: "Edit", - path: "#", - }, - { - name: "Order - Delivered", - action: "Edit", - path: "#", - }, - { - name: "Order - Cancelled", - action: "Edit", - path: "#", - }, - ]; - - return ( -
- - Email CMS - - - - - - Page - - Action - - - - - {pages.map((row) => ( - - - {row.name} - - - {" "} - - - - - - ))} - -
-
-
- ); -} diff --git a/src/views/CustomerSupport/EmailCMS/RegistrationEmail.js b/src/views/CustomerSupport/EmailCMS/RegistrationEmail.js deleted file mode 100644 index 9c4cbab..0000000 --- a/src/views/CustomerSupport/EmailCMS/RegistrationEmail.js +++ /dev/null @@ -1,207 +0,0 @@ -import { Typography } from "@material-ui/core"; -import { Box, Button } from "@mui/material"; - -import React, { useEffect, useState } from "react"; -import ReactrichTextEditor from "../../Content/reactrichTextEditor"; -import ReactQuill from "react-quill"; -import "react-quill/dist/quill.snow.css"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -import { useNavigate, useNavigation } from "react-router-dom"; - -// const TOOLBAR_OPTIONS = [ -// [{ header: [1, 2, 3, 4, 5, 6, false] }], -// [{ font: [] }], -// [{ list: "ordered" }, { list: "bullet" }], -// ["bold", "italic", "underline", "strike"], -// [{ color: [] }, { background: [] }], -// [{ align: [] }], -// [{ script: "super" }, { script: "sub" }], -// ["undo", "redo"], -// ]; - -export default function RegistrationEmail() { - const [title, setTitle] = useState("Registration Email"); - const [welcomemsg, setWelcomeMsg] = useState(""); - const [welcomemsgforDescription, setWelcomeMsgForDescription] = useState(""); - - const [subject, setSubject] = useState(""); - const [description, setDescription] = useState(""); - const [content, setContent] = useState(""); - const [added, setAdded] = useState(false); - const [olderContent, setOlderContent] = useState(""); - const [id, setId] = useState(null); - - const token = isAutheticated(); - - const getTermsAndConditions = async () => { - const response = await axios.get("/api/get-email-data", { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - if (response.status === 200) { - if (response.data?.registerEmaildata.length === 0) { - return; - } - // console.log(response); - // setContent(response?.data?.registerEmaildata[0]?.termsAndContionContent); - // setOlderContent( - // response?.data?.registerEmaildata[0]?.termsAndContionContent - // ); - setSubject(response?.data?.registerEmaildata[0]?.subject); - setDescription(response?.data?.registerEmaildata[0]?.description); - setId(response?.data?.registerEmaildata[0]?._id); - } - }; - - const addTermsandConditions = async () => { - const response = await axios.post( - "/api/register-email", - { subject: subject, description: description }, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); - if (response.status == 200) { - swal({ - title: "Congratulations!!", - text: response?.data?.message, - icon: "success", - button: "OK", - }); - } - }; - const handleCancelClick = () => { - setAdded(!added); - }; - - const handleSaveClick = async () => { - // if (id === null) { - await addTermsandConditions(); - setAdded(true); - // } else { - // await updateContent(); - // setAdded(false); - // } - - // Reload terms and conditions - // await getTermsAndConditions(); - }; - useEffect(() => { - // addTermsandConditions(); - getTermsAndConditions(); - }, [added]); - return ( -
-
- - -
- - - {/* setTitle(e.target.value)} - variant="outlined" - size="small" - fullWidth - /> */} - - {" "} - Email Confiramtion:{" "} - - -
- - - setWelcomeMsg(e.target.value)} - /> -
- App Name : Cheminova -
- - - - setSubject(e.target.value)} - /> -
- -
- - - setWelcomeMsgForDescription(e.target.value)} - /> - - -
-
-
- ); -} diff --git a/src/views/CustomerSupport/MessageList.js b/src/views/CustomerSupport/MessageList.js deleted file mode 100644 index 251473b..0000000 --- a/src/views/CustomerSupport/MessageList.js +++ /dev/null @@ -1,32 +0,0 @@ - -import React from 'react'; -import { Paper } from '@material-ui/core'; - -const MessageList = ({ messages }) => { - return ( - <> - {messages.map((msg, index) => ( -
- -
- {msg.user === 'user' ? 'User' : 'Admin'} -
-
- {msg.replyDate} -
-
{msg.message}
-
-
- ))} - - ); -}; - -export default MessageList; - diff --git a/src/views/CustomerSupport/SupportReply.js b/src/views/CustomerSupport/SupportReply.js deleted file mode 100644 index 1712a37..0000000 --- a/src/views/CustomerSupport/SupportReply.js +++ /dev/null @@ -1,346 +0,0 @@ -import React, { useEffect, useState } from "react"; -// import Button from "@material-ui/core/Button"; -import { Link, useNavigate, useParams } from "react-router-dom"; -import swal from "sweetalert"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -import { Button, ImageList, InputLabel, ImageListItem } from "@mui/material"; -import MessageList from "./MessageList"; -import { useDispatch, useSelector } from "react-redux"; - -import toast from "react-hot-toast"; -const SupportReply = () => { - const token = isAutheticated(); - const navigate = useNavigate(); - const [data, setData] = useState({ - user: "admin", - replyDate: "", - message: "", - }); - - const [loading, setLoading] = useState(false); - - const handleChange = (e) => { - setData((prev) => ({ ...prev, [e.target.id]: e.target.value })); - }; - const options = { - weekday: "short", // Abbreviated weekday (e.g., "Tue") - day: "numeric", // Numeric day (e.g., "5") - month: "short", // Abbreviated month (e.g., "Mar") - year: "numeric", // Numeric year (e.g., "2024") - hour: "numeric", // Numeric hour (e.g., "10") - minute: "2-digit", // Two-digit minute (e.g., "27") - hour12: true, // Use 12-hour clock (true/false) - }; - - const { ticketID } = useParams(); - - - const [ticketDetails, setticketDetails] = useState(null); - const [fetchData, setFetchData] = useState(false); - - const getSupportTicketDetails = async () => { - // console.log(ticketID); - axios - .get(`/api/support/getOne/${ticketID}`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - // console.log(res?.data); - // setticketDetails(res.data?.support); - // setTicket(res.data?.support); - console.log(res.data?.support); - getuserName(res.data?.support); - // setLoading(false); - }) - .catch((error) => { - swal({ - title: error, - text: "please login to access the resource or refresh the page ", - icon: "error", - button: "Retry", - dangerMode: true, - }); - // setLoading(false); - }); - }; - // ************************************ - // updating message in backend************ - const handleSubmit = () => { - if (data.message.trim() === "") { - swal({ - title: "Warning", - text: "Fill all mandatory fields", - icon: "error", - button: "Close", - dangerMode: true, - }); - return; - } - setLoading(true); - const formData = { - message: data.message, - replyDate: new Date().toLocaleString("en-US", options), - user: "admin", - }; - axios - .patch( - `/api/support/update/${ticketID}`, - { - message: formData, - }, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ) - .then((res) => { - toast.success("Message Sent successfully!"); - setLoading(false); - setData({ message: "" }); - setFetchData(true); - navigate("/support/request", { replace: true }); - }) - .catch((error) => { - swal({ - title: "Error", - text: "Something went wrong", - icon: "error", - button: "Close", - }); - }); - }; - // ************************************ - const getuserName = async (ticket) => { - try { - const userId = ticket.addedBy; - let resp = await axios.get(`/api/v1/admin/user/${userId}`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - console.log(resp?.data?.user?.name); - const userName = resp?.data?.user?.name; - const userMailId = resp?.data?.user?.email; - // console.log(userName); - // Update support ticket with user name - const ticketWithUserName = { - ...ticket, - userName: userName, - userMailId: userMailId, - }; - setticketDetails(ticketWithUserName); - } catch (error) { - // Handle errors - } - }; - - React.useEffect(() => { - getSupportTicketDetails(); - setFetchData(false); - }, [fetchData]); - - // ************************************ - return ( -
-
-
-
-
- Support Chat -
-
-

-
-
- {/* */} - {/* */} -
-
-
-
-
-
-
-
-
- - Ticket ID: {ticketDetails?.ticketId} - - - User ID: {ticketDetails?.addedBy} - - - User Name: {ticketDetails?.userName} - - - User MailId: {ticketDetails?.userMailId} - - - Date and Time: {ticketDetails?.createdOn} - - - Subject: {ticketDetails?.subject} - - - Description:{" "} - {ticketDetails?.description - ? ticketDetails?.description - : "No Description"} - -
-
- {ticketDetails?.image?.length > 0 && ( -
- - Image: - - - {ticketDetails?.image?.map((item) => ( - - {item.title - - ))} - -
- )} -
-
- {ticketDetails && ( - - )} -
- -
- - - - {data.message ? ( - <> - - {500 - data.message.length} characters left - - - ) : ( - <> - )} -
-
- - {/* */} - - {/* */} -
-
-
-
-
-
- ); -}; - -export default SupportReply; diff --git a/src/views/CustomerSupport/SupportRequest.js b/src/views/CustomerSupport/SupportRequest.js deleted file mode 100644 index 93ccdbd..0000000 --- a/src/views/CustomerSupport/SupportRequest.js +++ /dev/null @@ -1,428 +0,0 @@ -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"; -import { useDispatch, useSelector } from "react-redux"; - -import { CircularProgress, TextField } from "@material-ui/core"; -import { cilSearch } from "@coreui/icons"; -import CIcon from "@coreui/icons-react"; -import Fuse from "fuse.js"; -const SupportRequest = () => { - const token = isAutheticated(); - const navigate = useNavigate(); - const [loading, setLoading] = useState(true); - const [SupportRequestsData, setSupportRequestsData] = useState([]); - - const [currentPage, setCurrentPage] = useState(1); - const [itemPerPage, setItemPerPage] = useState(10); - const [showData, setShowData] = useState(SupportRequestsData); - const [searchTerm, setSearchTerm] = useState(""); - - useEffect(() => { - setTimeout(() => { - if (searchTerm !== "") { - let searchedResult = []; - searchedResult = SupportRequestsData.filter((item) => - item.ticketId.toString().includes(searchTerm) - ); - - setShowData(searchedResult); - } - else{ - getSupportTicketsData(); - } - }, 100); - }, [searchTerm]); - - const handleShowEntries = (e) => { - setCurrentPage(1); - setItemPerPage(e.target.value); - }; - const getSupportTicketsData = async () => { - axios - .get(`/api/support/getAll/`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - - setSupportRequestsData( - res.data?.support.filter((ticket) => ticket.status === "Open") - ); - // setLoading(false); - }) - .catch((error) => { - swal({ - title: error, - text: "please login to access the resource or refresh the page ", - icon: "error", - button: "Retry", - dangerMode: true, - }); - setLoading(false); - }); - }; - React.useEffect(() => { - setLoading(true); - getSupportTicketsData(); - }, [token]); - const statusupdate = (ticketId) => { - axios - .patch( - `/api/support/update/${ticketId}`, - { - status: "Close", - }, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ) - .then((res) => { - swal({ - title: "Success", - text: "Ticket Closed Successfully", - icon: "success", - button: "Close", - }); - getSupportTicketsData(); - }) - .catch((error) => { - swal({ - title: "Error", - text: "Something went wrong", - icon: "error", - button: "Close", - }); - }); - }; - - useEffect(() => { - // const loadData = () => { - const indexOfLastPost = currentPage * itemPerPage; - const indexOfFirstPost = indexOfLastPost - itemPerPage; - setShowData(SupportRequestsData.slice(indexOfFirstPost, indexOfLastPost)); - setLoading(false); - // }; - // loadData(); - }, [currentPage, itemPerPage, SupportRequestsData]); - - return ( -
-
-
-
-
-
-
- Customer Support Requests -
- -
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
- - -
- {/* ********* */} -
- setSearchTerm(e.target.value)} - /> - -
- {/* ********** */} -
- -
- - - - - - - - - - - - - {!loading && showData.length === 0 && ( - - - - )} - {loading ? ( - - - - ) : ( - showData.map((ticket, i) => { - return ( - - - - - - - - - );}) - )} - -
Ticket IDSubjectCreated OnLast ReplyStatus - Action -
-
No Open Tickets Available
-
- {/* Loading... */} - -
{ticket.ticketId}{ticket.subject}{ticket.createdOn}{ticket.lastreply}{ticket.status} - - -
-
- -
-
-
- Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "} - {Math.min( - currentPage * itemPerPage, - SupportRequestsData.length - )}{" "} - of {SupportRequestsData.length} entries -
-
- -
-
-
    -
  • - setCurrentPage((prev) => prev - 1)} - > - Previous - -
  • - - {!(currentPage - 1 < 1) && ( -
  • - - setCurrentPage((prev) => prev - 1) - } - > - {currentPage - 1} - -
  • - )} - -
  • - - {currentPage} - -
  • - - {!( - (currentPage + 1) * itemPerPage - itemPerPage > - SupportRequestsData.length - 1 - ) && ( -
  • - { - setCurrentPage((prev) => prev + 1); - }} - > - {currentPage + 1} - -
  • - )} - -
  • - SupportRequestsData.length - 1 - ) - ? "paginate_button page-item next" - : "paginate_button page-item next disabled" - } - > - setCurrentPage((prev) => prev + 1)} - > - Next - -
  • -
-
-
-
-
-
-
-
-
-
-
- ); -}; - -export default SupportRequest; diff --git a/src/views/CustomerSupport/SupportRequestClosed.js b/src/views/CustomerSupport/SupportRequestClosed.js deleted file mode 100644 index 6453642..0000000 --- a/src/views/CustomerSupport/SupportRequestClosed.js +++ /dev/null @@ -1,379 +0,0 @@ -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"; -import { useDispatch, useSelector } from "react-redux"; -import { CircularProgress, TextField } from "@material-ui/core"; -import { cilSearch } from "@coreui/icons"; -import CIcon from "@coreui/icons-react"; -import Fuse from "fuse.js"; -const SupportRequestClosed = () => { - const token = isAutheticated(); - const navigate = useNavigate(); - const [loading, setLoading] = useState(false); - const [success, setSuccess] = useState(true); - const [status, setStatus] = useState(""); - const [SupportRequestsData, setSupportRequestsData] = useState([]); - - const [currentPage, setCurrentPage] = useState(1); - const [itemPerPage, setItemPerPage] = useState(10); - const [showData, setShowData] = useState(SupportRequestsData); - const [searchTerm, setSearchTerm] = useState(""); - - useEffect(() => { - setTimeout(() => { - if (searchTerm !== "") { - let searchedResult = []; - searchedResult = SupportRequestsData.filter((item) => - item.ticketId.toString().includes(searchTerm) - ); - - setShowData(searchedResult); - } else { - getSupportTicketsData(); - } - }, 100); - }, [searchTerm]); - - const handleShowEntries = (e) => { - setCurrentPage(1); - setItemPerPage(e.target.value); - }; - const [ticketsData, setticketsData] = React.useState([]); - const getSupportTicketsData = async () => { - axios - .get(`/api/support/getAll/`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - setSupportRequestsData( - res.data?.support.filter((ticket) => ticket.status === "Close") - ); - setLoading(false); - }) - .catch((error) => { - swal({ - title: error, - text: "please login to access the resource or refresh the page ", - icon: "error", - button: "Retry", - dangerMode: true, - }); - setLoading(false); - }); - }; - React.useEffect(() => { - setLoading(true); - getSupportTicketsData(); - }, [token]); - - // console.log(showData); - - //********************************* */ - useEffect(() => { - const loadData = () => { - const indexOfLastPost = currentPage * itemPerPage; - const indexOfFirstPost = indexOfLastPost - itemPerPage; - setShowData(SupportRequestsData.slice(indexOfFirstPost, indexOfLastPost)); - }; - loadData(); - }, [currentPage, itemPerPage, SupportRequestsData]); - - return ( -
-
-
-
-
-
-
- Closed Customer Support Requests -
- -
-
-
-
- -
-
-
-
-
-
-
-
- -
-
-
-
- - -
- {/* ********* */} -
- setSearchTerm(e.target.value)} - /> - handleSearch(searchTerm)} - /> -
- {/* ********** */} -
- -
- - - - - - - - - - {/* */} - - - - - {!loading && showData.length === 0 && ( - - - - )} - {loading ? ( - - - - ) : ( - showData.map((ticket, i) => { - return ( - - - - - - - - - ); - }) - )} - -
Ticket IDSubjectCreated OnLast ReplyStatus - Action - Action
-
No Close Tickets Available
-
- {/* Loading... */} - -
- {ticket.ticketId} - {ticket.subject} - {ticket.createdOn} - - {ticket.lastreply} - {ticket.status} - - - -
-
- -
-
-
- Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "} - {Math.min( - currentPage * itemPerPage, - SupportRequestsData.length - )}{" "} - of {SupportRequestsData.length} entries -
-
- -
-
-
    -
  • - setCurrentPage((prev) => prev - 1)} - > - Previous - -
  • - - {!(currentPage - 1 < 1) && ( -
  • - - setCurrentPage((prev) => prev - 1) - } - > - {currentPage - 1} - -
  • - )} - -
  • - - {currentPage} - -
  • - - {!( - (currentPage + 1) * itemPerPage - itemPerPage > - SupportRequestsData.length - 1 - ) && ( -
  • - { - setCurrentPage((prev) => prev + 1); - }} - > - {currentPage + 1} - -
  • - )} - -
  • - SupportRequestsData.length - 1 - ) - ? "paginate_button page-item next" - : "paginate_button page-item next disabled" - } - > - setCurrentPage((prev) => prev + 1)} - > - Next - -
  • -
-
-
-
-
-
-
-
-
-
-
- ); -}; - -export default SupportRequestClosed; diff --git a/src/views/Home/editPanel1.js b/src/views/Home/editPanel1.js deleted file mode 100644 index 71518d2..0000000 --- a/src/views/Home/editPanel1.js +++ /dev/null @@ -1,394 +0,0 @@ -import { useEffect, useState } from "react"; -import Button from "@material-ui/core/Button"; -import { Link } from "react-router-dom"; -import ReactQuill from "react-quill"; -import "react-quill/dist/quill.snow.css"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -const TOOLBAR_OPTIONS = [ - [{ header: [1, 2, 3, 4, 5, 6, false] }], - [{ font: [] }], - [{ list: "ordered" }, { list: "bullet" }], - ["bold", "italic", "underline", "strike"], - [{ color: [] }, { background: [] }], - [{ align: [] }], - [{ script: "super" }, { script: "sub" }], - ["undo", "redo"], -]; -import CloudUploadIcon from "@mui/icons-material/CloudUpload"; -import DeleteSharpIcon from "@mui/icons-material/DeleteSharp"; -import { Box, TextField, Checkbox, FormControlLabel } from "@mui/material"; - -const EditPanel1 = () => { - const token = isAutheticated(); - const [loading, setLoading] = useState(false); - const [displayPanel, setDisplayPanel] = useState(false); - const [content, setContent] = useState(""); - const [olderContent, setOlderContent] = useState(""); - const [image, setimage] = useState(null); - const [title, setTitle] = useState(""); - const [error, setError] = useState(""); - const [newUpdatedImages, setNewUpdatedImages] = useState(null); - const [Img, setImg] = useState(true); - const [id, setId] = useState(null); - - const handleContentChange = (content, delta, source, editor) => { - setContent(editor.getHTML()); - }; - //get Blogdata - const getPanel = async () => { - try { - const res = await axios.get(`/api/panel/panel1/get`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }); - setTitle(res?.data?.panel1[0]?.title); - setimage(res?.data?.panel1[0]?.image); - setContent(res?.data?.panel1[0]?.content); - setOlderContent(res?.data?.panel1[0]?.content); - setDisplayPanel(res?.data?.panel1[0]?.displayPanel); - setId(res?.data?.panel1[0]?._id); - setImg(false); - } catch (err) { - swal({ - title: "Error", - text: "Unable to fetch the panel content", - icon: "error", - button: "Retry", - dangerMode: true, - }); - } - }; - - useEffect(() => { - getPanel(); - }, []); - - const handleFileChange = (e) => { - const files = e.target.files; - // Reset error state - setError(""); - - // Check if more than one image is selected - if (files.length > 1 || Img === false || newUpdatedImages !== null) { - setError("You can only upload one image."); - return; - } - - // Check file types and append to selectedFiles - const allowedTypes = ["image/jpeg", "image/png", "image/jpg"]; - const file = files[0]; // Only one file is selected, so we get the first one - - if (allowedTypes.includes(file.type)) { - setNewUpdatedImages(file); - setimage(file); - } else { - setError("Please upload only PNG, JPEG, or JPG files."); - } - }; - - const handelDelete = async (public_id) => { - console.log(public_id); - const ary = public_id?.split("/"); - setNewUpdatedImages(null); - - const res = await axios.delete( - `/api/v1/blog/deleteImage/jatinMor/Blog/${ary[2]}`, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ); - if (res) { - setimage(null); - setImg(true); - } - }; - - const addContent = async () => { - const formData = new FormData(); - formData.append("title", title); - formData.append("content", content); - formData.append("displayPanel", displayPanel); - formData.append("image", image); - - const response = await axios.post("/api/panel/panel1/add", formData, { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - if (response.status == 201) { - swal({ - title: "Congratulations!!", - text: "Panel 1 added successfully!", - icon: "success", - button: "OK", - }); - } - }; - - const updateContent = () => { - if (title === "" || content === "") { - swal({ - title: "Warning", - text: "Fill all mandatory fields", - icon: "error", - button: "Close", - dangerMode: true, - }); - return; - } - setLoading(true); - - const formData = new FormData(); - formData.append("title", title); - formData.append("content", content); - formData.append("displayPanel", displayPanel); - - if (newUpdatedImages !== null) { - formData.append("image", newUpdatedImages); - } - - axios - .patch(`/api/panel/panel1/update/${id}`, formData, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/form-data", - "Access-Control-Allow-Origin": "*", - }, - }) - .then((res) => { - swal({ - title: "Updated", - text: " Updated successfully!", - icon: "success", - button: "ok", - }); - setLoading(false); - }) - .catch((err) => { - setLoading(false); - - const message = err.response?.data?.message - ? err.response?.data?.message - : "Something went wrong!"; - swal({ - title: "Warning", - text: message, - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - }; - - const handleSaveClick = async () => { - if (olderContent.length === 0) { - addContent(); - } else { - updateContent(); - } - // // Reload terms and conditions - // await getPrivacyPolicy(); - }; - - const handleChange = (event) => { - setDisplayPanel(event.target.checked); - }; - return ( -
-
-
-
-
- Panel 1 -
-
-

-
- -
- - } - label="Display Panel" - /> - - - - -
-
-
-
-
-
-
-
-
- - setTitle(e.target.value)} - /> -
-
- - - - - {error &&

{error}

} -
- - *You cannot upload more than 1 image - -
- - - {image !== null ? ( - - Panel Image - {console.log("image", image)} - - { image?.public_id&& handelDelete(image?.public_id)} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - />} - - ) : null} - -
-
-
-
-
-
-
- - -
-
-
-
-
- ); -}; - -export default EditPanel1; diff --git a/src/views/Home/editPanel2.js b/src/views/Home/editPanel2.js deleted file mode 100644 index 7daf96f..0000000 --- a/src/views/Home/editPanel2.js +++ /dev/null @@ -1,409 +0,0 @@ -import { useEffect, useState } from "react"; -import Button from "@material-ui/core/Button"; -import { Link } from "react-router-dom"; -import ReactQuill from "react-quill"; -import "react-quill/dist/quill.snow.css"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -const TOOLBAR_OPTIONS = [ - [{ header: [1, 2, 3, 4, 5, 6, false] }], - [{ font: [] }], - [{ list: "ordered" }, { list: "bullet" }], - ["bold", "italic", "underline", "strike"], - [{ color: [] }, { background: [] }], - [{ align: [] }], - [{ script: "super" }, { script: "sub" }], - ["undo", "redo"], -]; -import CloudUploadIcon from "@mui/icons-material/CloudUpload"; -import DeleteSharpIcon from "@mui/icons-material/DeleteSharp"; -import { - Box, - TextField, - Checkbox, - FormControlLabel -} from "@mui/material"; - -const EditPanel2 = () => { - const token = isAutheticated(); - const [loading, setLoading] = useState(false); - const [displayPanel, setDisplayPanel] = useState(false); - const [content, setContent] = useState(""); - const [olderContent, setOlderContent] = useState(""); - const [image, setimage] = useState(""); - const [title, setTitle] = useState(""); - const [error, setError] = useState(""); - const [newUpdatedImages, setNewUpdatedImages] = useState(null); - const [Img, setImg] = useState(true); - const [id, setId] = useState(null); - - const handleContentChange = (content, delta, source, editor) => { - setContent(editor.getHTML()); - }; - //get panel data - const getPanel = async () => { - try { - const res = await axios.get(`/api/panel/panel2/get`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }); - if (res?.status === 200) { - setTitle(res?.data?.panel2[0]?.title); - setimage(res?.data?.panel2[0]?.image); - setContent(res?.data?.panel2[0]?.content); - setOlderContent(res?.data?.panel2[0]?.content); - setDisplayPanel(res?.data?.panel2[0]?.displayPanel); - setId(res?.data?.panel2[0]?._id); - setImg(false); - - } - - } catch (err) { - console.error(err) - swal({ - title: "Error", - text: "Unable to fetch the panel content", - icon: "error", - button: "Retry", - dangerMode: true, - }); - } - }; - - useEffect(() => { - getPanel(); - }, []); - - const handleFileChange = (e) => { - const files = e.target.files; - // Reset error state - setError(""); - - // Check if more than one image is selected - if (files.length > 1 || newUpdatedImages !== null) { - setError("You can only upload one image."); - return; - } - - // Check file types and append to selectedFiles - const allowedTypes = ["image/jpeg", "image/png", "image/jpg"]; - const file = files[0]; // Only one file is selected, so we get the first one - - if (allowedTypes.includes(file.type)) { - setNewUpdatedImages(file); - setimage(file); - - } else { - setError("Please upload only PNG, JPEG, or JPG files."); - } - }; - - const handelDelete = async (public_id) => { - const ary = public_id?.split("/"); - setNewUpdatedImages(null); - - const res = await axios.delete( - `/api/v1/blog/deleteImage/jatinMor/Blog/${ary[2]}`, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ); - if (res) { - setimage(null); - setImg(true); - } - }; - - - const addContent = async () => { - - const formData = new FormData(); - formData.append("title", title); - formData.append("content", content); - formData.append("displayPanel", displayPanel); - formData.append("image", image); - - - const response = await axios.post( - "/api/panel/panel2/add", - formData, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); - if (response.status == 201) { - swal({ - title: "Congratulations!!", - text: "Panel 2 added successfully!", - icon: "success", - button: "OK", - }); - } - }; - - const updateContent = () => { - if (title === "" || content === "") { - swal({ - title: "Warning", - text: "Fill all mandatory fields", - icon: "error", - button: "Close", - dangerMode: true, - }); - return; - } - setLoading(true); - - - const formData = new FormData(); - formData.append("title", title); - formData.append("content", content); - formData.append("displayPanel", displayPanel); - - if (newUpdatedImages !== null) { - formData.append("image", newUpdatedImages); - } - - axios - .patch(`/api/panel/panel2/update/${id}`, formData, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/form-data", - "Access-Control-Allow-Origin": "*", - }, - }) - .then((res) => { - swal({ - title: "Updated", - text: " Updated successfully!", - icon: "success", - button: "ok", - }); - setLoading(false); - }) - .catch((err) => { - setLoading(false); - - const message = err.response?.data?.message - ? err.response?.data?.message - : "Something went wrong!"; - swal({ - title: "Warning", - text: message, - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - }; - - const handleSaveClick = async () => { - console.log(olderContent) - if (olderContent?.length === 0 || olderContent===undefined) { - addContent(); - } else { - updateContent(); - } - // // Reload terms and conditions - // await getPrivacyPolicy(); - }; - - const handleChange = (event) => { - setDisplayPanel(event.target.checked); - }; - return ( -
-
-
-
-
- Panel 2 -
-
-

-
- -
- - } - label="Display Panel" - /> - - - - - - -
-
-
-
-
-
-
-
-
- - setTitle(e.target.value)} - /> -
-
- - - - - {error &&

{error}

} -
- - *You cannot upload more than 1 image - -
- - - {image && ( - - Panel Image - { image?.public_id&& handelDelete(image?.public_id)} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - />} - - )} - - -
-
-
-
-
-
-
- - -
-
-
-
-
- ); -}; - -export default EditPanel2; diff --git a/src/views/Home/editPanel3.js b/src/views/Home/editPanel3.js deleted file mode 100644 index b771b3c..0000000 --- a/src/views/Home/editPanel3.js +++ /dev/null @@ -1,407 +0,0 @@ -import { useEffect, useState } from "react"; -import Button from "@material-ui/core/Button"; -import { Link } from "react-router-dom"; -import ReactQuill from "react-quill"; -import "react-quill/dist/quill.snow.css"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -const TOOLBAR_OPTIONS = [ - [{ header: [1, 2, 3, 4, 5, 6, false] }], - [{ font: [] }], - [{ list: "ordered" }, { list: "bullet" }], - ["bold", "italic", "underline", "strike"], - [{ color: [] }, { background: [] }], - [{ align: [] }], - [{ script: "super" }, { script: "sub" }], - ["undo", "redo"], -]; -import CloudUploadIcon from "@mui/icons-material/CloudUpload"; -import DeleteSharpIcon from "@mui/icons-material/DeleteSharp"; -import { - Box, - TextField, - Checkbox, - FormControlLabel -} from "@mui/material"; - -const EditPanel3 = () => { - const token = isAutheticated(); - const [loading, setLoading] = useState(false); - const [displayPanel, setDisplayPanel] = useState(false); - const [content, setContent] = useState(""); - const [olderContent, setOlderContent] = useState(""); - const [image, setimage] = useState(""); - const [title, setTitle] = useState(""); - const [error, setError] = useState(""); - const [newUpdatedImages, setNewUpdatedImages] = useState(null); - const [Img, setImg] = useState(true); - const [id, setId] = useState(null); - - const handleContentChange = (content, delta, source, editor) => { - setContent(editor.getHTML()); - }; - //get Blogdata - const getPanel = async () => { - try { - const res = await axios.get(`/api/panel/panel3/get`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }); - if (res?.status === 200) { - setTitle(res?.data?.panel3[0]?.title); - setimage(res?.data?.panel3[0]?.image); - setContent(res?.data?.panel3[0]?.content); - setOlderContent(res?.data?.panel3[0]?.content); - setDisplayPanel(res?.data?.panel3[0]?.displayPanel); - setId(res?.data?.panel3[0]?._id); - setImg(false); - - } - - } catch (err) { - console.error(err) - swal({ - title: "Error", - text: "Unable to fetch the panel content", - icon: "error", - button: "Retry", - dangerMode: true, - }); - } - }; - - useEffect(() => { - getPanel(); - }, []); - - const handleFileChange = (e) => { - const files = e.target.files; - // Reset error state - setError(""); - - // Check if more than one image is selected - if (files.length > 1 || Img === false || newUpdatedImages !== null) { - setError("You can only upload one image."); - return; - } - - // Check file types and append to selectedFiles - const allowedTypes = ["image/jpeg", "image/png", "image/jpg"]; - const file = files[0]; // Only one file is selected, so we get the first one - - if (allowedTypes.includes(file.type)) { - setNewUpdatedImages(file); - setimage(file); - - } else { - setError("Please upload only PNG, JPEG, or JPG files."); - } - }; - - const handelDelete = async (public_id) => { - const ary = public_id?.split("/"); - setNewUpdatedImages(null); - - const res = await axios.delete( - `/api/v1/blog/deleteImage/jatinMor/Blog/${ary[2]}`, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ); - if (res) { - setimage(null); - setImg(true); - } - }; - - const addContent = async () => { - - const formData = new FormData(); - formData.append("title", title); - formData.append("content", content); - formData.append("displayPanel", displayPanel); - formData.append("image", image); - - - const response = await axios.post( - "/api/panel/panel3/add", - formData, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); - if (response.status == 201) { - swal({ - title: "Congratulations!!", - text: "Panel 3 added successfully!", - icon: "success", - button: "OK", - }); - } - }; - - const updateContent = () => { - if (title === "" || content === "") { - swal({ - title: "Warning", - text: "Fill all mandatory fields", - icon: "error", - button: "Close", - dangerMode: true, - }); - return; - } - setLoading(true); - - - const formData = new FormData(); - formData.append("title", title); - formData.append("content", content); - formData.append("displayPanel", displayPanel); - - if (newUpdatedImages !== null) { - formData.append("image", newUpdatedImages); - } - - axios - .patch(`/api/panel/panel3/update/${id}`, formData, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/form-data", - "Access-Control-Allow-Origin": "*", - }, - }) - .then((res) => { - swal({ - title: "Updated", - text: " Updated successfully!", - icon: "success", - button: "ok", - }); - setLoading(false); - }) - .catch((err) => { - setLoading(false); - - const message = err.response?.data?.message - ? err.response?.data?.message - : "Something went wrong!"; - swal({ - title: "Warning", - text: message, - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - }; - - const handleSaveClick = async () => { - if (olderContent.length === 0) { - addContent(); - } else { - updateContent(); - } - // // Reload terms and conditions - // await getPrivacyPolicy(); - }; - - const handleChange = (event) => { - setDisplayPanel(event.target.checked); - }; - return ( -
-
-
-
-
- Panel 3 -
-
-

-
- -
- - } - label="Display Panel" - /> - - - - - - -
-
-
-
-
-
-
-
-
- - setTitle(e.target.value)} - /> -
-
- - - - - {error &&

{error}

} -
- - *You cannot upload more than 1 image - -
- - - {image && ( - - Panel Image - { image?.public_id&& handelDelete(image?.public_id)} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - />} - - )} - - -
-
-
-
-
-
-
- - -
-
-
-
-
- ); -}; - -export default EditPanel3; diff --git a/src/views/Home/editPanel4.js b/src/views/Home/editPanel4.js deleted file mode 100644 index b74329a..0000000 --- a/src/views/Home/editPanel4.js +++ /dev/null @@ -1,402 +0,0 @@ -import { useEffect, useState } from "react"; -import Button from "@material-ui/core/Button"; -import { Link } from "react-router-dom"; -import ReactQuill from "react-quill"; -import "react-quill/dist/quill.snow.css"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -const TOOLBAR_OPTIONS = [ - [{ header: [1, 2, 3, 4, 5, 6, false] }], - [{ font: [] }], - [{ list: "ordered" }, { list: "bullet" }], - ["bold", "italic", "underline", "strike"], - [{ color: [] }, { background: [] }], - [{ align: [] }], - [{ script: "super" }, { script: "sub" }], - ["undo", "redo"], -]; -import CloudUploadIcon from "@mui/icons-material/CloudUpload"; -import DeleteSharpIcon from "@mui/icons-material/DeleteSharp"; -import { Box, TextField, Checkbox, FormControlLabel } from "@mui/material"; - -const Editpanel4 = () => { - const token = isAutheticated(); - const [loading, setLoading] = useState(false); - const [displayPanel, setDisplayPanel] = useState(false); - const [content, setContent] = useState(""); - const [olderContent, setOlderContent] = useState(""); - const [image, setimage] = useState(""); - const [title, setTitle] = useState(""); - const [error, setError] = useState(""); - const [newUpdatedImages, setNewUpdatedImages] = useState(null); - const [Img, setImg] = useState(true); - const [id, setId] = useState(null); - - const handleContentChange = (content, delta, source, editor) => { - setContent(editor.getHTML()); - }; - //get Blogdata - const getPanel = async () => { - try { - const res = await axios.get(`/api/panel/panel4/get`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }); - if (res?.status === 200) { - setTitle(res?.data?.panel4[0]?.title); - if ( - res?.data?.panel4[0]?.image !== undefined && - res?.data?.panel4[0]?.image !== null - ) { - setimage(res?.data?.panel4[0]?.image); - } - setContent(res?.data?.panel4[0]?.content); - setOlderContent(res?.data?.panel4[0]?.content); - setDisplayPanel(res?.data?.panel4[0]?.displayPanel); - setId(res?.data?.panel4[0]?._id); - setImg(false); - } - } catch (err) { - console.error(err); - swal({ - title: "Error", - text: "Unable to fetch the panel content", - icon: "error", - button: "Retry", - dangerMode: true, - }); - } - }; - - useEffect(() => { - getPanel(); - }, []); - - const handleFileChange = (e) => { - const files = e.target.files; - // Reset error state - setError(""); - - // Check if more than one image is selected - if (files.length > 1 || newUpdatedImages !== null) { - setError("You can only upload one image."); - return; - } - - // Check file types and append to selectedFiles - const allowedTypes = ["image/jpeg", "image/png", "image/jpg"]; - const file = files[0]; // Only one file is selected, so we get the first one - - if (allowedTypes.includes(file.type)) { - setNewUpdatedImages(file); - setimage(file); - } else { - setError("Please upload only PNG, JPEG, or JPG files."); - } - }; - - const handelDelete = async (public_id) => { - const ary = public_id?.split("/"); - setNewUpdatedImages(null); - - const res = await axios.delete( - `/api/v1/blog/deleteImage/jatinMor/Blog/${ary[2]}`, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ); - if (res) { - setimage(null); - setImg(true); - } - }; - - const addContent = async () => { - const formData = new FormData(); - formData.append("title", title); - formData.append("content", content); - formData.append("displayPanel", displayPanel); - formData.append("image", image); - - const response = await axios.post("/api/panel/panel4/add", formData, { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - if (response.status == 201) { - swal({ - title: "Congratulations!!", - text: "Panel 4 added successfully!", - icon: "success", - button: "OK", - }); - } - }; - - const updateContent = () => { - if (title === "" || content === "") { - swal({ - title: "Warning", - text: "Fill all mandatory fields", - icon: "error", - button: "Close", - dangerMode: true, - }); - return; - } - setLoading(true); - - const formData = new FormData(); - formData.append("title", title); - formData.append("content", content); - formData.append("displayPanel", displayPanel); - - if (newUpdatedImages !== null) { - formData.append("image", newUpdatedImages); - } - - axios - .patch(`/api/panel/panel4/update/${id}`, formData, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/form-data", - "Access-Control-Allow-Origin": "*", - }, - }) - .then((res) => { - swal({ - title: "Updated", - text: " Updated successfully!", - icon: "success", - button: "ok", - }); - setLoading(false); - }) - .catch((err) => { - setLoading(false); - - const message = err.response?.data?.message - ? err.response?.data?.message - : "Something went wrong!"; - swal({ - title: "Warning", - text: message, - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - }; - - const handleSaveClick = async () => { - if (!olderContent) { - addContent(); - } else { - updateContent(); - } - // // Reload terms and conditions - // await getPrivacyPolicy(); - }; - - const handleChange = (event) => { - setDisplayPanel(event.target.checked); - }; - return ( -
-
-
-
-
- Panel 4 -
-
-

-
- -
- - } - label="Display Panel" - /> - - - - -
-
-
-
-
-
-
-
-
- - setTitle(e.target.value)} - /> -
-
- - - - - {error &&

{error}

} -
- - *You cannot upload more than 1 image - -
- - - {image && ( - - Panel Image - {image?.public_id && ( - handelDelete(image?.public_id)} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - /> - )} - - )} - -
-
-
-
-
-
-
- - -
-
-
-
-
- ); -}; - -export default Editpanel4; diff --git a/src/views/Home/home.js b/src/views/Home/home.js deleted file mode 100644 index 1562859..0000000 --- a/src/views/Home/home.js +++ /dev/null @@ -1,165 +0,0 @@ -import { - Paper, - Table, - TableBody, - TableCell, - TableContainer, - TableHead, - TableRow, - Typography, - } from "@mui/material"; -import axios from "axios"; -import React, { useEffect, useState } from "react"; -import { Link } from "react-router-dom"; -import { isAutheticated } from "src/auth"; - - export default function Home() { - const [displayPanel1,setDisplayPanel1] = useState("Not Displayed"); - const [displayPanel2,setDisplayPanel2] = useState("Not Displayed"); - const [displayPanel3,setDisplayPanel3] = useState("Not Displayed"); - const [displayPanel4,setDisplayPanel4] = useState("Not Displayed"); - const [loading, setLoading] = useState(false); - let token = isAutheticated(); - - async function getPanelStatus(){ - try { - setLoading(true) - let response1 = await axios.get('/api/panel/panel1/get', { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - } - }) - - let response2 = await axios.get('/api/panel/panel2/get', { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - } - }); - let response3 = await axios.get('/api/panel/panel3/get', { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - } - }); - let response4 = await axios.get('/api/panel/panel4/get', { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - } - }); - if(response1 && response2 && response3 && response4){ - if(response1?.data?.panel1[0]?.displayPanel){ - setDisplayPanel1("Displayed") - } - if(response2?.data?.panel2[0]?.displayPanel){ - setDisplayPanel2("Displayed"); - } - if(response3?.data?.panel3[0]?.displayPanel){ - setDisplayPanel3("Displayed"); - } - if(response4?.data?.panel4[0]?.displayPanel){ - setDisplayPanel4("Displayed"); - } - setLoading(false); - } - } catch (error) { - console.error(error); - } - } - useEffect(()=>{ - getPanelStatus() - },[]) - - const pages = [ - { - name: "Panel 1", - action: "Edit", - path: "/home/panel-1", - status:displayPanel1 - }, - { - name: "Panel 2", - action: "Edit", - path: "/home/panel-2", - status:displayPanel2 - }, - { - name: "Panel 3", - action: "Edit", - path: "/home/panel-3", - status:displayPanel3 - }, - { - name: "Panel 4", - action: "Edit", - path: "/home/panel-4", - status:displayPanel4 - }, - - ]; - - return ( -
- - Home - - - - - - Page - - Display Status - - - Action - - - - - - {pages.map((row) => ( - - - {row.name} - - - {loading ? "loading" : `${row.status}`} - - - - {" "} - - - - - - - ))} - -
-
-
- ); - } - \ No newline at end of file diff --git a/src/views/Images/ShopImage.js b/src/views/Images/ShopImage.js deleted file mode 100644 index 2f42ef3..0000000 --- a/src/views/Images/ShopImage.js +++ /dev/null @@ -1,706 +0,0 @@ -import React, { useState, useEffect } from "react"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -import { - Button, - Box, - IconButton, - Modal, - Pagination, - TextField, - Typography, -} from "@mui/material"; -import CloseIcon from "@mui/icons-material/Close"; -import { ClipLoader } from "react-spinners"; -import swal from "sweetalert"; -import CloudUploadIcon from "@mui/icons-material/CloudUpload"; -import DeleteSharpIcon from "@mui/icons-material/DeleteSharp"; - -const style = { - position: "absolute", - top: "50%", - left: "50%", - transform: "translate(-50%, -50%)", - width: 400, - bgcolor: "background.paper", - borderRadius: "0.5rem", - boxShadow: 24, - width: "500px", -}; - -const Banners = () => { - const token = isAutheticated(); - const [loading, setLoading] = useState(true); - const [updating, setUpdating] = useState(true); // for loading state - // const [isUpdate, setIsUpdate] = useState(false); // for edit state - const [saveLoding, setSaveLoading] = useState(true); - const [edit, setEdit] = useState(false); - const [bannerName, setBannerName] = useState(""); - const [bannerImage, setBannerImage] = useState(""); - const [error, setError] = useState(""); - const [bannerId, setBannerId] = useState(""); - const [banner, setBanner] = useState([]); - const [itemPerPage, setItemPerPage] = useState(10); - const [page, setPage] = useState(1); - const [open, setOpen] = useState(false); - const [olderBannerName, setOlderBaannerName] = useState(""); - const [olderImage, setOlderImage] = useState(""); - - const handleOpen = () => setOpen(true); - const handleClose = () => { - setOpen(false); - // setUpdating(false); - setEdit(false); - - setBannerName(""); - setBannerId(""); - setOlderImage(""); - setBannerImage(""); - }; - - const getBanner = async () => { - try { - const response = await axios.get("/api/shopImage/getImage", { - // headers: { - // Authorization: `Bearer ${token}`, - // }, - }); - - if (response.status === 200) { - // console.log(response); - setBanner(response?.data?.image); - setLoading(false); - } - } catch (error) { - swal({ - title: error, - text: " please login to access the resource ", - icon: "error", - button: "Retry", - dangerMode: true, - }); - } - }; - - useEffect(() => { - getBanner(); - }, []); - // }, [token, banner]); - - const handleEditClick = (_id, bannerImage) => { - setOpen(true); - console.log("bannerImage", bannerImage); - setOlderImage(bannerImage); - - setBannerId(_id); - setOlderBaannerName(bannerName); - setEdit(true); - // setUpdating(false); - }; - // const bannerNamesArray = []; - // const setBannerNamesArray = () => { - // banner && - // banner.map((banner) => { - // bannerNamesArray.push(banner.bannerName.toLowerCase()); - // }); - // }; - // setBannerNamesArray(); - - const handleUpdate = () => { - // const filteredArrayNames = bannerNamesArray.filter( - // (item) => item !== olderBannerName.toLowerCase() - // ); - // console.log(filteredArrayNames, "filter"); - // const bannerExits = filteredArrayNames.includes(bannerName.toLowerCase()); - // if (bannerExits) { - // swal({ - // title: "Warning", - // text: "Banner already exists ", - // icon: "error", - // button: "Retry", - // dangerMode: true, - // }); - // return; - // } - - if (!bannerImage && !olderImage) { - swal({ - title: "Warning", - text: "Please fill all the required fields!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - return; - } - setUpdating(false); - const formData = new FormData(); - - formData.append("bannerImage", bannerImage); - - formData.append("olderImage", JSON.stringify(olderImage)); - - axios - .patch(`/api/shopImage/update/${bannerId}`, formData, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - // setUpdating(true); - // setIsUpdate(false); - handleClose(); - setBannerId(""); - setBannerName(""); - setBannerImage(""); - setOlderImage(""); - setUpdating(true); - setEdit(false); - swal({ - title: "Congratulations!!", - text: "The banner was updated successfully!", - icon: "success", - button: "OK", - }); - // getCategories(); // Refresh the category list after updating - }) - .catch((err) => { - // console.log(err); - swal({ - title: "Sorry, please try again", - text: err, - icon: "error", - button: "Retry", - dangerMode: true, - }); - setUpdating(true); - }); - }; - - 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/shopImage/delete/${_id}`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - swal({ - title: "Congratulations!!", - text: "The banner was deleted successfully!", - icon: "success", - button: "OK", - }); - // getCategories(); // Refresh the category list after deleting - }) - .catch((err) => { - swal({ - title: "", - text: "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - }); - }; - - const handleSaveBanner = async () => { - // const bannerExits = bannerNamesArray.includes(bannerName.toLowerCase()); - // if (bannerExits) { - // swal({ - // title: "Warning", - // text: "Banner Already exits.", - // icon: "error", - // button: "Retry", - // dangerMode: true, - // }); - // return; - // } - if (!bannerImage) { - swal({ - title: "Warning", - text: "Please fill all the required fields!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - return; - } - setSaveLoading(false); - setLoading(true); - const formData = new FormData(); - formData.append("bannerName", bannerName); - formData.append("bannerImage", bannerImage); - - axios - .post("/api/shopImage/add", formData, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/formdata", - }, - }) - .then((response) => { - if (response.status === 201) { - setOpen(false); - setLoading(false); - setSaveLoading(true); - setBannerName(""); - setBannerImage(""); - setOlderImage(""); - swal({ - title: "Added", - text: "New Banner added successfully!", - icon: "success", - button: "OK", - }); - // getCategories(); // Refresh the category list after adding - } - }) - .catch((error) => { - setSaveLoading(true); - swal({ - title: error, - text: "something went wrong", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - }; - // const getPageCount = () => { - // return Math.max(1, Math.ceil(banner?.length / itemPerPage)); - // }; - - const handleFileChange = (e) => { - const files = e.target.files[0]; - - // Check file types and append to selectedFiles - const allowedTypes = ["image/jpeg", "image/png", "image/jpg"]; - if (allowedTypes.includes(files.type)) { - setBannerImage(files); - } - }; - const handeldeleteImage = () => { - setBannerImage(""); - }; - return ( -
-
-
-
-
-
-
- Shop Page Image -
- -
- {/* */} - - - {/* - - Banner Name - - handleClose()}> - - - */} - {/*
*/} - {/* - setBannerName( - e.target.value.charAt(0).toUpperCase() + - e.target.value.slice(1) - ) - } - /> */} - {/* {bannerName ? ( - <> - - {25 - bannerName.length} characters left - - - ) : ( - <> - )} */} - - - - {bannerImage && ( - - bannerImage - handeldeleteImage()} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - /> - - )} - {olderImage && ( - - bannerImage - setOlderImage("")} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - /> - - )} - - - {error &&

{error}

} -

- Upload jpg, jpeg and png only* -

- - - {!edit && ( - - )} - {edit && ( - - )} - - -
-
-
-
-
-
- -
-
-
-
-
-
- {/*
- -
*/} -
-
- -
- - - - - - - - - - - {!loading && banner?.length === 0 && ( - - - - )} - {loading ? ( - - - - ) : ( - banner && - banner.map((item, i) => ( - - - {/* */} - - - - )) - )} - -
ImageActionDimension
- -
- Loading... -
- - {/* {item?.image} */} -
{}
-
-
{item.bannerName}
-
- - {/* */} - 1200 x 800 pixels
-
- - {/*
- setPage(value)} - /> -
*/} -
-
-
-
-
-
-
- ); -}; - -export default Banners; diff --git a/src/views/Patients/Patient.js b/src/views/Patients/Patient.js deleted file mode 100644 index 01a6376..0000000 --- a/src/views/Patients/Patient.js +++ /dev/null @@ -1,650 +0,0 @@ - - -import React, { useState, useEffect, useRef } from "react"; -import { Link } 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"; -const Patient = () => { - const token = isAutheticated(); - const navigate = useNavigate(); - const [loading, setLoading] = useState(false); - const [success, setSuccess] = useState(true); - const [patientsData, setPatientsData] = useState([]); - - const nameRef = useRef(); - // const categoryRef = useRef(); - const mobileRef = useRef() - const VerifyPatientRef = useRef(); - - const [currentPage, setCurrentPage] = useState(1); - const [itemPerPage, setItemPerPage] = useState(10); - const [totalData, setTotalData] = useState(0); - - // const { - // edit, - // add, - // delete: deletepermission, - // } = checkPermission("Patient Master"); - const getPatientsData = async () => { - setLoading(true); - await axios - .get(`/api/patient/getAll/`, { - headers: { - Authorization: `Bearer ${token}`, - }, - params: { - page: currentPage, - show: itemPerPage, - name: nameRef.current.value, - mobileNumber: mobileRef.current.value, - isVerified: VerifyPatientRef.current.value, - }, - }) - .then((res) => { - // console.log("res.data?.data", res.data); - setPatientsData(res.data?.patient); - setTotalData(res.data?.total_data); - setLoading(false); - }) - .catch((err) => { - const msg = err?.response?.data?.message || "Something went wrong!"; - swal({ - title: err, - text: msg, - icon: "error", - button: "Retry", - dangerMode: true, - }); - setLoading(false); - }); - - setLoading(false); - }; - - // const getCatagories = () => { - // axios - // .get(`/api/category/getCategories`, { - // headers: { - // "Access-Control-Allow-Origin": "*", - // Authorization: `Bearer ${token}`, - // }, - // }) - // .then((res) => { - // setCategories(res?.data?.categories); - // }); - // }; - - - // useEffect(() => { - // getCatagories(); - // }, []); - - useEffect(() => { - getPatientsData(); - }, [success, itemPerPage, currentPage]); - - 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/patient/delete/${id}`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - swal({ - title: "Deleted", - text: "Patient Deleted successfully!", - icon: "success", - button: "ok", - }); - setSuccess((prev) => !prev); - }) - .catch((err) => { - let msg = err?.response?.data?.message - ? err?.response?.data?.message - : "Something went wrong!"; - swal({ - title: "Warning", - text: msg, - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - }); - }; - const handleVerifydPatient = (id) => { - swal({ - title: "Are you sure?", - icon: "warning", - buttons: { - Yes: { text: "Yes", value: true }, - Cancel: { text: "Cancel", value: "cancel" }, - }, - }).then((value) => { - if (value === true) { - axios - .patch(`/api/patient/admin/feature_product/status/${id}`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - swal({ - title: "Changed", - text: " Verify Patient status changed successfully!", - icon: "success", - button: "ok", - }); - setSuccess((prev) => !prev); - }) - .catch((err) => { - let msg = err?.response?.data?.msg - ? err?.response?.data?.msg - : "Something went wrong!"; - swal({ - title: "Warning", - text: msg, - icon: "warning", - button: "ok", - dangerMode: true, - }); - }); - } - }); - }; - const handleStatus = (id) => { - swal({ - title: "Are you sure?", - icon: "warning", - buttons: { - Yes: { text: "Yes", value: true }, - Cancel: { text: "Cancel", value: "cancel" }, - }, - }).then((value) => { - if (value === true) { - axios - .patch(`/api/patient/admin/status/${id}`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - swal({ - title: "Changed", - text: "Patient status changed successfully!", - icon: "success", - button: "ok", - }); - setSuccess((prev) => !prev); - }) - .catch((err) => { - swal({ - title: "Warning", - text: "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - }); - }; - return ( -
-
-
-
-
-
-
- Patients -
- {/*
- -
*/} -
-
-
- -
-
-
-
-
-
-
- -
-
-
- - -
-
- - -
- {/*
- - -
*/} -
- - -
-
- -
-
- -
- - - - {/* */} - - {/* */} - - - {/* */} - - - - - - - - - - - - - - {loading ? ( - - - - ) : patientsData?.length > 0 ? ( - patientsData?.map((patient, i) => { - return ( - - {/* */} - - - - - - - - - - - - - - - - - - - - ); - }) - ) : ( - !loading && - patientsData?.length === 0 && ( - - - - ) - )} - -
ImageNameCategoryMobile No.PriceEmailVerifyDevice AddedRegister OnAction
- Loading... -
- {patient?.image && - patient?.image?.length !== 0 ? ( - <> - preview - - ) : ( -
-

No

-

image

-

uploaded!

-
- )} -
{patient?.name}{patient?.mobileNumber}{patient?.email ? patient?.email : <>No Email Added! - } - - {patient?.isVerified ? "YES" : "NO"} - - - - - - {patient?.deviceAdded ? "YES" : "NO"} - - - - - {new Date(patient.createdAt).toLocaleString( - "en-IN", - { - weekday: "short", - month: "short", - day: "numeric", - year: "numeric", - hour: "numeric", - minute: "numeric", - hour12: true, - } - )} - - {/* - - */} - - - - - {/* - - */} - - - - -
-
No Patient 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 Patient; diff --git a/src/views/Patients/ViewPatient.js b/src/views/Patients/ViewPatient.js deleted file mode 100644 index b6f82c4..0000000 --- a/src/views/Patients/ViewPatient.js +++ /dev/null @@ -1,263 +0,0 @@ -import React, { useState, useEffect } from "react"; -import axios from "axios"; -import { useLocation, useNavigate, useParams } from "react-router-dom"; -import { isAutheticated } from "src/auth"; - -const ViewPatient = () => { - // const id = useParams()?.id; - - const location = useLocation(); - const { currencyDetails } = location.state || {}; - - const { id } = useParams(); - const token = isAutheticated(); - - const [patientData, setPatientData] = useState({}); - const [SAW, setSAW] = useState([ - { volume: "", weight: "" }, - { volume: "", weight: "" }, - { volume: "", weight: "" }, - { volume: "", weight: "" }, - { volume: "", weight: "" }, - ]); - const navigate = useNavigate(); - - const getPatientData = async () => { - axios - .get(`/api/patient/getOne/${id}`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - console.log(res.data.data); - setPatientData(res.data.data); - if (res.data.data?.variants) { - setSAW((prev) => [...res.data.data?.variants]); - } - }) - .catch((err) => { }); - }; - useEffect(() => { - getPatientData(); - }, []); - - const onCancel = () => { - navigate("//patients"); - }; - let count = 1; - return ( -
-
-
- {/* */} -
-
-
-

Patient Details

- - -
-
-
- {/* */} - -
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name{patientData?.name}
Patient Group{patientData?.category?.categoryName}
Images - {patientData?.image && - patientData?.image?.length !== 0 - ? patientData?.image.map((e, i) => ( - preview - )) - : "No Images Uploaded!"} -
Description{patientData?.description}
Patient Status - {patientData?.patient_Status} -
Special Instructions -

- {patientData?.special_instructions - ? patientData?.special_instructions - : "---"} -

-
- - - - - - - - - - - - {SAW.map( - (r, i) => - r.variant_Name !== "" && ( - - - - - - - ) - )} - {SAW.filter((e) => e.variant_Name !== "").length === - 0 && ( - - - - )} - -
- Varients: -
Variant NamePriceVAT
- {r?.variant_Name} - - {currencyDetails?.CurrencySymbol} - {r?.price} - - {r?.gst_Id?.name + " " + r?.gst_Id?.tax + "%"} -
- No data available -
- {/*
- - - {patientData?.patient_Fabric?.length > 0 ? ( - <> - - - - - - - - - {patientData?.patient_Fabric?.map((r, i) => ( - - - - - - ))} - - - ) : ( - <> -
No Fabric Allotted for this patient!
- - )} -
- Patient Fabric: -
S. No. Name Use For Part
{++i} - {r?.fabric_Name} - {r?.for_Part}
-
*/} - {/*
- - - {patientData?.relevent_patient?.length > 0 ? ( - <> - - - - - - - - {patientData?.relevent_patient?.map((r, i) => ( - - - - - ))} - - - ) : ( - <> -
No relevent item for this patient !
- - )} -
- Relevent Patient: -
S. No.Patient Name
{count++}{r?.name}
-
*/} -
- - {/* */} -
-
-
-
-
- {/* */} -
-
- ); -}; - -export default ViewPatient; diff --git a/src/views/PointOfSale/AddressSelectionModal.js b/src/views/PointOfSale/AddressSelectionModal.js deleted file mode 100644 index 32cf183..0000000 --- a/src/views/PointOfSale/AddressSelectionModal.js +++ /dev/null @@ -1,77 +0,0 @@ -import React from "react"; -import Modal from "react-modal"; - -const AddressSelectionModal = ({ isOpen, onClose, addresses, onSelect }) => { - const modalStyle = { - overlay: { - backgroundColor: "rgba(0, 0, 0, 0.5)", - }, - content: { - top: "50%", - left: "50%", - right: "auto", - bottom: "auto", - marginRight: "-50%", - transform: "translate(-50%, -50%)", - maxWidth: "800px", - width: "90%", - }, - }; - - const tableStyle = { - width: "100%", - borderCollapse: "collapse", - }; - - const thTdStyle = { - border: "1px solid #ddd", - padding: "8px", - }; - - const thStyle = { - ...thTdStyle, - backgroundColor: "#f2f2f2", - }; -// console.log(addresses); - return ( - -

Select Address

- - - - - - - - - - - {/* Add additional columns as needed */} - - - - {addresses.map((address, index) => ( - onSelect(address)} - style={{ cursor: "pointer", ...thTdStyle }} - > - - - - - - - - {/* Add additional columns as needed */} - - ))} - -
First NameLast NamePhone NumberStreetCityPostal CodeState
{address.first_Name}{address.last_Name}{address.phone_Number}{address.street}{address.city}{address.postalCode}{address.state}
- -
- ); -}; - -export default AddressSelectionModal; - diff --git a/src/views/PointOfSale/Pos.js b/src/views/PointOfSale/Pos.js deleted file mode 100644 index 630b030..0000000 --- a/src/views/PointOfSale/Pos.js +++ /dev/null @@ -1,1242 +0,0 @@ -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"; -import swal from "sweetalert"; -import { - Box, - FormControl, - IconButton, - InputLabel, - MenuItem, - Select, - TextField, - Container, - Grid, - Paper, - Typography, -} from "@mui/material"; -import toast, { Toaster } from "react-hot-toast"; -import SearchIcon from "@mui/icons-material/Search"; -import ClearIcon from "@mui/icons-material/Clear"; -// import PercentIcon from "@mui/icons-material/Percent"; -import Table from "@mui/material/Table"; -import TableBody from "@mui/material/TableBody"; -import TableCell from "@mui/material/TableCell"; -import TableContainer from "@mui/material/TableContainer"; -import TableHead from "@mui/material/TableHead"; -import TableRow from "@mui/material/TableRow"; -import AddressSelectionModal from "./AddressSelectionModal"; - -const Pos = () => { - const token = isAutheticated(); - const [query, setQuery] = useState(""); - const navigate = useNavigate(); - const [loading, setLoading] = useState(true); - - const [usersWithAddresses, setUsersWithAddresses] = useState([]); - - const getUsersWithAddresses = async () => { - try { - const usersResponse = await axios.get("/api/v1/admin/users", { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - const users = usersResponse.data.users; - - const usersWithAddressesPromises = users.map(async (user) => { - try { - const addressResponse = await axios.get( - `/api/shipping/address/user/address/${user._id}`, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); - const userWithAddress = { - ...user, - address: addressResponse.data?.UserShippingAddress || [], - }; - return userWithAddress; - } catch (error) { - throw new Error(`Error fetching address for user ${user._id}`); - } - }); - - const usersWithAddresses = await Promise.all(usersWithAddressesPromises); - setUsersWithAddresses(usersWithAddresses); - } catch (error) { - swal({ - title: error, - text: "Please login to access the resource or refresh the page.", - icon: "error", - button: "Retry", - dangerMode: true, - }); - } - }; - - useEffect(() => { - getUsersWithAddresses(); - }, [token]); - const [showData, setShowData] = useState(usersWithAddresses); - const [currentUser, setCurrentUser] = useState(null); - const [storedelivery, setStoreDelivery] = useState(""); - - // Function to handle change in radio button selection - const handleSalesTypeChange = (event) => { - setSalesType(event.target.value); - }; - const handlestoredeliveryChange = (event) => { - setStoreDelivery(event.target.value); - }; - useEffect(() => { - setTimeout(() => { - if (query !== "") { - setCurrentUser(null); - const lowerCaseQuery = query.toLowerCase(); // Convert query to lowercase - - const searchedResult = usersWithAddresses.filter((item) => - item.name.toString().toLowerCase().includes(lowerCaseQuery) - ); - - setShowData(searchedResult); - setLoading(false); - } - }, 100); - }, [query]); - - const handleClick = (id) => { - setQuery(""); - const customer = usersWithAddresses.find((user) => user._id === id); - setCurrentUser(customer); - }; - - // part 2*****************************8 - const [productData, setProductData] = useState([]); - const [filteredItems, setFilteredItems] = useState([]); - const [categories, setCategories] = useState([]); - const [selectedCategories, setSelectedCategories] = useState([]); - const [categoryValue, setCategoryValue] = useState("All"); - const [cartItem, setCartItem] = useState([]); - const [individualSubtotals, setIndividualSubtotals] = useState([]); - const [total, setTotal] = useState(0); - // varient - const [selectedVariants, setSelectedVariants] = useState({}); - - const getAllProducts = async () => { - try { - const response = await axios.get("/api/product/getAll/user/"); - if (response.status === 200) { - // setProductData(response?.data?.product); - const activeProducts = response?.data?.product.filter( - (product) => product.product_Status === "Active" - ); - setProductData(activeProducts); - } - } catch (error) { - console.error("Error fetching products:", error); - } - }; - - const getCaterogy = async () => { - try { - const response = await axios.get("/api/category/getCategories"); - if (response.status === 200) { - setCategories(response?.data?.categories); - } - } catch (error) { - console.error("Error fetching categories:", error); - } - }; - const handleChange = (event) => { - const { name, value } = event.target; - - if (name === "category") { - setCategoryValue(value); - setSelectedCategories((prevCategories) => { - if (prevCategories.includes(value)) { - return prevCategories.filter((category) => category !== value); - } else { - return [...prevCategories, value]; - } - }); - } - }; - const items = () => { - setFilteredItems( - productData?.filter((item) => { - const categoryMatch = - categoryValue === "All" || - item.category.categoryName === categoryValue; - return categoryMatch; - }) - ); - }; - - useEffect(() => { - setLoading(true); - getAllProducts() - .then(() => { - getCaterogy(); - }) - .catch((error) => { - console.error("Error fetching products:", error); - }) - .finally(() => { - setLoading(false); // Set loading to false after data fetching - }); - }, [token]); - - useEffect(() => { - items(); - }, [categoryValue, productData]); - const styles = { - selectHeading: { - fontFamily: "inter", - fontWeight: "600", - fontSize: "16px", - color: "#6C7275", - marginBottom: ".5rem", - }, - tableContainer: { - maxHeight: 360, - height: 360, - overflowY: "auto", // Enable vertical scrolling - }, - headingStyle: { - fontFamily: "inter", - fontWeight: "600", - fontSize: "16px", - color: "#121212", - width: "70%", - borderBottom: "1px solid black", - }, - }; - - const addToCart = async (item) => { - try { - const selectedVariant = selectedVariants[item._id]; - if (selectedVariant) { - // Fetch tax details using the gstdetails function - const taxRate = selectedVariant?.gst_Id?.tax / 100; - const taxAmount = selectedVariant.price * taxRate; - const subtotal = - parseFloat(selectedVariant.price) + parseFloat(taxAmount); - - const existingCartItemIndex = cartItem.findIndex( - (cartItem) => - cartItem.product._id === item._id && - cartItem.variant._id === selectedVariant._id - ); - - if (existingCartItemIndex !== -1) { - const newCart = [...cartItem]; - const existingCartItem = newCart[existingCartItemIndex]; - - existingCartItem.quantity += 1; - existingCartItem.subtotal = - parseFloat(existingCartItem.quantity) * - parseFloat(existingCartItem.subtotal); - - setCartItem(newCart); - swal("Item quantity updated in cart", "", "success"); - } else { - setCartItem([ - ...cartItem, - { - product: item, - quantity: 1, - variant: { - _id: selectedVariant._id, - gst_Id: selectedVariant.gst_Id, - price: selectedVariant.price, - volume: selectedVariant.volume, - weight: selectedVariant.weight, - variant_Name: selectedVariant.variant_Name, - }, - subtotal: subtotal.toFixed(2), // Format the subtotal to two decimal places - }, - ]); - swal("Item added to cart", "", "success"); - } - } - } catch (error) { - console.error("Error adding item to cart:", error); - swal("Error", "Failed to add item to cart", "error"); - } - }; - - const handleIncrease = (index) => { - const newCart = [...cartItem]; - const item = newCart[index]; - const taxRate = item.variant?.gst_Id?.tax / 100; - const taxAmount = item.variant?.price * taxRate; - const price = item.variant ? item.variant?.price : item.product.price; - const totalAmount = - (item.quantity + 1) * (parseFloat(price) + parseFloat(taxAmount)); - - newCart[index].quantity += 1; - newCart[index].subtotal = totalAmount; - - setCartItem(newCart); - }; - const handleDecrease = (index) => { - const newCart = [...cartItem]; - const item = newCart[index]; - const taxRate = item.variant?.gst_Id?.tax / 100; - const taxAmount = item.variant?.price * taxRate; - const price = item.variant ? item.variant?.price : item.product.price; - const totalAmount = - (item.quantity - 1) * (parseFloat(price) + parseFloat(taxAmount)); - - newCart[index].quantity -= 1; - newCart[index].subtotal = totalAmount; - - setCartItem(newCart); - }; - - const removeCartItemHandler = (id, variant) => { - const newCart = cartItem.filter( - (item) => item.product._id !== id || item.variant._id !== variant - ); - setCartItem(newCart); - }; - - // Calculate subtotal of all items in cart - const calculateTotal = () => { - let subtotal = 0; - cartItem.forEach((item) => { - subtotal += parseFloat(item.subtotal); - }); - // Round the subtotal to two decimal places - const roundedSubtotal = parseFloat(subtotal.toFixed(2)); - setTotal(roundedSubtotal); - }; - - useEffect(() => { - calculateTotal(); - }, [cartItem]); - - // console.log(usersWithAddresses); - const [showChangeAddress, setShowChangeAddress] = useState(false); - const [selectedAddress, setSelectedAddress] = useState( - currentUser?.address[0] - ); - useEffect(() => { - setSelectedAddress(currentUser?.address[0]); - }, [currentUser]); - const handleChangeAddress = () => { - setShowChangeAddress(true); - }; - - const handleSelectAddress = (address) => { - setSelectedAddress(address); - setShowChangeAddress(false); - }; - - const checkoutCash = async () => { - const config = { - headers: { - Authorization: `Bearer ${token}`, - }, - }; - - const cartData = cartItem.map((item) => ({ - product: item.product, // Entire product object - quantity: item.quantity, - variant: item.variant, // Entire variant object - subtotal: item.subtotal, - })); - - const order = { - userr: currentUser._id, - address: selectedAddress._id, - cart: cartData, - subtotal: total, - orderType: "PointOfSale", - }; - - // Send POST request to backend API endpoint - axios - .post("/api/order/pos-checkout/", order, config) - .then((response) => { - // Handle successful response - swal({ - title: "Order Placed!", - text: `Order ID: ${ - response.data.order.orderID - }\nDate and Time: ${new Date( - response.data.order.createdAt - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - })}`, - icon: "success", - button: "OK", - }); - - // Clear cart items, reset current user and address, and reset radio button states - setCartItem([]); - setCurrentUser(null); - setSelectedAddress(null); - setStoreDelivery(""); - setTotal(0); - setCategoryValue("All"); - }) - .catch((error) => { - // Handle errors - console.error("Error placing order:", error); - - toast.error( - "Error! There was an error placing your order. Please try again later." - ); - }); - }; - - // for QR Code - const checkoutQRCode = async () => { - try { - const { - data: { key }, - } = await axios.get( - `/api/order/getRzpKey/${currentUser.name}/${currentUser.email}`, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ); - - const cartData = cartItem.map((item) => ({ - product: item.product, // Entire product object - quantity: item.quantity, - variant: item.variant, // Entire variant object - subtotal: item.subtotal, - })); - - const { - data: { order }, - } = await axios.post( - "/api/order/Rzpcheckout", - { - userr: currentUser._id, - address: selectedAddress._id, - cart: cartData, - subtotal: total, - orderType: "PointOfSale", - }, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ); - - const options = { - key, - amount: order.amount, - currency: "INR", - name: "Smellika", - description: "Smellika RazorPay", - image: - "https://res.cloudinary.com/dnmgivd1x/image/upload/v1707058241/bolo/Logo/aasy4ulmbbtqmcxi64j0.jpg", - order_id: order.id, - // callback_url: - // "http://localhost:5000/api/order/pos-paymentverification/", - callback_url: - "https://api.smellika.com/api/order/pos-paymentverification/", - - prefill: { - name: currentUser.name, - email: currentUser.email, - }, - notes: { - address: "Razorpay Corporate Office", - }, - theme: { - color: "#121212", - }, - }; - - const razor = new window.Razorpay(options); - - razor.on("payment.success", async function (response) { - // Handle successful payment - console.log("Payment successful:", response); - }); - - razor.open(); - } catch (error) { - if ( - error.response && - error.response.data && - error.response.data.message - ) { - // If error.response and its properties exist, handle the error message - toast.error(error.response.data.message); - } else { - // If error.response or its properties are undefined, handle the error generically - toast.error("An error occurred. Please try again later."); - } - } - }; - - // Function to set default variant for each product - const setDefaultVariants = () => { - const defaultVariants = {}; - filteredItems.forEach((item) => { - defaultVariants[item._id] = - item.variants && item.variants.length > 0 ? item.variants[0] : null; - }); - setSelectedVariants(defaultVariants); - }; - - // Function to handle variant change - const handleVariantChange = (productId, event) => { - const selectedVariantName = event.target.value; - const selectedVariant = filteredItems - .find((item) => item._id === productId) - ?.variants.find( - (variant) => variant.variant_Name === selectedVariantName - ); - setSelectedVariants((prevState) => ({ - ...prevState, - [productId]: selectedVariant, - })); - }; - // console.log(selectedVariants); - // console.log(cartItem); - // Call setDefaultVariants when the component mounts - useEffect(() => { - setDefaultVariants(); - }, [filteredItems]); - - // console.log("currentUser", currentUser); - return ( -
-
-
- {/* Part 1: Top Part */} -
-
-
-
- {/* Customer search */} -
- - Select Customer: - - setQuery(e.target.value)} - InputProps={{ - endAdornment: ( - handleSearchClick(query)} - > - - - ), - disableUnderline: true, - }} - /> -
- {query !== "" && ( -
- - - - - - - - - - {!loading && showData.length === 0 && ( - - - - )} - {loading ? ( - - - - ) : ( - showData.map((user, index) => ( - { - if (user.address.length === 0) { - toast.error( - "Please add an address for shopping." - ); - } else { - handleClick(user?._id); - } - }} - className={`cursor-pointer hover:bg-gray-100 ${ - user.address.length === 0 ? "opacity-50" : "" - }`} - > - - {user.address.length === 0 ? ( - - ) : ( - <> - - - - )} - - )) - )} - -
Customer NameAddressMobile No.
-
- -
-
- Loading... -
{user.name} - Add address for shopping - - {`${user?.address[0]?.street}, ${user?.address[0]?.city}, ${user?.address[0]?.state}, ${user?.address[0]?.country}, ${user?.address[0]?.postalCode}`} - {`${user?.address[0]?.phone_Number}`}
-
- )} - {/* Display selected customer */} -
- {currentUser && ( -
-
-
-
- - Customer Name: - - {`${currentUser?.name}`} -
-
- - Mobile No.: - - {`${selectedAddress?.phone_Number}`} -
-
- - Address: - - {`${selectedAddress?.street}, ${selectedAddress?.city}, ${selectedAddress?.state}, ${selectedAddress?.country}, ${selectedAddress?.postalCode}`} -
- -
-
-
- )} - {/* Render AddressSelectionModal only when currentUser exists */} - {currentUser && ( - setShowChangeAddress(false)} - addresses={currentUser.address} - onSelect={handleSelectAddress} - /> - )} -
-
-
-
-
- {/* Part 2: Panel 1 and Panel 2 */} -
- {/* Panel 1 (Left Hand Side) */} -
-
- {/* Category selection */} -
- - Categories: - - - - -
- {/* Product display */} -
-
- - - - - - - - - - - - {filteredItems.map((item, index) => ( - - - - - - - - - ))} - -
Product ImageProduct NamevariantPriceAction
- {item.image && item.image.length > 0 && ( - Product Image - )} - {item.name} - {item.variants && item.variants.length > 0 ? ( - - - - ) : ( - "No Variant" - )} - - {selectedVariants[item._id] - ? selectedVariants[item._id].price - : item.price} - - -
-
-
-
-
- {/* Panel 2 (Right Hand Side) */} -
-
- {/* Display added products */} - - Added Products: - - {/* Display added products */} -
- - - - - - - - - - Product - - - Quantity - - - Price - - - GST - - - - Subtotal - - - - - {cartItem.length === 0 ? ( - - - - Add products for shopping - - - - ) : ( - cartItem.map((row, index) => ( - - - {/* {row.product} */} - - - - - - - {row?.product.name} - - - removeCartItemHandler( - row?.product._id, - row.variant._id - ) - } - sx={{ - color: "#6C7275", - width: "105%", - display: "flex", - alignItems: "center", - // justifyContent: "space-between", - cursor: "pointer", - ml: "10px", - - // border: 'solid' - }} - > - - - Remove - - - - - - - - - handleDecrease(index) - } - > - - - - - {row && row.quantity} - - handleIncrease(index) - } - > - + - - - - - ₹ - {row?.variant.price - ? row.variant.price - : row.product.price} - {/* {selectedVariants[row._id] - ? selectedVariants[row._id].price - : row.price} */} - - - ₹ - {Number( - (row.variant?.price * - row.variant?.gst_Id?.tax) / - 100 - )?.toFixed(2)} - - - - ₹{Number(row?.subtotal)?.toFixed(2)} - - - )) - )} - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {currentUser ? ( -
- - In-Store delivery: - -
- - -
-
- - -
- {storedelivery && ( - - )} -
- ) : ( -
-

- Please Add user and their address to place the order -

-
- )} -
- - {/* Total Section */} -
- - Total: - - - ₹{total} - -
-
-
-
-
-
-
-
-
- ); -}; - -export default Pos; diff --git a/src/views/Products/Productcomponents/ProductDetails.js b/src/views/Products/Productcomponents/ProductDetails.js index be051da..8b5141a 100644 --- a/src/views/Products/Productcomponents/ProductDetails.js +++ b/src/views/Products/Productcomponents/ProductDetails.js @@ -165,7 +165,7 @@ const ProductDetails = (props) => {
+
+
+ + +
+
+
+ + +
+
+ + +
+
+ + + + + + + + + + {/* OTP Modal */} + setShowModal(false)}> + + Enter OTP + + + + OTP + + setFormData({ ...formData, otp: e.target.value }) + } + required + /> + + + + + + + + + ); +}; + +export default AddSalesCoOrdinator; diff --git a/src/views/SalesCoOrdinators/EditSalesCoOrdinator.js b/src/views/SalesCoOrdinators/EditSalesCoOrdinator.js new file mode 100644 index 0000000..679f630 --- /dev/null +++ b/src/views/SalesCoOrdinators/EditSalesCoOrdinator.js @@ -0,0 +1,395 @@ +import React, { useState, useEffect } from "react"; +import axios from "axios"; +import { useNavigate, useParams } from "react-router-dom"; +import { isAutheticated } from "src/auth"; +import Modal from "react-bootstrap/Modal"; +import Button from "react-bootstrap/Button"; +import Form from "react-bootstrap/Form"; +import swal from "sweetalert"; + +const EditSalesCoOrdinator = () => { + const navigate = useNavigate(); + const token = isAutheticated(); + const { id } = useParams(); + + const [formData, setFormData] = useState({ + name: "", + email: "", + countryCode: "", + mobileNumber: "", + currentPassword: "", + newPassword: "", + confirmPassword: "", + otp: "", + }); + + const [showVerifyModal, setShowVerifyModal] = useState(false); + const [showPasswordModal, setShowPasswordModal] = useState(false); + + useEffect(() => { + getSalesCoOrdinatorData(); + }, []); + + const getSalesCoOrdinatorData = async () => { + try { + const response = await axios.get(`/api/salescoordinator/getOne/${id}`, { + headers: { + Authorization: `Bearer ${token}`, + }, + }); + const { data } = response.data; + + // Assuming country code always starts with + and is followed by 1-3 digits + const fullMobileNumber = data?.mobileNumber || ""; + const countryCodeMatch = fullMobileNumber.match(/^\+\d{1,2}/); + const countryCode = countryCodeMatch ? countryCodeMatch[0] : ""; + const mobileNumber = fullMobileNumber.replace(countryCode, ""); + + setFormData({ + name: data?.name || "", + email: data?.email || "", + countryCode: countryCode, + mobileNumber: mobileNumber, + currentPassword: "", + newPassword: "", + confirmPassword: "", + otp: "", + }); + } catch (error) { + console.error("Error fetching sales coordinator data: ", error); + } + }; + + const handleChange = (e) => { + setFormData({ ...formData, [e.target.name]: e.target.value }); + }; + + const handleUpdateBasicInfo = () => { + axios + .patch( + `/api/salescoordinator/profile/update/${id}`, + { + name: formData.name, + email: formData.email, + }, + { + headers: { + Authorization: `Bearer ${token}`, + }, + } + ) + .then((response) => { + swal({ + title: "Success", + text: "Sales coordinator information updated successfully!", + icon: "success", + button: "OK", + }); + }) + .catch((error) => { + let msg = error?.response?.data?.message || "Something went wrong!"; + swal({ + title: "Warning", + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + }); + }; + + const handleVerifyMobile = () => { + axios + .post( + `/api/salescoordinator/update-mobile-number/${id}`, + { + newCountryCode: formData.countryCode, + newMobileNumber: formData.mobileNumber, + }, + { + headers: { + Authorization: `Bearer ${token}`, + }, + } + ) + .then(() => { + setShowVerifyModal(true); + }) + .catch((error) => { + let msg = error?.response?.data?.message || "Something went wrong!"; + swal({ + title: "Warning", + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + }); + }; + + const handleVerifyOTP = () => { + axios + .post( + "/api/salescoordinator/verify-updated-mobile-otp", + { + otp: formData.otp, + newMobileNumber: `${formData.countryCode}${formData.mobileNumber}`, + }, + { + headers: { + Authorization: `Bearer ${token}`, + "Content-Type": "application/json", + }, + } + ) + .then(() => { + setShowVerifyModal(false); + // Handle success, if needed + }) + .catch((error) => { + let msg = error?.response?.data?.message || "Something went wrong!"; + swal({ + title: "Warning", + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + }); + }; + + const handleChangePassword = () => { + axios + .put( + `/api/salescoordinator/password/update/${id}`, + { + oldPassword: formData.currentPassword, + newPassword: formData.newPassword, + confirmPassword: formData.confirmPassword, + }, + { + headers: { + Authorization: `Bearer ${token}`, + }, + } + ) + .then(() => { + setShowPasswordModal(false); + swal({ + title: "Success", + text: "Password updated successfully!", + icon: "success", + button: "OK", + }); + }) + .catch((error) => { + let msg = error?.response?.data?.message || "Something went wrong!"; + swal({ + title: "Warning", + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + }); + }; + + const onCancel = () => { + navigate("/salescoordinators"); + }; + + return ( +
+
+
+
+
+
+

Edit Sales Coordinator

+ +
+
+
+ +
+
+
+
+
+ + +
+
+ + +
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+
+
+
+ + {/* OTP Verification Modal */} + setShowVerifyModal(false)} + > + + Verify Mobile + + + + Enter OTP + + + + + + + + + + {/* Change Password Modal */} + setShowPasswordModal(false)} + > + + Change Password + + + + Current Password + + + + New Password + + + + Confirm New Password + + + + + + + + +
+
+
+ ); +}; + +export default EditSalesCoOrdinator; diff --git a/src/views/SalesCoOrdinators/SalesCoOrdinator.js b/src/views/SalesCoOrdinators/SalesCoOrdinator.js new file mode 100644 index 0000000..77d57bd --- /dev/null +++ b/src/views/SalesCoOrdinators/SalesCoOrdinator.js @@ -0,0 +1,428 @@ +import React, { useState, useEffect, useRef } from "react"; +import { Link } 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"; + +const SalesCoOrdinator = () => { + const token = isAutheticated(); + const navigate = useNavigate(); + const [loading, setLoading] = useState(false); + const [success, setSuccess] = useState(true); + const [salescoordinatorsData, setSalesCoOrdinatorsData] = useState([]); + + const nameRef = useRef(); + const mobileRef = useRef(); + const VerifySalesCoOrdinatorRef = useRef(); + + const [currentPage, setCurrentPage] = useState(1); + const [itemPerPage, setItemPerPage] = useState(10); + const [totalData, setTotalData] = useState(0); + + const getSalesCoOrdinatorsData = async () => { + setLoading(true); + try { + const res = await axios.get(`/api/salescoordinator/getAll/`, { + headers: { + Authorization: `Bearer ${token}`, + }, + params: { + page: currentPage, + show: itemPerPage, + name: nameRef.current.value, + mobileNumber: mobileRef.current.value, + isVerified: VerifySalesCoOrdinatorRef.current.value, + }, + }); + // console.log(res.data.salesCoOrinators + // ); + setSalesCoOrdinatorsData(res.data?.salesCoOrinators); + setTotalData(res.data?.total_data); + } catch (err) { + const msg = err?.response?.data?.message || "Something went wrong!"; + swal({ + title: "Error", + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + getSalesCoOrdinatorsData(); + }, [success, itemPerPage, currentPage]); + + 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/salescoordinator/delete/${id}`, { + headers: { + "Access-Control-Allow-Origin": "*", + Authorization: `Bearer ${token}`, + }, + }) + .then((res) => { + swal({ + title: "Deleted", + text: "SalesCoOrdinator Deleted successfully!", + icon: "success", + button: "ok", + }); + setSuccess((prev) => !prev); + }) + .catch((err) => { + let msg = err?.response?.data?.message + ? err?.response?.data?.message + : "Something went wrong!"; + swal({ + title: "Warning", + text: msg, + icon: "error", + button: "Retry", + dangerMode: true, + }); + }); + } + }); + }; + + return ( +
+
+
+
+
+
+
+ SalesCoOrdinators +
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ +
+ + + + + + + + + + + + + + {loading ? ( + + + + ) : salescoordinatorsData?.length > 0 ? ( + salescoordinatorsData?.map((salescoordinator, i) => { + return ( + + + + + + + + + ); + }) + ) : ( + + + + )} + +
NameMobile No.EmailVerifyRegister OnAction
+ Loading... +
+ {salescoordinator?.name} + + {salescoordinator?.mobileNumber} + + {salescoordinator?.email ? ( + salescoordinator?.email + ) : ( + + No Email Added! + + )} + + + {salescoordinator?.isVerified + ? "YES" + : "NO"} + + + {new Date( + salescoordinator.createdAt + ).toLocaleString("en-IN", { + weekday: "short", + month: "short", + day: "numeric", + year: "numeric", + hour: "numeric", + minute: "numeric", + hour12: true, + })} + + {/* + + */} + + + + + + +
+
No SalesCoOrdinator 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 SalesCoOrdinator; diff --git a/src/views/configuration/Currency.js b/src/views/configuration/Currency.js index dd948e2..a542f05 100644 --- a/src/views/configuration/Currency.js +++ b/src/views/configuration/Currency.js @@ -150,45 +150,45 @@ const Currency = () => { }); }; - 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/currency/${_id}`, { - headers: { - Authorization: `Bearer ${token}`, - }, - }) - .then((res) => { - swal({ - title: "Congratulations!!", - text: "The Currency is deleted successfully!", - icon: "success", - button: "OK", - }); - setSucess((prev) => !prev); + // 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/currency/${_id}`, { + // headers: { + // Authorization: `Bearer ${token}`, + // }, + // }) + // .then((res) => { + // swal({ + // title: "Congratulations!!", + // text: "The Currency is deleted successfully!", + // icon: "success", + // button: "OK", + // }); + // setSucess((prev) => !prev); - // getCategories(); // Refresh the category list after deleting - }) - .catch((err) => { - swal({ - title: "Error", - text: "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - }); - }; + // // getCategories(); // Refresh the category list after deleting + // }) + // .catch((err) => { + // swal({ + // title: "Error", + // text: "Something went wrong!", + // icon: "error", + // button: "Retry", + // dangerMode: true, + // }); + // }); + // } + // }); + // }; const handleSaveCurrency = async () => { // const CurrencyExits = CurrencyNamesArray.includes( @@ -295,7 +295,7 @@ const Currency = () => {
- + */} { }} onChange={(e) => setCurrencySymbol(e.target.value)} /> - - {/* - - {CurrencyImage && ( - - CurrencyImage - handeldeleteImage()} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - /> - - )} - {olderImage && ( - - CurrencyImage - setOlderImage("")} - fontSize="small" - sx={{ - color: "white", - position: "absolute", - cursor: "pointer", - padding: "0.2rem", - background: "black", - borderRadius: "50%", - }} - /> - - )} - - - {error &&

{error}

} -

- Upload jpg, jpeg and png only* -

*/} - { > Edit - + */} )) diff --git a/src/views/configuration/Logo.js b/src/views/configuration/Logo.js index 4251782..ed3f6ef 100644 --- a/src/views/configuration/Logo.js +++ b/src/views/configuration/Logo.js @@ -27,12 +27,17 @@ function Logo() { Authorization: `Bearer ${token}`, }, }); - - configDetails.data.result.map((item) => { - setHeaderlogo(item?.logo[0]?.Headerlogo); - setFooterlogo(item?.logo[0]?.Footerlogo); - setAdminlogo(item?.logo[0]?.Adminlogo); - }); + // console.log(configDetails.data.result[0]?.logo[0]); + const data = configDetails.data.result[0]?.logo[0]; + setHeaderlogo(data?.Headerlogo); + setFooterlogo(data?.Footerlogo); + setAdminlogo(data?.Adminlogo); + // configDetails.data.result.map((item) => { + // console.log(item); + // setHeaderlogo(item?.logo[0]?.Headerlogo); + // setFooterlogo(item?.logo[0]?.Footerlogo); + // setAdminlogo(item?.logo[0]?.Adminlogo); + // }); } getConfiguration(); }, []); diff --git a/src/views/configuration/Web_Images.js b/src/views/configuration/Web_Images.js deleted file mode 100644 index d83f9d0..0000000 --- a/src/views/configuration/Web_Images.js +++ /dev/null @@ -1,423 +0,0 @@ -import React, { useEffect, useState } from "react"; - -import swal from "sweetalert"; -import ClipLoader from "react-spinners/ClipLoader"; -import { Link } from "react-router-dom"; -import axios from "axios"; -import { isAutheticated } from "src/auth"; -import { object } from "prop-types"; - -function Web_Images() { - const [loading, setLoading] = useState(false); - const [RegisterImglogo, setRegisterImglogo] = useState(""); - const [LoginImg, setLoginImg] = useState(""); - const [ShopImg, setShopImg] = useState(""); - const [display, setDisplay] = useState(true); - const token = isAutheticated(); - - // urlcreated images - - const [RegisterImglogoUrl, setRegisterImglogoUrl] = useState(""); - const [LoginImgUrl, setLoginImgUrl] = useState(""); - const [ShopImgUrl, setShopImgUrl] = useState(""); - - useEffect(() => { - // async function getConfiguration() { - // const configDetails = await axios.get(`/api/config`, { - // headers: { - // Authorization: `Bearer ${token}`, - // }, - // }); - - // console.log("configDetails.data.result", configDetails.data.result); - // configDetails.data.result.map((item) => { - // setRegisterImglogo(item?.logo[0]?.Adminlogo); - // setLoginImg(item?.logo[0]?.Footerlogo); - // setShopImg(item?.logo[0]?.Adminlogo); - // }); - // } - const getRegisterImage = async () => { - const response = await axios.get("/api/registerImage/getImage", { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - if (response.status === 200) { - setRegisterImglogo(response?.data?.image[0]?.image?.secure_url); - } - }; - const getLoginImage = async () => { - const response = await axios.get("/api/loginImage/getImage", { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - if (response.status === 200) { - setLoginImg(response?.data?.image[0]?.image?.secure_url); - } - }; - const getShopImage = async () => { - const response = await axios.get("/api/shopImage/getImage", { - headers: { - Authorization: `Bearer ${token}`, - }, - }); - if (response.status === 200) { - setShopImg(response?.data?.image[0]?.image?.secure_url); - } - }; - - getRegisterImage(); - getLoginImage(); - getShopImage(); - }, []); - // async function handelChange(e) { - // setDisplay(false); - // console.log(e.target.name === "Web_Images htmlFor Website RegisterImg(148 x 48 px)"); - // if (e.target.name === "Web_Images htmlFor Website RegisterImg(148 x 48 px)") { - // console.log(e.target.files[0]); - // setRegisterImglogo(e.target.files[0]); - // } else if (e.target.name === "Web_Images htmlFor Website Footer(148 x 48 px)") { - // setLoginImg(e.target.files[0]); - // } else if (e.target.name === "Web_Images htmlFor Admin RegisterImg(148 x 48 px)") { - // setShopImg(e.target.files[0]); - // } - // } - const [Rloading, setRLoading] = useState(false); - async function handeRegister(e) { - e.preventDefault(); - if (typeof RegisterImglogo !== "object" || RegisterImglogo === null) { - swal({ - title: "Warning", - text: "Please select file", - icon: "warning", - button: "Ok", - dangerMode: true, - }); - return; - } - - const formdata = new FormData(); - formdata.append("RegisterImglogo", RegisterImglogo); - setRLoading(true); - await axios - .post(`/api/registerImage/addmodify/`, formdata, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/formdata", - "Access-Control-Allow-Origin": "*", - }, - }) - .then((res) => { - setRLoading(false); - swal("Success!", res.data.message); - }) - .catch((error) => { - setRLoading(false); - }); - } - const [Lloading, setLLoading] = useState(false); - - async function handeLogin(e) { - e.preventDefault(); - if (typeof LoginImg !== "object" || LoginImg === null) { - swal({ - title: "Warning", - text: "Please select file", - icon: "warning", - button: "Ok", - dangerMode: true, - }); - return; - } - - const formdata = new FormData(); - formdata.append("LoginImg", LoginImg); - setLLoading(true); - - await axios - .post(`/api/loginImage/addmodify/`, formdata, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/formdata", - "Access-Control-Allow-Origin": "*", - }, - }) - .then((res) => { - setLLoading(false); - swal("Success!", res.data.message); - }) - .catch((error) => { - setLLoading(false); - }); - } - - const [Shoploading, setShoploading] = useState(false); - async function handeShopImage(e) { - e.preventDefault(); - if (typeof ShopImg !== "object" || ShopImg === null) { - swal({ - title: "Warning", - text: "Please select file", - icon: "warning", - button: "Ok", - dangerMode: true, - }); - return; - } - - const formdata = new FormData(); - formdata.append("ShopImg", ShopImg); - setShoploading(true); - await axios - .post(`/api/shopImage/addmodify/`, formdata, { - headers: { - Authorization: `Bearer ${token}`, - "Content-Type": "multipart/formdata", - "Access-Control-Allow-Origin": "*", - }, - }) - .then((res) => { - setShoploading(false); - swal("Success!", res.data.message); - }) - .catch((error) => { - setShoploading(false); - }); - } - - // async function handelSubmit() { - // setLoading(true); - - // const formdata = new FormData(); - // formdata.append("RegisterImglogo", RegisterImglogo); - // formdata.append("LoginImg", LoginImg); - // formdata.append("ShopImg", ShopImg); - - // await axios - // .post(`/api/config/logo`, formdata, { - // headers: { - // Authorization: `Bearer ${token}`, - // "Content-Type": "multipart/formdata", - // "Access-Control-Allow-Origin": "*", - // }, - // }) - // .then((res) => { - // setLoading(false); - // swal("Success!", res.data.message, res.data.status); - // }) - // .catch((error) => { - // setLoading(false); - // }); - // } - - return ( -
-
-
-
-
-
-
-
-
-
-

Website Images

- -
-
-
-
- <> - -
- { - setRegisterImglogo(e.target.files[0]); - if ( - e.target.files && - e.target.files[0] - ) { - setRegisterImglogoUrl({ - image: URL.createObjectURL( - e.target.files[0] - ), - }); - } - }} - className="form-control input-field mb-3 col-md-6 d-inline-block" - id="basicpill-phoneno-input" - /> - - - {display ? ( - - ) : ( - "" - )} -
- -
- { - setLoginImg(e.target.files[0]); - - if (e.target.files && e.target.files[0]) { - setLoginImgUrl({ - image: URL.createObjectURL( - e.target.files[0] - ), - }); - } - }} - className="form-control input-field mt-1 col-md-6 d-inline-block" - id="basicpill-phoneno-input" - /> - {" "} - {display ? ( - - ) : ( - "" - )} - - { - setShopImg(e.target.files[0]); - - if (e.target.files && e.target.files[0]) { - setShopImgUrl({ - image: URL.createObjectURL( - e.target.files[0] - ), - }); - } - }} - className="form-control input-field col-md-6 d-inline-block" - id="basicpill-phoneno-input" - /> - {" "} - {display ? ( - - ) : ( - "" - )} - -
-
-
- {/*
-
-
- -
-
-
*/} -
-
-
- - {/* */} -
-
-
-
-
- {/* */} -
- {/* */} -
-
- ); -} - -export default Web_Images; diff --git a/src/views/configuration/tax/Addtax.js b/src/views/configuration/tax/Addtax.js index 80b2ec7..53ec925 100644 --- a/src/views/configuration/tax/Addtax.js +++ b/src/views/configuration/tax/Addtax.js @@ -81,7 +81,7 @@ function Addtax() { justify-content-between " > -

Add New VAT Rate

+

Add New GST Rate

@@ -102,7 +102,7 @@ function Addtax() { Save - + @@ -79,7 +79,7 @@ function Tax() { > Name - VAT Rate + GST Rate Action diff --git a/src/views/orders/POSViewOrders.js b/src/views/orders/POSViewOrders.js deleted file mode 100644 index 0c3c263..0000000 --- a/src/views/orders/POSViewOrders.js +++ /dev/null @@ -1,945 +0,0 @@ -import React, { useState, useEffect, useRef } from "react"; -import axios from "axios"; -import { Link, useNavigate, useParams } from "react-router-dom"; -import QRCode from "react-qr-code"; -import { isAutheticated } from "src/auth"; -import { useDispatch, useSelector } from "react-redux"; -import { addItemsToCart } from "src/redux/Actions/cartAction"; -import toast from "react-hot-toast"; -import { cibBlackberry } from "@coreui/icons"; -import Button from "@material-ui/core/Button"; - -function POSViewOrders() { - const { status, id } = useParams(); - const [success, setSuccess] = useState(true); - - const { cartItems, subTotal, shippingCharge, tax, shipingInfo, total } = - useSelector((state) => state.cart); - - const AllStates = useSelector((state) => state); - const getValue = useRef(); - const getFranchiseeID = useRef(); - const dispatch = useDispatch(); - const navigate = useNavigate(); - const printOrderRef = useRef(); - const token = isAutheticated(); - const [productData, setProductData] = useState([]); - const [allFranchisee, setAllFranchisee] = useState([]); - const [allTax, setAllTax] = useState([]); - const [orderDetails, setOrderDetails] = useState(); - - const [productDetails, setProductDetails] = useState(); - const [loading, setLoading] = useState(true); - const [orderId, setOrderId] = useState(null); - const [orderStatus, setOrderStatus] = useState(""); - // const [data, setData] = useState({ - // product_Name: '', - // address: '', - // quantity: '', - // contact_Number: '', - // total_Price: '', - // }) - useEffect(() => { - const getSingleOrder = async () => { - setLoading(true); - const res = await axios.get(`/api/order/getOne/${id}`, { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - }); - if (res.data) { - setLoading(false); - setOrderId(res.data?.order?.order_id); - setOrderDetails(res.data?.order); - console.log(res.data); - // let options = { - // Franchisee: res.data?.order?.shippingInfo?.Franchisee?._id, - // name: res.data?.order?.shippingInfo?.name, - - // contact_Number: res.data?.order?.shippingInfo?.contact_Number, - // contact_Person_Name: res.data?.order?.shippingInfo?.contact_Person_Name, - // address: res.data?.order?.shippingInfo?.address, - // city: res.data?.order?.shippingInfo?.city, - // price_Lable: res.data?.order?.shippingInfo?.Franchisee?.price_Lable, - // state: res.data?.order?.shippingInfo?.state, - // banner: res.data?.order?.shippingInfo?.Franchisee?.banner?.url, - // // Franchisee_Url: res?.data?.data?.url - // } - // dispatch({ type: "addShippingInfo", payload: options }); - // if (res.data?.order?.orderItems) { - // res.data?.order?.orderItems.map((i, ind) => { - // dispatch({ type: "addToCart", payload: i }); - // dispatch({ type: "calculatePrice" }); - - // }) - // } - } - }; - getSingleOrder(); - }, [token]); - - const handleChange = (e) => { - if (e.target.type === "text") { - setData((prev) => ({ ...prev, [e.target.id]: e.target.value })); - } else { - if (e.target.value === "") toast.error("please select status"); - setOrderStatus(e.target.value); - } - }; - const handleQuantityChange = (e) => { - setData((prev) => ({ - ...prev, - quantity: e.target.value, - total_Price: productDetails?.base_Price * e.target.value, - })); - }; - // ------------------------------------------------------ - - const handlechangestatus = () => { - if (orderStatus === "dispatched") { - swal({ - title: `Are you sure for ${orderStatus}?`, - icon: "warning", - content: { - element: "div", - attributes: { - innerHTML: - '' + - '', - }, - }, - buttons: { - Yes: { text: "Submit", value: true }, - - Cancel: { text: "Cancel", value: "cancel" }, - }, - }).then((result) => { - if (result === true) { - // You have the input values, you can use them in your API call - const courierName = document.getElementById("input1").value.trim(); - const TrackingID = document.getElementById("input2").value.trim(); - - // Check if values are entered - if (courierName === "" || TrackingID === "") { - swal({ - title: "Warning", - text: "Please enter values Courier Name And Tracking ID", - icon: "warning", - button: "Ok", - dangerMode: true, - }); - } else { - axios - .patch( - `/api/order/change/status/${id}`, - { - status: orderStatus, - courierName, - TrackingID, - sendemail: orderDetails?.user?.email, - customerName: orderDetails?.user?.name, - }, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ) - .then((res) => { - console.log("status"); - toast.success( - `Order status change ${status} to ${orderStatus}` - ); - // setSuccess((prev) => !prev); - }) - .catch((err) => { - swal({ - title: "Warning", - text: err.response.data.message - ? err.response.data.message - : "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - } - // else { - // swal.close(); // Close the popup if canceled - // } - }); - } else if (orderStatus === "cancelled") { - swal({ - title: `Are you sure for ${orderStatus}?`, - icon: "warning", - content: { - element: "div", - attributes: { - innerHTML: - '

Reson for cancellation.?

', - }, - }, - buttons: { - Yes: { text: "Submit", value: true }, - - Cancel: { text: "Cancel", value: "cancel" }, - }, - }).then((result) => { - if (result === true) { - // You have the input values, you can use them in your API call - const ReasonforCancellation = document - .getElementById("input1") - .value.trim(); - - // Check if values are entered - if (ReasonforCancellation === "") { - swal({ - title: "Warning", - text: "Please enter Reason for Cancellation", - icon: "warning", - button: "Ok", - dangerMode: true, - }); - } else { - axios - .patch( - `/api/order/change/status/${id}`, - { - status: orderStatus, - ReasonforCancellation, - }, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ) - .then((res) => { - console.log("status"); - toast.success( - `Order status change ${status} to ${orderStatus}` - ); - // setSuccess((prev) => !prev); - }) - .catch((err) => { - swal({ - title: "Warning", - text: err.response.data.message - ? err.response.data.message - : "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - } - // else { - // swal.close(); // Close the popup if canceled - // } - }); - } else if (orderStatus === "delivered") { - swal({ - title: `Are you sure for ${orderStatus}?`, - icon: "warning", - content: { - element: "div", - attributes: { - innerHTML: - '', - // '', - }, - }, - buttons: { - Yes: { text: "Submit", value: true }, - - Cancel: { text: "Cancel", value: "cancel" }, - }, - }).then((result) => { - if (result === true) { - // You have the input values, you can use them in your API call - const DDate = document.getElementById("input1").value.trim(); - - // Check if values are entered - if (DDate === "") { - swal({ - title: "Warning", - text: "Please enter Delivered Date", - icon: "warning", - button: "Ok", - dangerMode: true, - }); - } else { - axios - .patch( - `/api/order/change/status/${id}`, - { - status: orderStatus, - DDate, - }, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ) - .then((res) => { - console.log("status"); - toast.success( - `Order status change ${status} to ${orderStatus}` - ); - // setSuccess((prev) => !prev); - }) - .catch((err) => { - swal({ - title: "Warning", - text: err.response.data.message - ? err.response.data.message - : "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - } - // else { - // swal.close(); // Close the popup if canceled - // } - }); - } else { - swal({ - title: `Are you sure for ${orderStatus}?`, - icon: "warning", - - buttons: { - Yes: { text: "Yes", value: true }, - Cancel: { text: "Cancel", value: "cancel" }, - }, - }).then((value) => { - if (value === true) { - axios - .patch( - `/api/order/change/status/${id}`, - { status: orderStatus }, - { - headers: { - "Access-Control-Allow-Origin": "*", - Authorization: `Bearer ${token}`, - }, - } - ) - .then((res) => { - console.log("status"); - toast.success(`order status change ${status} to ${orderStatus}`); - // setSuccess((prev) => !prev); - }) - .catch((err) => { - swal({ - title: "Warning", - text: err.response.data.message - ? err.response.data.message - : "Something went wrong!", - icon: "error", - button: "Retry", - dangerMode: true, - }); - }); - } - }); - } - }; - - function getBack() { - navigate(`/orders/${status}`, { replace: true }); - } - - return ( - <> - {" "} -
-
-
-
-
-
-
-

View Order

-
-
- {orderDetails?.orderID && ( - -
Order ID : {orderDetails?.orderID}
{" "} -
- )} -
- {orderDetails?.courier_name && ( -
- -
- Courier Name: {orderDetails?.courier_name} -
{" "} -
- Tracking ID : {orderDetails?.courier_tracking_id} -
-
-
- )} - {orderDetails?.isDelivered && ( -
- -
Delivered: Yes
{" "} -
- Delivered Date: {orderDetails?.DeliveredDate} -
-
-
- )} -
- {/* */} - - - - -
-
-
-
- {loading ? ( -
-
- Loading... -
-
- ) : ( -
-
- {orderDetails?.shipingInfo !== null && ( -
-
- {/*
- -
- - - -
- -
*/} - -
-
- Products : {orderDetails?.orderItems?.length} -
-
- - {orderDetails?.orderItems && - orderDetails?.orderItems.map( - (productDetails, i) => ( -
-
-
- {productDetails?.name} -
-
-
- {productDetails?.name} -
-
-
-
- - {" "} - Quantity:{" "} - {productDetails?.quantity} - -
- -

- Subtotal: ₹ - {productDetails?.product_Subtotal} -

-

- Variant:{" "} - {productDetails?.variant_Name} -

-
-
-

- Price: ₹ - {productDetails?.price} -

-

- GST: ₹ - {productDetails?.gst_amount} -

-
-
-
-
-
-
- ) - )} -
- Shipping Charge: ₹ - {orderDetails?.shipping_charge} -
- Total Order Value: ₹ - {orderDetails?.total_amount} -
-
-
-
- )} - -
-
- - - - - - - - - - - - - - - - - - - - - - - - {orderDetails?.status_timeline?.cancelled && ( - - - - - - )} - {/* - - - - */} - -
Order Placed On : - {orderDetails?.createdAt - ? new Date( - orderDetails?.createdAt - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : new Date( - productData?.placed_on - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - })} -
- Processing Started - : - {orderDetails?.status_timeline?.processing - ? new Date( - orderDetails?.status_timeline?.processing - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} -
- Dispatched On - : - {orderDetails?.status_timeline?.dispatched - ? new Date( - orderDetails?.status_timeline?.dispatched - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} -
- Delivered On - : - {orderDetails?.status_timeline?.delivered - ? new Date( - orderDetails?.status_timeline?.delivered - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} -
- Cancelled On - : - {orderDetails?.status_timeline?.cancelled - ? new Date( - orderDetails?.status_timeline?.cancelled - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} -
Returned On : - {orderDetails?.status_timeline?.returned - ? new Date( - orderDetails?.status_timeline?.returned - ).toLocaleString("en-IN", { - month: "short", - day: "numeric", - year: "numeric", - hour: "2-digit", - minute: "numeric", - hour12: true, - }) - : "-"} -
-
-
-
-
-
-
-
- {orderDetails?.orderStatus !== "cancelled" ? ( -
- Order Status: {orderDetails?.orderStatus} -
- ) : ( - <> -
- Order Status: {orderDetails?.orderStatus} -
-

- {" "} - Order Cancelled Reason:{" "} - {orderDetails?.order_Cancelled_Reason} -

- - )} - {/* order status change */}{" "} -
- {" "} - {status !== "cancelled" && - status !== "returned" && - status !== "delivered" && ( -
- -
-
- -
- {orderStatus && ( -
- -
- )} -
-
- )} -
- {/* */} - - {/*
- - -
*/} -
- {orderDetails?.shipingInfo !== null && ( -
-
- {/*
- {orderDetails?.shippingInfo?.name} -
*/} -
-
- Name: {orderDetails?.shippingInfo?.first_Name}{" "} - {orderDetails?.shippingInfo?.last_Name} -
- -

- Contact No. :{" "} - {orderDetails?.shippingInfo?.phone_Number} -

- - street. : {orderDetails?.shippingInfo?.street} - - -

- City : {orderDetails?.shippingInfo?.city} -

-

- State : {orderDetails?.shippingInfo?.state} -

-

- country : {orderDetails?.shippingInfo?.country} -

-

- Postal Code. :{" "} - {orderDetails?.shippingInfo?.postalCode} -

-
-
-
-
- )} -
- -
-
- -
- -
- -
-
- -
-
- -
-
- -
-
-
-
-
- )} -
-
-
-
- {/* */} -
- - ); -} - -export default POSViewOrders; diff --git a/src/views/orders/PrintOrderDetails.js b/src/views/orders/PrintOrderDetails.js index 4c1c18f..734b3ce 100644 --- a/src/views/orders/PrintOrderDetails.js +++ b/src/views/orders/PrintOrderDetails.js @@ -178,7 +178,7 @@ const PrintOrderDetails = React.forwardRef(({ orderData }, ref) => { Qnty Tax Type Gross Amount - VAT Rate + GST Rate Net Amount