浏览代码

fix: dashboard

父节点
当前提交
3e65e4dcda

+ 5
- 4
app/Http/Controllers/DashboardController.php 查看文件

3
 namespace App\Http\Controllers;
3
 namespace App\Http\Controllers;
4
 
4
 
5
 use App\Services\DashboardService;
5
 use App\Services\DashboardService;
6
-use App\Services\QueryService;
7
 use Illuminate\Http\Request;
6
 use Illuminate\Http\Request;
8
 
7
 
9
 class DashboardController extends Controller
8
 class DashboardController extends Controller
16
      */
15
      */
17
     public function __invoke(Request $request)
16
     public function __invoke(Request $request)
18
     {
17
     {
19
-        // dd(QueryService::statisticDualYear("purchase_details", "purchases"));
18
+        // DashboardService::dump();
20
 
19
 
21
         return inertia("Dashboards/Index", [
20
         return inertia("Dashboards/Index", [
22
             "productAmount" => DashboardService::productAmount(),
21
             "productAmount" => DashboardService::productAmount(),
23
-            "productFavorites" => DashboardService::productFavorites(),
24
-            "salePurchaseStatistic" => DashboardService::salePurchaseStatistic(),
22
+            "productBestSelling" => DashboardService::productBestSelling(),
23
+            "salePurchaseAmountStatistic" => DashboardService::salePurchaseAmountStatistic(),
24
+            "salePriceStatistic" => DashboardService::salePriceStatistic(),
25
+            "purchasePriceStatistic" => DashboardService::purchasePriceStatistic(),
25
         ]);
26
         ]);
26
     }
27
     }
27
 }
28
 }

+ 65
- 11
app/Services/DashboardService.php 查看文件

6
 
6
 
7
 class DashboardService
7
 class DashboardService
8
 {
8
 {
9
-    public static function productFavorites()
9
+    public static function productBestSelling()
10
     {
10
     {
11
-        return DB::table("sale_details")
11
+        $query = DB::table("sale_details")
12
             ->selectRaw(
12
             ->selectRaw(
13
-                "sale_details.product_number,
14
-                 products.name AS title,
13
+                "products.name AS title,
15
                  SUM(sale_details.qty) AS qty,
14
                  SUM(sale_details.qty) AS qty,
16
                  products.profit"
15
                  products.profit"
17
             )
16
             )
25
             ->orderByRaw("qty DESC")
24
             ->orderByRaw("qty DESC")
26
             ->limit(5)
25
             ->limit(5)
27
             ->get();
26
             ->get();
27
+
28
+        return [
29
+            "title" => __("words.best_product"),
30
+            "data" => $query,
31
+        ];
28
     }
32
     }
29
 
33
 
30
     public static function productAmount()
34
     public static function productAmount()
31
     {
35
     {
32
         return [
36
         return [
33
-            QueryService::amount("sales", __("words.sale")),
34
-            QueryService::amount("purchases", __("words.purchase")),
35
-            QueryService::amount("products", __("words.product")),
36
-            QueryService::amount("stock_products", __("words.stock_product")),
37
+            "data" => [
38
+                QueryService::amount(
39
+                    "sales",
40
+                    __("words.sale"),
41
+                    __("words.today")
42
+                ),
43
+                QueryService::amount(
44
+                    "purchases",
45
+                    __("words.purchase"),
46
+                    __("words.today")
47
+                ),
48
+                QueryService::amount(
49
+                    "products",
50
+                    __("words.product"),
51
+                    __("words.today")
52
+                ),
53
+                QueryService::amount(
54
+                    "stock_products",
55
+                    __("words.stock_product"),
56
+                    __("words.today")
57
+                ),
58
+            ],
59
+        ];
60
+    }
61
+
62
+    public static function salePurchaseAmountStatistic()
63
+    {
64
+        return [
65
+            "title" => __("words.sale_and_purchase"),
66
+            "data" => [
67
+                __("words.sale") => QueryService::amountStatistic("sales"),
68
+                __("words.purchase") => QueryService::amountStatistic(
69
+                    "purchases"
70
+                ),
71
+            ],
37
         ];
72
         ];
38
     }
73
     }
39
 
74
 
40
-    public static function salePurchaseStatistic()
75
+    public static function salePriceStatistic()
41
     {
76
     {
42
         return [
77
         return [
43
-            __("words.sale") => QueryService::statistic("sales"),
44
-            __("words.purchase") => QueryService::statistic("purchases"),
78
+            "title" => __("words.sale"),
79
+            "data" => QueryService::priceStatistic("sale_details"),
45
         ];
80
         ];
46
     }
81
     }
82
+
83
+    public static function purchasePriceStatistic()
84
+    {
85
+        return [
86
+            "title" => __("words.purchase"),
87
+            "data" => QueryService::priceStatistic("purchase_details"),
88
+        ];
89
+    }
90
+
91
+    public static function dump()
92
+    {
93
+        return dd(
94
+            self::productAmount(),
95
+            self::productBestSelling(),
96
+            self::salePurchaseAmountStatistic(),
97
+            self::salePriceStatistic(),
98
+            self::purchasePriceStatistic()
99
+        );
100
+    }
47
 }
101
 }

