Skip to content

Commit

Permalink
fix: handle routes properly
Browse files Browse the repository at this point in the history
  • Loading branch information
RitvikSardana committed Dec 19, 2024
1 parent c42c031 commit 747adf2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion desk/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<RouterView class="antialiased" :key="$route.fullPath" />
<RouterView class="antialiased" />
<Toasts />
<KeymapDialog />
<Dialogs />
Expand Down
14 changes: 7 additions & 7 deletions desk/src/components/SidebarLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[bgColor]: isActive,
[hvColor]: !isActive,
}"
@click="handle"
@click="handleNavigation"
>
<span
class="shrink-0 text-gray-700"
Expand Down Expand Up @@ -57,12 +57,12 @@ const props = withDefaults(defineProps<P>(), {
});
const router = useRouter();
function handle() {
function handleNavigation() {
props.onClick();
if (props.to) {
router.push({
name: props.to,
});
}
if (!props.to) return;
if (props.to === router.currentRoute.value.name) return;
router.push({
name: props.to,
});
}
</script>
11 changes: 8 additions & 3 deletions desk/src/pages/TicketAgent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ const props = defineProps({
required: true,
},
});
watch(
() => props.ticketId,
() => {
ticket.reload();
}
);
provide("communicationArea", communicationAreaRef);
let storage = useStorage("ticket_agent", {
Expand All @@ -184,9 +189,9 @@ const ticket = createResource({
url: "helpdesk.helpdesk.doctype.hd_ticket.api.get_one",
cache: ["Ticket", props.ticketId],
auto: true,
params: {
makeParams: () => ({
name: props.ticketId,
},
}),
transform: (data) => {
if (data._assign) {
data.assignees = JSON.parse(data._assign).map((assignee) => {
Expand Down
9 changes: 7 additions & 2 deletions desk/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,9 @@ export const router = createRouter({

router.beforeEach(async (to, _, next) => {
const authStore = useAuthStore();
const userStore = useUserStore();

if (authStore.isLoggedIn) {
await authStore.init();
await userStore.users.fetch();
}

if (!authStore.isLoggedIn) {
Expand All @@ -246,3 +244,10 @@ router.beforeEach(async (to, _, next) => {
next();
}
});

router.afterEach(async (to) => {
const isCustomerPortal = to.meta.public ?? false;
if (isCustomerPortal) return;
const userStore = useUserStore();
await userStore.users.fetch();
});

0 comments on commit 747adf2

Please sign in to comment.