Compare commits

...

2 Commits

Author SHA1 Message Date
Cauê Faleiros
f92348958b Make dashboard trend line optional
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m6s
2026-07-14 14:51:07 -03:00
Cauê Faleiros
ba9cc3ad01 Fix large sold quantity icon layout 2026-07-14 14:23:28 -03:00
3 changed files with 28 additions and 12 deletions

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"

View File

@@ -493,7 +493,7 @@ const ProductGroupDetails = () => {
<div className="overflow-x-auto"> <div className="overflow-x-auto">
<table className="w-full min-w-[1100px] table-fixed text-left text-sm"> <table className="w-full min-w-[1100px] table-fixed text-left text-sm">
<colgroup> <colgroup>
<col className="w-[120px]" /> <col className="w-[150px]" />
<col className="w-[360px]" /> <col className="w-[360px]" />
<col className="w-[120px]" /> <col className="w-[120px]" />
<col className="w-[100px]" /> <col className="w-[100px]" />
@@ -533,9 +533,9 @@ const ProductGroupDetails = () => {
</span> </span>
</td> </td>
<td className="px-6 py-2.5 whitespace-nowrap"> <td className="px-6 py-2.5 whitespace-nowrap">
<div className="flex items-center gap-2"> <div className="flex min-w-0 items-center gap-2">
<Package className="h-3.5 w-3.5 text-zinc-400 dark:text-dark-muted" /> <Package className="h-3.5 w-3.5 shrink-0 text-zinc-400 dark:text-dark-muted" />
<span className="font-bold text-zinc-900 dark:text-dark-text">{formatNumber(row.quantitySold)} un.</span> <span className="min-w-0 font-bold tabular-nums text-zinc-900 dark:text-dark-text">{formatNumber(row.quantitySold)} un.</span>
</div> </div>
</td> </td>
<td className="px-6 py-2.5 whitespace-nowrap font-bold text-zinc-900 dark:text-dark-text">{formatNumber(row.stock)} un.</td> <td className="px-6 py-2.5 whitespace-nowrap font-bold text-zinc-900 dark:text-dark-text">{formatNumber(row.stock)} un.</td>

View File

@@ -626,7 +626,7 @@ const Products = () => {
<col className="w-[120px]" /> <col className="w-[120px]" />
<col className="w-[390px]" /> <col className="w-[390px]" />
<col className="w-[170px]" /> <col className="w-[170px]" />
<col className="w-[130px]" /> <col className="w-[150px]" />
<col className="w-[120px]" /> <col className="w-[120px]" />
<col className="w-[130px]" /> <col className="w-[130px]" />
<col className="w-[130px]" /> <col className="w-[130px]" />
@@ -670,9 +670,9 @@ const Products = () => {
</span> </span>
</td> </td>
<td className="px-6 py-2.5 whitespace-nowrap"> <td className="px-6 py-2.5 whitespace-nowrap">
<div className="flex items-center gap-2"> <div className="flex min-w-0 items-center gap-2">
<Package className="w-3.5 h-3.5 text-zinc-400 dark:text-dark-muted" /> <Package className="h-3.5 w-3.5 shrink-0 text-zinc-400 dark:text-dark-muted" />
<span className="font-bold text-zinc-900 dark:text-dark-text">{formatNumber(product.quantitySold)} un.</span> <span className="min-w-0 font-bold tabular-nums text-zinc-900 dark:text-dark-text">{formatNumber(product.quantitySold)} un.</span>
</div> </div>
</td> </td>
<td className="px-6 py-2.5 font-bold text-zinc-900 dark:text-dark-text whitespace-nowrap">{formatNumber(product.stock)} un.</td> <td className="px-6 py-2.5 font-bold text-zinc-900 dark:text-dark-text whitespace-nowrap">{formatNumber(product.stock)} un.</td>