Skip to content

Commit

Permalink
feat: agent can update customer from portal
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitbhanushali committed Apr 21, 2024
1 parent c7c320b commit fe51560
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
29 changes: 28 additions & 1 deletion desk/src/pages/ticket/TicketDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,15 @@
<span class="block text-sm text-gray-700">
{{ o.label }}
</span>
<FormControl
v-if="o.type === 'select'"
:type="o.type"
:value="data[o.field]"
:options="customers?.data"
@change="update(o.field, $event.target.value)"
/>
<Autocomplete
v-else
:options="o.store.dropdown"
:placeholder="`Select a ${o.label}`"
:value="data[o.field]"
Expand All @@ -136,7 +144,7 @@
<script setup lang="ts">
import { computed, inject } from "vue";
import { Autocomplete } from "@/components";
import { createResource, Tooltip } from "frappe-ui";
import { createResource, Tooltip, FormControl } from "frappe-ui";
import { dayjs } from "@/dayjs";
import { emitter } from "@/emitter";
import { createToast } from "@/utils";
Expand Down Expand Up @@ -167,8 +175,27 @@ const options = computed(() => [
label: "Team",
store: useTeamStore(),
},
{
field: "customer",
label: "Customer",
type: "select",
},
]);
const customers = createResource({
url: "helpdesk.utils.get_customer",
params: {
contact: ticket?.data?.raised_by,
},
auto: true,
transform: (data) => {
return data.map((d) => ({
label: d,
value: d,
}));
},
});
function update(fieldname: string, value: string) {
createResource({
url: "frappe.client.set_value",
Expand Down
2 changes: 1 addition & 1 deletion helpdesk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def refetch_resource(key: str | List[str], user=None):
def capture_event(event: str):
return _capture(event, "helpdesk")


@frappe.whitelist()
def get_customer(contact: str) -> tuple[str]:
"""
Get `Customer` from `Contact`
Expand Down

0 comments on commit fe51560

Please sign in to comment.