diff --git a/components/EntityShow.vue b/components/EntityShow.vue index dc3dec8..dbfb20b 100644 --- a/components/EntityShow.vue +++ b/components/EntityShow.vue @@ -45,6 +45,7 @@ const router = useRouter() const route = useRoute() const dataStore = useDataStore() const modal = useModal() +const auth = useAuthStore() const dataType = dataStore.dataTypes[type] @@ -97,6 +98,43 @@ const onTabChange = (index) => { router.push(`${router.currentRoute.value.path}?tabIndex=${index}`) } +const changePinned = async () => { + let newPins = [] + + if(auth.profile.pinned_on_navigation.find(i => i.datatype === type && i.id === props.item.id)){ + //Remove Pin + + newPins = auth.profile.pinned_on_navigation.filter(i => !(i.datatype === type && i.id === props.item.id)) + } else { + //Add Pin + + newPins = [ + ...auth.profile.pinned_on_navigation, + { + id: props.item.id, + icon: "i-heroicons-document", + type: "standardEntity", + datatype: type, + label: props.item[dataType.templateColumns.find(i => i.title).key] + } + ] + } + + const res = await useNuxtApp().$api(`/api/user/${auth.user.id}/profile`,{ + method: "PUT", + body: { + data: { + pinned_on_navigation: newPins + } + } + }) + + await auth.fetchMe() + + + +} +