Fixes varios #2 #88

Merged
jsegarra merged 17 commits from wbuezas/hedera-web-mindshore:bugfix/fixes-2 into 4922-vueMigration 2024-10-04 18:14:44 +00:00
4 changed files with 120 additions and 23 deletions
Showing only changes of commit c950bf5ef1 - Show all commits

View File

@ -1,5 +1,11 @@
@mixin mobile { @mixin mobile {
@media screen and (max-width: 1023px) { @media screen and (max-width: 768px) {
@content; @content;
} }
}
@mixin tablet {
@media screen and (min-width: 769px) and (max-width: 1024px) {
@content;
}
} }

View File

@ -16,10 +16,11 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const { notify } = useNotify(); const { notify } = useNotify();
const appStore = useAppStore(); const appStore = useAppStore();
const { localeDates } = storeToRefs(appStore); const { localeDates, isMobile } = storeToRefs(appStore);
const stepperRef = ref(null); const stepperRef = ref(null);
const showNavigationButtons = ref(true);
const loading = ref(false); const loading = ref(false);
const today = ref(null); const today = ref(null);
const addresses = ref([]); 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 onNextStep = async stepIndex => {
const currentStep = steps[orderForm.value.method][stepIndex]; const currentStep = steps[orderForm.value.method][stepIndex];
if (currentStep.onBeforeNextStep) { if (currentStep.onBeforeNextStep) {
@ -220,6 +228,8 @@ const onNextStep = async stepIndex => {
return; return;
} }
hideNavigationButtons();
currentStep.stepDone = true; currentStep.stepDone = true;
await stepperRef.value.next(); await stepperRef.value.next();
@ -230,6 +240,7 @@ const onNextStep = async stepIndex => {
}; };
const onPreviousStep = async stepIndex => { const onPreviousStep = async stepIndex => {
hideNavigationButtons();
await stepperRef.value.previous(); await stepperRef.value.previous();
const previousStep = steps[orderForm.value.method][stepIndex - 1]; const previousStep = steps[orderForm.value.method][stepIndex - 1];
@ -301,15 +312,16 @@ onMounted(async () => {
</script> </script>
<template> <template>
<QPage class="vn-w-sm"> <QPage class="page-container">
<QStepper <QStepper
v-if="steps[orderForm.method] && steps[orderForm.method].length" v-if="steps[orderForm.method] && steps[orderForm.method].length"
v-model="currentStep" v-model="currentStep"
ref="stepperRef" ref="stepperRef"
animated animated
keep-alive keep-alive
:flat="isMobile"
contracted contracted
class="default-radius" class="default-radius stepper-container"
> >
<QStep <QStep
v-for="(step, stepIndex) in steps[orderForm.method]" v-for="(step, stepIndex) in steps[orderForm.method]"
@ -317,6 +329,7 @@ onMounted(async () => {
:name="step.name" :name="step.name"
:done="step.stepDone" :done="step.stepDone"
done-color="accent" done-color="accent"
class="step-container full-height"
> >
<!-- Method step --> <!-- Method step -->
<div <div
@ -436,33 +449,88 @@ onMounted(async () => {
<span>{{ confirmPlaceText }}</span> <span>{{ confirmPlaceText }}</span>
</div> </div>
</div> </div>
<QStepperNavigation class="flex justify-between"> <QBtn
<QBtn v-if="showNavigationButtons"
flat color="primary"
color="primary" @click="onPreviousStep(stepIndex)"
@click="onPreviousStep(stepIndex)" :disabled="currentStep === 'method'"
:label="step.backButtonLabel || t('back')" icon="arrow_back"
class="q-ml-sm" dense
:class="{ invisible: currentStep === 'method' }" class="left-navigation-button"
/> >
<QBtn <QTooltip>
@click="onNextStep(stepIndex)" {{ t(`${step.backButtonLabel || 'back'}`) }}
color="primary" </QTooltip>
:label="step.nextButtonLabel || t('next')" </QBtn>
/> <QBtn
</QStepperNavigation> v-if="showNavigationButtons"
@click="onNextStep(stepIndex)"
:color="currentStep === 'confirm' ? 'accent ' : 'primary'"
:icon="
currentStep === 'confirm' ? 'check' : 'arrow_forward'
"
dense
class="right-navigation-button"
>
<QTooltip>
{{ t(`${step.nextButtonLabel || 'next'}`) }}
</QTooltip>
</QBtn>
</QStep> </QStep>
</QStepper> </QStepper>
</QPage> </QPage>
</template> </template>
<style lang="scss" scoped> <style lang="scss">
@import 'src/css/responsive';
.step-title { .step-title {
min-width: 100%; min-width: 100%;
margin-bottom: 16px; margin-bottom: 16px;
text-align: center; text-align: center;
font-weight: bold; font-weight: bold;
} }
.page-container {
max-width: 544px;
margin: auto;
@include mobile {
max-height: calc(100svh - 64px);
padding: 0 !important;
}
}
.stepper-container > * {
@include mobile {
max-height: calc(100svh - 136px);
}
}
.step-container {
@include mobile {
.q-stepper__step-content {
height: calc(100svh - 64px);
}
}
}
.left-navigation-button {
position: absolute;
left: 5px;
top: 50%;
@include mobile {
top: 35%;
}
}
.right-navigation-button {
position: absolute;
right: 5px;
top: 50%;
@include mobile {
top: 35%;
}
}
</style> </style>
<i18n lang="yaml"> <i18n lang="yaml">

View File

@ -68,7 +68,7 @@ export const useAppStore = defineStore('hedera', {
}, },
async init() { async init() {
this.router.push({ name: 'login' }); // this.router.push({ name: 'login' });
this.getBasketOrderId(); this.getBasketOrderId();
this.getLocaleDates(); this.getLocaleDates();
}, },
@ -151,6 +151,10 @@ export const useAppStore = defineStore('hedera', {
isMobile() { isMobile() {
const $q = useQuasar(); const $q = useQuasar();
return $q?.screen?.width <= 768; return $q?.screen?.width <= 768;
},
isTablet() {
const $q = useQuasar();
return $q?.screen?.width <= 1024;
} }
} }
}); });

View File

@ -37,6 +37,10 @@ export const useUserStore = defineStore('user', {
actions: { actions: {
async init() { async init() {
this.isGuest = localStorage.getItem('hederaGuest') || false; this.isGuest = localStorage.getItem('hederaGuest') || false;
const autoLoginStatus = await this.tryAutoLogin();
if (!autoLoginStatus) {
this.router.push({ name: 'login' });
}
await this.fetchUser(); await this.fetchUser();
await this.supplantInit(); await this.supplantInit();
this.updateSiteLocale(); this.updateSiteLocale();
@ -48,6 +52,21 @@ export const useUserStore = defineStore('user', {
localStorage.getItem('vnToken'); 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) { async login(user, password, remember) {
const params = { user, password }; const params = { user, password };
const res = await api.post('Accounts/login', params); const res = await api.post('Accounts/login', params);