All files / components/account dashboard.vue

0% Statements 0/19
0% Branches 0/24
0% Functions 0/6
0% Lines 0/19

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 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
<template>
  <div class="dashboard-container">
    <p v-if="this.$auth.user" id="username" class="cursor-pointer" @click="resetTabs">{{ this.$auth.user.data.email }}</p>
 
    <div v-if="this.$auth.user">
      <div class="d-flex justify-content-between align-items-center cursor-pointer mb-2" @click="showAccountDetails">
<!--        <p id="id-cont">ID cont: <span>34532</span></p>-->
        <p id="id-cont">Detalii cont</p>
        <svg :class="{'active': isAccountInfoActive, 'rotated': isAccountInfoActive}" class="dropdown-arrow"
             fill='rgb(154, 117, 63)' height='8' viewBox='0 0 12 8' width='12' xmlns='http://www.w3.org/2000/svg'>
          <path d="M0 0 L12 0 L6 8 Z"/>
        </svg>
      </div>
      <div>
        <hr class="line"/>
        <div :class="{'d-none': !isAccountInfoActive}" class="user-info">
          <p v-if="this.$auth.user">Nume: <span>{{ this.$auth.user.data.name }}</span></p>
          <p v-if="this.$auth.user">Tel: <span>{{ this.$auth.user.data.phone }}</span></p>
<!--          <p>Prenume: <span>Prenume</span></p>-->
<!--          <p>Adresa: <span>Str. 1, Bl. 3, Sc. 2, Ap. 42, Et. 7, Pitesti, Arges</span></p>-->
          <p v-if="this.$auth.user">Email: <span>{{ this.$auth.user.data.email }}</span></p>
          <hr class="line"/>
        </div>
      </div>
    </div>
 
    <div v-if="this.$auth.user" class="my-2">
<!--      <div class="favorite-container">-->
<!--        <dashboard-dropdown-->
<!--          :dropdownSpecs="{-->
<!--            level: 0, // level of indentation-->
<!--            text: 'Favorite', // dropdown text-->
<!--            val: favItemsLength, // number of items-->
<!--            dropMethod: () => toggleTab('favorites', false), // method called when dropdown is clicked-->
<!--            isActive: activeTab === 'favorites', // if the tab is active-->
<!--            isRotated: favItemsLength, // if the arrow is rotated-->
<!--            isClickable: true // if the dropdown is clickable-->
<!--          }"-->
<!--        ></dashboard-dropdown>-->
<!--        <div :class="{'active': activeTab === 'favorites'}" class="sub-menus">-->
<!--          <dashboard-dropdown-->
<!--            v-for="(category, index) in Object.keys(favoriteItems)"-->
<!--            :key="index"-->
<!--            :dropdownSpecs="{-->
<!--              level: 1, // level of indentation-->
<!--              text: category, // dropdown text-->
<!--              val: favoriteItems[category].length, // number of items-->
<!--              dropMethod: () => {}, // method called when dropdown is clicked-->
<!--              isActive: false, // if the tab is active-->
<!--              isRotated: false, // if the arrow is rotated-->
<!--              isClickable: false // if the dropdown is clickable-->
<!--            }"-->
<!--          ></dashboard-dropdown>-->
<!--        </div>-->
 
