Lifecycle planning, and consistent empty and loading states
- Inventory: end of support and replacement cost per asset; a Lifecycle page showing what ages out year by year and what replacing it will cost; support ending within 90 days in the weekly digest - Lists: a shared empty state saying what is missing, why, and the one thing to do; "nothing matches" with a clear button; skeleton rows instead of empty-looking lists while loading Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
92726568b7
commit
846af02851
50 files changed
+4434
-233
No files matched your search
@@ -5,7 +5,7 @@ import { db } from "../db/client.js";
|
||||
import { assetKinds, assets, servers } from "../db/schema.js";
|
||||
import { requireAuth, requireRole } from "../auth/middleware.js";
|
||||
import { recordAudit } from "../services/audit.js";
|
||||
import { isRealDate } from "../services/inventory.js";
|
||||
import { isRealDate, lifecycleReport } from "../services/inventory.js";
|
||||
import { blanksToFill, differences, hardwareOf } from "../services/inventoryAutofill.js";
|
||||
import { getSettings, updateSettings } from "../services/settingsStore.js";
|
||||
import { asyncHandler } from "../utils/asyncHandler.js";
|
||||
@@ -26,6 +26,8 @@ const assetSchema = z.object({
|
||||
purchaseDate: date,
|
||||
purchasePrice: z.number().min(0).max(1_000_000_000).nullable().optional(),
|
||||
warrantyUntil: date,
|
||||
endOfSupport: date,
|
||||
replacementCost: z.number().min(0).max(1_000_000_000).nullable().optional(),
|
||||
location: text(120),
|
||||
rackUnit: text(30),
|
||||
powerWatts: z.number().int().min(0).max(100_000).nullable().optional(),
|
||||
@@ -46,6 +48,8 @@ function values(d: z.infer<typeof assetSchema>) {
|
||||
purchaseDate: clean(d.purchaseDate),
|
||||
purchasePrice: d.purchasePrice ?? null,
|
||||
warrantyUntil: clean(d.warrantyUntil),
|
||||
endOfSupport: clean(d.endOfSupport),
|
||||
replacementCost: d.replacementCost ?? null,
|
||||
location: clean(d.location),
|
||||
rackUnit: clean(d.rackUnit),
|
||||
powerWatts: d.powerWatts ?? null,
|
||||
@@ -83,6 +87,14 @@ inventoryRouter.get("/", asyncHandler(async (_req, res) => {
|
||||
});
|
||||
}));
|
||||
|
||||
// What ages out when, for planning what to replace: this year, the next few, later, and what has no date.
|
||||
inventoryRouter.get("/lifecycle", asyncHandler(async (req, res) => {
|
||||
const asked = Number(req.query.years);
|
||||
const years = Number.isInteger(asked) && asked >= 1 && asked <= 10 ? asked : 5;
|
||||
const [rows, settings] = await Promise.all([db.select().from(assets), getSettings()]);
|
||||
res.json({ ...lifecycleReport(rows, new Date(), years), currency: settings.inventory.currency });
|
||||
}));
|
||||
|
||||
const configSchema = z.object({
|
||||
currency: z.string().trim().max(8),
|
||||
pricePerKwh: z.number().min(0).max(1000).nullable(),
|
||||
|
||||
Reference in new issue
Block a user