From 4d08c92af56b89d8e79fb6eaf65873dc99fc3a12 Mon Sep 17 00:00:00 2001 From: Madhura68 Date: Sat, 25 Apr 2026 19:17:12 +0200 Subject: [PATCH] =?UTF-8?q?feat(todos):=20fix=20QuickInput=20=E2=80=94=20a?= =?UTF-8?q?llow=20input=20without=20a=20product=20selected?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Product select is no longer required; 'Geen product' is the default - Input and submit button are no longer disabled for users with no products - Form resets only on success (useEffect on state.success) instead of resetting on every submit including failures - Inline error from server action is now displayed below the form - Removed 'Maak eerst een product aan' message that blocked the form Co-Authored-By: Claude Sonnet 4.6 --- components/todos/todo-list.tsx | 70 ++++++++++++++++------------------ 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/components/todos/todo-list.tsx b/components/todos/todo-list.tsx index a325261..1cdfe0f 100644 --- a/components/todos/todo-list.tsx +++ b/components/todos/todo-list.tsx @@ -41,39 +41,39 @@ interface TodoListProps { } function QuickInput({ products, isDemo }: { products: Product[]; isDemo: boolean }) { - const [, formAction] = useActionState(createTodoAction, undefined) + const [state, formAction] = useActionState(createTodoAction, undefined) const ref = useRef(null) + useEffect(() => { + if (state?.success) ref.current?.reset() + }, [state]) + return ( -
setTimeout(() => ref.current?.reset(), 0)} - className="flex gap-2 mb-6" - > - - - - - -
+
+
+ + + + + +
+ {typeof state?.error === 'string' && ( +

{state.error}

+ )} +
) } @@ -260,15 +260,11 @@ export function TodoList({ todos, products, isDemo }: TodoListProps) {
- {products.length === 0 && ( -

Maak eerst een product aan om todo's toe te voegen.

- )} - - {todos.length === 0 && products.length > 0 ? ( + {todos.length === 0 ? (

Geen todo's. Voeg er een toe hierboven.

- ) : todos.length > 0 ? ( + ) : ( <>
{open.map(todo => ( @@ -321,7 +317,7 @@ export function TodoList({ todos, products, isDemo }: TodoListProps) {
)} - ) : null} + )} {promotePbi && ( setPromotePbi(null)} />