) => {
+ return (
+
+ {
+ // The type checker seems to lose the types when using Object.entries here.
+ Object.entries(fields).map(
+ ([fieldName, fieldType]: [string, unknown]) => (
+
+ ),
+ )
+ }
+
+ );
+};
+
+const GenericEditFormField = ({
+ doc,
+ fieldName,
+ fieldType,
+}: {
+ doc: T;
+ fieldName: keyof T["data"];
+ fieldType: GenericFieldType;
+}) => {
+ const { dispatch } = useDocumentCache();
+
+ // The type checker really doesn't like indexing into this type implicitly, so we'll store it in a temporary to give it the right hints.
+ const data = doc.data as T["data"];
+
+ async function saveField(value: string) {
+ const updated: T = await pb.collection("documents").update(doc.id, {
+ data: {
+ ...doc.data,
+ [fieldName]: value,
+ },
+ });
+ dispatch({ type: "setDocument", doc: updated });
+ }
+
+ switch (fieldType) {
+ case "multiline":
+ return (
+
+ );
+ case "singleline":
+ return (
+
+ );
+ case "checkbox":
+ return (
+ saveField(e.target.value)}
+ className="accent-emerald-500 w-5 h-5"
+ />
+ );
+ }
+};
diff --git a/src/components/documents/NewCampaignDocumentForm.tsx b/src/components/documents/NewCampaignDocumentForm.tsx
index 40154ef..5b09628 100644
--- a/src/components/documents/NewCampaignDocumentForm.tsx
+++ b/src/components/documents/NewCampaignDocumentForm.tsx
@@ -20,6 +20,8 @@ export const NewCampaignDocumentForm = ({
switch (docType) {
case "session":
return ;
+ case "thread":
+ return ;
default:
throw new Error(
`Rendered NewCampaignDocumentForm with unsupported docType: ${docType}`,