IKHSAN
ENID Baca dalam Bahasa Indonesia

opendesk

Public
Branch
main
Latest commit
08d9f3328 October 2026

agent.ts

Open raw
import { computed } from "vue";
import { defineStore } from "pinia";
import { createListResource } from "frappe-ui";

export const useAgentStore = defineStore("agent", () => {
  const agents = createListResource({
    doctype: "OD Agent",
    fields: ["name", "agent_name", "user", "user.user_image"],
    filters: { is_active: 1 },
    pageLength: 99999,
  });

  const dropdown = computed(() =>
    agents.data?.map((o) => ({
      label: o.agent_name,
      value: o.name,
      image: o.user_image,
    }))
  );

  function searchAgents(query: string) {
    return agents.data.filter((a) =>
      a.user?.toLowerCase().includes(query.toLowerCase())
    );
  }

  return {
    dropdown,
    agents,
    searchAgents,
  };
});
bytes
729
lines
33
Type
ts
Latest commit
28 October 2026