Merge pull request 'Guest adjustments' (!147) from wbuezas/hedera-web-mindshore:feature/guest-adjustments into beta
gitea/hedera-web/pipeline/head There was a failure building this commit Details

Reviewed-on: #147
Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
Javier Segarra 2025-04-25 17:28:17 +00:00
commit a8277a2473
3 changed files with 37 additions and 33 deletions

View File

@ -22,7 +22,6 @@ import { formatDateTitle, currency } from 'src/lib/filters.js';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import debounce from 'src/utils/debouncer.js'; import debounce from 'src/utils/debouncer.js';
const jApi = inject('jApi');
const api = inject('api'); const api = inject('api');
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStore(); const appStore = useAppStore();
@ -671,11 +670,9 @@ onBeforeMount(async () => {
if (!isGuest.value) { if (!isGuest.value) {
await appStore.check('catalog'); await appStore.check('catalog');
} else { } else {
const resultSet = await jApi.execQuery( const { data } = await api.post('Orders/configureForGuest');
'CALL myOrder_configureForGuest(@orderId); SELECT @orderId;' const orderId = data[0]?.['@orderId'] || null;
); appStore.basketOrderId = orderId;
resultSet.fetchResult();
appStore.basketOrderId = resultSet.fetchValue();
} }
await getOrder(); await getOrder();
await getCategories(); await getCategories();

View File

@ -32,8 +32,7 @@ export const useAppStore = defineStore('hedera', {
}), }),
actions: { actions: {
async getMenuLinks() { async getMenuLinks() {
const { data: sections } = await api.get('MyMenus'); const { data: sections } = await api.get('MyMenus/myMenu');
if (!sections) return; if (!sections) return;
const sectionMap = new Map(); const sectionMap = new Map();
@ -92,32 +91,39 @@ export const useAppStore = defineStore('hedera', {
async checkRedirect(checkoutContinue) { async checkRedirect(checkoutContinue) {
const orderId = this.basketOrderId; const orderId = this.basketOrderId;
const myOrder_checkConfig = await api.post('applications/myOrder_checkConfig/execute-proc', { const myOrder_checkConfig = await api.post(
schema: 'hedera', 'applications/myOrder_checkConfig/execute-proc',
params: [orderId], {
}, { schema: 'hedera',
validateStatus: () => true, params: [orderId]
}); },
{
validateStatus: () => true
}
);
if (myOrder_checkConfig.status >= 200 && myOrder_checkConfig.status < 300) { if (
return true; myOrder_checkConfig.status >= 200 &&
myOrder_checkConfig.status < 300
) {
return true;
} }
switch (myOrder_checkConfig.data.error?.message) { switch (myOrder_checkConfig.data.error?.message) {
case 'orderNotOwnedByUser': case 'orderNotOwnedByUser':
notify(t(`errors.orderNotOwnedByUser`), 'negative'); notify(t(`errors.orderNotOwnedByUser`), 'negative');
case 'orderConfirmed': case 'orderConfirmed':
case 'orderNotOwnedByUser': case 'orderNotOwnedByUser':
this.unloadOrder(); this.unloadOrder();
await this.redirect(); await this.redirect();
break; break;
default: default:
this.router.push({ this.router.push({
name: 'checkout', name: 'checkout',
params: { id: this.basketOrderId }, params: { id: this.basketOrderId },
query: { continue: checkoutContinue } query: { continue: checkoutContinue }
}); });
notify(myOrder_checkConfig.data.error.message, 'negative'); notify(myOrder_checkConfig.data.error.message, 'negative');
} }
return false; return false;

View File

@ -8,7 +8,6 @@ const { notify } = useNotify();
const TOKEN_MULTIMEDIA = 'tokenMultimedia'; const TOKEN_MULTIMEDIA = 'tokenMultimedia';
const TOKEN = 'token'; const TOKEN = 'token';
export const useUserStore = defineStore('user', () => { export const useUserStore = defineStore('user', () => {
const token = ref(''); const token = ref('');
const tokenMultimedia = ref(''); const tokenMultimedia = ref('');
@ -33,7 +32,10 @@ export const useUserStore = defineStore('user', () => {
router = _router; router = _router;
isGuest.value = localStorage.getItem('hederaGuest') || false; isGuest.value = localStorage.getItem('hederaGuest') || false;
await getToken(); await getToken();
if (!isLoggedIn.value) { if (isGuest.value) {
await fetchUser();
return;
} else if (!isLoggedIn.value) {
const autoLoginStatus = await tryAutoLogin(); const autoLoginStatus = await tryAutoLogin();
if (!autoLoginStatus) { if (!autoLoginStatus) {
router.push({ name: 'login' }); router.push({ name: 'login' });
@ -291,7 +293,6 @@ export const useUserStore = defineStore('user', () => {
companyId.value = data.companyFk; companyId.value = data.companyFk;
}; };
const $reset = () => { const $reset = () => {
token.value = ''; token.value = '';
tokenMultimedia.value = ''; tokenMultimedia.value = '';