Makes a generic document row
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user