From c950bf5ef17949da50a4863f3f2e8230f8518227 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Mon, 30 Sep 2024 12:42:35 -0300 Subject: [PATCH] Add lateral arrows to stepper and add hedera tryAutoLogin logic --- src/css/responsive.scss | 12 +++- src/pages/Ecomerce/CheckoutView.vue | 106 +++++++++++++++++++++++----- src/stores/app.js | 6 +- src/stores/user.js | 19 +++++ 4 files changed, 120 insertions(+), 23 deletions(-) diff --git a/src/css/responsive.scss b/src/css/responsive.scss index 5e170ab8..e06defc2 100644 --- a/src/css/responsive.scss +++ b/src/css/responsive.scss @@ -1,5 +1,11 @@ @mixin mobile { - @media screen and (max-width: 1023px) { - @content; - } + @media screen and (max-width: 768px) { + @content; + } +} + +@mixin tablet { + @media screen and (min-width: 769px) and (max-width: 1024px) { + @content; + } } diff --git a/src/pages/Ecomerce/CheckoutView.vue b/src/pages/Ecomerce/CheckoutView.vue index 946815be..301758f0 100644 --- a/src/pages/Ecomerce/CheckoutView.vue +++ b/src/pages/Ecomerce/CheckoutView.vue @@ -16,10 +16,11 @@ const route = useRoute(); const router = useRouter(); const { notify } = useNotify(); const appStore = useAppStore(); -const { localeDates } = storeToRefs(appStore); +const { localeDates, isMobile } = storeToRefs(appStore); const stepperRef = ref(null); +const showNavigationButtons = ref(true); const loading = ref(false); const today = ref(null); const addresses = ref([]); @@ -210,6 +211,13 @@ const getWarehouses = async () => { } }; +const hideNavigationButtons = () => { + showNavigationButtons.value = false; + setTimeout(() => { + showNavigationButtons.value = true; + }, 350); +}; + const onNextStep = async stepIndex => { const currentStep = steps[orderForm.value.method][stepIndex]; if (currentStep.onBeforeNextStep) { @@ -220,6 +228,8 @@ const onNextStep = async stepIndex => { return; } + hideNavigationButtons(); + currentStep.stepDone = true; await stepperRef.value.next(); @@ -230,6 +240,7 @@ const onNextStep = async stepIndex => { }; const onPreviousStep = async stepIndex => { + hideNavigationButtons(); await stepperRef.value.previous(); const previousStep = steps[orderForm.value.method][stepIndex - 1]; @@ -301,15 +312,16 @@ onMounted(async () => { - diff --git a/src/stores/app.js b/src/stores/app.js index 43619b69..ed16085e 100644 --- a/src/stores/app.js +++ b/src/stores/app.js @@ -68,7 +68,7 @@ export const useAppStore = defineStore('hedera', { }, async init() { - this.router.push({ name: 'login' }); + // this.router.push({ name: 'login' }); this.getBasketOrderId(); this.getLocaleDates(); }, @@ -151,6 +151,10 @@ export const useAppStore = defineStore('hedera', { isMobile() { const $q = useQuasar(); return $q?.screen?.width <= 768; + }, + isTablet() { + const $q = useQuasar(); + return $q?.screen?.width <= 1024; } } }); diff --git a/src/stores/user.js b/src/stores/user.js index 4fc4c650..5c347005 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -37,6 +37,10 @@ export const useUserStore = defineStore('user', { actions: { async init() { this.isGuest = localStorage.getItem('hederaGuest') || false; + const autoLoginStatus = await this.tryAutoLogin(); + if (!autoLoginStatus) { + this.router.push({ name: 'login' }); + } await this.fetchUser(); await this.supplantInit(); this.updateSiteLocale(); @@ -48,6 +52,21 @@ export const useUserStore = defineStore('user', { localStorage.getItem('vnToken'); }, + async tryAutoLogin() { + const guest = localStorage.getItem('hederaGuest'); + + if (this.isGuest || guest) { + localStorage.setItem('hederaGuest', true); + return true; + } + + if (!this.token) this.getToken(); + + if (this.token) return true; + + return false; + }, + async login(user, password, remember) { const params = { user, password }; const res = await api.post('Accounts/login', params);