|
|
@ -2,9 +2,19 @@ import { PRIMARY_COLOR } from '../../_constants/common' |
|
|
|
import RDoughnutChart from '../chart/RDoughnutChart' |
|
|
|
import RDoughnutChart from '../chart/RDoughnutChart' |
|
|
|
import './boxChart.scss' |
|
|
|
import './boxChart.scss' |
|
|
|
import { VerticalBarChart } from '../chart/VerticalBarChart' |
|
|
|
import { VerticalBarChart } from '../chart/VerticalBarChart' |
|
|
|
import { useState } from 'react' |
|
|
|
import { useEffect, useState } from 'react' |
|
|
|
import InputDate from '../Auth/InputDate' |
|
|
|
import InputDate from '../Auth/InputDate' |
|
|
|
import { renderIconDate } from '../renderIcon' |
|
|
|
import { renderIconButton, renderIconButtonLeft, renderIconDate } from '../renderIcon' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Btn = ({ icon, isDisabled = false, onClick }) => { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<div className='d-flex justify-content-center align-items-center'> |
|
|
|
|
|
|
|
<button className={`d-flex custom-button ${isDisabled ? "button-disable" : ""}`} onClick={onClick} disabled={isDisabled}> |
|
|
|
|
|
|
|
<div>{icon}</div> |
|
|
|
|
|
|
|
</button> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default function BoxDoughnutBarChart({ |
|
|
|
export default function BoxDoughnutBarChart({ |
|
|
|
dataDoughnut = [],
|
|
|
|
dataDoughnut = [],
|
|
|
@ -23,7 +33,6 @@ export default function BoxDoughnutBarChart({ |
|
|
|
|
|
|
|
|
|
|
|
const handleMonthChange = (date) => { |
|
|
|
const handleMonthChange = (date) => { |
|
|
|
setMonth(date) |
|
|
|
setMonth(date) |
|
|
|
onSetDateBarChart?.(date) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const renderDoughnutSection = () => ( |
|
|
|
const renderDoughnutSection = () => ( |
|
|
@ -59,26 +68,58 @@ export default function BoxDoughnutBarChart({ |
|
|
|
)} |
|
|
|
)} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
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 ( |
|
|
|
return ( |
|
|
|
<div className="box-chart-container"> |
|
|
|
<div className="box-chart-container"> |
|
|
|
{renderDoughnutSection()} |
|
|
|
{renderDoughnutSection()} |
|
|
|
{renderBarSection()} |
|
|
|
{renderBarSection()} |
|
|
|
<div className='d-flex justify-content-center align-item-center' style={{width: 140, alignSelf: 'center'}}> |
|
|
|
<div className='d-flex justify-content-center align-items-center'> |
|
|
|
<InputDate |
|
|
|
<Btn icon={renderIconButtonLeft()} isDisabled={false} onClick={handleClickPrev} /> |
|
|
|
maxDate={new Date()} |
|
|
|
<div className='d-flex justify-content-center align-item-center' style={{width: 140, alignSelf: 'center'}}> |
|
|
|
label={''} |
|
|
|
<InputDate |
|
|
|
styleContainer={{flex: 1}} |
|
|
|
maxDate={new Date()} |
|
|
|
value={month} |
|
|
|
label={''} |
|
|
|
setValue={handleMonthChange} |
|
|
|
styleContainer={{flex: 1}} |
|
|
|
name="month" |
|
|
|
value={month} |
|
|
|
renderLabelIcon={renderIconDate} |
|
|
|
setValue={handleMonthChange} |
|
|
|
errorText={monthError} |
|
|
|
name="month" |
|
|
|
errorAbsolute={true} |
|
|
|
renderLabelIcon={renderIconDate} |
|
|
|
popperPlacement='top' |
|
|
|
errorText={monthError} |
|
|
|
typeErrText='underAbsolute' |
|
|
|
errorAbsolute={true} |
|
|
|
isMonthPicker |
|
|
|
popperPlacement='top' |
|
|
|
/> |
|
|
|
typeErrText='underAbsolute' |
|
|
|
|
|
|
|
isMonthPicker |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<Btn icon={renderIconButton()} isDisabled={isDisabledNext} onClick={handleClickNext} /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
) |
|
|
|
) |
|
|
|