All files companyUserDashBoard.vue

34.09% Statements 15/44
0% Branches 0/6
36.36% Functions 4/11
34.09% Lines 15/44

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249                                                                                                                                                                                                                                          1x   1x 1x 1x           1x                     1x       1x         1x                     1x                     1x                             1x               1x   1x 1x               1x                                                                                          
<template>
  <div>
    <div class="container studContainer">
      <h2 class="text-left mt-3">
        Company User Dashboard
 
        <div class="float-right">
          <router-link to="/logout">
            <b-button pill variant="danger" class="float-right">
              Logout
            </b-button>
          </router-link>
        </div>
        <div class="float-right" style="margin-left:80%">
          <router-link to="/addEvent">
            <b-button pill variant="info" class="float-right">
              Create Event
              <font-awesome-icon icon="calendar-day" class="ml-1" />
            </b-button>
          </router-link>
        </div>
      </h2>
 
      <b-card no-body class="mb-3" v-if="events.length">
        <b-card-header header-tag="header" class="p-0" role="tab">
          <b-button
            block
            v-b-toggle.private-accordion
            variant="info"
            class="btn-lg text-left"
            id="pvtEvent-btn"
          >
            All Events
            <span>(Latest events)</span>
            <font-awesome-icon
              icon="chevron-circle-down"
              class="mt-1 ml-1 float-right"
              id="arrow-down0"
            />
            <font-awesome-icon
              icon="chevron-circle-up"
              class="mt-1 ml-1 float-right d-none"
              id="arrow-up0"
            />
          </b-button>
        </b-card-header>
        <b-collapse
          id="private-accordion"
          visible
          accordion="private-accd"
          role="tabpane2"
        >
          <b-card-body>
            <table class="table table-hover">
              <thead>
                <tr>
                  <th scope="col">Event Name</th>
                  <th scope="col">Event Type</th>
                  <th scope="col">Event Location</th>
                  <th scope="col">EventDate</th>
                  <th scope="col">Open Company</th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="event in events" :key="event.id">
                  <td>{{ event.eventName }}</td>
                  <td>{{ event.eventType }}</td>
                  <td>{{ event.eventLocation }}</td>
                  <td>{{ event.eventDate }}</td>
                  <td
                    @click="
                      $bvModal.show('addModal');
 
                      openCompany(event.id);
                    "
                  >
                    <button type="button" id="companydetails" class="btn btn-primary">
                      company details
                    </button>
                  </td>
                </tr>
              </tbody>
            </table>
          </b-card-body>
        </b-collapse>
      </b-card>
      <b-modal id="addModal" hide-footer centered>
        <template #modal-title>
          Company details
        </template>
        <div
          class="d-flex flex-column justify-content-center align-items-center"
        >
          <div>
            <!-- <label for="select event">Select Event</label> -->
            <span> Company Name : {{ cdetails.companyName }} </span>
          </div>
          <div>
            <span> company Location : {{ cdetails.companyLocation }} </span>
          </div>
 
          <div>
            <b-button
              class="mt-3 col-12"
              block
              @click="$bvModal.hide('addModal')"
              >ok</b-button
            >
          </div>
        </div>
      </b-modal>
    </div>
  </div>
</template>
<script>
// import EventItem from "../components/Events/EventItem";
// import Loader from "../components/Utils/Loader";
import $ from "jquery";
 
let publicAccd = true;
let editEventAccd = true;
let pvtEventAccd = true;
 
export default {
  name: "AdminDashboard",
 
  data() {
    return {
      userId: this.$store.getters.userDetails.id,
 
      events: [],
      editAccessEvents: [],
      noEditAccess: [],
      cdetails: { companyName: "", companyLocation: "" },
    };
  },
 
  async mounted() {
    console.log(
      JSON.parse(localStorage.getItem("user_details")),
      "------local storage user details"
    );
    console.log(
      this.$store.getters.userDetails.id,
      this.$store.getters.userDetails.role,
      "---role froms store"
    );
    $("#public-btn").click(function() {
      if (publicAccd) {
        $("#arrow-down0").addClass("d-none");
        $("#arrow-up0").removeClass("d-none");
      } else {
        $("#arrow-down0").removeClass("d-none");
        $("#arrow-up0").addClass("d-none");
      }
      publicAccd = !publicAccd;
    });
 
    $("#editEvent-btn").click(function() {
      if (editEventAccd) {
        $("#arrow-down1").addClass("d-none");
        $("#arrow-up1").removeClass("d-none");
      } else {
        $("#arrow-down1").removeClass("d-none");
        $("#arrow-up1").addClass("d-none");
      }
      editEventAccd = !editEventAccd;
    });
 
    $("#pvtEvent-btn").click(function() {
      console.log("*********private button*****");
      if (pvtEventAccd) {
        alert("hello");
        $("#arrow-down2").addClass("d-none");
        $("#arrow-up2").removeClass("d-none");
      } else {
        alert("hello");
        $("#arrow-down2").removeClass("d-none");
        $("#arrow-up2").addClass("d-none");
      }
      pvtEventAccd = !pvtEventAccd;
      alert(pvtEventAccd);
    });
 
    await this.getAllEvents();
  },
  methods: {
    /**
     * @vuese
     * This method gets all events for the userid
     */
    async getAllEvents() {
      let userId=this.$store.getters.userDetails.id;
 
      console.log("entereddd");
      await this.$axios
        .get('/getAllEventsByUID/'+userId)
        .then((response) => {
          // console.log("********  inside public events fn  ************");
          // console.log(response.data);
          // console.log("********  inside public events fn  ************");
 
          //this.eventsCount = response.data.length;
          this.events = response.data;
 
          // this.privateEvents.filter()
        })
        .catch((error) => {
          console.log("cameeeeee");
          console.log(error);
        });
    },
    /**
     * @vuese
     * This method gets company details by id
     */
    async openCompany(id) {
      await this.$axios
        .get("/getCompanyDetails/" + id)
        .then((response) => {
          // console.log("********  inside public events fn  ************");
          // console.log(response.data);
          // console.log("********  inside public events fn  ************");
          console.log(response.data, "kdfbhkdsfjdfhbhhhh  ====");
          this.cdetails = response.data[0];
 
          // this.privateEvents.filter()
        })
        .catch((error) => {
          console.log("cameeeeee");
          console.log(error);
        });
    },
  },
};
</script>
<style scoped>
.txt-gray {
  color: #333;
}
 
.b-radius {
  border-radius: 20px !important;
}
.studContainer {
  padding-bottom: 5%;
}
</style>