I've the following code, I'd like to pass in the workspace Id to the deleteAction, and also disable it when deleting, and show an error on the UI when it fails, but not sure how to resolve the .bind thing.
export const WorkspaceButtons = ({ workspaceId }: { workspaceId: string }) => {
...
const [deleteState, deleteAction, isDeleting] = useActionState(
deleteWorkspace.bind(null, workspaceId),
{
error: null,
}
);
...
return <>
...
<form action={deleteWorkspace.bind(null, workspaceId)}>
<Button
disabled={isDeleting}
type="submit"
onClick={async () => {
console.log("Delete workspace clicked");
}}
variant={"destructive"}
className="w-full"
>
{t("WORKSPACE_DETAILS.DELETE")}
</Button>
</form>
</>;