Merge pull request 'Dev' (#113) from Dev into production

Reviewed-on: #113
This commit was merged in pull request #113.
This commit is contained in:
2026-10-14 19:14:48 +00:00
+5 -10
View File
@@ -41,11 +41,6 @@ function isoDate(d: Date) {
return d.toISOString().slice(0, 10)
}
// Shown only when the last TREND_DAYS days have no real ledger activity, so the
// chart isn't a flat zero line before there's any real movement to plot.
const SAMPLE_TREND_IN = [42, 58, 35, 70, 64, 30, 20, 85, 46, 55, 38, 62, 48, 72]
const SAMPLE_TREND_OUT = [30, 40, 45, 38, 50, 22, 15, 60, 33, 47, 28, 44, 36, 58]
export default function DashboardPage() {
const { activeBranchId, branchingEnabled } = useAuth()
@@ -98,13 +93,9 @@ export default function DashboardPage() {
const labels = days.map((d) => new Date(d).toLocaleDateString(undefined, { day: "numeric", month: "short" }))
if (!trend || trend.length === 0) {
return { labels, inData: SAMPLE_TREND_IN, outData: SAMPLE_TREND_OUT }
}
const inByDay = new Map(days.map((d) => [d, 0]))
const outByDay = new Map(days.map((d) => [d, 0]))
for (const entry of trend) {
for (const entry of trend ?? []) {
const day = entry.createdAt.slice(0, 10)
const bucket = entry.direction === "In" ? inByDay : outByDay
if (bucket.has(day)) bucket.set(day, (bucket.get(day) ?? 0) + entry.qtyBase)
@@ -213,6 +204,7 @@ export default function DashboardPage() {
</div>
{loaded ? (
movementTrend.inData.some((v) => v > 0) || movementTrend.outData.some((v) => v > 0) ? (
<div className="h-64 sm:h-72">
<LineChart
labels={movementTrend.labels}
@@ -222,6 +214,9 @@ export default function DashboardPage() {
]}
/>
</div>
) : (
<p className="py-6 text-center text-sm text-muted-foreground">No stock movement in the last {TREND_DAYS} days.</p>
)
) : (
!error && <Skeleton className="h-64 rounded-lg sm:h-72" />
)}