diff --git a/src/pages/Ecomerce/OrdersView.vue b/src/pages/Ecomerce/OrdersView.vue index 5285c56f..0c1ff6a5 100644 --- a/src/pages/Ecomerce/OrdersView.vue +++ b/src/pages/Ecomerce/OrdersView.vue @@ -1,5 +1,5 @@ diff --git a/src/utils/onUserId.js b/src/utils/onUserId.js new file mode 100644 index 00000000..28c1fcae --- /dev/null +++ b/src/utils/onUserId.js @@ -0,0 +1,19 @@ +import { watch } from 'vue'; + +import { useUserStore } from 'stores/user'; + +const userStore = useUserStore(); + +export const onUserId = (cb) => watch( + () => userStore?.user?.id, + async userId => { + if (userId) { + try { + await cb(userId); + } catch (error) { + console.error(error); + } + } + }, + { immediate: true } +);