"use server";
import { db } from "@/server/db";
import { stakes } from "@/server/db/schema";
import { eq } from "drizzle-orm";
import { StatusLabelProps } from "../_components/status-label";
export const saveStake = async (e: FormData, id: string) => {
const amount = e.get("amount") as string;
const status = e.get("status") as string;
await db
.update(stakes)
.set({
amount,
stakeStatus: status as StatusLabelProps["status"],
})
.where(eq(stakes.id, id));
return { success: true };
};
this is my file where i've action function I import that function and pass it in client component form like that
<form
action={async (e) => {
await saveStake(e, id);
}}
>
but throws error
Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.