Skip to content

Commit

Permalink
admin: Do the nav links properly
Browse files Browse the repository at this point in the history
  • Loading branch information
katajakasa committed Apr 2, 2024
1 parent 93757f8 commit d7ccb4f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions admin/src/components/NavigationList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
:key="`${item.title}-${child.title}`"
:prepend-icon="child.icon"
:title="child.title"
@click="navigateTo(child)"
:to="navigateTo(child)"
/>
</v-list-group>
<v-list-item
v-else
:key="`root-${item.title}`"
:prepend-icon="item.icon"
:title="item.title"
@click="navigateTo(item)"
:to="navigateTo(item)"
/>
</template>
</v-list>
</template>

<script setup lang="ts">
import { toRefs } from "vue";
import { useRouter } from "vue-router";
import { type RouteLocationRaw } from "vue-router";
import { PermissionTarget, useAuth } from "@/services/auth";
Expand All @@ -42,7 +42,6 @@ export type NavigationLinks = NavigationLink[];
const props = defineProps<{ items: NavigationLinks; event: number | undefined }>();
const router = useRouter();
const authService = useAuth();
const { event } = toRefs(props);
Expand All @@ -52,9 +51,11 @@ function filterLinks(items: NavigationLinks): NavigationLinks {
.filter((m) => !!m.noEventId || !!event.value);
}
function navigateTo(item: NavigationLink): void {
function navigateTo(item: NavigationLink): RouteLocationRaw | undefined {
if (!item.to) return;
const params = item.noEventId ? {} : { eventId: event.value };
router.push({ name: item.to, params });
return {
name: item.to,
params: item.noEventId ? {} : { eventId: event.value!.toString() },
};
}
</script>

0 comments on commit d7ccb4f

Please sign in to comment.