mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 13:01:00 +00:00
refactor(ui): adopt the React 19 ref-as-prop idiom and the toJson helper
Drop forwardRef from the textarea and native-select primitives — the last two holdouts under components/ui — so they accept ref as a plain prop like the input primitive already does. No call site passes a ref to either, and the React 19 prop path is the forward-looking shape. Route the inventory-consumption JSON-column write through the shared toJson helper instead of an inline `as unknown as Prisma.InputJsonValue` cast, keeping the WHY of the escape hatch in one place.
This commit is contained in:
1 parent
d50e277a2b
commit
151a56fc66
3 files changed
+17
-16
No files matched your search
@@ -59,13 +59,14 @@ const NATIVE_SELECT_CLASS =
|
||||
|
||||
export type NativeSelectProps = React.SelectHTMLAttributes<HTMLSelectElement>;
|
||||
|
||||
export const NativeSelect = React.forwardRef<
|
||||
HTMLSelectElement,
|
||||
NativeSelectProps
|
||||
>(function NativeSelect({ className, children, style, ...props }, ref) {
|
||||
export function NativeSelect({
|
||||
className,
|
||||
children,
|
||||
style,
|
||||
...props
|
||||
}: NativeSelectProps) {
|
||||
return (
|
||||
<select
|
||||
ref={ref}
|
||||
data-slot="native-select"
|
||||
className={cn(NATIVE_SELECT_CLASS, className)}
|
||||
style={style}
|
||||
@@ -74,4 +75,4 @@ export const NativeSelect = React.forwardRef<
|
||||
{children}
|
||||
</select>
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -39,13 +39,13 @@ import { cn } from "@/lib/utils";
|
||||
* Composition is via `cn(…)` so callers can override anything — the
|
||||
* primitive defaults are the strict pass, not the only pass.
|
||||
*/
|
||||
const Textarea = React.forwardRef<
|
||||
HTMLTextAreaElement,
|
||||
React.ComponentProps<"textarea">
|
||||
>(function Textarea(
|
||||
{ className, autoComplete, autoCapitalize, spellCheck, ...props },
|
||||
ref,
|
||||
) {
|
||||
function Textarea({
|
||||
className,
|
||||
autoComplete,
|
||||
autoCapitalize,
|
||||
spellCheck,
|
||||
...props
|
||||
}: React.ComponentProps<"textarea">) {
|
||||
const resolvedAutoComplete = autoComplete ?? "off";
|
||||
const resolvedAutoCapitalize = autoCapitalize ?? "sentences";
|
||||
const resolvedSpellCheck = spellCheck ?? true;
|
||||
@@ -53,7 +53,6 @@ const Textarea = React.forwardRef<
|
||||
|
||||
return (
|
||||
<textarea
|
||||
ref={ref}
|
||||
data-slot="textarea"
|
||||
autoComplete={resolvedAutoComplete}
|
||||
autoCapitalize={resolvedAutoCapitalize}
|
||||
@@ -71,6 +70,6 @@ const Textarea = React.forwardRef<
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export { Textarea };
|
||||
@@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
import { Prisma, type PrismaClient } from "@/generated/prisma/client";
|
||||
import { toJson } from "@/lib/db";
|
||||
import { annotate } from "@/lib/logging/context";
|
||||
import {
|
||||
computeExpiresAt,
|
||||
@@ -263,7 +264,7 @@ export async function consumeForIntake(input: {
|
||||
// registered later when a sync replay revisits the row.
|
||||
await tx.medicationIntakeEvent.update({
|
||||
where: { id: eventId },
|
||||
data: { inventoryConsumption: stamp as unknown as Prisma.InputJsonValue },
|
||||
data: { inventoryConsumption: toJson(stamp) },
|
||||
});
|
||||
|
||||
annotate({
|
||||
|
||||
Reference in new issue
Block a user