+ 35
- 37
app/Services/QueryService.php 查看文件

2
 
2
 
3
 namespace App\Services;
3
 namespace App\Services;
4
 
4
 
5
+use Carbon\Carbon;
5
 use Illuminate\Support\Facades\DB;
6
 use Illuminate\Support\Facades\DB;
6
 
7
 
7
 class QueryService
8
 class QueryService
8
 {
9
 {
9
-    public static function amount(string $table, string $title)
10
-    {
10
+    public static function amount(
11
+        string $table,
12
+        string $title,
13
+        string $description
14
+    ) {
11
         return DB::table($table)
15
         return DB::table($table)
12
             ->selectRaw(
16
             ->selectRaw(
13
-                "COUNT(*) AS amount,
14
-                 (SELECT COUNT(*) FROM products WHERE DATE(updated_at) = CURDATE()) AS amountToday"
17
+                "COUNT(*) AS amount, (
18
+                 SELECT
19
+                    COUNT(*)
20
+                 FROM
21
+                    products
22
+                 WHERE
23
+                    DATE(updated_at) = CURDATE()) AS amountToday"
15
             )
24
             )
16
             ->get()
25
             ->get()
17
             ->transform(
26
             ->transform(
18
-                fn($sale) => [
27
+                fn($table) => [
19
                     "title" => $title,
28
                     "title" => $title,
20
-                    "amount" => $sale->amount,
21
-                    "amountToday" => $sale->amountToday,
29
+                    "amount" => $table->amount,
30
+                    "amountToday" => $table->amountToday,
31
+                    "amountTodayDescription" => $description,
22
                 ]
32
                 ]
23
             )
33
             )
24
             ->first();
34
             ->first();
25
     }
35
     }
26
 
36
 
27
-    public static function statistic(string $table)
37
+    public static function amountStatistic(string $table)
28
     {
38
     {
29
         return DB::table($table)
39
         return DB::table($table)
30
             ->selectRaw(
40
             ->selectRaw(
31
                 "COUNT(*) AS amount,
41
                 "COUNT(*) AS amount,
32
                  DATE_FORMAT(created_at, '%b') AS month"
42
                  DATE_FORMAT(created_at, '%b') AS month"
33
             )
43
             )
34
-            ->groupByRaw("MONTH(created_at)")
44
+            ->groupByRaw("month")
45
+            ->orderByRaw("created_at")
35
             ->get()
46
             ->get()
36
             ->pluck("amount", "month");
47
             ->pluck("amount", "month");
37
     }
48
     }
38
 
49
 
39
-    public static function statisticDualYear(string $table, string $tableJoin)
50
+    public static function priceStatistic(string $table)
40
     {
51
     {
41
         return DB::table($table)
52
         return DB::table($table)
42
             ->selectRaw(
53
             ->selectRaw(
43
-                "DATE_FORMAT($table.created_at, '%Y') AS year,
44
-                 DATE_FORMAT($table.created_at, '%b') AS month,
45
-                 IF(
46
-                 $tableJoin.ppn,
47
-                 $table.price + $table.price * ((
48
-                 SELECT
49
-                    ppn
50
-                 FROM
51
-                    ppns) / 100),
52
-                 $table.price
53
-                 ) AS price,
54
-                 COUNT(*) AS total"
55
-            )
56
-            ->join(
57
-                $tableJoin,
58
-                "$tableJoin.number",
59
-                "=",
60
-                "$table.purchase_number"
61
-            )
62
-            ->groupByRaw(
63
-                "YEAR($table.created_at),
64
-                 MONTH($table.created_at),
65
-                 year,
66
-                 month,
67
-                 price
68
-                 DESC"
54
+                "price,
55
+                 created_at"
69
             )
56
             )
70
-            ->get();
57
+            ->orderByRaw("created_at")
58
+            ->get()
59
+            ->groupBy([
60
+                fn($value) => Carbon::parse($value->created_at)->format("Y"),
61
+                fn($value) => Carbon::parse($value->created_at)->format("M"),
62
+            ])
63
+            ->take(2)
64
+            ->transform(
65
+                fn($year) => $year->transform(
66
+                    fn($month) => $month->sum(fn($arr) => $arr->price)
67
+                )
68
+            );
71
     }
69
     }
72
 }
