diff --git a/apps/web/components/dashboard/categories/CategoriesView.tsx b/apps/web/components/dashboard/categories/CategoriesView.tsx index b8dbe3e..afb4fc0 100644 --- a/apps/web/components/dashboard/categories/CategoriesView.tsx +++ b/apps/web/components/dashboard/categories/CategoriesView.tsx @@ -57,7 +57,7 @@ export default function CategoriesView() { {c.name} {c.description} - categoryStats[c.id].numEntries + {c.id} {children} - Metrics for {hour.date} at {hour.datetime} + Metrics for {hour.date} at {spacetime(hour.datetime).format("{hour} {ampm}")} {(hour.measurements && hour.measurements.length > 0) || pendingMeasurement ? (<> {/*
Measurements
*/}
- {hour.measurements.map(measurement => { + {hour.measurements!.map(measurement => { const metric = metrics.find(m => m.id === measurement.metricId); if (metric!.type === "timeseries") { return (
-
-
{metric.name}
+
+
{metric!.name}
- { - setValue({ - metricId: metric.id, - hourId: hour.id, - dayId: hour.dayId, - value: parseFloat(value), - }); - }} /> + { + setValue({ + metricId: metric!.id, + hourId: hour.id!, + dayId: hour.dayId, + value: parseFloat(value!), + }); + }} /> { - decrement({ metricId: metric.id, hourId: hour.id, dayId: hour.dayId }); + decrement({ metricId: metric!.id!, hourId: hour.id! }); }} />
diff --git a/packages/trpc/routers/hours.ts b/packages/trpc/routers/hours.ts index 992a9d2..bb9e868 100644 --- a/packages/trpc/routers/hours.ts +++ b/packages/trpc/routers/hours.ts @@ -154,7 +154,7 @@ export const hoursAppRouter = router({ .input( z.object({ date: z.string(), - hourTime: z.number(), + datetime: z.date(), dayId: z.string(), code: z.string().nullish(), comment: z.string().nullable().optional(), @@ -205,7 +205,7 @@ export const hoursAppRouter = router({ .set(newProps) .where( and( - eq(hours.time, input.hourTime), + eq(hours.datetime, input.datetime), eq(hours.dayId, input.dayId), eq(hours.userId, ctx.user!.id) ) @@ -216,7 +216,7 @@ export const hoursAppRouter = router({ // ...hourRes[0] // }; - return hourJoinsQuery(ctx, input.hourTime, input.dayId,); + return hourJoinsQuery(ctx, input.datetime, input.dayId,); }), diff --git a/packages/trpc/routers/metrics.ts b/packages/trpc/routers/metrics.ts index 0e9162d..764fce0 100644 --- a/packages/trpc/routers/metrics.ts +++ b/packages/trpc/routers/metrics.ts @@ -1,5 +1,5 @@ import { TRPCError } from "@trpc/server"; -import { and, desc, eq, inArray, notExists } from "drizzle-orm"; +import { and, asc, desc, eq, inArray, notExists } from "drizzle-orm"; import { z } from "zod"; import { DatabaseError, ErrorCodes } from "@lifetracker/db"; @@ -17,7 +17,9 @@ export const metricsAppRouter = router({ const dbMeasurements = await ctx.db .select() .from(metrics) - .where(eq(metrics.userId, ctx.user.id)); + .where(eq(metrics.userId, ctx.user.id)) + .orderBy(asc(metrics.name)) + ; return dbMeasurements; }),