a tool for shared writing and social publishing
at update/looseleafs 26 lines 740 B view raw
1"use server"; 2 3import { getIdentityData } from "actions/getIdentityData"; 4import { supabaseServerClient } from "supabase/serverClient"; 5 6export async function saveLeafletDraft( 7 leaflet_id: string, 8 metadata: { title: string; description: string }, 9 entitiesToDelete: string[], 10) { 11 let identity = await getIdentityData(); 12 if (!identity || !identity.atp_did) return null; 13 14 // Save as a looseleaf draft in leaflets_to_documents with null document 15 await supabaseServerClient.from("leaflets_to_documents").upsert({ 16 leaflet: leaflet_id, 17 document: null, 18 title: metadata.title, 19 description: metadata.description, 20 }); 21 22 await supabaseServerClient 23 .from("entities") 24 .delete() 25 .in("id", entitiesToDelete); 26}