Blame view

pages/vendor/dashboard/index.js 4.2 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";
11 12

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

jaymehta committed
17 18 19 20 21
  const ApprovalStatus = () => {
    if (user) {
      switch (user.approved) {
        case "approved":
          return <></>;
22

jaymehta committed
23 24 25 26 27 28 29 30
        case "rejected":
          return (
            <>
              <div class="alert alert-danger" role="alert">
                Your profile has been rejected! Please contact the admin for more details!
              </div>
            </>
          );
31

jaymehta committed
32 33 34 35 36 37 38 39 40 41 42 43 44
        case "pending":
          return (
            <>
              <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="bgCircleBlue">
                  <Image alt="" src="/images/vendor/icon-tick.svg" width="15" height="10" />
                </div> */}
                  <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>
                  {/* <button type="button" className="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> */}
45
                </div>
jaymehta committed
46 47 48 49 50 51 52 53 54 55 56

                {/* <div className="infoSent">
                <div className="bgCircleBlue">
                  <Image alt="" src="/images/vendor/icon-tick.svg" width="15" height="10" />
                </div>
                <div className="px-3">
                  <p className="p1">Business information sent successfully.</p>
                  <p className="p2">Kindly wait until we verify the details. You can start adding activities once your account is verified.</p>
                </div>
                <div>
                  <Image alt="" src="/images/vendor/icon-close.svg" width="14" height="14" />
57
                </div>
jaymehta committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
              </div> */}
              </div>
            </>
          );

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

        default:
          break;
      }
    }
  };

  return (
    <Layout>
      <div className="sidebarContainer">
Jyotsna committed
75
        <Sidebar />
jaymehta committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
        <div className="content">
          <div className="row">
            <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>
            <div className="text-center py-2 mb-5">
              <p className="p3">No information is available right now</p>
              <Button
                onClick={() => {
                  router.push("/vendor/activity-details");
                }}
                type="button"
                variant=""
                className="btnAdd"
                disabled={user?.approved != "approved"}
              >
                <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>
101
            </div>
jaymehta committed
102 103 104 105 106
          </div>
        </div>
      </div>
    </Layout>
  );
107 108
};

jaymehta committed
109 110 111 112 113 114 115 116 117 118 119 120 121
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: {}
  };
});