<!--      </div>-->
      <div v-if="this.$auth.user" class="mb-2 mt-1 mt-lgxl-2">
        <div class="istoric-container">
          <dashboard-dropdown
            :dropdownSpecs="{
              level: 0, // level of indentation
              text: 'Istoric comenzi', // dropdown text
              val: '6', // number of items
              dropMethod: () => toggleTab('history', false), // method called when dropdown is clicked
              isActive: activeTab === 'history', // if the tab is active
              isRotated: false, // if the arrow is rotated
              isClickable: true // if the dropdown is clickable
            }"
          ></dashboard-dropdown>
        </div>
      </div>
 
      <hr class="line mb-2"/>
 
      <div  v-if="this.$auth.user">
 
        <div>
          <div class="cursor-pointer d-inline" @click="() => toggleTab('edit-user', false)">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="rgb(154, 117, 63)"
                 :class="{'active': activeTab === 'edit-user'}" class="bi bi-pencil-fill icon" viewBox="0 0 16 16">
              <path
                d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
            </svg>
            <span :class="{'active': activeTab === 'edit-user'}" class="icon-text">Editeaza Contul</span>
          </div>
        </div>
 
        <div>
          <div class="cursor-pointer d-inline" @click="() => toggleTab('change-pass', false)">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
                 :class="{'active': activeTab === 'change-pass'}" fill="rgb(154, 117, 63)" class="bi bi-lock icon"
                 viewBox="0 0 16 16">
              <path
                d="M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2zM5 8h6a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1z"/>
            </svg>
            <span :class="{'active': activeTab === 'change-pass'}" class="icon-text">Schimba Parola</span>
          </div>
        </div>
 
        <div class="mb-2">
          <div class="cursor-pointer d-inline" @click="() => toggleTab('delete-account', false)">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"
                 :class="{'active': activeTab === 'delete-account'}" fill="rgb(154, 117, 63)" class="bi bi-trash icon"
                 viewBox="0 0 16 16">
              <path
                d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
              <path fill-rule="evenodd"
                    d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
            </svg>
            <span class="icon-text" :class="{'active': activeTab === 'delete-account'}">Sterge Contul</span>
          </div>
        </div>
 
        <hr class="line"/>
      </div>
 
      <button v-if="this.$auth.user && activeTab === 'none'" class="log-out py-2 mt-4 px-0" @click="$auth.logout()">
        Log out
        <img data-not-lazy src="~/assets/svgs/arrow-right-golden.svg" class="arrow" alt="Arrow">
      </button>
    </div>
 
 
  </div>
</template>
 
<script>
import simpleArrowComp from '../utilities/arrow-components/simple-arrow-comp.vue';
import dashboardDropdown from './dashboard-dropdown.vue';
 
export default {
  components: {simpleArrowComp, dashboardDropdown},
 
  data() {
    return {
      activeTab: 'none',
      isAccountInfoActive: false
    }
  },
 
  watch: {
 
    '$route.path': function(val) {
      if (val === '/user/myaccount' && this.activeTab !== 'none') {
        this.activeTab = 'none';
      }
    }
 
  },
 
  methods: {
    /**
     * Changes the current tab and redirects to the corresponding link
     * @see toggleTab
     * @param {string} activeTab
     * @param {boolean} fromMounted
     * @returns void
     */
    toggleTab(activeTab, fromMounted) {
 
      if (this.activeTab === activeTab && this.$auth.user) {
        this.activeTab = 'none';
        if (!fromMounted) this.$router.replace({path: '/user/myaccount'});
        return;
      }
 
      if (this.activeTab !== activeTab && activeTab) {
 
        this.activeTab = activeTab;
        if (!fromMounted) this.$router.replace({path: `/user/myaccount/${activeTab}`});
      }
    },
 
    /**
     * Toggles the account info tab
     * @see showAccountDetails
     * @returns void
     */
    showAccountDetails() {
      this.isAccountInfoActive = !this.isAccountInfoActive;
    },
 
    /**
     * Toggles to user main tab
     * @see resetTabs
     * @returns void
     */
 
    resetTabs() {
      this.activeTab = 'none';
      this.$router.push({path: '/user/myaccount'});
    }
  },
 
 
  /**
   * Toggles the active tab based on the current link when the component mounts
   * @see mounted
   * @returns void
   *
   */
  mounted() {
    // if (this.$route.params.option) {
    if (this.$route.path === '/user/myaccount/history') this.toggleTab('history', true);
    if (this.$route.path === '/user/myaccount/edit-user') this.toggleTab('edit-user', true);
    if (this.$route.path === '/user/myaccount/change-pass')  this.toggleTab('change-pass', true);
    if (this.$route.path === '/user/myaccount/delete-account') this.toggleTab('delete-account', true);
    //}
  },
}
</script>
 
<style lang="scss" scoped>
 
#username {
  font-size: 1.8rem;
  font-family: SoleilLight;
  color: rgb(154, 117, 63);
}
 
#id-cont {
  font-size: 1rem;
  margin-bottom: 0;
  color: rgb(0, 21, 44);
  //color: rgb(154, 117, 63);
}
 
#id-cont span {
  color: rgb(0, 21, 44);
  font-family: SoleilLight;
}
 
.dropdown-arrow {
  width: 0.9rem;
  height: 0.6rem;
  transform: rotate(-90deg);
}
 
.dropdown-arrow.active {
  fill: rgb(0, 21, 44);
}
 
.icon-text.active {
  color: rgb(0, 21, 44);
}
 
