From 0dca8a702906b9b718b1c6215f08e0051bdd6e13 Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Tue, 25 Mar 2025 14:50:19 +0700 Subject: [PATCH] refactor: handle role can approve invoice --- src/pages/05_quotation/QuotationForm.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 33ee0cd8..f62ac8a6 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -76,6 +76,7 @@ import { api } from 'src/boot/axios'; import { RouterLink, useRoute } from 'vue-router'; import { initLang, initTheme, Lang } from 'src/utils/ui'; import { convertTemplate } from 'src/utils/string-template'; +import { getRole } from 'src/services/keycloak'; type Node = { [key: string]: any; @@ -211,6 +212,17 @@ const attachmentData = ref< url?: string; }[] >([]); +const hideBtnApproveInvoice = computed(() => { + const role = getRole(); + const allowedRoles = [ + 'system', + 'head_of_admin', + 'admin', + 'head_of_accountant', + 'accountant', + ]; + return !role || !role.some((r) => allowedRoles.includes(r)); +}); const getToolbarConfig = computed(() => { const toolbar = [['left', 'center', 'justify'], ['toggle'], ['clip']]; @@ -2317,6 +2329,7 @@ function covertToNode() { " >