Skip to content

Commit 532abb5

Browse files
Merge branch 'main' into agent_communication_area
2 parents 3f29ac6 + 03295f1 commit 532abb5

File tree

5 files changed

+68
-7
lines changed

5 files changed

+68
-7
lines changed

desk/src/pages/InvalidPage.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<div
3+
class="grid h-full place-items-center px-4 py-20 text-center text-lg text-gray-600"
4+
>
5+
<div class="space-y-2">
6+
<div>Invalid page or not permitted to access</div>
7+
<Button :route="{ name: 'TicketsAgent' }">
8+
<template #prefix><TicketIcon class="w-4" /></template>
9+
Tickets
10+
</Button>
11+
</div>
12+
</div>
13+
</template>
14+
15+
<script setup>
16+
import TicketIcon from "@/components/icons/TicketIcon.vue";
17+
</script>

desk/src/pages/ticket/TicketDetails.vue

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,15 @@
115115
<span class="block text-sm text-gray-700">
116116
{{ o.label }}
117117
</span>
118+
<FormControl
119+
v-if="o.type === 'select'"
120+
:type="o.type"
121+
:value="data[o.field]"
122+
:options="customers?.data"
123+
@change="update(o.field, $event.target.value)"
124+
/>
118125
<Autocomplete
126+
v-else
119127
:options="o.store.dropdown"
120128
:placeholder="`Select a ${o.label}`"
121129
:value="data[o.field]"
@@ -136,7 +144,7 @@
136144
<script setup lang="ts">
137145
import { computed, inject } from "vue";
138146
import { Autocomplete } from "@/components";
139-
import { createResource, Tooltip } from "frappe-ui";
147+
import { createResource, Tooltip, FormControl } from "frappe-ui";
140148
import { dayjs } from "@/dayjs";
141149
import { emitter } from "@/emitter";
142150
import { createToast } from "@/utils";
@@ -167,8 +175,27 @@ const options = computed(() => [
167175
label: "Team",
168176
store: useTeamStore(),
169177
},
178+
{
179+
field: "customer",
180+
label: "Customer",
181+
type: "select",
182+
},
170183
]);
171184
185+
const customers = createResource({
186+
url: "helpdesk.utils.get_customer",
187+
params: {
188+
contact: ticket?.data?.raised_by,
189+
},
190+
auto: true,
191+
transform: (data) => {
192+
return data.map((d) => ({
193+
label: d,
194+
value: d,
195+
}));
196+
},
197+
});
198+
172199
function update(fieldname: string, value: string) {
173200
createResource({
174201
url: "frappe.client.set_value",

desk/src/router/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ const routes = [
5555
name: ONBOARDING_PAGE,
5656
component: () => import("@/pages/onboarding/SimpleOnboarding.vue"),
5757
},
58+
{
59+
path: "/:invalidpath",
60+
name: "Invalid Page",
61+
component: () => import("@/pages/InvalidPage.vue"),
62+
},
5863
{
5964
path: "",
6065
name: "AgentRoot",
@@ -197,8 +202,16 @@ router.beforeEach(async (to) => {
197202
await authStore.init();
198203
await usersStore.init();
199204

200-
if ((to.meta.agent && !authStore.hasDeskAccess) || isAuthRoute) {
201-
router.replace({ name: WEBSITE_ROOT });
205+
if (isAuthRoute && authStore.isLoggedIn) {
206+
if (authStore.isAgent) {
207+
router.replace({ name: AGENT_PORTAL_LANDING });
208+
} else {
209+
router.replace({ name: CUSTOMER_PORTAL_LANDING });
210+
}
211+
} else if (!isAuthRoute && !authStore.isLoggedIn) {
212+
router.replace({ name: "Login" });
213+
} else if (to.matched.length === 0) {
214+
router.replace({ name: "Invalid Page" });
202215
}
203216
} catch {
204217
if (!isAuthRoute) {

helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,16 @@ def before_validate(self):
167167
self.check_update_perms()
168168
self.set_ticket_type()
169169
self.set_raised_by()
170-
self.set_contact()
171-
self.set_customer()
172170
self.set_priority()
173171
self.set_first_responded_on()
174172
self.set_feedback_values()
175173
self.apply_escalation_rule()
176174
self.set_sla()
177175

176+
if self.via_customer_portal:
177+
self.set_contact()
178+
self.set_customer()
179+
178180
def validate(self):
179181
self.validate_feedback()
180182
self.validate_ticket_type()
@@ -240,7 +242,9 @@ def set_customer(self):
240242
if self.customer:
241243
return
242244
customer = get_customer(self.contact)
243-
if len(customer) > 0:
245+
246+
# let agent assign the customer when one contact has more than one customer
247+
if len(customer) == 1:
244248
self.customer = customer[0]
245249

246250
def set_priority(self):

helpdesk/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def refetch_resource(key: str | List[str], user=None):
6868
def capture_event(event: str):
6969
return _capture(event, "helpdesk")
7070

71-
71+
@frappe.whitelist()
7272
def get_customer(contact: str) -> tuple[str]:
7373
"""
7474
Get `Customer` from `Contact`

0 commit comments

Comments
 (0)