70
 }

+ 33
- 33
lang/en/words.php 查看文件

1
 <?php
1
 <?php
2
 
2
 
3
 return [
3
 return [
4
-
5
     /*
4
     /*
6
     |--------------------------------------------------------------------------
5
     |--------------------------------------------------------------------------
7
     | Words Language Lines
6
     | Words Language Lines
11
     |
10
     |
12
      */
11
      */
13
 
12
 
14
-    'active' => 'Active',
15
-    'not_active' => 'Not Active',
16
-    'male' => 'Male',
17
-    'female' => 'Female',
18
-    'income' => 'Income',
19
-    'expense' => 'Expense',
20
-    'today' => 'Today',
21
-    'this_month' => 'This Month',
22
-    'total' => 'Total',
23
-    'discount_given' => 'Discount Given',
24
-    'transaction' => 'Transaction',
25
-    'expense' => 'Expense',
26
-    'laundry_type' => 'Laundry Type',
27
-    'product_type' => 'Product Type',
28
-    'transaction_statistic' => 'Transaction Statistic',
29
-    'mutation_statistic' => 'Mutations Statistic',
30
-    'transaction_outlet_statistic' => 'Transaction Statistic/Outlet',
31
-    'per_year' => 'Per Year',
32
-    'top_customer' => 'Top customer',
33
-    'top_number_customer' => 'Top :number Customer',
34
-    'member' => 'Member',
35
-    'member_expired' => 'Member has expired please Top Up again',
36
-    'type_member' => 'Type Member',
37
-    'type_vehicle' => 'Type Kendaraan',
38
-    'top_up_rank' => 'Top Up',
39
-    'top_up_number_rank' => 'Top Up :number Rank',
40
-    'user' => 'User',
41
-    'sale' => 'Sale',
42
-    'purchase' => 'Purchase',
43
-    'product' => 'Product',
44
-    'stock_product' => 'Stock Product'
45
-
13
+    "active" => "Active",
14
+    "not_active" => "Not Active",
15
+    "male" => "Male",
16
+    "female" => "Female",
17
+    "income" => "Income",
18
+    "expense" => "Expense",
19
+    "today" => "Today",
20
+    "this_month" => "This Month",
21
+    "total" => "Total",
22
+    "discount_given" => "Discount Given",
23
+    "transaction" => "Transaction",
24
+    "expense" => "Expense",
25
+    "laundry_type" => "Laundry Type",
26
+    "product_type" => "Product Type",
27
+    "transaction_statistic" => "Transaction Statistic",
28
+    "mutation_statistic" => "Mutations Statistic",
29
+    "transaction_outlet_statistic" => "Transaction Statistic/Outlet",
30
+    "per_year" => "Per Year",
31
+    "top_customer" => "Top customer",
32
+    "top_number_customer" => "Top :number Customer",
33
+    "member" => "Member",
34
+    "member_expired" => "Member has expired please Top Up again",
35
+    "type_member" => "Type Member",
36
+    "type_vehicle" => "Type Kendaraan",
37
+    "top_up_rank" => "Top Up",
38
+    "top_up_number_rank" => "Top Up :number Rank",
39
+    "user" => "User",
40
+    "sale" => "Sale",
41
+    "purchase" => "Purchase",
42
+    "product" => "Product",
43
+    "stock_product" => "Stock Product",
44
+    "best_product" => "Best Product",
45
+    "sale_and_purchase" => "Sale and Purchase",
46
 ];
46
 ];

