import React from 'react';
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout';
import { Head } from '@inertiajs/react';
import { formatIDR } from '@/utils';
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
BarElement,
Title,
Tooltip,
Legend,
} from 'chart.js'
import { Bar } from 'react-chartjs-2'
ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip)
export default function Dashboard(props) {
const {
total_sale_today, total_item_today, total_product, total_customer,
sale_days,
list_favorite_product,
list_customer
} = props
const options = {
responsive: true,
};
const data = {
labels: sale_days.map((item) => item.date),
datasets: [
{
label: 'Sales',
data: sale_days.map((item) => item.count),
// backgroundColor: 'rgb(87, 13, 248, 0.5)', //rgb(87, 13, 248, 0.5) //rgba(255, 99, 132, 0.5)
backgroundColor: [
'rgba(201, 203, 207, 1)',
'rgba(255, 159, 64, 1)',
'rgba(255, 205, 86, 1)',
'rgba(75, 192, 192, 1)',
'rgba(54, 162, 235, 1)',
'rgba(153, 102, 255, 1)',
'rgba(255, 99, 132, 1)'
],
},
],
}
return (
Total Penjualan
Hari Ini
{total_sale_today}
Total Barang Terjual
Hari Ini
{total_item_today}
Jumlah Barang
{total_product}
Jumlah Pelanggan
{total_customer}
{/* Chart : jumlah transaksi 7 hari terkahir */}
Penjualan 7 Hari Terakhir
{/* list produk paling laris dengan jumlah penjualan */}
Barang Terlaris
Kode
|
Barang
|
Jumlah
|
{list_favorite_product.map(product => (
{product.product.code}
|
{product.product.name}
|
{formatIDR(product.qty)}
|
))}
{/* list customer yang bertransaksi dengan total transaksi */}
Pelanggan Hari Ini
Pelanggan
|
Total Belanja
|
{list_customer.map(customer => (
{customer.customer !== null ? customer.customer.name : 'Umum'}
|
{formatIDR(customer.stotal)}
|
))}
);
}