2022-11-29 06:10:04 +00:00
|
|
|
import { onMounted, ref } from 'vue';
|
2022-11-24 06:21:45 +00:00
|
|
|
import axios from 'axios';
|
|
|
|
import { defineStore } from 'pinia';
|
|
|
|
|
2022-11-29 06:10:04 +00:00
|
|
|
export const useNavigationStore = defineStore('navigationStore', () => {
|
2022-11-24 06:21:45 +00:00
|
|
|
const modules = ['customer', 'claim', 'ticket'];
|
|
|
|
const pinned = ref([]);
|
|
|
|
|
2022-11-29 06:10:04 +00:00
|
|
|
onMounted(() => fetchPinned())
|
|
|
|
|
2022-11-24 06:21:45 +00:00
|
|
|
async function fetchPinned() {
|
|
|
|
const response = await axios.get('StarredModules/getStarredModules');
|
|
|
|
// const filteredModules = modules.value.filter((module) => {
|
|
|
|
// return response.data.find((element) => element.moduleFk == salixModules[module.name]);
|
|
|
|
// });
|
|
|
|
|
|
|
|
return (pinned.value = response.data);
|
|
|
|
}
|
|
|
|
|
2022-11-29 06:10:04 +00:00
|
|
|
function togglePinned(module) {
|
|
|
|
if (pinned.value.includes(module)) {
|
|
|
|
const index = pinned.value.indexOf(module);
|
|
|
|
pinned.value.splice(index, 1);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pinned.value.push(module);
|
|
|
|
}
|
|
|
|
|
2022-11-24 06:21:45 +00:00
|
|
|
return {
|
|
|
|
modules,
|
|
|
|
pinned,
|
2022-11-29 06:10:04 +00:00
|
|
|
togglePinned,
|
2022-11-24 06:21:45 +00:00
|
|
|
};
|
|
|
|
});
|