Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle routes properly #2107

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</div>
</div>
<div class="border-b pb-3">
<div class="text-3xl font-semibold text-gray-900">
<div class="text-2xl font-semibold text-gray-900">
{{ title }}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>
</div>
<div class="border-b pb-3">
<div class="text-3xl font-semibold text-gray-900">
<div class="text-2xl font-semibold text-gray-900">
{{ title }}
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions desk/src/pages/ticket/TicketTextEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
private: true,
}"
@success="(f: File) => $emit('update:attachments', [...attachments, f])"
@failure="
() =>
createToast({
title: 'Error Uploading File',
icon: 'x',
iconClasses: 'text-red-600',
})
"
>
<template #default="{ openFileSelector }">
<Button theme="gray" variant="ghost" @click="openFileSelector()">
Expand Down Expand Up @@ -85,6 +93,7 @@ import {
UserAvatar,
} from "@/components";
import { File } from "@/types";
import { createToast } from "@/utils";

interface P {
content: string;
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();
});
Loading