From f5a1e058c4001e4eb2d0c83701a7b7c74b4210ad Mon Sep 17 00:00:00 2001
From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com>
Date: Tue, 23 Apr 2024 14:43:00 +0700
Subject: [PATCH] feat: add color to stat card
---
src/components/StatCardComponent.vue | 8 ++---
src/pages/01_branch-management/MainPage.vue | 35 +++++++++++----------
2 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/src/components/StatCardComponent.vue b/src/components/StatCardComponent.vue
index 3f309188..3de5281b 100644
--- a/src/components/StatCardComponent.vue
+++ b/src/components/StatCardComponent.vue
@@ -6,13 +6,13 @@ const props = withDefaults(
branch: {
count: number;
label: string;
- color?: 'pink' | 'purple' | 'green';
+ color: 'pink' | 'purple' | 'green';
}[];
dark?: boolean;
- isBranch?: boolean;
+ labelI18n?: boolean;
}>(),
{
- isBranch: false,
+ labelI18n: false,
},
);
@@ -40,7 +40,7 @@ const props = withDefaults(
{{ v.count }}
- {{ isBranch ? $t(v.label) : v.label }}
+ {{ labelI18n ? $t(v.label) : v.label }}
diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue
index f457be1d..dd7ac111 100644
--- a/src/pages/01_branch-management/MainPage.vue
+++ b/src/pages/01_branch-management/MainPage.vue
@@ -96,8 +96,8 @@ onMounted(async () => {
if (_stats) {
stats.value.push(
- { count: _stats.hq, label: 'branchHQLabel' },
- { count: _stats.br, label: 'branchLabel' },
+ { count: _stats.hq, label: 'branchHQLabel', color: 'pink' },
+ { count: _stats.br, label: 'branchLabel', color: 'purple' },
);
}
});
@@ -127,9 +127,9 @@ const fieldSelectedBranch = ref<{
value: 'branchHQLabel',
});
-const stats = ref<
- { count: number; label: string; color?: 'pink' | 'purple' }[]
->([]);
+const stats = ref<{ count: number; label: string; color: 'pink' | 'purple' }[]>(
+ [],
+);
const defaultFormData = {
headOfficeId: null,
@@ -338,17 +338,18 @@ async function onSubmit() {
const _stats = await branchStore.stats();
if (_stats) {
- stats.value[0] = {
- count: _stats.hq,
- label: 'branchHQLabel',
- color: 'pink',
- };
-
- stats.value[1] = {
- count: _stats.br,
- label: 'branchLabel',
- color: 'purple',
- };
+ stats.value = [
+ {
+ count: _stats.hq,
+ label: 'branchHQLabel',
+ color: 'pink',
+ },
+ {
+ count: _stats.br,
+ label: 'branchLabel',
+ color: 'purple',
+ },
+ ];
}
}
@@ -388,7 +389,7 @@ watch(locale, () => {