Makes a generic document row

This commit is contained in:
2025-05-31 17:19:50 -07:00
parent d5dfa8c30a
commit 6b6636d695
6 changed files with 82 additions and 26 deletions

View File

@@ -1,13 +1,19 @@
// SecretForm.tsx
// Form for adding a new secret to a session.
import { useState } from "react";
import type { Session, Secret } from "@/lib/types";
import type { Secret } from "@/lib/types";
import { pb } from "@/lib/pocketbase";
/**
* Renders a form to add a new secret. Calls onCreate with the new secret document.
*/
export const SecretForm = ({ session, onCreate }: { session: Session; onCreate: (secret: Secret) => Promise<void>; }) => {
export const SecretForm = ({
campaign,
onCreate,
}: {
campaign: string;
onCreate: (secret: Secret) => Promise<void>;
}) => {
const [newSecret, setNewSecret] = useState("");
const [adding, setAdding] = useState(false);
const [error, setError] = useState<string | null>(null);
@@ -19,7 +25,7 @@ export const SecretForm = ({ session, onCreate }: { session: Session; onCreate:
setError(null);
try {
const secretDoc: Secret = await pb.collection("documents").create({
campaign: session.campaign,
campaign,
data: {
secret: {
text: newSecret,