Make dashboard trend line optional
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m6s

This commit is contained in:
Cauê Faleiros
2026-07-14 14:51:07 -03:00
parent ba9cc3ad01
commit f92348958b

View File

@@ -303,6 +303,7 @@ const Dashboard = () => {
const [focusedSellerId, setFocusedSellerId] = useState<string | null>(null); const [focusedSellerId, setFocusedSellerId] = useState<string | null>(null);
const [sellerMetric, setSellerMetric] = useState<SellerMetricKey>('revenue'); const [sellerMetric, setSellerMetric] = useState<SellerMetricKey>('revenue');
const [selectedSellerBucket, setSelectedSellerBucket] = useState<string | null>(null); const [selectedSellerBucket, setSelectedSellerBucket] = useState<string | null>(null);
const [showSellerTrend, setShowSellerTrend] = useState(false);
const loadDashboardMetrics = useCallback(async (range: DateRange, options?: { force?: boolean }) => { const loadDashboardMetrics = useCallback(async (range: DateRange, options?: { force?: boolean }) => {
setIsMetricsLoading(true); setIsMetricsLoading(true);
@@ -603,13 +604,28 @@ const Dashboard = () => {
: sellerTimeSeries.isFallback : sellerTimeSeries.isFallback
? sellerMetricConfig.fallbackDescription ? sellerMetricConfig.fallbackDescription
: sellerTimeSeries.dateBucket === 'day' : sellerTimeSeries.dateBucket === 'day'
? `${sellerMetricConfig.trendDescription} Média móvel de 7 dias.` ? sellerMetricConfig.trendDescription
: sellerTimeSeries.dateBucket === 'week' : sellerTimeSeries.dateBucket === 'week'
? 'Evolução agrupada por semana. Média móvel de 4 semanas.' ? 'Evolução agrupada por semana no período selecionado.'
: 'Evolução agrupada por mês. Média móvel de 3 meses.'} : 'Evolução agrupada por mês no período selecionado.'}
</p> </p>
</div> </div>
<div className="flex flex-wrap items-center gap-2"> <div className="flex flex-wrap items-center gap-2">
{!sellerTimeSeries.isHourly && !sellerTimeSeries.isFallback && sellerTimeSeries.movingAverageWindow > 1 && (
<button
type="button"
onClick={() => setShowSellerTrend(current => !current)}
aria-pressed={showSellerTrend}
className={`h-9 cursor-pointer rounded-lg border px-3 text-xs font-bold transition-colors ${
showSellerTrend
? 'border-brand-primary bg-brand-primary/10 text-brand-primary'
: 'border-dark-border bg-dark-input text-dark-muted hover:text-dark-text'
}`}
title="Mostrar ou esconder média móvel"
>
Tendência
</button>
)}
<div className="inline-flex rounded-xl border border-dark-border bg-dark-input p-1"> <div className="inline-flex rounded-xl border border-dark-border bg-dark-input p-1">
{sellerMetricOptions.map(option => ( {sellerMetricOptions.map(option => (
<button <button
@@ -684,7 +700,7 @@ const Dashboard = () => {
content={<SellerMetricTooltip focusedSellerId={effectiveFocusedSellerId} sellers={sellerTimeSeries.sellers} metricConfig={sellerMetricConfig} isHourly={sellerTimeSeries.isHourly} dateBucket={sellerTimeSeries.dateBucket} />} content={<SellerMetricTooltip focusedSellerId={effectiveFocusedSellerId} sellers={sellerTimeSeries.sellers} metricConfig={sellerMetricConfig} isHourly={sellerTimeSeries.isHourly} dateBucket={sellerTimeSeries.dateBucket} />}
cursor={{ stroke: CHART_AXIS_COLOR, strokeDasharray: '4 4' }} cursor={{ stroke: CHART_AXIS_COLOR, strokeDasharray: '4 4' }}
/> />
{!sellerTimeSeries.isHourly && !sellerTimeSeries.isFallback && sellerTimeSeries.movingAverageWindow > 1 && ( {showSellerTrend && !sellerTimeSeries.isHourly && !sellerTimeSeries.isFallback && sellerTimeSeries.movingAverageWindow > 1 && (
<Line <Line
type="monotone" type="monotone"
dataKey="movingAverage" dataKey="movingAverage"