Просмотр исходного кода

fix(kanban): reload cards when franchisee switches unit

Watch selectedUnit.id from userStore — when unit changes the axios
interceptor already updates X-Unit-Id, so just reloading is enough
for the backend to return the correct unit's cards.
ebagabee 2 недель назад
Родитель
Сommit
e8f017a398
1 измененных файлов с 8 добавлено и 1 удалено
  1. 8 1
      src/pages/kanban/KanbanPage.vue

+ 8 - 1
src/pages/kanban/KanbanPage.vue

@@ -81,19 +81,21 @@
 </template>
 
 <script setup>
-import { ref, reactive, defineAsyncComponent, onMounted } from "vue";
+import { ref, reactive, defineAsyncComponent, onMounted, watch } from "vue";
 import { useQuasar } from "quasar";
 import draggable from "vuedraggable";
 
 import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
 import KanbanCard from "./components/KanbanCard.vue";
 import { getKanbans, reorderKanbans } from "src/api/kanban";
+import { userStore } from "src/stores/user";
 
 const AddEditKanbanDialog = defineAsyncComponent(
   () => import("./components/AddEditKanbanDialog.vue"),
 );
 
 const $q = useQuasar();
+const { selectedUnit } = userStore();
 const loading = ref(false);
 
 const columns = [
@@ -159,6 +161,11 @@ const openDialog = (card = null, phase = "a_fazer") => {
   });
 };
 
+// Reload whenever the user switches units via the top selector
+watch(() => selectedUnit?.id, (newId, oldId) => {
+  if (newId !== oldId) loadCards();
+});
+
 onMounted(loadCards);
 </script>