"use server";

import { BUCKETS } from "./schema";
import { createAdminClient } from "./server";
import { requireTenant } from "./tenant-guard";

type DeleteResult = { ok: boolean; error?: string };

export async function deletePropertyImageAction(fileId: string): Promise<DeleteResult> {
  await requireTenant();
  const { storage } = createAdminClient();

  try {
    await storage.deleteFile(BUCKETS.propertyImages, fileId);
    return { ok: true };
  } catch {
    return { ok: false, error: "Fotoğraf silinemedi." };
  }
}
