change employeee route and restriction
This commit is contained in:
commit
4ec18b7fb9
@ -50,6 +50,7 @@
|
|||||||
"draft-js": "^0.11.7",
|
"draft-js": "^0.11.7",
|
||||||
"draft-js-export-html": "^1.4.1",
|
"draft-js-export-html": "^1.4.1",
|
||||||
"draft-js-import-html": "^1.4.1",
|
"draft-js-import-html": "^1.4.1",
|
||||||
|
"file-saver": "^2.0.5",
|
||||||
"md5": "^2.3.0",
|
"md5": "^2.3.0",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"prop-types": "^15.7.2",
|
"prop-types": "^15.7.2",
|
||||||
@ -57,10 +58,11 @@
|
|||||||
"react": "18.0.0",
|
"react": "18.0.0",
|
||||||
"react-bootstrap": "^2.7.0",
|
"react-bootstrap": "^2.7.0",
|
||||||
"react-chartjs-2": "^5.2.0",
|
"react-chartjs-2": "^5.2.0",
|
||||||
"react-datepicker": "^4.8.0",
|
"react-datepicker": "^4.25.0",
|
||||||
"react-dom": "^18.0.0",
|
"react-dom": "^18.0.0",
|
||||||
"react-draft-wysiwyg": "^1.15.0",
|
"react-draft-wysiwyg": "^1.15.0",
|
||||||
"react-hot-toast": "^2.4.0",
|
"react-hot-toast": "^2.4.0",
|
||||||
|
"react-modal": "^3.16.1",
|
||||||
"react-qr-code": "^2.0.11",
|
"react-qr-code": "^2.0.11",
|
||||||
"react-quill": "^2.0.0",
|
"react-quill": "^2.0.0",
|
||||||
"react-redux": "^7.2.9",
|
"react-redux": "^7.2.9",
|
||||||
@ -75,7 +77,8 @@
|
|||||||
"styled-components": "^6.0.8",
|
"styled-components": "^6.0.8",
|
||||||
"sweetalert": "^2.1.2",
|
"sweetalert": "^2.1.2",
|
||||||
"sweetalert2": "^11.4.0",
|
"sweetalert2": "^11.4.0",
|
||||||
"uuid": "^9.0.1"
|
"uuid": "^9.0.1",
|
||||||
|
"xlsx": "^0.18.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"auto-changelog": "~2.3.0",
|
"auto-changelog": "~2.3.0",
|
||||||
|
@ -7,22 +7,14 @@
|
|||||||
* License MIT
|
* License MIT
|
||||||
-->
|
-->
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
|
||||||
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<meta
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
|
||||||
name="viewport"
|
<meta name="description" content="CoreUI for React - Open Source Bootstrap Admin Template" />
|
||||||
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
|
||||||
/>
|
|
||||||
<meta
|
|
||||||
name="description"
|
|
||||||
content="CoreUI for React - Open Source Bootstrap Admin Template"
|
|
||||||
/>
|
|
||||||
<meta name="author" content="Łukasz Holeczek" />
|
<meta name="author" content="Łukasz Holeczek" />
|
||||||
<meta
|
<meta name="keyword" content="Bootstrap,Admin,Template,Open,Source,CSS,SCSS,HTML,RWD,Dashboard,React" />
|
||||||
name="keyword"
|
|
||||||
content="Bootstrap,Admin,Template,Open,Source,CSS,SCSS,HTML,RWD,Dashboard,React"
|
|
||||||
/>
|
|
||||||
<title>Smellika Admin</title>
|
<title>Smellika Admin</title>
|
||||||
<!--
|
<!--
|
||||||
manifest.json provides metadata used when your web app is added to the
|
manifest.json provides metadata used when your web app is added to the
|
||||||
@ -30,10 +22,7 @@
|
|||||||
-->
|
-->
|
||||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
|
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||||
<link
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" />
|
||||||
rel="stylesheet"
|
|
||||||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
|
|
||||||
/>
|
|
||||||
<link rel="react" href="https://coreui.io/react/" />
|
<link rel="react" href="https://coreui.io/react/" />
|
||||||
|
|
||||||
<!-- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> -->
|
<!-- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script> -->
|
||||||
@ -51,9 +40,9 @@
|
|||||||
|
|
||||||
<!-- <link href="/assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" /> -->
|
<!-- <link href="/assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css" rel="stylesheet" /> -->
|
||||||
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" /> -->
|
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" /> -->
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<noscript> You need to enable JavaScript to run this app. </noscript>
|
<noscript> You need to enable JavaScript to run this app. </noscript>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<!--
|
<!--
|
||||||
@ -66,6 +55,8 @@
|
|||||||
To begin the development, run `npm start` or `yarn start`.
|
To begin the development, run `npm start` or `yarn start`.
|
||||||
To create a production bundle, use `npm run build` or `yarn build`.
|
To create a production bundle, use `npm run build` or `yarn build`.
|
||||||
-->
|
-->
|
||||||
</body>
|
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
|
||||||
<!-- <script src="/assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script> -->
|
</body>
|
||||||
|
<!-- <script src="/assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script> -->
|
||||||
|
|
||||||
</html>
|
</html>
|
15
src/App.js
15
src/App.js
@ -47,10 +47,13 @@ const App = () => {
|
|||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// console.log(response.data)
|
// console.log("jjjjjjjj", response.data);
|
||||||
const data = response.data;
|
const data = response?.data;
|
||||||
if (data.success && data.user.role === "admin") {
|
if (
|
||||||
setUserData(data.user);
|
data?.success &&
|
||||||
|
(data?.user?.role === "admin" || data?.user?.role === "Employee")
|
||||||
|
) {
|
||||||
|
setUserData(data?.user);
|
||||||
} else {
|
} else {
|
||||||
setUserData(false);
|
setUserData(false);
|
||||||
}
|
}
|
||||||
@ -62,7 +65,6 @@ const App = () => {
|
|||||||
};
|
};
|
||||||
getUser();
|
getUser();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
<Suspense fallback={loading}>
|
<Suspense fallback={loading}>
|
||||||
@ -87,7 +89,8 @@ const App = () => {
|
|||||||
path="/"
|
path="/"
|
||||||
name="Home"
|
name="Home"
|
||||||
element={
|
element={
|
||||||
userdata?.role === "admin" ? (
|
userdata &&
|
||||||
|
(userdata.role === "admin" || userdata.role === "Employee") ? (
|
||||||
<DefaultLayout />
|
<DefaultLayout />
|
||||||
) : userdata === false ? (
|
) : userdata === false ? (
|
||||||
<Login />
|
<Login />
|
||||||
|
106
src/_nav.js
106
src/_nav.js
@ -24,6 +24,7 @@ import {
|
|||||||
cilUser,
|
cilUser,
|
||||||
cilAlarm,
|
cilAlarm,
|
||||||
cilFeaturedPlaylist,
|
cilFeaturedPlaylist,
|
||||||
|
cilLocationPin,
|
||||||
} from "@coreui/icons";
|
} from "@coreui/icons";
|
||||||
import { CNavGroup, CNavItem, CNavTitle, CTabContent } from "@coreui/react";
|
import { CNavGroup, CNavItem, CNavTitle, CTabContent } from "@coreui/react";
|
||||||
|
|
||||||
@ -33,59 +34,64 @@ const _nav = [
|
|||||||
name: "Dashboard",
|
name: "Dashboard",
|
||||||
to: "/dashboard",
|
to: "/dashboard",
|
||||||
icon: <CIcon icon={cilSpeedometer} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilSpeedometer} customClassName="nav-icon" />,
|
||||||
|
group: "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Customers",
|
name: "Customers",
|
||||||
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
||||||
to: "/customers-details",
|
to: "/customers-details",
|
||||||
|
group: "Customers",
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// component: CNavItem,
|
|
||||||
// name: "Design",
|
|
||||||
// icon: <CIcon icon={cibMaterialDesign} customClassName="nav-icon" />,
|
|
||||||
// to: "/design",
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
component: CNavGroup,
|
component: CNavGroup,
|
||||||
name: "Charts",
|
name: "Charts",
|
||||||
icon: <CIcon icon={cilCat} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCat} customClassName="nav-icon" />,
|
||||||
|
group: "",
|
||||||
|
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "new user day wise",
|
name: "new user day wise",
|
||||||
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
||||||
to: "/new-user-day-wise",
|
to: "/new-user-day-wise",
|
||||||
|
group: "Charts",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Revenue By Product",
|
name: "Revenue By Product",
|
||||||
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
||||||
to: "/revenue-by-product",
|
to: "/revenue-by-product",
|
||||||
|
group: "Charts",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Revenue By State",
|
name: "Revenue By State",
|
||||||
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
||||||
to: "/revenue-by-state",
|
to: "/revenue-by-state",
|
||||||
|
group: "Charts",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Revenue By City",
|
name: "Revenue By City",
|
||||||
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
||||||
to: "/revenue-by-city",
|
to: "/revenue-by-city",
|
||||||
|
group: "Charts",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Orders (Day Wise)",
|
name: "Orders (Day Wise)",
|
||||||
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
||||||
to: "/orders-day-wise",
|
to: "/orders-day-wise",
|
||||||
|
group: "Charts",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Revenue (Day Wise)",
|
name: "Revenue (Day Wise)",
|
||||||
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilTennisBall} customClassName="nav-icon" />,
|
||||||
to: "/revenue-day-wise",
|
to: "/revenue-day-wise",
|
||||||
|
group: "Charts",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -94,24 +100,29 @@ const _nav = [
|
|||||||
component: CNavGroup,
|
component: CNavGroup,
|
||||||
name: "Product Management",
|
name: "Product Management",
|
||||||
icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
|
||||||
|
group: "",
|
||||||
|
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Categories",
|
name: "Categories",
|
||||||
icon: <CIcon icon={cilCat} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCat} customClassName="nav-icon" />,
|
||||||
to: "/categories",
|
to: "/categories",
|
||||||
|
group: "Product Management",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Products",
|
name: "Products",
|
||||||
icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
|
||||||
to: "/products",
|
to: "/products",
|
||||||
|
group: "Product Management",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "GST Rate",
|
name: "GST Rate",
|
||||||
icon: <CIcon icon={cilTablet} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilTablet} customClassName="nav-icon" />,
|
||||||
to: "/tax",
|
to: "/tax",
|
||||||
|
group: "Product Management",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -119,12 +130,15 @@ const _nav = [
|
|||||||
component: CNavGroup,
|
component: CNavGroup,
|
||||||
name: "Orders",
|
name: "Orders",
|
||||||
icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
||||||
|
group: "",
|
||||||
|
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "New",
|
name: "New",
|
||||||
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
to: "/orders/new",
|
to: "/orders/new",
|
||||||
|
group: "Orders",
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// component: CNavItem,
|
// component: CNavItem,
|
||||||
@ -137,24 +151,42 @@ const _nav = [
|
|||||||
name: "Processing",
|
name: "Processing",
|
||||||
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
to: "/orders/processing",
|
to: "/orders/processing",
|
||||||
|
group: "Orders",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Dispatched",
|
name: "Dispatched",
|
||||||
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
to: "/orders/dispatched",
|
to: "/orders/dispatched",
|
||||||
|
group: "Orders",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Delivered",
|
name: "Delivered",
|
||||||
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
to: "/orders/delivered",
|
to: "/orders/delivered",
|
||||||
|
group: "Orders",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Cancelled",
|
name: "Cancelled",
|
||||||
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
to: "/orders/cancelled",
|
to: "/orders/cancelled",
|
||||||
|
group: "Orders",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: "In Store Cash Orders",
|
||||||
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
|
to: "/inStoreCashOrders/new",
|
||||||
|
group: "Orders",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: "In Store QRCode Orders",
|
||||||
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
|
to: "/InStoreQRCodeOrders/new",
|
||||||
|
group: "Orders",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -162,49 +194,58 @@ const _nav = [
|
|||||||
component: CNavGroup,
|
component: CNavGroup,
|
||||||
name: "Website Related",
|
name: "Website Related",
|
||||||
icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
||||||
|
group: "",
|
||||||
|
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Banner",
|
name: "Banner",
|
||||||
icon: <CIcon icon={cilImage} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilImage} customClassName="nav-icon" />,
|
||||||
to: "/banner",
|
to: "/banner",
|
||||||
|
group: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Register Image",
|
name: "Register Image",
|
||||||
icon: <CIcon icon={cilImage} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilImage} customClassName="nav-icon" />,
|
||||||
to: "/registerImage",
|
to: "/registerImage",
|
||||||
|
group: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Login Image",
|
name: "Login Image",
|
||||||
icon: <CIcon icon={cilImage} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilImage} customClassName="nav-icon" />,
|
||||||
to: "/loginImage",
|
to: "/loginImage",
|
||||||
|
group: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Shop Page Image",
|
name: "Shop Page Image",
|
||||||
icon: <CIcon icon={cilImage} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilImage} customClassName="nav-icon" />,
|
||||||
to: "/shopImage",
|
to: "/shopImage",
|
||||||
|
group: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Testimonials",
|
name: "Testimonials",
|
||||||
icon: <CIcon icon={cilCompress} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCompress} customClassName="nav-icon" />,
|
||||||
to: "/testimonials",
|
to: "/testimonials",
|
||||||
|
group: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
component: CNavItem,
|
// component: CNavItem,
|
||||||
name: "Contact Requests",
|
// name: "Contact Requests",
|
||||||
icon: <CIcon icon={cilContact} customClassName="nav-icon" />,
|
// icon: <CIcon icon={cilContact} customClassName="nav-icon" />,
|
||||||
to: "/contact/request",
|
// to: "/contact/request",
|
||||||
},
|
// group: "Website Related",
|
||||||
|
// },
|
||||||
|
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "SEO and Analytics",
|
name: "SEO and Analytics",
|
||||||
icon: <CIcon icon={cilContact} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilContact} customClassName="nav-icon" />,
|
||||||
to: "/seo/request/new",
|
to: "/seo/request/new",
|
||||||
|
group: "Website Related",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -212,12 +253,14 @@ const _nav = [
|
|||||||
name: "Content ",
|
name: "Content ",
|
||||||
icon: <CIcon icon={cilText} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilText} customClassName="nav-icon" />,
|
||||||
to: "/content",
|
to: "/content",
|
||||||
|
group: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Home",
|
name: "Home",
|
||||||
icon: <CIcon icon={cilFeaturedPlaylist} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilFeaturedPlaylist} customClassName="nav-icon" />,
|
||||||
to: "/home",
|
to: "/home",
|
||||||
|
group: "Website Related",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -225,18 +268,22 @@ const _nav = [
|
|||||||
component: CNavGroup,
|
component: CNavGroup,
|
||||||
name: "Configuration",
|
name: "Configuration",
|
||||||
icon: <CIcon icon={cilAppsSettings} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilAppsSettings} customClassName="nav-icon" />,
|
||||||
|
group: "",
|
||||||
|
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Social Media",
|
name: "Social Media",
|
||||||
icon: <CIcon icon={cilMedicalCross} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilMedicalCross} customClassName="nav-icon" />,
|
||||||
to: "/socialmedia",
|
to: "/socialmedia",
|
||||||
|
group: "Configuration",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Application Name",
|
name: "Application Name",
|
||||||
icon: <CIcon icon={cilText} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilText} customClassName="nav-icon" />,
|
||||||
to: "/application/name",
|
to: "/application/name",
|
||||||
|
group: "Configuration",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -244,18 +291,21 @@ const _nav = [
|
|||||||
name: "Address",
|
name: "Address",
|
||||||
icon: <CIcon icon={cilAddressBook} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilAddressBook} customClassName="nav-icon" />,
|
||||||
to: "/address",
|
to: "/address",
|
||||||
|
group: "Configuration",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Logos",
|
name: "Logos",
|
||||||
icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCommand} customClassName="nav-icon" />,
|
||||||
to: "/logo",
|
to: "/logo",
|
||||||
|
group: "Configuration",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Copyright Message",
|
name: "Copyright Message",
|
||||||
icon: <CIcon icon={cilText} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilText} customClassName="nav-icon" />,
|
||||||
to: "/copyright/message",
|
to: "/copyright/message",
|
||||||
|
group: "Configuration",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -264,18 +314,22 @@ const _nav = [
|
|||||||
component: CNavGroup,
|
component: CNavGroup,
|
||||||
name: "Affiliate & Coupons",
|
name: "Affiliate & Coupons",
|
||||||
icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilCart} customClassName="nav-icon" />,
|
||||||
|
group: "",
|
||||||
|
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Coupons",
|
name: "Coupons",
|
||||||
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
to: "/affiliate/coupons",
|
to: "/affiliate/coupons",
|
||||||
|
group: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Affiliates",
|
name: "Affiliates",
|
||||||
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
to: "/affiliate/affiliates",
|
to: "/affiliate/affiliates",
|
||||||
|
group: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@ -284,19 +338,29 @@ const _nav = [
|
|||||||
component: CNavGroup,
|
component: CNavGroup,
|
||||||
name: "Customer Service",
|
name: "Customer Service",
|
||||||
icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilClipboard} customClassName="nav-icon" />,
|
||||||
|
group: "",
|
||||||
|
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Customer Support",
|
name: "Customer Support",
|
||||||
icon: <CIcon icon={cilAlarm} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilAlarm} customClassName="nav-icon" />,
|
||||||
to: "/support/request",
|
to: "/support/request",
|
||||||
|
group: "Customer Service",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
component: CNavItem,
|
component: CNavItem,
|
||||||
name: "Contact Requests",
|
name: "Contact Requests",
|
||||||
icon: <CIcon icon={cilUser} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilUser} customClassName="nav-icon" />,
|
||||||
to: "/contact/request",
|
to: "/contact/request",
|
||||||
|
group: "Customer Service",
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// component: CNavItem,
|
||||||
|
// name: "Email CMS",
|
||||||
|
// icon: <CIcon icon={cilLocationPin} customClassName="nav-icon" />,
|
||||||
|
// to: "/email-cms",
|
||||||
|
// },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
//Blog start
|
//Blog start
|
||||||
@ -305,8 +369,24 @@ const _nav = [
|
|||||||
name: "Blog",
|
name: "Blog",
|
||||||
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
to: "/blogs",
|
to: "/blogs",
|
||||||
|
group: "Blog",
|
||||||
|
},
|
||||||
|
// Employee
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: "Employees & Access",
|
||||||
|
icon: <CIcon icon={cilImage} customClassName="nav-icon" />,
|
||||||
|
to: "/employee",
|
||||||
|
group: "Employees & Access",
|
||||||
|
},
|
||||||
|
//Point of Sale start
|
||||||
|
{
|
||||||
|
component: CNavItem,
|
||||||
|
name: "Point of Sale",
|
||||||
|
icon: <CIcon icon={cilNotes} customClassName="nav-icon" />,
|
||||||
|
to: "/pos",
|
||||||
|
group: "Point of Sale",
|
||||||
},
|
},
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// component: CNavGroup,
|
// component: CNavGroup,
|
||||||
// name: "Blog",
|
// name: "Blog",
|
||||||
|
@ -1,16 +1,56 @@
|
|||||||
import React, { Suspense } from 'react'
|
import React, { Suspense, useEffect, useState } from "react";
|
||||||
import { Navigate, Route, Routes } from 'react-router-dom'
|
import { Navigate, Route, Routes } from "react-router-dom";
|
||||||
import { CContainer, CSpinner } from '@coreui/react'
|
import { CContainer, CSpinner } from "@coreui/react";
|
||||||
|
|
||||||
// routes config
|
// routes config
|
||||||
import routes from '../routes'
|
import routes from "../routes";
|
||||||
|
import { isAutheticated } from "src/auth";
|
||||||
|
import axios from "axios";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
const AppContent = () => {
|
const AppContent = () => {
|
||||||
|
const [userper, setuserper] = useState(null);
|
||||||
|
const token = isAutheticated();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const getUser = async () => {
|
||||||
|
let existanceData = localStorage.getItem("authToken");
|
||||||
|
if (!existanceData) {
|
||||||
|
setuserper(null);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
let response = await axios.get(`/api/v1/user/details`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const data = response?.data;
|
||||||
|
if (
|
||||||
|
data?.success &&
|
||||||
|
(data?.user?.role === "admin" || data?.user?.role === "Employee")
|
||||||
|
) {
|
||||||
|
setuserper(data?.user);
|
||||||
|
} else {
|
||||||
|
setuserper(null);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setuserper(null);
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getUser();
|
||||||
|
}, []);
|
||||||
|
const [appRoutes, setAppRoutes] = useState(routes);
|
||||||
return (
|
return (
|
||||||
<CContainer lg>
|
<CContainer lg>
|
||||||
<Suspense fallback={<CSpinner color="primary" />}>
|
<Suspense fallback={<CSpinner color="primary" />}>
|
||||||
<Routes>
|
<Routes>
|
||||||
{routes.map((route, idx) => {
|
{appRoutes.map((route, idx) => {
|
||||||
|
if (
|
||||||
|
userper?.role === "admin" ||
|
||||||
|
route.navName?.trim() === "" ||
|
||||||
|
(userper?.accessTo && userper?.accessTo[route?.navName] === true)
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
route.element && (
|
route.element && (
|
||||||
<Route
|
<Route
|
||||||
@ -21,15 +61,14 @@ const AppContent = () => {
|
|||||||
element={<route.element />}
|
element={<route.element />}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
|
}
|
||||||
})}
|
})}
|
||||||
<Route path="/" element={<Navigate to="dashboard" replace />} />
|
<Route path="/" element={<Navigate to="dashboard" replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</CContainer>
|
</CContainer>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export default React.memo(AppContent);
|
||||||
|
|
||||||
export default React.memo(AppContent)
|
|
||||||
|
@ -27,12 +27,61 @@ const AppSidebar = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const unfoldable = useSelector((state) => state.sidebarUnfoldable);
|
const unfoldable = useSelector((state) => state.sidebarUnfoldable);
|
||||||
const sidebarShow = useSelector((state) => state.sidebarShow);
|
const sidebarShow = useSelector((state) => state.sidebarShow);
|
||||||
|
const [navigationItem, setNavigationItem] = useState(navigation);
|
||||||
|
|
||||||
|
const [userdata, setUserData] = useState(null);
|
||||||
|
const token = isAutheticated();
|
||||||
|
console.log("userDatt", userdata);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const getUser = async () => {
|
||||||
|
let existanceData = localStorage.getItem("authToken");
|
||||||
|
if (!existanceData) {
|
||||||
|
// console.log(existanceData.userData)
|
||||||
|
setUserData(false);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
// console.log('requesting user data from server')
|
||||||
|
let response = await axios.get(`/api/v1/user/details`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// console.log(response.data)
|
||||||
|
const data = response.data;
|
||||||
|
if (
|
||||||
|
(data.success && data.user.role === "admin") ||
|
||||||
|
data.user.role === "Employee"
|
||||||
|
) {
|
||||||
|
setUserData(data.user);
|
||||||
|
} else {
|
||||||
|
setUserData(false);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
setUserData(false);
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getUser();
|
||||||
|
}, []);
|
||||||
|
useEffect(() => {
|
||||||
|
if (userdata && userdata.accessTo) {
|
||||||
|
const filteredNavigation = navigation.filter((item) => {
|
||||||
|
if (userdata.accessTo[item.name]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
setNavigationItem(filteredNavigation);
|
||||||
|
} else {
|
||||||
|
setNavigationItem(navigation);
|
||||||
|
}
|
||||||
|
}, [userdata]);
|
||||||
|
|
||||||
///----------------------//
|
///----------------------//
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const token = isAutheticated();
|
|
||||||
|
|
||||||
// urlcreated images
|
// urlcreated images
|
||||||
const [AppName, setAppName] = useState("");
|
const [AppName, setAppName] = useState("");
|
||||||
const [HeaderlogoUrl, setHeaderlogoUrl] = useState("");
|
const [HeaderlogoUrl, setHeaderlogoUrl] = useState("");
|
||||||
@ -87,7 +136,7 @@ const AppSidebar = () => {
|
|||||||
</CSidebarBrand>
|
</CSidebarBrand>
|
||||||
<CSidebarNav>
|
<CSidebarNav>
|
||||||
<SimpleBar>
|
<SimpleBar>
|
||||||
<AppSidebarNav items={navigation} />
|
<AppSidebarNav items={navigationItem} />
|
||||||
</SimpleBar>
|
</SimpleBar>
|
||||||
</CSidebarNav>
|
</CSidebarNav>
|
||||||
<CSidebarToggler
|
<CSidebarToggler
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
import React from 'react'
|
import React from "react";
|
||||||
import { AppContent, AppSidebar, AppFooter, AppHeader } from '../components/index'
|
import {
|
||||||
|
AppContent,
|
||||||
|
AppSidebar,
|
||||||
|
AppFooter,
|
||||||
|
AppHeader,
|
||||||
|
} from "../components/index";
|
||||||
|
|
||||||
const DefaultLayout = () => {
|
const DefaultLayout = () => {
|
||||||
return (
|
return (
|
||||||
@ -13,7 +18,7 @@ const DefaultLayout = () => {
|
|||||||
<AppFooter />
|
<AppFooter />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default DefaultLayout
|
export default DefaultLayout;
|
||||||
|
643
src/routes.js
643
src/routes.js
@ -137,60 +137,168 @@ import { element } from "prop-types";
|
|||||||
import OrderdayChart from "./views/Charts/OrderDaywise";
|
import OrderdayChart from "./views/Charts/OrderDaywise";
|
||||||
import RevenueCharts from "./views/Charts/RevenueCharts";
|
import RevenueCharts from "./views/Charts/RevenueCharts";
|
||||||
import AddCustomer from "./views/customerDetails/addCustomer";
|
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";
|
||||||
const routes = [
|
const routes = [
|
||||||
{ path: "/", exact: true, name: "Home" },
|
// { path: "/", exact: true, name: "Home", navName: "" },
|
||||||
|
//dashboard
|
||||||
|
|
||||||
|
{ path: "/dashboard", name: "Dashboard", element: Dashboard, navName: "" },
|
||||||
{
|
{
|
||||||
path: "/change_password",
|
path: "/change_password",
|
||||||
name: "Change Password",
|
name: "Change Password",
|
||||||
element: Change_Password,
|
element: Change_Password,
|
||||||
|
navName: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/profile/edit",
|
||||||
|
name: "Edit Profile",
|
||||||
|
element: EditProfile,
|
||||||
|
navName: "",
|
||||||
},
|
},
|
||||||
{ path: "/profile/edit", name: "Edit Profile", element: EditProfile },
|
|
||||||
// { path: '/profile', name: 'Profile', element: Profile },
|
// { 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",
|
||||||
|
name: "products",
|
||||||
|
element: Products,
|
||||||
|
navName: "Product Management",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/product/add",
|
||||||
|
name: "Add products",
|
||||||
|
element: AddProduct,
|
||||||
|
navName: "Product Management",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/product/edit/:id",
|
||||||
|
name: "Edit products",
|
||||||
|
element: EditProduct,
|
||||||
|
navName: "Product Management",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/product/view/:id",
|
||||||
|
name: "view products",
|
||||||
|
element: ViewProduct,
|
||||||
|
navName: "Product Management",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/categories",
|
||||||
|
name: "Categories",
|
||||||
|
element: Categories,
|
||||||
|
navName: "Product Management",
|
||||||
|
},
|
||||||
|
//Gst tax
|
||||||
|
{
|
||||||
|
path: "/tax",
|
||||||
|
name: "Tax Rates",
|
||||||
|
element: Tax,
|
||||||
|
navName: "Product Management",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/tax/add",
|
||||||
|
name: "Add Tax",
|
||||||
|
element: Addtax,
|
||||||
|
navName: "Product Management",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/tax/edit/:id",
|
||||||
|
name: "Edit Tax",
|
||||||
|
element: Edittax,
|
||||||
|
navName: "Product Management",
|
||||||
|
},
|
||||||
|
//----------------------- End Product Management Routes------------------------------------------------
|
||||||
|
|
||||||
//Product
|
|
||||||
{ path: "/products", name: "products", element: Products },
|
|
||||||
{ path: "/product/add", name: "Add products", element: AddProduct },
|
|
||||||
{ path: "/product/edit/:id", name: "Edit products", element: EditProduct },
|
|
||||||
{ path: "/product/view/:id", name: "view products", element: ViewProduct },
|
|
||||||
//Departure
|
//Departure
|
||||||
{ path: "/departures", name: "Departures", element: Departures },
|
// { path: "/departures", name: "Departures", element: Departures },
|
||||||
{ path: "/departure/add", name: "Add Departure", element: AddDeparture },
|
// { path: "/departure/add", name: "Add Departure", element: AddDeparture },
|
||||||
{ path: "/product/edit/:id", name: "Edit products", element: EditProduct },
|
// { path: "/product/edit/:id", name: "Edit products", element: EditProduct },
|
||||||
{ path: "/product/view/:id", name: "view products", element: ViewProduct },
|
// { path: "/product/view/:id", name: "view products", element: ViewProduct },
|
||||||
|
|
||||||
// Appointments
|
// Appointments
|
||||||
{ path: "/appointments", name: "Appointments", element: Appointments },
|
// { path: "/appointments", name: "Appointments", element: Appointments },
|
||||||
{
|
// {
|
||||||
path: "/appointment/view/:id",
|
// path: "/appointment/view/:id",
|
||||||
name: "View Appointment",
|
// name: "View Appointment",
|
||||||
element: ViewAppointment,
|
// element: ViewAppointment,
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
path: "/appointment/edit/:id",
|
// path: "/appointment/edit/:id",
|
||||||
name: "Edit Appointment",
|
// name: "Edit Appointment",
|
||||||
element: EditAppointment,
|
// element: EditAppointment,
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
path: "/appointment/new",
|
// path: "/appointment/new",
|
||||||
name: "Add Appointment",
|
// name: "Add Appointment",
|
||||||
element: AddNewAppointment,
|
// element: AddNewAppointment,
|
||||||
},
|
// },
|
||||||
|
//------------------customers Route-------------------------
|
||||||
{
|
{
|
||||||
path: "/customers-details",
|
path: "/customers-details",
|
||||||
name: "User Table",
|
name: "Customers",
|
||||||
element: CustomerTable,
|
element: CustomerTable,
|
||||||
|
navName: "Customers",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/customers-details/:_id",
|
path: "/customers-details/:_id",
|
||||||
name: "User Table",
|
name: "Customers",
|
||||||
element: SingleUserAllDetails,
|
element: SingleUserAllDetails,
|
||||||
|
navName: "Customers",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/add-customer",
|
path: "/add-customer",
|
||||||
name: "User Table",
|
name: "Customers",
|
||||||
element: AddCustomer,
|
element: AddCustomer,
|
||||||
|
navName: "Customers",
|
||||||
},
|
},
|
||||||
|
//------------------ End customers Route-------------------------
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// path: "/users-address/add",
|
// path: "/users-address/add",
|
||||||
// name: "User Address",
|
// name: "User Address",
|
||||||
@ -203,7 +311,7 @@ const routes = [
|
|||||||
// },
|
// },
|
||||||
{
|
{
|
||||||
path: "/users-address/view",
|
path: "/users-address/view",
|
||||||
name: "view address",
|
name: "Customers",
|
||||||
element: viewDetails,
|
element: viewDetails,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -229,27 +337,23 @@ const routes = [
|
|||||||
// element: ViewHealthCareProvider,
|
// element: ViewHealthCareProvider,
|
||||||
// },
|
// },
|
||||||
// Categories
|
// Categories
|
||||||
{
|
|
||||||
path: "/categories",
|
|
||||||
name: "Categories",
|
|
||||||
element: Categories,
|
|
||||||
},
|
|
||||||
// Design
|
// Design
|
||||||
{
|
// {
|
||||||
path: "/design",
|
// path: "/design",
|
||||||
name: "Design",
|
// name: "Design",
|
||||||
element: Design,
|
// element: Design,
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
path: "//campaigns",
|
// path: "/campaigns",
|
||||||
name: "campaigns",
|
// name: "campaigns",
|
||||||
element: Campaign,
|
// element: Campaign,
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
path: "//campaign/add",
|
// path: "/campaign/add",
|
||||||
name: "Add Campaigns",
|
// name: "Add Campaigns",
|
||||||
element: AddCampaign,
|
// element: AddCampaign,
|
||||||
},
|
// },
|
||||||
// {
|
// {
|
||||||
// path: "/campaigns/edit/:id",
|
// path: "/campaigns/edit/:id",
|
||||||
// name: "Edit healthcare providers",
|
// name: "Edit healthcare providers",
|
||||||
@ -263,342 +367,461 @@ const routes = [
|
|||||||
|
|
||||||
// { path: '/franchisee/view/:id', name: 'view franchisee', element: ViewFra },
|
// { path: '/franchisee/view/:id', name: 'view franchisee', element: ViewFra },
|
||||||
//Contact Requests
|
//Contact Requests
|
||||||
|
// ----------------Customer Service Routes-------------------------------
|
||||||
{
|
{
|
||||||
path: "/contact/request",
|
path: "/contact/request",
|
||||||
name: "Contact Requests",
|
name: "Customer Service",
|
||||||
element: ContactRequests,
|
element: ContactRequests,
|
||||||
|
navName: "Customer Service",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/contact/request/new",
|
path: "/contact/request/new",
|
||||||
name: "AddContact Request",
|
name: "Customer Service",
|
||||||
element: AddContactRequest,
|
element: AddContactRequest,
|
||||||
|
navName: "Customer Service",
|
||||||
},
|
},
|
||||||
//Support Requests
|
//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",
|
path: "/support/request",
|
||||||
name: "CustomerSupport Requests",
|
name: "Customer Service",
|
||||||
element: SupportRequest,
|
element: SupportRequest,
|
||||||
|
navName: "Customer Service",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/support/request/closed",
|
path: "/support/request/closed",
|
||||||
name: "Closed CustomerSupport Requests",
|
name: "Customer Service",
|
||||||
element: SupportRequestClosed,
|
element: SupportRequestClosed,
|
||||||
|
navName: "Customer Service",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/support/request/closed/:ticketID",
|
path: "/support/request/closed/:ticketID",
|
||||||
name: "Closed CustomerSupport Request view",
|
name: "Customer Service",
|
||||||
element: CloseRequestView,
|
element: CloseRequestView,
|
||||||
|
navName: "Customer Service",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/support/request/reply/:ticketID",
|
path: "/support/request/reply/:ticketID",
|
||||||
name: "CustomerSupport Reply",
|
name: "Customer Service",
|
||||||
element: SupportReply,
|
element: SupportReply,
|
||||||
|
navName: "Customer Service",
|
||||||
},
|
},
|
||||||
// Content ---- >
|
// ---------------- End Customer Service Routes-------------------------------
|
||||||
|
|
||||||
{
|
|
||||||
path: "/content",
|
|
||||||
name: "Content",
|
|
||||||
element: Content,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/content/terms-and-conditions",
|
|
||||||
name: "Content",
|
|
||||||
element: EditTermsConditions,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/content/privacy-policy",
|
|
||||||
name: "Content",
|
|
||||||
element: EditPrivacyPolicy,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/content/shipping-policy",
|
|
||||||
name: "Content",
|
|
||||||
element: EditShippingPolicy,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/content/refund-policy",
|
|
||||||
name: "Content",
|
|
||||||
element: EditRefundpolicy,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/content/about-us",
|
|
||||||
name: "Content",
|
|
||||||
element: EditAboutUs,
|
|
||||||
},
|
|
||||||
|
|
||||||
// Home
|
|
||||||
{
|
|
||||||
path: "/home",
|
|
||||||
name: "Home",
|
|
||||||
element: Home,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/home/panel-1",
|
|
||||||
name: "EditPanel1",
|
|
||||||
element: EditPanel1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/home/panel-2",
|
|
||||||
name: "EditPanel2",
|
|
||||||
element: EditPanel2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/home/panel-3",
|
|
||||||
name: "EditPanel3",
|
|
||||||
element: EditPanel3,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/home/panel-4",
|
|
||||||
name: "EditPanel4",
|
|
||||||
element: Editpanel4,
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// { path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint },
|
// { path: '/complaint/view/:id', name: 'view Complain', element: ViewComplaint },
|
||||||
//Complaints
|
//Complaints
|
||||||
|
|
||||||
|
//-------------------------------website related routes----------------------------------
|
||||||
|
{
|
||||||
|
path: "/banner",
|
||||||
|
name: "Banners",
|
||||||
|
element: Banners,
|
||||||
|
navName: "Website Related",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/registerImage",
|
||||||
|
name: "RegisterImage",
|
||||||
|
element: RegisterImage,
|
||||||
|
navName: "Website Related",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/loginImage",
|
||||||
|
name: "LoginImage",
|
||||||
|
element: LoginImage,
|
||||||
|
navName: "Website Related",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/shopImage",
|
||||||
|
name: "ShopImage",
|
||||||
|
element: ShopImage,
|
||||||
|
navName: "Website Related",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/testimonials",
|
path: "/testimonials",
|
||||||
name: "Testimonials",
|
name: "Testimonials",
|
||||||
element: Testimonials,
|
element: Testimonials,
|
||||||
|
navName: "Website Related",
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: "/testimonial/new",
|
path: "/testimonial/new",
|
||||||
name: "AddTestimonial",
|
name: "AddTestimonial",
|
||||||
element: AddTestimonial,
|
element: AddTestimonial,
|
||||||
|
navName: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/testimonial/view/:id",
|
path: "/testimonial/view/:id",
|
||||||
name: "ViewTestimonial",
|
name: "ViewTestimonial",
|
||||||
element: ViewTestimonial,
|
element: ViewTestimonial,
|
||||||
|
navName: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/testimonial/edit/:id",
|
path: "/testimonial/edit/:id",
|
||||||
name: "EditTestimonial",
|
name: "EditTestimonial",
|
||||||
element: EditTestimonial,
|
element: EditTestimonial,
|
||||||
|
navName: "Website Related",
|
||||||
|
},
|
||||||
|
//seo
|
||||||
|
{
|
||||||
|
path: "/seo/request/new",
|
||||||
|
name: "seo Request",
|
||||||
|
element: AddSeoRequest,
|
||||||
|
navName: "Website Related",
|
||||||
|
},
|
||||||
|
// Content ---- >
|
||||||
|
{
|
||||||
|
path: "/content",
|
||||||
|
name: "Website Related",
|
||||||
|
element: Content,
|
||||||
|
navName: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/banner",
|
path: "/content/terms-and-conditions",
|
||||||
name: "Banners",
|
name: "Website Related",
|
||||||
element: Banners,
|
element: EditTermsConditions,
|
||||||
|
navName: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/registerImage",
|
path: "/content/privacy-policy",
|
||||||
name: "RegisterImage",
|
name: "Website Related",
|
||||||
element: RegisterImage,
|
element: EditPrivacyPolicy,
|
||||||
|
navName: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/loginImage",
|
path: "/content/shipping-policy",
|
||||||
name: "LoginImage",
|
name: "Website Related",
|
||||||
element: LoginImage,
|
element: EditShippingPolicy,
|
||||||
|
navName: "Website Related",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/shopImage",
|
path: "/content/refund-policy",
|
||||||
name: "ShopImage",
|
name: "Website Related",
|
||||||
element: ShopImage,
|
element: EditRefundpolicy,
|
||||||
|
navName: "Website Related",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/content/about-us",
|
||||||
|
name: "Website Related",
|
||||||
|
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
|
//informations
|
||||||
{ path: "/informations", name: "Informations", element: Informations },
|
// { path: "/informations", name: "Informations", element: Informations },
|
||||||
|
// {
|
||||||
|
// path: "/information/new",
|
||||||
|
// name: "Add Informations",
|
||||||
|
// element: AddInformations,
|
||||||
|
// },
|
||||||
|
|
||||||
|
//--------------Order Management Routes---------------------------------------
|
||||||
{
|
{
|
||||||
path: "/information/new",
|
path: "/orders/new",
|
||||||
name: "Add Informations",
|
name: "New Orders",
|
||||||
element: AddInformations,
|
element: NewOrders,
|
||||||
|
navName: "Orders",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/order/add",
|
||||||
|
name: "add Order",
|
||||||
|
element: AddOrder,
|
||||||
|
navName: "Orders",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/orders/edit/:id",
|
||||||
|
name: "Edit Order",
|
||||||
|
element: EditOrder,
|
||||||
|
navName: "Orders",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/orders/:status/:id",
|
||||||
|
name: "View Order",
|
||||||
|
element: ViewOrders,
|
||||||
|
navName: "Orders",
|
||||||
},
|
},
|
||||||
|
|
||||||
//Order Management
|
|
||||||
|
|
||||||
{ path: "/orders/new", name: "New Orders", element: NewOrders },
|
|
||||||
{ path: "/order/add", name: "add Order", element: AddOrder },
|
|
||||||
{ path: "/orders/edit/:id", name: "Edit Order", element: EditOrder },
|
|
||||||
{ path: "/orders/:status/:id", name: "View Order", element: ViewOrders },
|
|
||||||
|
|
||||||
{
|
{
|
||||||
path: "/orders/processing",
|
path: "/orders/processing",
|
||||||
name: "Processing Orders",
|
name: "Processing Orders",
|
||||||
element: ProcessingOrders,
|
element: ProcessingOrders,
|
||||||
|
navName: "Orders",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/orders/dispatched",
|
path: "/orders/dispatched",
|
||||||
name: "Dispatched Orders",
|
name: "Dispatched Orders",
|
||||||
element: DispatchedOrders,
|
element: DispatchedOrders,
|
||||||
|
navName: "Orders",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/orders/delivered",
|
path: "/orders/delivered",
|
||||||
name: "Delivered Orders",
|
name: "Delivered Orders",
|
||||||
element: DeliveredOrders,
|
element: DeliveredOrders,
|
||||||
|
navName: "Orders",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/orders/cancelled",
|
path: "/orders/cancelled",
|
||||||
name: "Cancelled Orders",
|
name: "Cancelled Orders",
|
||||||
element: CancelledOrders,
|
element: CancelledOrders,
|
||||||
|
navName: "Orders",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/orders/returned",
|
path: "/orders/returned",
|
||||||
name: "Returned Orders",
|
name: "Returned Orders",
|
||||||
element: ReturnedOrders,
|
element: ReturnedOrders,
|
||||||
|
navName: "Orders",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/inStoreCashOrders/new",
|
||||||
|
name: "In Store Cash Orders",
|
||||||
|
element: InStoreCashOrders,
|
||||||
|
navName: "Orders",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/InStoreQRCodeOrders/new",
|
||||||
|
name: "In Store QR Code Orders",
|
||||||
|
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-----------------------
|
||||||
|
|
||||||
// { path: "/order/:status/:id", name: "View Order", element: ViewOdr },
|
// { path: "/order/:status/:id", name: "View Order", element: ViewOdr },
|
||||||
|
|
||||||
//dashboard
|
|
||||||
|
|
||||||
{ path: "/dashboard", name: "Dashboard", element: Dashboard },
|
|
||||||
|
|
||||||
//------------settings------------------------//
|
//------------settings------------------------//
|
||||||
|
|
||||||
{ path: "/policies", name: "Policies", element: Policies },
|
// { path: "/policies", name: "Policies", element: Policies },
|
||||||
|
|
||||||
{ path: "/socialmedia", name: "Social Media", element: Socialmedia },
|
// { path: "/purpose", name: "Purpose", element: Purpose },
|
||||||
{ path: "/purpose", name: "Purpose", element: Purpose },
|
// { path: "/purpose/add", name: "Add Purpose", element: AddPurpose },
|
||||||
{ path: "/purpose/add", name: "Add Purpose", element: AddPurpose },
|
// //languge
|
||||||
//languge
|
|
||||||
|
|
||||||
{ path: "/languages", name: "languages", element: Languages },
|
// { path: "/languages", name: "languages", element: Languages },
|
||||||
{ path: "/language/add", name: "Add languages", element: AddLanguage },
|
// { path: "/language/add", name: "Add languages", element: AddLanguage },
|
||||||
{ path: "/language/edit/:id", name: "Edit languages", element: EditLanguage },
|
// { path: "/language/edit/:id", name: "Edit languages", element: EditLanguage },
|
||||||
//business Type
|
//business Type
|
||||||
|
|
||||||
{ path: "/business_type", name: "business", element: BusinessType },
|
// { path: "/business_type", name: "business", element: BusinessType },
|
||||||
{
|
// {
|
||||||
path: "/business_type/add",
|
// path: "/business_type/add",
|
||||||
name: "Add business",
|
// name: "Add business",
|
||||||
element: AddBusinessType,
|
// element: AddBusinessType,
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
path: "/business_type/edit/:id",
|
// path: "/business_type/edit/:id",
|
||||||
name: "Edit business",
|
// name: "Edit business",
|
||||||
element: EditBusinessType,
|
// element: EditBusinessType,
|
||||||
},
|
// },
|
||||||
|
|
||||||
//purpose
|
//purpose
|
||||||
|
|
||||||
{ path: "/purpose", name: "purpose", element: Purpose },
|
// { path: "/purpose", name: "purpose", element: Purpose },
|
||||||
{ path: "/purpose/add", name: "Add purpose", element: AddPurpose },
|
// { path: "/purpose/add", name: "Add purpose", element: AddPurpose },
|
||||||
{ path: "/purpose/edit/:id", name: "Edit purpose", element: EditPurpose },
|
// { path: "/purpose/edit/:id", name: "Edit purpose", element: EditPurpose },
|
||||||
|
|
||||||
//languge
|
//languge
|
||||||
|
|
||||||
|
//-----------------Configuration Routes-----------------------------------
|
||||||
|
{
|
||||||
|
path: "/socialmedia",
|
||||||
|
name: "Social Media",
|
||||||
|
element: Socialmedia,
|
||||||
|
navName: "Configuration",
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: "/application/name",
|
path: "/application/name",
|
||||||
name: "ApplicationName",
|
name: "ApplicationName",
|
||||||
element: ApplicationName,
|
element: ApplicationName,
|
||||||
|
navName: "Configuration",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/copyright/message",
|
path: "/copyright/message",
|
||||||
name: "Copyright Message",
|
name: "Copyright Message",
|
||||||
element: CopyrightMessage,
|
element: CopyrightMessage,
|
||||||
|
navName: "Configuration",
|
||||||
},
|
},
|
||||||
|
|
||||||
{ path: "/address", name: "Address", element: Address },
|
|
||||||
{ path: "/logo", name: "Logo", element: Logo },
|
|
||||||
|
|
||||||
//Taxes
|
|
||||||
{ path: "/tax", name: "Tax Rates", element: Tax },
|
|
||||||
{ path: "/tax/add", name: "Add Tax", element: Addtax },
|
|
||||||
{ path: "/tax/edit/:id", name: "Edit Tax", element: Edittax },
|
|
||||||
// -------------------------------------------//
|
|
||||||
|
|
||||||
{
|
{
|
||||||
path: "/seo/request/new",
|
path: "/address",
|
||||||
name: "seo Request",
|
name: "Address",
|
||||||
element: AddSeoRequest,
|
element: Address,
|
||||||
|
navName: "Configuration",
|
||||||
|
},
|
||||||
|
{ path: "/logo", name: "Logo", element: Logo, navName: "Configuration" },
|
||||||
|
//----------------- End Configuration Routes-----------------------------------
|
||||||
|
|
||||||
|
//-----------------Affiliate & Coupons Routes-----------------------------------
|
||||||
|
{
|
||||||
|
path: "/affiliate/coupons",
|
||||||
|
name: "Coupon",
|
||||||
|
element: Coupons,
|
||||||
|
navName: "Affiliate & Coupons",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/affiliate/affiliates",
|
||||||
|
name: "Affiliate",
|
||||||
|
element: Affiliates,
|
||||||
|
navName: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
//
|
|
||||||
//Affiliate Dashboard
|
|
||||||
{ path: "/affiliate/coupons", name: "Coupon", element: Coupons },
|
|
||||||
{ path: "/affiliate/affiliates", name: "Affiliate", element: Affiliates },
|
|
||||||
{
|
{
|
||||||
path: "/affiliate/coupons/create",
|
path: "/affiliate/coupons/create",
|
||||||
name: "Create Coupon",
|
name: "Create Coupon",
|
||||||
element: CreateCoupon,
|
element: CreateCoupon,
|
||||||
|
navName: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/affiliate/affiliates/create",
|
path: "/affiliate/affiliates/create",
|
||||||
name: "Create Affiliate",
|
name: "Create Affiliate",
|
||||||
element: CreateAffiliate,
|
element: CreateAffiliate,
|
||||||
|
navName: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/affiliate/affiliates/edit/:id",
|
path: "/affiliate/affiliates/edit/:id",
|
||||||
name: "Edit Affiliate",
|
name: "Edit Affiliate",
|
||||||
element: EditAffiliate,
|
element: EditAffiliate,
|
||||||
|
navName: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/affiliate/affiliates/pay/:id",
|
path: "/affiliate/affiliates/pay/:id",
|
||||||
name: "Pay Affiliate",
|
name: "Pay Affiliate",
|
||||||
element: PayAffiliate,
|
element: PayAffiliate,
|
||||||
|
navName: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/affiliate/affiliates/history/:id",
|
path: "/affiliate/affiliates/history/:id",
|
||||||
name: "Pay Affiliate",
|
name: "Pay Affiliate",
|
||||||
element: AffiliateHistory,
|
element: AffiliateHistory,
|
||||||
|
navName: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/affiliate/coupons/edit/:id",
|
path: "/affiliate/coupons/edit/:id",
|
||||||
name: "Edit Coupon",
|
name: "Edit Coupon",
|
||||||
element: EditCoupon,
|
element: EditCoupon,
|
||||||
|
navName: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/affiliate/coupons/history/:id",
|
path: "/affiliate/coupons/history/:id",
|
||||||
name: "Edit Coupon",
|
name: "Edit Coupon",
|
||||||
element: CouponHistory,
|
element: CouponHistory,
|
||||||
|
navName: "Affiliate & Coupons",
|
||||||
},
|
},
|
||||||
//Blogs Section
|
//----------------- End Affiliate & Coupons Routes-----------------------------------
|
||||||
|
|
||||||
|
//---------- Blog Routes---------------------------------
|
||||||
{
|
{
|
||||||
path: "/blogs",
|
path: "/blogs",
|
||||||
name: "Blogs",
|
name: "Blogs",
|
||||||
element: Blogs,
|
element: Blogs,
|
||||||
|
navName: "Blog",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/blogs/create",
|
path: "/blogs/create",
|
||||||
name: "Blogs",
|
name: "Blogs",
|
||||||
element: CreateBlog,
|
element: CreateBlog,
|
||||||
|
navName: "Blog",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/blog/edit/:id",
|
path: "/blog/edit/:id",
|
||||||
name: "Blogs",
|
name: "Blogs",
|
||||||
element: UpdateBlog,
|
element: UpdateBlog,
|
||||||
|
navName: "Blog",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/blog/view/:id",
|
path: "/blog/view/:id",
|
||||||
name: "Blogs",
|
name: "Blogs",
|
||||||
element: ViewBlog,
|
element: ViewBlog,
|
||||||
|
navName: "Blog",
|
||||||
},
|
},
|
||||||
//Charts
|
|
||||||
|
//----------End Blog Routes---------------------------------
|
||||||
|
// ------------------------Employee Routes-----------------------
|
||||||
{
|
{
|
||||||
path: "/new-user-day-wise",
|
path: "/employee",
|
||||||
name: "new user day wise",
|
name: "Employee",
|
||||||
element: UserCharts,
|
element: Employee,
|
||||||
|
navName: "Employees & Access",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/revenue-by-product",
|
path: "/add-employee",
|
||||||
name: "Revenue By Product",
|
name: "Employee",
|
||||||
element: ProductrevenueCharts,
|
element: AddEmployee,
|
||||||
|
navName: "Employees & Access",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "/revenue-by-state",
|
path: "edit-employee/:id",
|
||||||
name: "Revenue By State",
|
name: "Employee",
|
||||||
element: StateRevenueCharts,
|
element: EditEmployee,
|
||||||
|
navName: "Employees & Access",
|
||||||
},
|
},
|
||||||
|
// ------------------------ End Employee Routes-----------------------
|
||||||
|
|
||||||
|
//---------Point of Sale Section Routes------------------------
|
||||||
{
|
{
|
||||||
path: "/revenue-by-city",
|
path: "/pos",
|
||||||
name: "Revenue By City",
|
name: "Point of Sale",
|
||||||
element: CityRevenueCharts,
|
element: Pos,
|
||||||
|
navName: "Point of Sale",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Export to excel
|
||||||
{
|
{
|
||||||
path: "/orders-day-wise",
|
path: "/exp",
|
||||||
name: "Orders (Day Wise)",
|
name: "Point of Sale",
|
||||||
element: OrderdayChart,
|
element: ExportToExcel,
|
||||||
},
|
navName: "Point of Sale",
|
||||||
{
|
|
||||||
path: "/revenue-day-wise",
|
|
||||||
name: "Revenue (Day Wise)",
|
|
||||||
element: RevenueCharts,
|
|
||||||
},
|
},
|
||||||
|
//--------- End Point of Sale Section Routes------------------------
|
||||||
];
|
];
|
||||||
|
|
||||||
export default routes;
|
export default routes;
|
||||||
|
111
src/views/CustomerSupport/EmailCMS/EmailCms.js
Normal file
111
src/views/CustomerSupport/EmailCMS/EmailCms.js
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
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 (
|
||||||
|
<div className="main-content">
|
||||||
|
<Typography variant="h6" fontWeight={"bold"}>
|
||||||
|
Email CMS
|
||||||
|
</Typography>
|
||||||
|
<TableContainer component={Paper}>
|
||||||
|
<Table sx={{ minWidth: 650 }} aria-label="simple table">
|
||||||
|
<TableHead>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell style={{ fontWeight: "bold" }}>Page</TableCell>
|
||||||
|
<TableCell style={{ fontWeight: "bold" }} align="right">
|
||||||
|
Action
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableHead>
|
||||||
|
<TableBody>
|
||||||
|
{pages.map((row) => (
|
||||||
|
<TableRow
|
||||||
|
key={row.name}
|
||||||
|
sx={{ "&:last-child td, &:last-child th": { border: 0 } }}
|
||||||
|
>
|
||||||
|
<TableCell component="th" scope="row">
|
||||||
|
{row.name}
|
||||||
|
</TableCell>
|
||||||
|
<TableCell align="right">
|
||||||
|
{" "}
|
||||||
|
<Link to={row.path}>
|
||||||
|
<button
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
marginRight: "1rem",
|
||||||
|
}}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-info btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
mt-1
|
||||||
|
mx-1
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{row.action}
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
207
src/views/CustomerSupport/EmailCMS/RegistrationEmail.js
Normal file
207
src/views/CustomerSupport/EmailCMS/RegistrationEmail.js
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
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 (
|
||||||
|
<div>
|
||||||
|
<div style={{ display: "flex" }}>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={handleSaveClick}
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
marginRight: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={handleCancelClick}
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
marginRight: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Box style={{ background: "#FFFFFF", color: "black", padding: "1rem" }}>
|
||||||
|
{/* <TextField
|
||||||
|
type="text"
|
||||||
|
value={title}
|
||||||
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
|
variant="outlined"
|
||||||
|
size="small"
|
||||||
|
fullWidth
|
||||||
|
/> */}
|
||||||
|
<Typography
|
||||||
|
style={{ margin: "0.5rem 0rem", fontWeight: "bold" }}
|
||||||
|
variant="h6"
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
Email Confiramtion:{" "}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="welcomeMsg" className="form-label">
|
||||||
|
Welcome Message*
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
style={{ width: "300px" }}
|
||||||
|
id="welcomeMsg"
|
||||||
|
placeholder="Eg: Welcome to "
|
||||||
|
value={welcomemsg}
|
||||||
|
onChange={(e) => setWelcomeMsg(e.target.value)}
|
||||||
|
/>
|
||||||
|
<h6 style={{ fontWeight: "bold", marginTop: "1rem" }}>
|
||||||
|
App Name : Smellika
|
||||||
|
</h6>
|
||||||
|
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Subject*
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="title"
|
||||||
|
value={subject}
|
||||||
|
onChange={(e) => setSubject(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="welcomeMsgforDes" className="form-label">
|
||||||
|
Welcome Message for Description*
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
style={{ width: "300px" }}
|
||||||
|
id="welcomeMsgforDes"
|
||||||
|
placeholder="Eg: Welcome to "
|
||||||
|
value={welcomemsgforDescription}
|
||||||
|
onChange={(e) => setWelcomeMsgForDescription(e.target.value)}
|
||||||
|
/>
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Description *
|
||||||
|
</label>
|
||||||
|
<textarea
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="description"
|
||||||
|
rows="10"
|
||||||
|
cols="100"
|
||||||
|
value={description}
|
||||||
|
placeholder="your message..."
|
||||||
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
454
src/views/EmployeeAccess/Employee.js
Normal file
454
src/views/EmployeeAccess/Employee.js
Normal file
@ -0,0 +1,454 @@
|
|||||||
|
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,
|
||||||
|
} from "@mui/material";
|
||||||
|
import SearchIcon from "@mui/icons-material/Search";
|
||||||
|
import Fuse from "fuse.js";
|
||||||
|
import { Typography } from "@material-ui/core";
|
||||||
|
// import OrderDetails from "./orderDetails";
|
||||||
|
const Employee = () => {
|
||||||
|
const token = isAutheticated();
|
||||||
|
const [query, setQuery] = useState("");
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [loading1, setLoading1] = useState(true);
|
||||||
|
const [success, setSuccess] = useState(true);
|
||||||
|
const [employee, setemployee] = useState([]);
|
||||||
|
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
const [itemPerPage, setItemPerPage] = useState(10);
|
||||||
|
const [showData, setShowData] = useState(employee);
|
||||||
|
|
||||||
|
const handleShowEntries = (e) => {
|
||||||
|
setCurrentPage(1);
|
||||||
|
setItemPerPage(e.target.value);
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
const loadData = () => {
|
||||||
|
const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
setShowData(employee.slice(indexOfFirstPost, indexOfLastPost));
|
||||||
|
};
|
||||||
|
loadData();
|
||||||
|
}, [currentPage, itemPerPage, employee]);
|
||||||
|
console.log(employee);
|
||||||
|
|
||||||
|
// const getemployee = async () => {
|
||||||
|
// axios
|
||||||
|
// .get(`/api/v1/admin/employee`, {
|
||||||
|
// headers: {
|
||||||
|
// Authorization: `Bearer ${token}`,
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// setemployee(res.data.employee);
|
||||||
|
// 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);
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// getemployee();
|
||||||
|
// }, [success]);
|
||||||
|
// console.log(employee);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// const loadData = () => {
|
||||||
|
// const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
// const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
// setShowData(employee.slice(indexOfFirstPost, indexOfLastPost));
|
||||||
|
// };
|
||||||
|
// loadData();
|
||||||
|
// }, [currentPage, itemPerPage, employee]);
|
||||||
|
// console.log(employee);
|
||||||
|
|
||||||
|
// 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/user-address/deleteAddress/${id}`, {
|
||||||
|
// headers: {
|
||||||
|
// "Access-Control-Allow-Origin": "*",
|
||||||
|
// Authorization: `Bearer ${token}`,
|
||||||
|
// },
|
||||||
|
// })
|
||||||
|
// .then((res) => {
|
||||||
|
// swal({
|
||||||
|
// title: "Deleted",
|
||||||
|
// text: "Address Deleted successfully!",
|
||||||
|
// icon: "success",
|
||||||
|
// button: "ok",
|
||||||
|
// });
|
||||||
|
// setSuccess((prev) => !prev);
|
||||||
|
// })
|
||||||
|
// .catch((err) => {
|
||||||
|
// swal({
|
||||||
|
// title: "Warning",
|
||||||
|
// text: "Something went wrong!",
|
||||||
|
// icon: "error",
|
||||||
|
// button: "Retry",
|
||||||
|
// dangerMode: true,
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
|
// get All employee
|
||||||
|
const getemployee = async () => {
|
||||||
|
axios
|
||||||
|
.get(`/api/v1/admin/employee`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
setemployee(res.data.employee);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
getemployee();
|
||||||
|
}, [success]);
|
||||||
|
console.log(employee);
|
||||||
|
console.log("showdata", showData);
|
||||||
|
// const trueEntries = Object.entries(showData.).filter(
|
||||||
|
// ([key, value]) => value === true
|
||||||
|
// );
|
||||||
|
const renderAccessTo = (accessTo) => {
|
||||||
|
return Object.entries(accessTo)
|
||||||
|
.filter(([key, value]) => value === true)
|
||||||
|
.map(([key, value]) => key)
|
||||||
|
.join(", ");
|
||||||
|
};
|
||||||
|
const handleDelete = async (id) => {
|
||||||
|
try {
|
||||||
|
// Send a DELETE request to your API to delete the employee by ID
|
||||||
|
const res = await axios.delete(`/api/v1/admin/delete-employee/${id}`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// If deletion is successful, update the employee list
|
||||||
|
swal({
|
||||||
|
title: "Congratulations!!",
|
||||||
|
text: res?.data?.message,
|
||||||
|
icon: "success",
|
||||||
|
buttons: "OK",
|
||||||
|
});
|
||||||
|
setemployee(employee.filter((employee) => employee._id !== id));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error deleting employee:", error);
|
||||||
|
swal({
|
||||||
|
title: "",
|
||||||
|
text: "Something went wrong!",
|
||||||
|
icon: "error",
|
||||||
|
button: "Retry",
|
||||||
|
dangerMode: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
page-title-box
|
||||||
|
d-flex
|
||||||
|
align-items-center
|
||||||
|
justify-content-between
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
All Employees
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="page-title-right">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
navigate("/add-employee");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Add Employee
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row ml-0 mr-0 mb-10 ">
|
||||||
|
<div className="col-sm-12 col-md-12">
|
||||||
|
<div className="dataTables_length">
|
||||||
|
<label className="w-100">
|
||||||
|
Show
|
||||||
|
<select
|
||||||
|
style={{ width: "10%" }}
|
||||||
|
name=""
|
||||||
|
onChange={(e) => handleShowEntries(e)}
|
||||||
|
className="
|
||||||
|
select-w
|
||||||
|
custom-select custom-select-sm
|
||||||
|
form-control form-control-sm
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="25">25</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
<option value="100">100</option>
|
||||||
|
</select>
|
||||||
|
entries
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="table-responsive table-shoot mt-3">
|
||||||
|
<table
|
||||||
|
className="table table-centered table-nowrap"
|
||||||
|
style={{ border: "1px solid" }}
|
||||||
|
>
|
||||||
|
<thead
|
||||||
|
className="thead-info"
|
||||||
|
style={{ background: "rgb(140, 213, 213)" }}
|
||||||
|
>
|
||||||
|
<tr>
|
||||||
|
<th>Employee Name</th>
|
||||||
|
<th>Email</th>
|
||||||
|
|
||||||
|
<th>Access to </th>
|
||||||
|
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{!loading && showData.length === 0 && (
|
||||||
|
<tr className="text-center">
|
||||||
|
<td colSpan="6">
|
||||||
|
<h5>No Data Available</h5>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
{loading ? (
|
||||||
|
<tr>
|
||||||
|
<td className="text-center" colSpan="6">
|
||||||
|
Loading...
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
) : (
|
||||||
|
showData.map((employee, i) => {
|
||||||
|
return (
|
||||||
|
<tr key={i}>
|
||||||
|
<td className="text-start">{employee.name}</td>
|
||||||
|
<td>{employee.email}</td>
|
||||||
|
|
||||||
|
<td
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
className="text-start"
|
||||||
|
>
|
||||||
|
{renderAccessTo(employee.accessTo)}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<th>
|
||||||
|
<button
|
||||||
|
onClick={() =>
|
||||||
|
navigate(`/edit-employee/${employee._id}`)
|
||||||
|
}
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
marginRight: "1rem",
|
||||||
|
}}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-primary btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
mx-1
|
||||||
|
mt-1
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
style={{
|
||||||
|
color: "white",
|
||||||
|
marginRight: "1rem",
|
||||||
|
}}
|
||||||
|
onClick={() => handleDelete(employee._id)}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-primary btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
mx-1
|
||||||
|
mt-1
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row mt-20">
|
||||||
|
<div className="col-sm-12 col-md-6 mb-20">
|
||||||
|
<div
|
||||||
|
className="dataTables_info"
|
||||||
|
id="datatable_info"
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
>
|
||||||
|
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
||||||
|
{Math.min(currentPage * itemPerPage, employee.length)}{" "}
|
||||||
|
of {employee.length} entries
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-sm-12 col-md-6">
|
||||||
|
<div className="d-flex">
|
||||||
|
<ul className="pagination ms-auto">
|
||||||
|
<li
|
||||||
|
className={
|
||||||
|
currentPage === 1
|
||||||
|
? "paginate_button page-item previous disabled"
|
||||||
|
: "paginate_button page-item previous"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => setCurrentPage((prev) => prev - 1)}
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{!(currentPage - 1 < 1) && (
|
||||||
|
<li className="paginate_button page-item">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={(e) =>
|
||||||
|
setCurrentPage((prev) => prev - 1)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{currentPage - 1}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<li className="paginate_button page-item active">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
{currentPage}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{!(
|
||||||
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
employee.length - 1
|
||||||
|
) && (
|
||||||
|
<li className="paginate_button page-item ">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentPage((prev) => prev + 1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{currentPage + 1}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<li
|
||||||
|
className={
|
||||||
|
!(
|
||||||
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
employee.length - 1
|
||||||
|
)
|
||||||
|
? "paginate_button page-item next"
|
||||||
|
: "paginate_button page-item next disabled"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => setCurrentPage((prev) => prev + 1)}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Employee;
|
212
src/views/EmployeeAccess/addEmployee.js
Normal file
212
src/views/EmployeeAccess/addEmployee.js
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
import { Box, Button, Typography } from "@mui/material";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import FormGroup from "@mui/material/FormGroup";
|
||||||
|
import FormControlLabel from "@mui/material/FormControlLabel";
|
||||||
|
import Checkbox from "@mui/material/Checkbox";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import _nav from "src/_nav";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
const AddEmployee = () => {
|
||||||
|
const [employeeName, setEmployeeName] = useState("");
|
||||||
|
const [phone, setPhone] = useState("");
|
||||||
|
const [email, setEmail] = useState("");
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const filteredNav = _nav.filter((item) => item.name !== "Employee");
|
||||||
|
const [checkedItems, setCheckedItems] = useState(
|
||||||
|
filteredNav.reduce((acc, item) => {
|
||||||
|
acc[item.name] = false;
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
);
|
||||||
|
|
||||||
|
// const filteredEntries = Object.fromEntries(
|
||||||
|
// Object.entries(checkedItems).filter(([key, value]) => value === true)
|
||||||
|
// );
|
||||||
|
// console.log(filteredEntries);
|
||||||
|
const handleCheckboxChange = (name) => (event) => {
|
||||||
|
setCheckedItems({
|
||||||
|
...checkedItems,
|
||||||
|
[name]: event.target.checked,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(checkedItems);
|
||||||
|
const generatePassword = (name, email) => {
|
||||||
|
const combinedStr = (name + email).toLowerCase(); // Convert to lowercase for consistency
|
||||||
|
const specialChars = "@#*!$%^&"; // Define the set of special characters
|
||||||
|
const alphaChars = combinedStr.match(/[a-zA-Z]/g); // Filter out alphabetic characters
|
||||||
|
const digitChars = combinedStr.match(/\d/g); // Filter out digits
|
||||||
|
const filteredChars = combinedStr.match(/[^\W_]/g); // Filter out non-alphanumeric characters
|
||||||
|
let passwordChars = alphaChars.concat(filteredChars); // Combine alphabetic and filtered characters
|
||||||
|
|
||||||
|
// Ensure at least one uppercase letter
|
||||||
|
if (!passwordChars.some((char) => char === char.toUpperCase())) {
|
||||||
|
const uppercaseChar = String.fromCharCode(
|
||||||
|
65 + Math.floor(Math.random() * 26)
|
||||||
|
);
|
||||||
|
passwordChars.push(uppercaseChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure at least one digit
|
||||||
|
if (!digitChars || digitChars.length === 0) {
|
||||||
|
const digitChar = Math.floor(Math.random() * 10).toString();
|
||||||
|
passwordChars.push(digitChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert a random special character at a random position in the password characters array
|
||||||
|
const specialChar = specialChars.charAt(
|
||||||
|
Math.floor(Math.random() * specialChars.length)
|
||||||
|
);
|
||||||
|
const randomIndex = Math.floor(Math.random() * (passwordChars.length + 1));
|
||||||
|
passwordChars.splice(randomIndex, 0, specialChar);
|
||||||
|
|
||||||
|
passwordChars = passwordChars.sort(() => Math.random() - 0.5); // Shuffle the characters
|
||||||
|
// passwordString.charAt(0).toUpperCase() + passwordString.slice(1) + "@";
|
||||||
|
const normalpassword = passwordChars.join("").slice(0, 8); // Take the first 8 characters
|
||||||
|
const passwordWithspecialChar =
|
||||||
|
normalpassword.charAt(0).toUpperCase() + normalpassword.slice(1) + "1@2";
|
||||||
|
return passwordWithspecialChar;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleFormSubmit = async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
console.log("request made");
|
||||||
|
try {
|
||||||
|
if (!employeeName || !email || !phone) {
|
||||||
|
throw new Error("Fill all fields!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate password based on name and email
|
||||||
|
const generatedPassword = generatePassword(employeeName, email);
|
||||||
|
console.log(generatedPassword); // Use generatedPassword instead of generatePassword
|
||||||
|
// Set generated password to user state
|
||||||
|
|
||||||
|
const response = await axios.post("/api/v1/user/register", {
|
||||||
|
// Send user details
|
||||||
|
name: employeeName,
|
||||||
|
email: email,
|
||||||
|
phone: phone,
|
||||||
|
role: "Employee",
|
||||||
|
accessTo: checkedItems,
|
||||||
|
password: generatedPassword, // Send generated password to the backend
|
||||||
|
});
|
||||||
|
console.log(response);
|
||||||
|
if (response.status === 201) {
|
||||||
|
toast.success("Employee Added Successful");
|
||||||
|
// setUserId(response.data.userId);
|
||||||
|
navigate("/employee");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error?.response);
|
||||||
|
// toast.error(error?.response);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Box style={{ background: "#FFFFFF", color: "black", padding: "1rem" }}>
|
||||||
|
<Typography
|
||||||
|
style={{ margin: "0.5rem 0rem", fontWeight: "bold" }}
|
||||||
|
variant="h6"
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
Add Employee:{" "}
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Employee Name*
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="title"
|
||||||
|
placeholder="Eg: Roshan Garg"
|
||||||
|
value={employeeName}
|
||||||
|
onChange={(e) => setEmployeeName(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Phone Number
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
id="title"
|
||||||
|
placeholder="Eg: 8516913819"
|
||||||
|
value={phone}
|
||||||
|
onChange={(e) => setPhone(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="welcomeMsgforDes" className="form-label">
|
||||||
|
Email*
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="email"
|
||||||
|
className="form-control"
|
||||||
|
id="welcomeMsgforDes"
|
||||||
|
placeholder="Eg: roshan@gmailcom "
|
||||||
|
value={email}
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Box>
|
||||||
|
<label htmlFor="welcomeMsgforDes" className="form-label">
|
||||||
|
Access to*
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
{filteredNav.map((item, index) => (
|
||||||
|
<div key={index}>
|
||||||
|
<Checkbox
|
||||||
|
checked={checkedItems[item.name] || false}
|
||||||
|
onChange={handleCheckboxChange(item.name)}
|
||||||
|
inputProps={{ "aria-label": "controlled" }}
|
||||||
|
/>
|
||||||
|
{item.name}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
<div style={{ display: "flex" }}>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={handleFormSubmit}
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
marginRight: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => navigate("/employee")}
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
marginRight: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddEmployee;
|
154
src/views/EmployeeAccess/editEmployee.js
Normal file
154
src/views/EmployeeAccess/editEmployee.js
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import axios from "axios";
|
||||||
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
import { Box, Button, Typography } from "@mui/material";
|
||||||
|
import Checkbox from "@mui/material/Checkbox";
|
||||||
|
import _nav from "src/_nav";
|
||||||
|
import { isAutheticated } from "src/auth";
|
||||||
|
|
||||||
|
const EditEmployee = () => {
|
||||||
|
const { id } = useParams();
|
||||||
|
const token = isAutheticated();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const [employeeName, setEmployeeName] = useState("");
|
||||||
|
const [phone, setPhone] = useState("");
|
||||||
|
const [checkedItems, setCheckedItems] = useState({});
|
||||||
|
const filteredNav = _nav.filter((item) => item.name !== "Employee");
|
||||||
|
|
||||||
|
const handleCheckboxChange = (name) => (event) => {
|
||||||
|
setCheckedItems({
|
||||||
|
...checkedItems,
|
||||||
|
[name]: event.target.checked,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const getSingleEmployee = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axios.get(`/api/v1/admin/user/${id}`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const { name, phone, accessTo } = response.data.user;
|
||||||
|
setEmployeeName(name);
|
||||||
|
setPhone(phone);
|
||||||
|
setCheckedItems(accessTo);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching employee:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getSingleEmployee();
|
||||||
|
}, [id, token]);
|
||||||
|
|
||||||
|
const handleUpdateEmployee = async () => {
|
||||||
|
try {
|
||||||
|
await axios.put(
|
||||||
|
`/api/v1/admin/update-employee/${id}`,
|
||||||
|
{
|
||||||
|
name: employeeName,
|
||||||
|
phone: phone,
|
||||||
|
accessTo: checkedItems,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
navigate("/employee");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating employee:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Box style={{ background: "#FFFFFF", color: "black", padding: "1rem" }}>
|
||||||
|
<Typography
|
||||||
|
style={{ margin: "0.5rem 0rem", fontWeight: "bold" }}
|
||||||
|
variant="h6"
|
||||||
|
>
|
||||||
|
Update Employee
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="title" className="form-label">
|
||||||
|
Employee Name*
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Enter employee name"
|
||||||
|
value={employeeName}
|
||||||
|
onChange={(e) => setEmployeeName(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-3">
|
||||||
|
<label htmlFor="phone" className="form-label">
|
||||||
|
Phone Number
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control"
|
||||||
|
placeholder="Enter phone number"
|
||||||
|
value={phone}
|
||||||
|
onChange={(e) => setPhone(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Box>
|
||||||
|
<label htmlFor="accessTo" className="form-label">
|
||||||
|
Access to*
|
||||||
|
</label>
|
||||||
|
<div>
|
||||||
|
{filteredNav.map((item, index) => (
|
||||||
|
<div key={index}>
|
||||||
|
<Checkbox
|
||||||
|
checked={checkedItems[item.name] || false}
|
||||||
|
onChange={handleCheckboxChange(item.name)}
|
||||||
|
inputProps={{ "aria-label": "controlled" }}
|
||||||
|
/>
|
||||||
|
{item.name}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<div style={{ display: "flex" }}>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={handleUpdateEmployee}
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
marginRight: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Update Employee
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
onClick={() => navigate("/employee")}
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
marginRight: "5px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EditEmployee;
|
77
src/views/PointOfSale/AddressSelectionModal.js
Normal file
77
src/views/PointOfSale/AddressSelectionModal.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
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 (
|
||||||
|
<Modal isOpen={isOpen} onRequestClose={onClose} style={modalStyle}>
|
||||||
|
<h2>Select Address</h2>
|
||||||
|
<table style={tableStyle}>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style={thStyle}>First Name</th>
|
||||||
|
<th style={thStyle}>Last Name</th>
|
||||||
|
<th style={thStyle}>Phone Number</th>
|
||||||
|
<th style={thStyle}>Street</th>
|
||||||
|
<th style={thStyle}>City</th>
|
||||||
|
<th style={thStyle}>Postal Code</th>
|
||||||
|
<th style={thStyle}>State</th>
|
||||||
|
{/* Add additional columns as needed */}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{addresses.map((address, index) => (
|
||||||
|
<tr
|
||||||
|
key={index}
|
||||||
|
onClick={() => onSelect(address)}
|
||||||
|
style={{ cursor: "pointer", ...thTdStyle }}
|
||||||
|
>
|
||||||
|
<td>{address.first_Name}</td>
|
||||||
|
<td>{address.last_Name}</td>
|
||||||
|
<td>{address.phone_Number}</td>
|
||||||
|
<td>{address.street}</td>
|
||||||
|
<td>{address.city}</td>
|
||||||
|
<td>{address.postalCode}</td>
|
||||||
|
<td>{address.state}</td>
|
||||||
|
{/* Add additional columns as needed */}
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<button onClick={onClose}>Close</button>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddressSelectionModal;
|
||||||
|
|
1242
src/views/PointOfSale/Pos.js
Normal file
1242
src/views/PointOfSale/Pos.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -33,7 +33,7 @@ const Dashboard = () => {
|
|||||||
//3rd
|
//3rd
|
||||||
const [product, setProduct] = useState([]);
|
const [product, setProduct] = useState([]);
|
||||||
const getAllProduct = async () => {
|
const getAllProduct = async () => {
|
||||||
let res = await axios.get(`/api/product/getAll/`, {
|
let res = await axios.get(`/api/product/getAll/user/`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
|
73
src/views/exportExcel.js
Normal file
73
src/views/exportExcel.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import * as XLSX from "xlsx";
|
||||||
|
import { saveAs } from "file-saver";
|
||||||
|
import { isAutheticated } from "src/auth";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
function ExportToExcel() {
|
||||||
|
const token = isAutheticated();
|
||||||
|
const [newOrdersData, setNewOrdersData] = useState([]);
|
||||||
|
|
||||||
|
const data = [
|
||||||
|
{ name: "John", email: "john@example.com", age: 28 },
|
||||||
|
{ name: "Jane", email: "jane@example.com", age: 32 },
|
||||||
|
// ... more data
|
||||||
|
];
|
||||||
|
useEffect(() => {
|
||||||
|
function getNewOrder() {
|
||||||
|
axios
|
||||||
|
.get(`/api/order/getAll/new`, {
|
||||||
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
const filteredOrders = res.data.order.filter(
|
||||||
|
(order) => order.orderType === "WebSite"
|
||||||
|
);
|
||||||
|
|
||||||
|
setNewOrdersData(filteredOrders);
|
||||||
|
// setLoading(false);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
// setLoading(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getNewOrder();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const exportToExcel = () => {
|
||||||
|
const flattenedData = newOrdersData.map((order) => ({
|
||||||
|
...order,
|
||||||
|
// Flatten shippingInfo object
|
||||||
|
shippingInfo: JSON.stringify(order.shippingInfo),
|
||||||
|
// Concatenate item names into a single string
|
||||||
|
items: order.items.map((item) => item.name).join(", "),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const worksheet = XLSX.utils.json_to_sheet(flattenedData);
|
||||||
|
const workbook = XLSX.utils.book_new();
|
||||||
|
XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
|
||||||
|
|
||||||
|
const excelBuffer = XLSX.write(workbook, {
|
||||||
|
bookType: "xlsx",
|
||||||
|
type: "array",
|
||||||
|
});
|
||||||
|
const blob = new Blob([excelBuffer], {
|
||||||
|
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8",
|
||||||
|
});
|
||||||
|
|
||||||
|
saveAs(blob, "exportedData.xlsx");
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="App">
|
||||||
|
<button onClick={exportToExcel}>Export as Excel</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ExportToExcel;
|
File diff suppressed because it is too large
Load Diff
@ -93,7 +93,7 @@ function EditOrder() {
|
|||||||
function getProductDetails() {
|
function getProductDetails() {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
axios
|
axios
|
||||||
.get(`/api/product/getAll/`, {
|
.get(`/api/product/getAll/admin`, {
|
||||||
headers: {
|
headers: {
|
||||||
"Access-Control-Allow-Origin": "*",
|
"Access-Control-Allow-Origin": "*",
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
|
386
src/views/orders/InStoreCashOrders.js
Normal file
386
src/views/orders/InStoreCashOrders.js
Normal file
@ -0,0 +1,386 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
import { isAutheticated } from "src/auth";
|
||||||
|
import Button from "@material-ui/core/Button";
|
||||||
|
|
||||||
|
function InStoreCashOrders() {
|
||||||
|
const token = isAutheticated();
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [success, setSuccess] = useState(true);
|
||||||
|
const [newOrdersData, setNewOrdersData] = useState([]);
|
||||||
|
console.log(newOrdersData);
|
||||||
|
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
const [itemPerPage, setItemPerPage] = useState(10);
|
||||||
|
const [showData, setShowData] = useState(newOrdersData);
|
||||||
|
|
||||||
|
const handleShowEntries = (e) => {
|
||||||
|
setCurrentPage(1);
|
||||||
|
setItemPerPage(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function getNewOrder() {
|
||||||
|
axios
|
||||||
|
.get(`/api/order/getAll/new`, {
|
||||||
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
const filteredOrders = res.data.order.filter(
|
||||||
|
(order) => order.orderType === "PointOfSale" && order.paymentMode === "cod"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Set the filtered orders data
|
||||||
|
setNewOrdersData(filteredOrders);
|
||||||
|
setLoading(false);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getNewOrder();
|
||||||
|
}, [success]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadData = () => {
|
||||||
|
const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
setShowData(newOrdersData.slice(indexOfFirstPost, indexOfLastPost));
|
||||||
|
};
|
||||||
|
loadData();
|
||||||
|
}, [currentPage, itemPerPage, newOrdersData]);
|
||||||
|
|
||||||
|
const handleDelete = (id) => {
|
||||||
|
console.log(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/order/delete/${id}`, {
|
||||||
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
page-title-box
|
||||||
|
d-flex
|
||||||
|
align-items-center
|
||||||
|
justify-content-between
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
New Orders
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* <div className="page-title-right">
|
||||||
|
<Link to="/order/add">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Add Order
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
</div> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row ml-0 mr-0 mb-10">
|
||||||
|
<div className="col-sm-12 col-md-12">
|
||||||
|
<div className="dataTables_length">
|
||||||
|
<label className="w-100">
|
||||||
|
Show
|
||||||
|
<select
|
||||||
|
style={{ width: "10%" }}
|
||||||
|
name=""
|
||||||
|
onChange={(e) => handleShowEntries(e)}
|
||||||
|
className="
|
||||||
|
select-w
|
||||||
|
custom-select custom-select-sm
|
||||||
|
form-control form-control-sm
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="25">25</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
<option value="100">100</option>
|
||||||
|
</select>
|
||||||
|
entries
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="table-responsive table-shoot mt-3">
|
||||||
|
<table
|
||||||
|
className="table table-centered table-nowrap"
|
||||||
|
style={{ border: "1px solid" }}
|
||||||
|
>
|
||||||
|
<thead
|
||||||
|
className="thead"
|
||||||
|
style={{ background: "rgb(140, 213, 213)" }}
|
||||||
|
>
|
||||||
|
<tr>
|
||||||
|
<th className="text-start">Order ID</th>
|
||||||
|
<th className="text-start">Customer</th>
|
||||||
|
<th className="text-start">Order value</th>
|
||||||
|
<th className="text-start">Order At</th>
|
||||||
|
<th className="text-start">Status</th>
|
||||||
|
<th className="text-start">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{!loading && showData.length === 0 && (
|
||||||
|
<tr className="text-center">
|
||||||
|
<td colSpan="6">
|
||||||
|
<h5>No Data Available</h5>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
{loading ? (
|
||||||
|
<tr>
|
||||||
|
<td className="text-center" colSpan="6">
|
||||||
|
Loading...
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
) : (
|
||||||
|
showData.map((order, i) => {
|
||||||
|
return (
|
||||||
|
<tr key={i}>
|
||||||
|
<td className="text-start">{order?.orderID}</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{order?.user?.name}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
₹{order?.total_amount}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{new Date(order?.createdAt).toLocaleString(
|
||||||
|
"en-IN",
|
||||||
|
{
|
||||||
|
month: "short",
|
||||||
|
day: "numeric",
|
||||||
|
year: "numeric",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "numeric",
|
||||||
|
hour12: true,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
<span className="badge text-bg-primary text-white">
|
||||||
|
{order?.orderStatus}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
||||||
|
<Link
|
||||||
|
to={`/inStoreOrders/${order.orderStatus}/${order._id}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
style={{ color: "white" }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-primary btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
ms-2 mt-1
|
||||||
|
"
|
||||||
|
>
|
||||||
|
View
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
|
{/* <Link to={`/orders/edit/${order._id}`}>
|
||||||
|
<button
|
||||||
|
style={{ color: "white" }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-info btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
ms-2 mt-1
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
|
</Link> */}
|
||||||
|
|
||||||
|
{/* <button
|
||||||
|
style={{ color: "white" }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-danger btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
ms-2 mt-1
|
||||||
|
"
|
||||||
|
onClick={() => handleDelete(order._id)}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button> */}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row mt-20">
|
||||||
|
<div className="col-sm-12 col-md-6 mb-20">
|
||||||
|
<div
|
||||||
|
className="dataTables_info"
|
||||||
|
id="datatable_info"
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
>
|
||||||
|
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
||||||
|
{Math.min(
|
||||||
|
currentPage * itemPerPage,
|
||||||
|
newOrdersData.length
|
||||||
|
)}{" "}
|
||||||
|
of {newOrdersData.length} entries
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-sm-12 col-md-6">
|
||||||
|
<div className="d-flex">
|
||||||
|
<ul className="pagination ms-auto">
|
||||||
|
<li
|
||||||
|
className={
|
||||||
|
currentPage === 1
|
||||||
|
? "paginate_button page-item previous disabled"
|
||||||
|
: "paginate_button page-item previous"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => setCurrentPage((prev) => prev - 1)}
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{!(currentPage - 1 < 1) && (
|
||||||
|
<li className="paginate_button page-item">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={(e) =>
|
||||||
|
setCurrentPage((prev) => prev - 1)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{currentPage - 1}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<li className="paginate_button page-item active">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
{currentPage}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{!(
|
||||||
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
newOrdersData.length - 1
|
||||||
|
) && (
|
||||||
|
<li className="paginate_button page-item ">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentPage((prev) => prev + 1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{currentPage + 1}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<li
|
||||||
|
className={
|
||||||
|
!(
|
||||||
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
newOrdersData.length - 1
|
||||||
|
)
|
||||||
|
? "paginate_button page-item next"
|
||||||
|
: "paginate_button page-item next disabled"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => setCurrentPage((prev) => prev + 1)}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default InStoreCashOrders;
|
386
src/views/orders/InStoreQRCodeOrders.js
Normal file
386
src/views/orders/InStoreQRCodeOrders.js
Normal file
@ -0,0 +1,386 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
import { isAutheticated } from "src/auth";
|
||||||
|
import Button from "@material-ui/core/Button";
|
||||||
|
|
||||||
|
function InStoreQRCodeOrders() {
|
||||||
|
const token = isAutheticated();
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [success, setSuccess] = useState(true);
|
||||||
|
const [newOrdersData, setNewOrdersData] = useState([]);
|
||||||
|
console.log(newOrdersData);
|
||||||
|
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
const [itemPerPage, setItemPerPage] = useState(10);
|
||||||
|
const [showData, setShowData] = useState(newOrdersData);
|
||||||
|
|
||||||
|
const handleShowEntries = (e) => {
|
||||||
|
setCurrentPage(1);
|
||||||
|
setItemPerPage(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function getNewOrder() {
|
||||||
|
axios
|
||||||
|
.get(`/api/order/getAll/new`, {
|
||||||
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
const filteredOrders = res.data.order.filter(
|
||||||
|
(order) => order.orderType === "PointOfSale" && order.paymentMode === "online"
|
||||||
|
);
|
||||||
|
|
||||||
|
// Set the filtered orders data
|
||||||
|
setNewOrdersData(filteredOrders);
|
||||||
|
setLoading(false);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getNewOrder();
|
||||||
|
}, [success]);
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadData = () => {
|
||||||
|
const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
setShowData(newOrdersData.slice(indexOfFirstPost, indexOfLastPost));
|
||||||
|
};
|
||||||
|
loadData();
|
||||||
|
}, [currentPage, itemPerPage, newOrdersData]);
|
||||||
|
|
||||||
|
const handleDelete = (id) => {
|
||||||
|
console.log(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/order/delete/${id}`, {
|
||||||
|
headers: {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
Authorization: `Bearer ${token}`,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
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,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
page-title-box
|
||||||
|
d-flex
|
||||||
|
align-items-center
|
||||||
|
justify-content-between
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
New Orders
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* <div className="page-title-right">
|
||||||
|
<Link to="/order/add">
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Add Order
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
</div> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-12">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row ml-0 mr-0 mb-10">
|
||||||
|
<div className="col-sm-12 col-md-12">
|
||||||
|
<div className="dataTables_length">
|
||||||
|
<label className="w-100">
|
||||||
|
Show
|
||||||
|
<select
|
||||||
|
style={{ width: "10%" }}
|
||||||
|
name=""
|
||||||
|
onChange={(e) => handleShowEntries(e)}
|
||||||
|
className="
|
||||||
|
select-w
|
||||||
|
custom-select custom-select-sm
|
||||||
|
form-control form-control-sm
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<option value="10">10</option>
|
||||||
|
<option value="25">25</option>
|
||||||
|
<option value="50">50</option>
|
||||||
|
<option value="100">100</option>
|
||||||
|
</select>
|
||||||
|
entries
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="table-responsive table-shoot mt-3">
|
||||||
|
<table
|
||||||
|
className="table table-centered table-nowrap"
|
||||||
|
style={{ border: "1px solid" }}
|
||||||
|
>
|
||||||
|
<thead
|
||||||
|
className="thead"
|
||||||
|
style={{ background: "rgb(140, 213, 213)" }}
|
||||||
|
>
|
||||||
|
<tr>
|
||||||
|
<th className="text-start">Order ID</th>
|
||||||
|
<th className="text-start">Customer</th>
|
||||||
|
<th className="text-start">Order value</th>
|
||||||
|
<th className="text-start">Order At</th>
|
||||||
|
<th className="text-start">Status</th>
|
||||||
|
<th className="text-start">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{!loading && showData.length === 0 && (
|
||||||
|
<tr className="text-center">
|
||||||
|
<td colSpan="6">
|
||||||
|
<h5>No Data Available</h5>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
{loading ? (
|
||||||
|
<tr>
|
||||||
|
<td className="text-center" colSpan="6">
|
||||||
|
Loading...
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
) : (
|
||||||
|
showData.map((order, i) => {
|
||||||
|
return (
|
||||||
|
<tr key={i}>
|
||||||
|
<td className="text-start">{order?.orderID}</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{order?.user?.name}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
₹{order?.total_amount}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{new Date(order?.createdAt).toLocaleString(
|
||||||
|
"en-IN",
|
||||||
|
{
|
||||||
|
month: "short",
|
||||||
|
day: "numeric",
|
||||||
|
year: "numeric",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "numeric",
|
||||||
|
hour12: true,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
<span className="badge text-bg-primary text-white">
|
||||||
|
{order?.orderStatus}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td className="text-start">
|
||||||
|
{/* <Link to={`/orders/${order.orderStatus}/${order._id}`}> */}
|
||||||
|
<Link
|
||||||
|
to={`/inStoreOrders/${order.orderStatus}/${order._id}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
style={{ color: "white" }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-primary btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
ms-2 mt-1
|
||||||
|
"
|
||||||
|
>
|
||||||
|
View
|
||||||
|
</button>
|
||||||
|
</Link>
|
||||||
|
{/* <Link to={`/orders/edit/${order._id}`}>
|
||||||
|
<button
|
||||||
|
style={{ color: "white" }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-info btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
ms-2 mt-1
|
||||||
|
"
|
||||||
|
>
|
||||||
|
Edit
|
||||||
|
</button>
|
||||||
|
</Link> */}
|
||||||
|
|
||||||
|
{/* <button
|
||||||
|
style={{ color: "white" }}
|
||||||
|
type="button"
|
||||||
|
className="
|
||||||
|
btn btn-danger btn-sm
|
||||||
|
waves-effect waves-light
|
||||||
|
btn-table
|
||||||
|
ms-2 mt-1
|
||||||
|
"
|
||||||
|
onClick={() => handleDelete(order._id)}
|
||||||
|
>
|
||||||
|
Delete
|
||||||
|
</button> */}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row mt-20">
|
||||||
|
<div className="col-sm-12 col-md-6 mb-20">
|
||||||
|
<div
|
||||||
|
className="dataTables_info"
|
||||||
|
id="datatable_info"
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
>
|
||||||
|
Showing {currentPage * itemPerPage - itemPerPage + 1} to{" "}
|
||||||
|
{Math.min(
|
||||||
|
currentPage * itemPerPage,
|
||||||
|
newOrdersData.length
|
||||||
|
)}{" "}
|
||||||
|
of {newOrdersData.length} entries
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-sm-12 col-md-6">
|
||||||
|
<div className="d-flex">
|
||||||
|
<ul className="pagination ms-auto">
|
||||||
|
<li
|
||||||
|
className={
|
||||||
|
currentPage === 1
|
||||||
|
? "paginate_button page-item previous disabled"
|
||||||
|
: "paginate_button page-item previous"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => setCurrentPage((prev) => prev - 1)}
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{!(currentPage - 1 < 1) && (
|
||||||
|
<li className="paginate_button page-item">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={(e) =>
|
||||||
|
setCurrentPage((prev) => prev - 1)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{currentPage - 1}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<li className="paginate_button page-item active">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
>
|
||||||
|
{currentPage}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{!(
|
||||||
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
newOrdersData.length - 1
|
||||||
|
) && (
|
||||||
|
<li className="paginate_button page-item ">
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => {
|
||||||
|
setCurrentPage((prev) => prev + 1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{currentPage + 1}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<li
|
||||||
|
className={
|
||||||
|
!(
|
||||||
|
(currentPage + 1) * itemPerPage - itemPerPage >
|
||||||
|
newOrdersData.length - 1
|
||||||
|
)
|
||||||
|
? "paginate_button page-item next"
|
||||||
|
: "paginate_button page-item next disabled"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="page-link"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => setCurrentPage((prev) => prev + 1)}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default InStoreQRCodeOrders;
|
@ -4,13 +4,19 @@ import axios from "axios";
|
|||||||
|
|
||||||
import { isAutheticated } from "src/auth";
|
import { isAutheticated } from "src/auth";
|
||||||
import Button from "@material-ui/core/Button";
|
import Button from "@material-ui/core/Button";
|
||||||
|
import { cilSearch } from "@coreui/icons";
|
||||||
|
import CIcon from "@coreui/icons-react";
|
||||||
|
import { TextField, FormControl, Select, MenuItem } from "@material-ui/core";
|
||||||
|
import { Typography } from "@material-ui/core";
|
||||||
|
import DatePicker from "react-datepicker";
|
||||||
|
import "react-datepicker/dist/react-datepicker.css";
|
||||||
|
|
||||||
function NewOrders() {
|
function NewOrders() {
|
||||||
const token = isAutheticated();
|
const token = isAutheticated();
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [success, setSuccess] = useState(true);
|
const [success, setSuccess] = useState(true);
|
||||||
const [newOrdersData, setNewOrdersData] = useState([]);
|
const [newOrdersData, setNewOrdersData] = useState([]);
|
||||||
console.log(newOrdersData);
|
// console.log(newOrdersData);
|
||||||
|
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
const [itemPerPage, setItemPerPage] = useState(10);
|
const [itemPerPage, setItemPerPage] = useState(10);
|
||||||
@ -21,7 +27,6 @@ function NewOrders() {
|
|||||||
setItemPerPage(e.target.value);
|
setItemPerPage(e.target.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
function getNewOrder() {
|
function getNewOrder() {
|
||||||
axios
|
axios
|
||||||
.get(`/api/order/getAll/new`, {
|
.get(`/api/order/getAll/new`, {
|
||||||
@ -31,7 +36,11 @@ function NewOrders() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setNewOrdersData(res.data.order);
|
const filteredOrders = res.data.order.filter(
|
||||||
|
(order) => order.orderType === "WebSite"
|
||||||
|
);
|
||||||
|
|
||||||
|
setNewOrdersData(filteredOrders);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@ -39,17 +48,10 @@ function NewOrders() {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getNewOrder();
|
|
||||||
}, [success]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = () => {
|
setLoading(true);
|
||||||
const indexOfLastPost = currentPage * itemPerPage;
|
getNewOrder();
|
||||||
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
}, [token]);
|
||||||
setShowData(newOrdersData.slice(indexOfFirstPost, indexOfLastPost));
|
|
||||||
};
|
|
||||||
loadData();
|
|
||||||
}, [currentPage, itemPerPage, newOrdersData]);
|
|
||||||
|
|
||||||
const handleDelete = (id) => {
|
const handleDelete = (id) => {
|
||||||
console.log(id);
|
console.log(id);
|
||||||
@ -86,7 +88,94 @@ function NewOrders() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
|
const [searchValue, setsearchValue] = useState("orderId");
|
||||||
|
const handleChange = (event) => {
|
||||||
|
const { name, value } = event.target;
|
||||||
|
if (name === "Search") {
|
||||||
|
setsearchValue(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const formatDate = (dateString) => {
|
||||||
|
const dateArray = dateString.split(" ");
|
||||||
|
const day = dateArray[0];
|
||||||
|
const month = dateArray[1];
|
||||||
|
const year = dateArray[2];
|
||||||
|
const monthNumber = new Date(Date.parse(`${month} 1, 2022`)).getMonth() + 1;
|
||||||
|
return `${year}-${
|
||||||
|
monthNumber < 10 ? "0" + monthNumber : monthNumber
|
||||||
|
}-${day}`;
|
||||||
|
};
|
||||||
|
// const formatDate = (date) => {
|
||||||
|
// const day = ("0" + date.getDate()).slice(-2);
|
||||||
|
// const month = ("0" + (date.getMonth() + 1)).slice(-2);
|
||||||
|
// const year = date.getFullYear();
|
||||||
|
// return `${year}-${month}-${day}`;
|
||||||
|
// };
|
||||||
|
console.log(searchTerm);
|
||||||
|
useEffect(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (searchTerm !== "") {
|
||||||
|
let searchedResult = [];
|
||||||
|
if (searchValue === "orderId") {
|
||||||
|
searchedResult = newOrdersData.filter((item) =>
|
||||||
|
item.orderID.toString().includes(searchTerm)
|
||||||
|
);
|
||||||
|
} else if (searchValue === "Name") {
|
||||||
|
searchedResult = newOrdersData.filter((item) =>
|
||||||
|
item.user?.name
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(searchTerm.toLowerCase())
|
||||||
|
);
|
||||||
|
} else if (searchValue === "City") {
|
||||||
|
searchedResult = newOrdersData.filter((item) =>
|
||||||
|
item.shippingInfo.city
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(searchTerm.toLowerCase())
|
||||||
|
);
|
||||||
|
} else if (searchValue === "Amount") {
|
||||||
|
searchedResult = newOrdersData.filter((item) =>
|
||||||
|
item.total_amount.toString().includes(searchTerm)
|
||||||
|
);
|
||||||
|
} else if (searchValue === "OrderDate") {
|
||||||
|
// Format input date
|
||||||
|
const formattedDate = formatDate(searchTerm);
|
||||||
|
|
||||||
|
searchedResult = newOrdersData.filter((item) =>
|
||||||
|
item.createdAt.includes(formattedDate)
|
||||||
|
);
|
||||||
|
} else if (searchValue === "ProductName") {
|
||||||
|
searchedResult = newOrdersData.filter((order) =>
|
||||||
|
order.orderItems.some((item) =>
|
||||||
|
item.name
|
||||||
|
.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(searchTerm.toLowerCase())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else if (searchValue === "MobileNumber") {
|
||||||
|
searchedResult = newOrdersData.filter((item) =>
|
||||||
|
item.shippingInfo.phone_Number.toString().includes(searchTerm)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
setShowData(searchedResult);
|
||||||
|
} else {
|
||||||
|
getNewOrder();
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}, [searchTerm, searchValue, newOrdersData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadData = () => {
|
||||||
|
const indexOfLastPost = currentPage * itemPerPage;
|
||||||
|
const indexOfFirstPost = indexOfLastPost - itemPerPage;
|
||||||
|
setShowData(newOrdersData.slice(indexOfFirstPost, indexOfLastPost));
|
||||||
|
};
|
||||||
|
loadData();
|
||||||
|
}, [currentPage, itemPerPage, newOrdersData]);
|
||||||
return (
|
return (
|
||||||
<div className="main-content">
|
<div className="main-content">
|
||||||
<div className="page-content">
|
<div className="page-content">
|
||||||
@ -127,13 +216,14 @@ function NewOrders() {
|
|||||||
<div className="col-lg-12">
|
<div className="col-lg-12">
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
|
<div className="d-flex align-items-center">
|
||||||
<div className="row ml-0 mr-0 mb-10">
|
<div className="row ml-0 mr-0 mb-10">
|
||||||
<div className="col-sm-12 col-md-12">
|
<div className="col-sm-12 col-md-12">
|
||||||
<div className="dataTables_length">
|
<div className="dataTables_length">
|
||||||
<label className="w-100">
|
<label className="w-100">
|
||||||
Show
|
Show
|
||||||
<select
|
<select
|
||||||
style={{ width: "10%" }}
|
style={{ width: "50px" }}
|
||||||
name=""
|
name=""
|
||||||
onChange={(e) => handleShowEntries(e)}
|
onChange={(e) => handleShowEntries(e)}
|
||||||
className="
|
className="
|
||||||
@ -152,6 +242,112 @@ function NewOrders() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="ml-5 mt-2" style={{ display: "flex" }}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
marginLeft: "1rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginRight: "1rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Search by :
|
||||||
|
</Typography>
|
||||||
|
<FormControl>
|
||||||
|
<Select
|
||||||
|
name="Search"
|
||||||
|
value={searchValue}
|
||||||
|
onChange={handleChange}
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
width: "120px",
|
||||||
|
height: "2rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MenuItem
|
||||||
|
value="orderId"
|
||||||
|
style={{ display: "block", marginLeft: "0.5rem" }}
|
||||||
|
>
|
||||||
|
orderId
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
value="Name"
|
||||||
|
style={{ display: "block", marginLeft: "0.5rem" }}
|
||||||
|
>
|
||||||
|
Name
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
value="City"
|
||||||
|
style={{ display: "block", marginLeft: "0.5rem" }}
|
||||||
|
>
|
||||||
|
City
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
value="Amount"
|
||||||
|
style={{ display: "block", marginLeft: "0.5rem" }}
|
||||||
|
>
|
||||||
|
Amount
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
value="OrderDate"
|
||||||
|
style={{ display: "block", marginLeft: "0.5rem" }}
|
||||||
|
>
|
||||||
|
OrderDate
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
value="ProductName"
|
||||||
|
style={{ display: "block", marginLeft: "0.5rem" }}
|
||||||
|
>
|
||||||
|
ProductName
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem
|
||||||
|
value="MobileNumber"
|
||||||
|
style={{ display: "block", marginLeft: "0.5rem" }}
|
||||||
|
>
|
||||||
|
MobileNumber
|
||||||
|
</MenuItem>
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
</div>
|
||||||
|
{/* <div>
|
||||||
|
{searchValue === "OrderDate" && (
|
||||||
|
<DatePicker
|
||||||
|
selected={searchTerm}
|
||||||
|
onChange={(date) => setSearchTerm(date)}
|
||||||
|
dateFormat="dd/MM/yyyy"
|
||||||
|
placeholderText="Select a date"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{searchValue !== "OrderDate" && (
|
||||||
|
<TextField
|
||||||
|
type="text"
|
||||||
|
placeholder="Search Here"
|
||||||
|
value={searchTerm}
|
||||||
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<CIcon icon={cilSearch} size="xl" />
|
||||||
|
</div> */}
|
||||||
|
<div>
|
||||||
|
<TextField
|
||||||
|
type="text"
|
||||||
|
placeholder="Search Here"
|
||||||
|
value={searchTerm}
|
||||||
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
|
/>
|
||||||
|
<CIcon icon={cilSearch} size="xl" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="table-responsive table-shoot mt-3">
|
<div className="table-responsive table-shoot mt-3">
|
||||||
<table
|
<table
|
||||||
|
945
src/views/orders/POSViewOrders.js
Normal file
945
src/views/orders/POSViewOrders.js
Normal file
@ -0,0 +1,945 @@
|
|||||||
|
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:
|
||||||
|
'<input id="input1" placeholder="Enter Courier Name" className="swal2-input" style="margin:3px;height:40px;text-align:center;">' +
|
||||||
|
'<input id="input2" placeholder="Courier Tracking ID" className="swal2-input" style="margin:3px;height:40px;text-align:center;">',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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:
|
||||||
|
'<p>Reson for cancellation.?</p><input id="input1" placeholder="Enter Reason for Cancellation" className="swal2-input" style="margin:3px;height:40px;text-align:center;">',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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:
|
||||||
|
'<input id="input1" type="date" placeholder="Delivered ON" className="swal2-input" style="height:40px;text-align:center;">',
|
||||||
|
// '<input id="input2" placeholder="Courier Tracking ID" className="swal2-input" style="margin:3px;height:40px">',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
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 (
|
||||||
|
<>
|
||||||
|
{" "}
|
||||||
|
<div className="main-content">
|
||||||
|
<div className="page-content">
|
||||||
|
<div className="container-fluid">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12">
|
||||||
|
<div
|
||||||
|
className="
|
||||||
|
page-title-box
|
||||||
|
d-flex
|
||||||
|
align-items-center
|
||||||
|
justify-content-between
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div style={{ fontSize: "22px" }} className="fw-bold">
|
||||||
|
<p> View Order</p>
|
||||||
|
</div>
|
||||||
|
<div className="m-4">
|
||||||
|
{orderDetails?.orderID && (
|
||||||
|
<span>
|
||||||
|
<h6 className="">Order ID : {orderDetails?.orderID}</h6>{" "}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{orderDetails?.courier_name && (
|
||||||
|
<div className="m-4">
|
||||||
|
<span>
|
||||||
|
<h6 className="">
|
||||||
|
Courier Name: {orderDetails?.courier_name}
|
||||||
|
</h6>{" "}
|
||||||
|
<h6 className="">
|
||||||
|
Tracking ID : {orderDetails?.courier_tracking_id}
|
||||||
|
</h6>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{orderDetails?.isDelivered && (
|
||||||
|
<div className="m-4">
|
||||||
|
<span>
|
||||||
|
<h6 className="">Delivered: Yes</h6>{" "}
|
||||||
|
<h6 className="">
|
||||||
|
Delivered Date: {orderDetails?.DeliveredDate}
|
||||||
|
</h6>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="page-title-right">
|
||||||
|
{/* <Button
|
||||||
|
variant="contained"
|
||||||
|
color="primary"
|
||||||
|
style={{
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginBottom: '1rem',
|
||||||
|
textTransform: 'capitalize',
|
||||||
|
marginRight: '5px',
|
||||||
|
}}
|
||||||
|
onClick={() => handleSubmit()}
|
||||||
|
disabled={loading}
|
||||||
|
>
|
||||||
|
{loading ? 'Loading' : 'Edit Now'}
|
||||||
|
</Button> */}
|
||||||
|
|
||||||
|
<Link
|
||||||
|
to={
|
||||||
|
orderDetails?.paymentMode === "cod"
|
||||||
|
? `/inStoreCashOrders/${status}`
|
||||||
|
: `/InStoreQRCodeOrders/${status}`
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="secondary"
|
||||||
|
style={{
|
||||||
|
fontWeight: "bold",
|
||||||
|
marginBottom: "1rem",
|
||||||
|
textTransform: "capitalize",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Back
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{loading ? (
|
||||||
|
<div className="d-flex justify-content-center">
|
||||||
|
<div className="spinner-border text-info" role="status">
|
||||||
|
<span className="visually-hidden">Loading...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-7 mt-3">
|
||||||
|
{orderDetails?.shipingInfo !== null && (
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
{/* <div className="mt-1">
|
||||||
|
<label className="fw-bold">Select Product:</label>
|
||||||
|
<div className="d-flex">
|
||||||
|
<select
|
||||||
|
className="form-control me-2"
|
||||||
|
// onChange={handleGetSingleProduct}
|
||||||
|
// value={productData?._id}
|
||||||
|
ref={getValue}
|
||||||
|
|
||||||
|
>
|
||||||
|
<option value="" >-----</option>
|
||||||
|
{productData && productData.map((item, index) =>
|
||||||
|
<option key={index} value={item?._id}>{item?.name}</option>
|
||||||
|
)}
|
||||||
|
|
||||||
|
</select>
|
||||||
|
<button className='btn-sm btn-primary' onClick={(e) => handleGetSingleProduct(e)}>Add</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div> */}
|
||||||
|
|
||||||
|
<div className="mt-2">
|
||||||
|
<h6 className="fw-bold">
|
||||||
|
Products : {orderDetails?.orderItems?.length}
|
||||||
|
</h6>
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
{orderDetails?.orderItems &&
|
||||||
|
orderDetails?.orderItems.map(
|
||||||
|
(productDetails, i) => (
|
||||||
|
<div className="my-2">
|
||||||
|
<div
|
||||||
|
className="row"
|
||||||
|
style={{ fontSize: "14px" }}
|
||||||
|
>
|
||||||
|
<div className="col-sm-4">
|
||||||
|
<img
|
||||||
|
src={productDetails?.image[0]?.url}
|
||||||
|
alt={productDetails?.name}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
objectFit: "contain",
|
||||||
|
maxHeight: "150px",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="col-sm-8">
|
||||||
|
<h6 className="m-0 ms-2">
|
||||||
|
{productDetails?.name}
|
||||||
|
</h6>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-sm-6">
|
||||||
|
<div
|
||||||
|
className="d-flex justify-content-center mt-3 me-3 "
|
||||||
|
style={{
|
||||||
|
width: "6rem",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="px-2 mt-1"
|
||||||
|
style={{}}
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
Quantity:{" "}
|
||||||
|
{productDetails?.quantity}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p className="m-0 mt-3 ms-3">
|
||||||
|
<stong> Subtotal:</stong> ₹
|
||||||
|
{productDetails?.product_Subtotal}
|
||||||
|
</p>
|
||||||
|
<p className="m-0 mt-3 ms-3">
|
||||||
|
<stong> Variant:</stong>{" "}
|
||||||
|
{productDetails?.variant_Name}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="col-sm-6">
|
||||||
|
<p className="m-0 mt-3">
|
||||||
|
<stong> Price:</stong> ₹
|
||||||
|
{productDetails?.price}
|
||||||
|
</p>
|
||||||
|
<p className="m-0 mt-3">
|
||||||
|
<stong> GST:</stong> ₹
|
||||||
|
{productDetails?.gst_amount}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
<div className="m-0 contents-center mt-3 mb-2">
|
||||||
|
<small className="mb-4">Shipping Charge: </small> ₹
|
||||||
|
{orderDetails?.shipping_charge}
|
||||||
|
<br />
|
||||||
|
<span className="mt-2"> Total Order Value: </span> ₹
|
||||||
|
{orderDetails?.total_amount}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="card my-1">
|
||||||
|
<div className="card-body">
|
||||||
|
<label className="fw-bold">Status Timeline :</label>
|
||||||
|
<table
|
||||||
|
className="table table-info table-sm m-0"
|
||||||
|
style={{
|
||||||
|
borderRadius: "8px",
|
||||||
|
borderCollapse: "collapse",
|
||||||
|
overflow: "hidden",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<tbody>
|
||||||
|
<tr className="text-center">
|
||||||
|
<th scope="row">Order Placed On</th>
|
||||||
|
<td> : </td>
|
||||||
|
<td>
|
||||||
|
{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,
|
||||||
|
})}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr className="text-center">
|
||||||
|
<th scope="row" className="text-warning">
|
||||||
|
Processing Started
|
||||||
|
</th>
|
||||||
|
<td className="text-warning"> : </td>
|
||||||
|
<td className="text-warning">
|
||||||
|
{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,
|
||||||
|
})
|
||||||
|
: "-"}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr className="text-center">
|
||||||
|
<th scope="row" className="text-primary">
|
||||||
|
Dispatched On
|
||||||
|
</th>
|
||||||
|
<td className="text-primary"> : </td>
|
||||||
|
<td className="text-primary">
|
||||||
|
{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,
|
||||||
|
})
|
||||||
|
: "-"}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr className="text-center">
|
||||||
|
<th scope="row" className="text-success">
|
||||||
|
Delivered On
|
||||||
|
</th>
|
||||||
|
<td className="text-success"> : </td>
|
||||||
|
<td className="text-success">
|
||||||
|
{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,
|
||||||
|
})
|
||||||
|
: "-"}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{orderDetails?.status_timeline?.cancelled && (
|
||||||
|
<tr className="text-center">
|
||||||
|
<th scope="row" className="text-danger">
|
||||||
|
Cancelled On
|
||||||
|
</th>
|
||||||
|
<td className="text-danger"> : </td>
|
||||||
|
<td className="text-danger">
|
||||||
|
{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,
|
||||||
|
})
|
||||||
|
: "-"}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
{/* <tr className="text-center">
|
||||||
|
<th scope="row">Returned On</th>
|
||||||
|
<td> : </td>
|
||||||
|
<td>
|
||||||
|
{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,
|
||||||
|
})
|
||||||
|
: "-"}
|
||||||
|
</td>
|
||||||
|
</tr> */}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-lg-5 mt-3">
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="mt-1">
|
||||||
|
{orderDetails?.orderStatus !== "cancelled" ? (
|
||||||
|
<h5 className="text-success">
|
||||||
|
Order Status: {orderDetails?.orderStatus}
|
||||||
|
</h5>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<h5 className="text-danger">
|
||||||
|
Order Status: {orderDetails?.orderStatus}
|
||||||
|
</h5>
|
||||||
|
<p className="text-danger">
|
||||||
|
{" "}
|
||||||
|
Order Cancelled Reason:{" "}
|
||||||
|
{orderDetails?.order_Cancelled_Reason}
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{/* order status change */}{" "}
|
||||||
|
<div className="mb-2">
|
||||||
|
{" "}
|
||||||
|
{status !== "cancelled" &&
|
||||||
|
status !== "returned" &&
|
||||||
|
status !== "delivered" && (
|
||||||
|
<div className="mt-1">
|
||||||
|
<label className="fw-bold">
|
||||||
|
Change Status :
|
||||||
|
</label>
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-lg-9">
|
||||||
|
<select
|
||||||
|
className="form-control"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={orderStatus}
|
||||||
|
>
|
||||||
|
{orderDetails?.orderStatus === "new" && (
|
||||||
|
<>
|
||||||
|
<option value="">New</option>
|
||||||
|
<option value="processing">
|
||||||
|
Processing
|
||||||
|
</option>
|
||||||
|
<option value="cancelled">
|
||||||
|
Cancelled
|
||||||
|
</option>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{orderDetails?.orderStatus ===
|
||||||
|
"processing" && (
|
||||||
|
<>
|
||||||
|
<option value="">Processing</option>
|
||||||
|
<option value="dispatched">
|
||||||
|
Dispatch
|
||||||
|
</option>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{orderDetails?.orderStatus ===
|
||||||
|
"dispatched" && (
|
||||||
|
<>
|
||||||
|
<option value="">Dispatch</option>
|
||||||
|
<option value="delivered">
|
||||||
|
Delivered
|
||||||
|
</option>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
{orderStatus && (
|
||||||
|
<div className="col-lg-3">
|
||||||
|
<button
|
||||||
|
className="btn btn-primary"
|
||||||
|
onClick={(e) => handlechangestatus(e)}
|
||||||
|
>
|
||||||
|
Update
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{/* */}
|
||||||
|
<label className="fw-bold mt-1">Shipping Info :</label>
|
||||||
|
{/* <div className="d-flex">
|
||||||
|
<select
|
||||||
|
className="form-control me-2"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={orderStatus}
|
||||||
|
ref={getFranchiseeID}
|
||||||
|
disabled={shipingInfo !== null}
|
||||||
|
>
|
||||||
|
<option value="" disabled></option>
|
||||||
|
{allFranchisee && allFranchisee.map((item, index) =>
|
||||||
|
<option key={index} value={item?._id}>{item?.name}</option>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
<button className='btn-sm btn-primary' onClick={(e) => handleGetSingleFrenchisee(e)} >Add</button>
|
||||||
|
</div> */}
|
||||||
|
</div>
|
||||||
|
{orderDetails?.shipingInfo !== null && (
|
||||||
|
<div className="">
|
||||||
|
<div className="row" style={{ fontSize: "14px" }}>
|
||||||
|
{/* <div className="col-sm-4">
|
||||||
|
<img
|
||||||
|
src={
|
||||||
|
orderDetails?.shippingInfo?.Franchisee?.banner
|
||||||
|
?.url
|
||||||
|
}
|
||||||
|
alt={orderDetails?.shippingInfo?.name}
|
||||||
|
// width='100%'
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
objectFit: "contain",
|
||||||
|
maxHeight: "100px",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div> */}
|
||||||
|
<div className="col-sm-12">
|
||||||
|
<h6 className="m-0 ms-2">
|
||||||
|
Name: {orderDetails?.shippingInfo?.first_Name}{" "}
|
||||||
|
{orderDetails?.shippingInfo?.last_Name}
|
||||||
|
</h6>
|
||||||
|
|
||||||
|
<p className="m-0 ms-2 mt-1">
|
||||||
|
Contact No. :{" "}
|
||||||
|
{orderDetails?.shippingInfo?.phone_Number}
|
||||||
|
</p>
|
||||||
|
<parent className="m-0 ms-2 mt-3">
|
||||||
|
street. : {orderDetails?.shippingInfo?.street}
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<p className="m-0 ms-2 mt-1">
|
||||||
|
City : {orderDetails?.shippingInfo?.city}
|
||||||
|
</p>
|
||||||
|
<p className="m-0 ms-2 mt-1">
|
||||||
|
State : {orderDetails?.shippingInfo?.state}
|
||||||
|
</p>
|
||||||
|
<p className="m-0 ms-2 mt-1">
|
||||||
|
country : {orderDetails?.shippingInfo?.country}
|
||||||
|
</p>
|
||||||
|
<p className="m-0 ms-2 mt-1">
|
||||||
|
Postal Code. :{" "}
|
||||||
|
{orderDetails?.shippingInfo?.postalCode}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="mt-3">
|
||||||
|
<label>
|
||||||
|
<span className="fw-bold">Payment Status : </span>
|
||||||
|
{orderDetails?.isPaid === false ? (
|
||||||
|
<span className="fw-bold text-danger">
|
||||||
|
Not Paid
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span className="fw-bold text-success">Paid</span>
|
||||||
|
)}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div className="">
|
||||||
|
<label>
|
||||||
|
<span className="fw-bold">Payment Mode : </span>
|
||||||
|
{orderDetails?.paymentMode === "online" ? (
|
||||||
|
<span className="fw-bold text-success">ONLINE</span>
|
||||||
|
) : (
|
||||||
|
<span className="fw-bold text-primary">
|
||||||
|
CASH ON DELIVERY
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="">
|
||||||
|
<label>
|
||||||
|
<span className="fw-bold"> Paid At: </span>
|
||||||
|
|
||||||
|
{orderDetails?.paidAt
|
||||||
|
? new Date(orderDetails?.paidAt).toLocaleString(
|
||||||
|
"en-IN",
|
||||||
|
{
|
||||||
|
month: "short",
|
||||||
|
day: "numeric",
|
||||||
|
year: "numeric",
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "numeric",
|
||||||
|
hour12: true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
: "----"}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div className="">
|
||||||
|
<label>
|
||||||
|
<span className="fw-bold"> Order Created By: </span>
|
||||||
|
{orderDetails?.user?.name}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div className="mt-1">
|
||||||
|
<label>
|
||||||
|
<span className="fw-bold">
|
||||||
|
Razorpay Payment ID :{" "}
|
||||||
|
</span>
|
||||||
|
{orderDetails?.razorpay_payment_id
|
||||||
|
? orderDetails?.razorpay_payment_id
|
||||||
|
: "----"}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div className="">
|
||||||
|
<label>
|
||||||
|
<span className="fw-bold">Razorpay Order ID : </span>
|
||||||
|
{orderDetails?.razorpay_order_id
|
||||||
|
? orderDetails?.razorpay_order_id
|
||||||
|
: "----"}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style={{ display: "none" }}>
|
||||||
|
{/* <PrintOrderDetails productData={productData} ref={printOrderRef} /> */}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default POSViewOrders;
|
@ -100,8 +100,10 @@ const Login = () => {
|
|||||||
setLoading({ loading: true });
|
setLoading({ loading: true });
|
||||||
try {
|
try {
|
||||||
const res = await axios.post("/api/v1/user/login/", auth);
|
const res = await axios.post("/api/v1/user/login/", auth);
|
||||||
|
console.log(res);
|
||||||
if (res.data.success == true) {
|
if (res.data.success == true) {
|
||||||
localStorage.setItem("authToken", res.data.token);
|
localStorage.setItem("authToken", res.data.token);
|
||||||
|
|
||||||
let response = await axios.get(`/api/v1/user/details`, {
|
let response = await axios.get(`/api/v1/user/details`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${res.data.token}`,
|
Authorization: `Bearer ${res.data.token}`,
|
||||||
@ -109,7 +111,7 @@ const Login = () => {
|
|||||||
});
|
});
|
||||||
// console.log(response.data)
|
// console.log(response.data)
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
if (data.user.role === "admin") {
|
if (data.user.role === "admin" || data.user.role === "Employee") {
|
||||||
history("/dashboard");
|
history("/dashboard");
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
Loading…
Reference in New Issue
Block a user