diff --git a/src/components/documents/DocumentLink.tsx b/src/components/documents/DocumentLink.tsx index 5cfe017..5303677 100644 --- a/src/components/documents/DocumentLink.tsx +++ b/src/components/documents/DocumentLink.tsx @@ -1,6 +1,6 @@ -import { makeDocumentPath, useDocumentPath } from "@/lib/documentPath"; +import { makeDocumentPath } from "@/lib/documentPath"; import type { DocumentId } from "@/lib/types"; -import { Link, useParams, useSearch } from "@tanstack/react-router"; +import { Link } from "@tanstack/react-router"; export type Props = React.PropsWithChildren<{ childDocId: DocumentId; diff --git a/src/components/documents/GenericEditForm.tsx b/src/components/documents/GenericEditForm.tsx index 922415c..6765a04 100644 --- a/src/components/documents/GenericEditForm.tsx +++ b/src/components/documents/GenericEditForm.tsx @@ -7,6 +7,7 @@ import { type DocumentField, type FieldType, } from "@/lib/fields"; +import { ToggleInput } from "../form/ToggleInput"; export type GenericFieldType = "multiline" | "singleline" | "checkbox"; @@ -70,12 +71,11 @@ const GenericEditFormField = ({ ); case "toggle": return ( - saveField(!!e.target.value)} - className="accent-emerald-500 w-5 h-5" - id={field.name} + ); } diff --git a/src/components/documents/GenericNewDocumentForm.tsx b/src/components/documents/GenericNewDocumentForm.tsx index 5b51c69..0fb8e74 100644 --- a/src/components/documents/GenericNewDocumentForm.tsx +++ b/src/components/documents/GenericNewDocumentForm.tsx @@ -1,5 +1,5 @@ -import { AutoSaveTextarea } from "@/components/AutoSaveTextarea"; import { useDocumentCache } from "@/context/document/hooks"; +import { DocumentTypeLabel } from "@/lib/documents"; import { getFieldsForType, type DocumentField, @@ -14,6 +14,10 @@ import { type DocumentType, } from "@/lib/types"; import { useCallback, useState } from "react"; +import { BaseForm } from "../form/BaseForm"; +import { MultiLineInput } from "../form/MultiLineInput"; +import { SingleLineInput } from "../form/SingleLineInput"; +import { ToggleInput } from "../form/ToggleInput"; export type GenericFieldType = "multiline" | "singleline" | "checkbox"; @@ -69,83 +73,68 @@ export const GenericNewDocumentForm = ({ setIsLoading(false); }, [campaignId, setIsLoading, setError, docData]); + // TODO: display name for docType return ( -
- {error && ( - // TODO: class and style for errors -
{error}
- )} - { + ( )) } - -
+ /> ); }; const GenericNewFormField = ({ field, value, + isLoading, onUpdate, }: { field: DocumentField; value: ValueForFieldType; - onUpdate: (value: ValueForFieldType) => void; -}) => { - return ( -
- - -
- ); -}; - -const GenericNewFormInput = ({ - field, - value, - onUpdate, -}: { - field: DocumentField; - value: ValueForFieldType; + isLoading: boolean; onUpdate: (value: ValueForFieldType) => void; }) => { switch (field.fieldType) { case "longText": return ( -