+ 33
- 33
lang/id/words.php 查看文件

1
 <?php
1
 <?php
2
 
2
 
3
 return [
3
 return [
4
-
5
     /*
4
     /*
6
     |--------------------------------------------------------------------------
5
     |--------------------------------------------------------------------------
7
     | Words Language Lines
6
     | Words Language Lines
11
     |
10
     |
12
      */
11
      */
13
 
12
 
14
-    'active' => 'Aktif',
15
-    'not_active' => 'Tidak aktif',
16
-    'male' => 'Laki-laki',
17
-    'female' => 'Perempuan',
18
-    'income' => 'Pendapatan',
19
-    'expense' => 'Pengeluaran',
20
-    'today' => 'Hari ini',
21
-    'this_month' => 'Bulan ini',
22
-    'total' => 'Total',
23
-    'discount_given' => 'Diskon diberikan',
24
-    'transaction' => 'Transaksi',
25
-    'expense' => 'Pengeluaran',
26
-    'laundry_type' => 'Jenis Laundry',
27
-    'product_type' => 'Jenis Produk',
28
-    'transaction_statistic' => 'Statistik Transaksi',
29
-    'mutation_statistic' => 'Statistik Mutasi',
30
-    'transaction_outlet_statistic' => 'Statistik Transaksi/Outlet',
31
-    'per_year' => 'Pertahun',
32
-    'top_customer' => 'Top Pelanggan',
33
-    'top_number_customer' => 'Top :number Pelanggan',
34
-    'member' => 'Member',
35
-    'member_expired' => 'Member telah expired silahkan lakukan Top Up kembali',
36
-    'type_member' => 'Jenis Member',
37
-    'type_vehicle' => 'Jenis Kendaraan',
38
-    'top_up_rank' => 'Top Up',
39
-    'top_up_number_rank' => 'Peringkat :number Top Up',
40
-    'user' => 'User',
41
-    'sale' => 'Penjualan',
42
-    'purchase' => 'Pembelian',
43
-    'product' => 'Produk',
44
-    'stock_product' => 'Stok Produk'
45
-
13
+    "active" => "Aktif",
14
+    "not_active" => "Tidak aktif",
15
+    "male" => "Laki-laki",
16
+    "female" => "Perempuan",
17
+    "income" => "Pendapatan",
18
+    "expense" => "Pengeluaran",
19
+    "today" => "Hari ini",
20
+    "this_month" => "Bulan ini",
21
+    "total" => "Total",
22
+    "discount_given" => "Diskon diberikan",
23
+    "transaction" => "Transaksi",
24
+    "expense" => "Pengeluaran",
25
+    "laundry_type" => "Jenis Laundry",
26
+    "product_type" => "Jenis Produk",
27
+    "transaction_statistic" => "Statistik Transaksi",
28
+    "mutation_statistic" => "Statistik Mutasi",
29
+    "transaction_outlet_statistic" => "Statistik Transaksi/Outlet",
30
+    "per_year" => "Pertahun",
31
+    "top_customer" => "Top Pelanggan",
32
+    "top_number_customer" => "Top :number Pelanggan",
33
+    "member" => "Member",
34
+    "member_expired" => "Member telah expired silahkan lakukan Top Up kembali",
35
+    "type_member" => "Jenis Member",
36
+    "type_vehicle" => "Jenis Kendaraan",
37
+    "top_up_rank" => "Top Up",
38
+    "top_up_number_rank" => "Peringkat :number Top Up",
39
+    "user" => "User",
40
+    "sale" => "Penjualan",
41
+    "purchase" => "Pembelian",
42
+    "product" => "Produk",
43
+    "stock_product" => "Stok Produk",
44
+    "best_product" => "Produk Terlaris",
45
+    "sale_and_purchase" => "Penjualan dan Pembelian",
46
 ];
46
 ];

