diff --git a/src/components/CreateCampaignButton.tsx b/src/components/CreateCampaignButton.tsx index a8a6052..0fe0046 100644 --- a/src/components/CreateCampaignButton.tsx +++ b/src/components/CreateCampaignButton.tsx @@ -1,12 +1,16 @@ -import { useState } from "react"; -import { pb } from "@/lib/pocketbase"; import { useAuth } from "@/context/auth/AuthContext"; +import { pb } from "@/lib/pocketbase"; import type { Campaign } from "@/lib/types"; +import { useState } from "react"; /** * Button and form for creating a new campaign. Handles UI state and creation logic. */ -export function CreateCampaignButton({ onCreated }: { onCreated?: (campaign: Campaign) => void }) { +export function CreateCampaignButton({ + onCreated, +}: { + onCreated?: (campaign: Campaign) => void; +}) { const [creating, setCreating] = useState(false); const [name, setName] = useState(""); const [loading, setLoading] = useState(false); @@ -29,7 +33,7 @@ export function CreateCampaignButton({ onCreated }: { onCreated?: (campaign: Cam }); setName(""); setCreating(false); - if (onCreated) onCreated({ id: record.id, name: record.name }); + if (onCreated) onCreated(record as Campaign); } catch (e: any) { setError(e?.message || "Failed to create campaign."); } finally { @@ -55,7 +59,7 @@ export function CreateCampaignButton({ onCreated }: { onCreated?: (campaign: Cam className="px-3 py-2 rounded bg-slate-800 text-slate-100 border border-slate-700 focus:outline-none focus:ring-2 focus:ring-violet-500" placeholder="Campaign name" value={name} - onChange={e => setName(e.target.value)} + onChange={(e) => setName(e.target.value)} disabled={loading} autoFocus /> @@ -68,7 +72,11 @@ export function CreateCampaignButton({ onCreated }: { onCreated?: (campaign: Cam