Turn a saved draft into the finished Rule, and greet with congratulations.

This commit is contained in:
adilallo committed 2026-11-22 18:01:56 -07:00
1 parent a2815ae05f
commit 851133e56d
11 files changed
+150 -23

No files matched your search

+2 -9
View File
@@ -11,7 +11,7 @@ import { apiRoute } from "../../../../lib/server/apiRoute";
import { putDraftBodySchema } from "../../../../lib/server/validation/createFlowSchemas";
import { readLimitedJson } from "../../../../lib/server/validation/requestBody";
import { jsonFromZodError } from "../../../../lib/server/validation/zodHttp";
import { deleteUploadsForDraft } from "../../../../lib/server/uploads/deleteUploadedFiles";
import { deleteRuleDraftForUser } from "../../../../lib/server/ruleDrafts";
import { linkUploadsToDraft } from "../../../../lib/server/uploads/linkUploads";
export const GET = apiRoute("drafts.me.get", async () => {
@@ -92,14 +92,7 @@ export const DELETE = apiRoute("drafts.me.delete", async () => {
// Idempotent: missing draft is a no-op so callers can fire-and-forget after
// publish / exit without worrying about prior state.
const draft = await prisma.ruleDraft.findUnique({
where: { userId: user.id },
select: { id: true },
});
if (draft) {
await deleteUploadsForDraft(draft.id);
}
await prisma.ruleDraft.deleteMany({ where: { userId: user.id } });
await deleteRuleDraftForUser(user.id);
return NextResponse.json({ ok: true });
});