+ 16
- 0
resources/js/pages/Dashboards/Components/CardCart.vue 查看文件

1
+<script setup>
2
+defineProps({
3
+  title: {
4
+    required: true,
5
+    type: String,
6
+  },
7
+})
8
+</script>
9
+
10
+<template>
11
+  <div class="card">
12
+    <h5>{{ title }}</h5>
13
+
14
+    <Chart v-bind="$attrs" />
15
+  </div>
16
+</template>

+ 10
- 6
resources/js/pages/Dashboards/Components/CardCount.vue 查看文件

1
 <script setup>
1
 <script setup>
2
 defineProps({
2
 defineProps({
3
-  products: {
3
+  data: {
4
     required: true,
4
     required: true,
5
-    type: Array,
5
+    type: Object,
6
   },
6
   },
7
 })
7
 })
8
 </script>
8
 </script>
9
 
9
 
10
 <template>
10
 <template>
11
-  <div v-for="product in products" class="col-12 lg:col-6 xl:col-3">
11
+  <div v-for="product in data.data" class="col-12 lg:col-6 xl:col-3">
12
     <div class="card mb-0">
12
     <div class="card mb-0">
13
       <div class="flex justify-content-between mb-3">
13
       <div class="flex justify-content-between mb-3">
14
         <div>
14
         <div>
26
           <i class="pi pi-th-large text-blue-500 text-xl"></i>
26
           <i class="pi pi-th-large text-blue-500 text-xl"></i>
27
         </div>
27
         </div>
28
       </div>
28
       </div>
29
-      <span class="text-green-500 font-medium"
30
-        >{{ product.amountToday }} {{ product.title.toLowerCase() }}
29
+
30
+      <span class="text-green-500 font-medium">
31
+        {{ product.amountToday }} {{ product.title.toLowerCase() }} {{ ' ' }}
32
+      </span>
33
+
34
+      <span class="text-500">
35
+        {{ product.amountTodayDescription.toLowerCase() }}
31
       </span>
36
       </span>
32
-      <span class="text-500"> hari ini</span>
33
     </div>
37
     </div>
34
   </div>
38
   </div>
35
 </template>
39
 </template>

+ 4
- 4
resources/js/pages/Dashboards/Components/CardProductFavorite.vue 查看文件

1
 <script setup>
1
 <script setup>
2
 defineProps({
2
 defineProps({
3
-  products: {
3
+  data: {
4
     required: true,
4
     required: true,
5
-    type: Array,
5
+    type: Object,
6
   },
6
   },
7
 })
7
 })
8
 </script>
8
 </script>
10
 <template>
10
 <template>
11
   <div class="card">
11
   <div class="card">
12
     <div class="flex justify-content-between align-items-center">
12
     <div class="flex justify-content-between align-items-center">
13
-      <h5>Produk Terlaris</h5>
13
+      <h5>{{ data.title }}</h5>
14
     </div>
14
     </div>
15
 
15
 
16
     <ul class="list-none p-0 m-0">
16
     <ul class="list-none p-0 m-0">
17
       <li
17
       <li
18
-        v-for="product in products"
18
+        v-for="product in data.data"
19
         class="flex flex-column md:flex-row md:align-items-center md:justify-content-between mb-4"
19
         class="flex flex-column md:flex-row md:align-items-center md:justify-content-between mb-4"
20
       >
20
       >
