import { createResource } from "frappe-ui"; import { defineStore } from "pinia"; import { computed, ComputedRef } from "vue"; import { globalStore } from "./globalStore"; export const useConfigStore = defineStore("config", () => { const { $socket } = globalStore(); const configResource = createResource({ url: "opendesk.api.config.get_config", auto: true, }); const config = computed(() => configResource.data || {}); const brandName = computed(() => config.value.brand_name); const brandLogo = computed(() => config.value.brand_logo); const favicon = computed(() => config.value.favicon); const teamRestrictionApplied = computed( () => !!parseInt(config.value.restrict_tickets_by_agent_group) ); const disableGlobalScopeForSavedReplies = computed( () => !!parseInt(config.value.disable_saved_replies_global_scope) ); const assignWithinTeam = computed( () => !!parseInt(config.value.assign_within_team) ); const skipEmailWorkflow: ComputedRef = computed( () => !!parseInt(config.value.skip_email_workflow) ); const isFeedbackMandatory = computed( () => !!parseInt(config.value.is_feedback_mandatory) ); const enableCommentReactions = computed( () => !!parseInt(config.value.enable_comment_reactions) ); $socket.on("opendesk:settings-updated", () => configResource.reload()); return { configResource, brandName, brandLogo, favicon, config, skipEmailWorkflow, isFeedbackMandatory, teamRestrictionApplied, assignWithinTeam, disableGlobalScopeForSavedReplies, enableCommentReactions, }; });