From 73f227f76b88242ce4d355a102f03ee8c14ed660 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 27 Dec 2024 21:47:07 +0530 Subject: [PATCH] fix: created a settings store --- frontend/src/stores/settings.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 frontend/src/stores/settings.js diff --git a/frontend/src/stores/settings.js b/frontend/src/stores/settings.js new file mode 100644 index 00000000..55675ae2 --- /dev/null +++ b/frontend/src/stores/settings.js @@ -0,0 +1,28 @@ +import { createDocumentResource } from 'frappe-ui' +import { reactive, ref } from 'vue' + +const settings = ref({}) +const brand = reactive({}) + +export function getSettings() { + const _settings = createDocumentResource({ + doctype: 'FCRM Settings', + name: 'FCRM Settings', + onSuccess: (data) => { + settings.value = data + brand.name = settings.value?.brand_name + brand.logo = settings.value?.brand_logo + brand.favicon = settings.value?.favicon + return data + }, + }) + + if (!settings.value?.length) { + _settings.fetch() + } + + return { + settings, + brand, + } +}