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)} />