import { PRIMARY_COLOR } from '../../_constants/common'
import RDoughnutChart from '../chart/RDoughnutChart'
import './boxChart.scss'
import { VerticalBarChart } from '../chart/VerticalBarChart'
import { useEffect, useState } from 'react'
import InputDate from '../Auth/InputDate'
import { renderIconButton, renderIconButtonLeft, renderIconDate } from '../renderIcon'
const Btn = ({ icon, isDisabled = false, onClick }) => {
return (
);
};
export default function BoxDoughnutBarChart({
dataDoughnut = [],
dataBarChart = [],
labelsBarChart = [],
dateBarChat,
onSetDateBarChart,
titleDoughnut,
subtitleDoughnut,
titleLine,
subTitleLine,
}) {
const [month, setMonth] = useState(dateBarChat)
const [monthError, setMonthError] = useState('')
const [current, target] = dataDoughnut
const handleMonthChange = (date) => {
setMonth(date)
}
const renderDoughnutSection = () => (
{titleDoughnut &&
{titleDoughnut}
}
{subtitleDoughnut &&
{subtitleDoughnut}
}
{current}
{target > 0 ? target : '...'}
)
const renderBarSection = () => (
{titleLine &&
{titleLine}
}
{subTitleLine &&
{subTitleLine}
}
{dataBarChart.length > 0 ? (
) : (
Không có dữ liệu để hiển thị
)}
)
const handleClickNext = () => {
const newMonth = month.getMonth() + 1;
const newYear = month.getFullYear();
if (newMonth > 11) {
setMonth(new Date(newYear + 1, 0, 1));
} else {
setMonth(new Date(newYear, newMonth, 1));
}
};
const handleClickPrev = () => {
const newMonth = month.getMonth() - 1;
const newYear = month.getFullYear();
if (newMonth < 0) {
setMonth(new Date(newYear - 1, 11, 1));
} else {
setMonth(new Date(newYear, newMonth, 1));
}
};
useEffect(() => {
onSetDateBarChart?.(month);
}, [month]);
const isDisabledNext = new Date(month).getMonth() === new Date().getMonth() && new Date(month).getFullYear() === new Date().getFullYear();
return (
{renderDoughnutSection()}
{renderBarSection()}
)
}