diff --git a/src/leihs/inventory/client/components/basic_form_field.cljs b/src/leihs/inventory/client/components/basic_form_field.cljs
new file mode 100644
index 00000000..9d522f2d
--- /dev/null
+++ b/src/leihs/inventory/client/components/basic_form_field.cljs
@@ -0,0 +1,57 @@
+(ns leihs.inventory.client.components.basic-form-field
+ (:require
+ ["@@/checkbox" :refer [Checkbox]]
+ ["@@/dropzone" :refer [Dropzone]]
+ ["@@/form" :refer [FormField FormItem FormLabel FormControl FormDescription FormMessage]]
+ ["@@/input" :refer [Input]]
+ ["@@/textarea" :refer [Textarea]]
+ [leihs.inventory.client.lib.utils :refer [cj jc]]
+ [leihs.inventory.client.routes.models.create.components.accessories-list :refer [AccessoryList]]
+ [uix.core :as uix :refer [defui $]]))
+
+comment "available form fields"
+(def fields-map
+ {"input" Input
+ "dropzone" Dropzone
+ "textarea" Textarea
+ "checkbox" Checkbox
+ "accessory-list" AccessoryList})
+
+(defui main
+ "Main function for rendering a form field component.
+
+ Arguments:
+ - `control`: The control element for the form field.
+ - `input`: A map containing input properties.
+ - `class-name`: A string for additional CSS class names for the input field
+ - `label`: A boolean indicating whether to display the label.
+ - `description`: A boolean indicating whether to display the description.
+ - `name`: The name of the form field.
+
+ Default values:
+ - `label`: true
+ - `description`: true
+ - `class-name`: empty string
+ - `name`: The name from the `input` map."
+
+ [{:keys [control input class-name
+ label description name]
+ :or {label true description true
+ class-name "" name (:name input)}}]
+
+ (let [comp (get fields-map (:component input))]
+ (when comp
+ ($ FormField {:control (cj control)
+ :name name
+ :render #($ FormItem
+ (when label ($ FormLabel (:label input)))
+ ($ FormControl
+ ($ comp (merge
+ {:class-name class-name}
+ (:props input)
+ (:field (jc %)))))
+
+ (when description ($ FormDescription
+ ($ :<> (:description input))))
+
+ ($ FormMessage))}))))
diff --git a/src/leihs/inventory/client/components/react/scrollspy/context.jsx b/src/leihs/inventory/client/components/react/scrollspy/context.jsx
index f7658124..ff6c9417 100644
--- a/src/leihs/inventory/client/components/react/scrollspy/context.jsx
+++ b/src/leihs/inventory/client/components/react/scrollspy/context.jsx
@@ -1,4 +1,4 @@
-import React, { useRef, useState } from "react"
+import React, { useState } from "react"
// Create the context
const ScrollspyContext = React.createContext()
@@ -10,9 +10,12 @@ export const ScrollspyProvider = ({ children }) => {
// Function to add an item
function addItem(item) {
- if (items.find((i) => i.id === item.id)) return
-
- setItems((prev) => [...prev, item])
+ setItems((prev) => {
+ if (prev.find((i) => i.id === item.id)) {
+ return [...prev]
+ }
+ return [...prev, item]
+ })
}
const value = {
diff --git a/src/leihs/inventory/client/components/react/scrollspy/scrollspy.jsx b/src/leihs/inventory/client/components/react/scrollspy/scrollspy.jsx
index 6b166d34..76a95657 100644
--- a/src/leihs/inventory/client/components/react/scrollspy/scrollspy.jsx
+++ b/src/leihs/inventory/client/components/react/scrollspy/scrollspy.jsx
@@ -7,7 +7,9 @@ import { cn } from "@@/utils"
export function Scrollspy({ children, className }) {
return (