.icon {
  width: 1.2rem;
  height: auto;
}
 
.icon.active {
  fill: rgb(0, 21, 44);
}
 
.dropdown-arrow.active.rotated {
  transform: rotate(0deg);
}
 
.cursor-pointer {
  cursor: pointer;
}
 
hr.line {
  border: 0;
  border-top: 0.5px solid rgb(154, 117, 63);
  height: 0.5px;
  opacity: 1;
  margin: 0;
}
 
.sub-menus {
  display: none;
}
 
.sub-menus.active {
  display: block;
}
 
.quantity, ::v-deep .quantity {
  font-size: 1rem;
  color: rgb(154, 117, 63);
}
 
.icon-text {
  color: rgb(154, 117, 63);
  font-size: 1rem;
  font-family: SoleilLight;
}
 
.user-info {
  background-color: #f1eae2;
}
 
.user-info p {
  font-size: 1rem;
  color: rgb(154, 117, 63);
}
 
.user-info span {
  font-size: 1rem;
  color: rgb(0, 21, 44);
}
 
button:hover {
  opacity: 0.6;
  text-transform: uppercase;
  font-family: SoleilBold;
}
 
button {
  border: 0;
  background-color: white;
  text-transform: uppercase;
  font-family: SoleilBold;
  font-size: 1rem;
  color: rgb(0, 21, 44);
}
 
button img {
  position: relative;
  bottom: 0.1rem;
  cursor: pointer;
  width: 1.2rem;
  margin-left: 0.2rem;
  height: 1.2rem;
}
 
@include media-breakpoint-down(lg) {
 
  button:hover {
    opacity: 1;
  }
 
  button {
    font-size: 1.1rem;
  }
 
  button img {
    width: 1.3rem;
    height: 1.3rem;
  }
 
  .dashboard-container {
    width: 100%;
  }
  #username {
    font-size: 2.4rem;
  }
 
  #id-cont,
  .user-products,
  ::v-deep .user-products,
  .quantity,
  ::v-deep .quantity,
  .icon-text,
  .user-info p,
  .user-info span {
    font-size: 1.6rem;
  }
 
  hr.line {
    height: 1px;
  }
 
  .dropdown-arrow,
  .icon {
    position: relative;
    top: -0.2rem;
  }
 
 
  .icon {
    width: 1.2rem;
  }
 
  .dropdown-arrow {
    width: 1.1rem;
    height: 1.2rem;
  }
}
 
@media screen and #{$ipad-pro-landscape-breakpoint},
screen and #{$ipad-pro-portrait-breakpoint},
screen and #{$ipad-landscape-breakpoint} {
 
  button:hover {
    opacity: 1;
  }
 
  button {
    font-size: 1.2rem;
  }
 
  button img {
    width: 1.4rem;
    height: 1.4rem;
  }
 
  .dashboard-container {
    width: 100%;
  }
  #username {
    font-size: 2.5rem;
  }
 
  #id-cont,
  .user-products,
  ::v-deep .user-products,
  .quantity,
  ::v-deep .quantity,
  .icon-text,
  .user-info p,
  .user-info span {
    font-size: 1.6rem;
  }
 
  hr.line {
    height: 1px;
  }
 
  .dropdown-arrow,
  .icon {
    position: relative;
    top: -0.3rem;
  }
 
 
  .icon {
    width: 1.3rem;
  }
 
  .dropdown-arrow {
    width: 1.2rem;
    height: 1.3rem;
  }
}
 
@include media-breakpoint-down(sm) {
  button:hover {
    opacity: 1;
  }
 
  button {
    font-size: 1rem;
  }
 
  button img {
    width: 1.1rem;
    height: 1.1rem;
  }
 
  .dashboard-container {
    width: 100%;
  }
  #username {
    font-size: 2rem;
  }
 
  #id-cont,
  .user-products,
  ::v-deep .user-products,
  .quantity,
  ::v-deep .quantity,
  .icon-text,
  .user-info p,
  .user-info span {
    font-size: 1.4rem;
  }
 
  hr.line {
    height: 1px;
  }
 
  .dropdown-arrow,
  .icon {
    position: relative;
    top: -0.1rem;
  }
 
 
  .icon {
    width: 1.1rem;
  }
 
  .dropdown-arrow {
    width: 1rem;
    height: 1.1rem;
  }
}
</style>