fix: number inputs not updating values between tabs

This commit is contained in:
trafficlunar 2026-03-29 21:55:40 +01:00
parent 7925c9e2f5
commit 825f74ef6d
4 changed files with 9 additions and 8 deletions

View file

@ -7,7 +7,8 @@ import { ReportStatus } from "@prisma/client";
import { prisma } from "@/lib/prisma"; import { prisma } from "@/lib/prisma";
export default async function Reports() { export default async function Reports() {
const reports = await prisma.report.findMany(); const reports = await prisma.report.findMany({ orderBy: { createdAt: "desc" } });
// TODO: add pagination
const updateStatus = async (formData: FormData) => { const updateStatus = async (formData: FormData) => {
"use server"; "use server";

View file

@ -7,11 +7,11 @@ interface Props {
export default function NumberInputs({ target }: Props) { export default function NumberInputs({ target }: Props) {
const [values, setValues] = useState<Record<string, number>>({ const [values, setValues] = useState<Record<string, number>>({
height: 0, height: target?.height ?? 0,
distance: 0, distance: target?.distance ?? 0,
rotation: 0, rotation: target?.rotation ?? 0,
size: 0, size: target?.size ?? 0,
stretch: 0, stretch: target?.stretch ?? 0,
}); });
if (!target) return null; if (!target) return null;

View file

@ -60,7 +60,7 @@ export default function EyesTab({ instructions }: Props) {
<div className="absolute inset-0 flex flex-col justify-center items-center"> <div className="absolute inset-0 flex flex-col justify-center items-center">
<ColorPicker disabled={currentTab.colorsDisabled} color={colors[tab]} setColor={setColor} tab={tab === 5 ? "eyeliner" : "eyes"} /> <ColorPicker disabled={currentTab.colorsDisabled} color={colors[tab]} setColor={setColor} tab={tab === 5 ? "eyeliner" : "eyes"} />
<NumberInputs target={instructions.current.eyes[currentTab.name]} /> <NumberInputs key={tab} target={instructions.current.eyes[currentTab.name]} />
</div> </div>
</> </>
); );

View file

@ -66,7 +66,7 @@ export default function OtherTab({ instructions }: Props) {
<div className="absolute inset-0 flex flex-col justify-center items-center"> <div className="absolute inset-0 flex flex-col justify-center items-center">
<ColorPicker disabled={tab === 0 || tab === 1} color={colors[tab]} setColor={setColor} tab={tab === 6 ? "eyeliner" : "hair"} /> <ColorPicker disabled={tab === 0 || tab === 1} color={colors[tab]} setColor={setColor} tab={tab === 6 ? "eyeliner" : "hair"} />
<NumberInputs target={instructions.current.other[currentTab.name]} /> <NumberInputs key={tab} target={instructions.current.other[currentTab.name]} />
{tab === 3 && ( {tab === 3 && (
<div className="flex gap-1.5 items-center mt-4"> <div className="flex gap-1.5 items-center mt-4">