Blame view

pages/vendor/dashboard/index.js 4.16 KB
1
import Image from "next/image";
jaymehta committed
2
import React, { useEffect, useState } from "react";
3 4 5 6
import Sidebar from "../../../components/layout/VendorDashboardSidebar";
import Layout from "../../../components/layout/Layout";
import { Button } from "react-bootstrap";
import { FaPlus } from "react-icons/fa";
jaymehta committed
7 8 9 10
import { useDispatch, useSelector } from "react-redux";
import { loadUser } from "../../../redux/actions/userActions";
import { wrapper } from "../../../redux/store";
import { useRouter } from "next/router";
Chetan committed
11
import { GenericLayout } from "../../../components/layout/Generics/GenericLayout";
12 13

const VendorDashboard = () => {
.  
jaymehta committed
14
  const { loadedUser, error } = useSelector(state => state.loadedUser);
jaymehta committed
15
  const router = useRouter();
.  
jaymehta committed
16
  console.log("user", loadedUser);
17

jaymehta committed
18
  const ApprovalStatus = () => {
.  
jaymehta committed
19 20
    if (loadedUser) {
      switch (loadedUser.approved) {
jaymehta committed
21
        case "approved":
.  
jaymehta committed
22 23 24 25 26 27 28 29 30 31 32 33
          return (
            <>
              <div className="col-12 offset-lg-2 col-lg-8 ">
                <div className="alert alert-success alert-dismissible fade show text-center" role="alert">
                  <div className="text-center">
                    <p className="p1 text-center">Profile is approved!</p>
                    <p className="p2 text-center">You can add activities.</p>
                  </div>
                </div>
              </div>
            </>
          );
34

jaymehta committed
35 36 37
        case "rejected":
          return (
            <>
.  
jaymehta committed
38 39 40 41 42 43 44
              <div className="col-12 offset-lg-2 col-lg-8 ">
                <div className="alert alert-danger alert-dismissible fade show text-center" role="alert">
                  <div className="text-center">
                    <p className="p1 text-center">Your profile has been rejected!</p>
                    <p className="p2 text-center"> Please contact the admin for more details!</p>
                  </div>
                </div>
jaymehta committed
45 46 47
              </div>
            </>
          );
48

jaymehta committed
49 50 51 52
        case "pending":
          return (
            <>
              <div className="col-12 offset-lg-2 col-lg-8 ">
.  
jaymehta committed
53
                <div className="alert alert-warning alert-dismissible fade show text-center" role="alert">
jaymehta committed
54 55 56 57
                  <div className="text-center">
                    <p className="p1 text-center">Business information sent successfully.</p>
                    <p className="p2 text-center">Kindly wait until we verify the details. You can start adding activities once your account is verified.</p>
                  </div>
58
                </div>
jaymehta committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72
              </div>
            </>
          );

        case "none":
          return <></>;

        default:
          break;
      }
    }
  };

  return (
Chetan committed
73 74 75 76
    <GenericLayout>
      {/* <div className="sidebarContainer">
        <Sidebar /> */}
        <div className="h-100 d-flex-align-items-center justify-content-center p-5">
jaymehta committed
77 78 79 80 81 82
            <ApprovalStatus />
            <div className="d-flex justify-content-center py-4">
              <span className="image-container">
                <Image alt="" layout="fill" src="/images/vendor/Isolation_Mode.png" className="image" />
              </span>
            </div>
Chetan committed
83
            <div className="text-center py-2">
jaymehta committed
84 85 86 87 88 89 90 91
              <p className="p3">No information is available right now</p>
              <Button
                onClick={() => {
                  router.push("/vendor/activity-details");
                }}
                type="button"
                variant=""
                className="btnAdd"
.  
jaymehta committed
92
                disabled={loadedUser?.approved != "approved"}
jaymehta committed
93 94 95 96 97 98 99
              >
                <span className="image-container me-2">
                  <Image alt="" layout="fill" src="/images/vendor/icon-plus.svg" width="14" height="14" className="image" />
                </span>
                {/* <FaPlus className="me-2" /> */}
                <span>Add Activity</span>
              </Button>
100
            </div>
jaymehta committed
101
          </div>
Chetan committed
102 103
      {/* </div> */}
    </GenericLayout>
jaymehta committed
104
  );
105 106
};

jaymehta committed
107 108 109 110 111 112 113 114 115 116 117 118 119
export default VendorDashboard;

/** For server side rendering */
export const getServerSideProps = wrapper.getServerSideProps(store => async ({ req, query }) => {
  // Get the menu data.

  // get the locations data.
  await store.dispatch(loadUser());

  return {
    props: {}
  };
});