21
         <span class="text-900 font-medium mr-2 mb-1 md:mb-0">{{
21
         <span class="text-900 font-medium mr-2 mb-1 md:mb-0">{{

+ 34
- 0
resources/js/pages/Dashboards/Composables/useStatistic.js 查看文件

1
+export function useStatistic(chartData) {
2
+  const chartSettings = {
3
+    title: null,
4
+    datasets: [
5
+      {
6
+        label: '-',
7
+        data: null,
8
+        fill: false,
9
+        backgroundColor: '#2f4860',
10
+        borderColor: '#2f4860',
11
+        tension: 0.4,
12
+      },
13
+      {
14
+        label: '-',
15
+        data: null,
16
+        fill: false,
17
+        backgroundColor: '#00bb7e',
18
+        borderColor: '#00bb7e',
19
+        tension: 0.4,
20
+      },
21
+    ],
22
+  }
23
+
24
+  let index = 0
25
+
26
+  for (const key in chartData.data) {
27
+    chartSettings.datasets[index].label = key
28
+    chartSettings.datasets[index].data = chartData.data[key]
29
+
30
+    index++
31
+  }
32
+
33
+  return { title: chartData.title, data: chartSettings }
34
+}

+ 34
- 0
resources/js/pages/Dashboards/Composables/useStatisticDualYear.js 查看文件

1
+export function useStatisticDualYear(chartData) {
2
+  const chartSettings = {
3
+    title: null,
4
+    datasets: [
5
+      {
6
+        label: '-',
7
+        data: [],
8
+        fill: false,
9
+        backgroundColor: '#2f4860',
10
+        borderColor: '#2f4860',
11
+        tension: 0.4,
12
+      },
13
+      {
14
+        label: '-',
15
+        data: [],
16
+        fill: false,
17
+        backgroundColor: '#00bb7e',
18
+        borderColor: '#00bb7e',
19
+        tension: 0.4,
20
+      },
21
+    ],
22
+  }
23
+
24
+  let index = 0
25
+
26
+  for (const key in chartData.data) {
27
+    chartSettings.datasets[index].label = key
28
+    chartSettings.datasets[index].data = chartData.data[key]
29
+
30
+    index++
31
+  }
32
+
33
+  return { title: chartData.title, data: chartSettings }
34
+}

+ 31
- 94
resources/js/pages/Dashboards/Index.vue 查看文件

1
 <script setup>
1
 <script setup>
2
+import { useStatistic } from './Composables/useStatistic'
3
+import { useStatisticDualYear } from './Composables/useStatisticDualYear'
4
+import CardCart from './Components/CardCart.vue'
2
 import CardCount from './Components/CardCount.vue'
5
 import CardCount from './Components/CardCount.vue'
3
 import CardProductFavorite from './Components/CardProductFavorite.vue'
6
 import CardProductFavorite from './Components/CardProductFavorite.vue'
4
 import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
7
 import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
5
-import { computed } from '@vue/reactivity'
6
 
8
 
7
 const props = defineProps([
9
 const props = defineProps([
8
   'productAmount',
10
   'productAmount',
9
-  'productFavorites',
10
-  'salePurchaseStatistic',
11
+  'productBestSelling',
12
+  'salePurchaseAmountStatistic',
13
+  'salePriceStatistic',
14
+  'purchasePriceStatistic',
11
 ])
15
 ])
12
 
16
 
13
-const salePurchase = computed(() => {
14
-  const data = {
15
-    datasets: [
16
-      {
17
-        label: null,
18
-        data: null,
19
-        fill: false,
20
-        backgroundColor: '#2f4860',
21
-        borderColor: '#2f4860',
22
-        tension: 0.4,
23
-      },
24
-      {
25
-        label: null,
26
-        data: null,
27
-        fill: false,
28
-        backgroundColor: '#00bb7e',
29
-        borderColor: '#00bb7e',
30
-        tension: 0.4,
31
-      },
32
-    ],
33
-  }
17
+const salePurchaseAmountStatistic = useStatistic(
18
+  props.salePurchaseAmountStatistic
19
+)
34
 
20
 
35
-  let index = 0
21
+const salePriceStatistic = useStatisticDualYear(props.salePriceStatistic)
36
 
22
 
37
-  for (const key in props.salePurchaseStatistic) {
38
-    data.datasets[index].label = key
39
-    data.datasets[index].data = props.salePurchaseStatistic[key]
40
-
41
-    console.info(props.salePurchaseStatistic[key])
42
-
43
-    index++
44
-  }
45
-
46
-  return data
47
-})
48
-
49
-const barData = {
50
-  labels: [
51
-    'Jan',
52
-    'Feb',
53
-    'Mar',
54
-    'Apr',
55
-    'May',
56
-    'Jun',
57
-    'Jul',
58
-    'Aug',
59
-    'Sep',
60
-    'Oct',
61
-    'Nov',
62
-    'Dec',
63
-  ],
64
-  datasets: [
65
-    {
66
-      label: 'Bulan lalu',
67
-      data: [
68
-        65_000_000, 59_000_000, 80_000_000, 81_000_000, 56_000_000, 55_000_000,
69
-        40_000_000,
70
-      ],
71
-      fill: false,
72
-      backgroundColor: '#2f4860',
73
-      borderColor: '#2f4860',
74
-      tension: 0.4,
75
-    },
76
-    {
77
-      label: 'Bulan ini',
78
-      data: [
79
-        28_000_000, 48_000_000, 40_000_000, 19_000_000, 86_000_000, 27_000_000,
80
-        90_000_000,
81
-      ],
82
-      fill: false,
83
-      backgroundColor: '#00bb7e',
84
-      borderColor: '#00bb7e',
85
-      tension: 0.4,
86
-    },
87
-  ],
88
-}
23
+const purchasePriceStatistic = useStatisticDualYear(
24
+  props.purchasePriceStatistic
25
+)
89
 </script>
26
 </script>
90
 
27
 
91
 <template>
28
 <template>
93
     <div class="grid">
30
     <div class="grid">
94
       <div class="col-12">
31
       <div class="col-12">
95
         <div class="grid">
32
         <div class="grid">
96
-          <CardCount :products="productAmount" />
33
+          <CardCount :data="productAmount" />
97
         </div>
34
         </div>
98
       </div>
35
       </div>
99
 
36
 
100
       <div class="col-12 xl:col-6">
37
       <div class="col-12 xl:col-6">
101
         <div class="grid">
38
         <div class="grid">
102
           <div class="col-12">
39
           <div class="col-12">
103
-            <div class="card">
104
-              <h5>Pembelian dan Penjualan</h5>
105
-
106
-              <Chart type="line" :data="salePurchase" />
107
-            </div>
40
+            <CardProductFavorite :data="productBestSelling" />
108
           </div>
41
           </div>
109
 
42
 
110
           <div class="col-12">
43
           <div class="col-12">
111
-            <CardProductFavorite :products="productFavorites" />
44
+            <CardCart
45
+              type="line"
46
+              :title="salePurchaseAmountStatistic.title"
47
+              :data="salePurchaseAmountStatistic.data"
48
+            />
112
           </div>
49
           </div>
113
         </div>
50
         </div>
114
       </div>
51
       </div>
116
       <div class="col-12 xl:col-6">
53
       <div class="col-12 xl:col-6">
117
         <div class="grid">
54
         <div class="grid">
118
           <div class="col-12">
55
           <div class="col-12">
119
-            <div class="card">
120
-              <h5>Pembelian</h5>
121
-
122
-              <Chart type="bar" :data="barData" />
123
-            </div>
56
+            <CardCart
57
+              type="bar"
58
+              :title="salePriceStatistic.title"
59
+              :data="salePriceStatistic.data"
60
+            />
124
           </div>
61
           </div>
125
 
62
 
126
           <div class="col-12">
63
           <div class="col-12">
127
-            <div class="card">
128
-              <h5>Pendapatan</h5>
129
-
130
-              <Chart type="bar" :data="barData" />
131
-            </div>
64
+            <CardCart
65
+              type="bar"
66
+              :title="purchasePriceStatistic.title"
67
+              :data="purchasePriceStatistic.data"
68
+            />
132
           </div>
69
           </div>
133
         </div>
70
         </div>
134
       </div>
71
       </div>