import type { ActionFunctionArgs } from "react-router";
import { authenticate } from "../shopify.server";
import db from "../db.server";

export const action = async ({ request }: ActionFunctionArgs) => {
  const { shop } = await authenticate.webhook(request);
  await db.session.deleteMany({ where: { shop } });
  await db.appSettings.deleteMany({ where: { shop } });
  await db.deliveryRule.deleteMany({ where: { shop } });
  await db.deliveryOrder.deleteMany({ where: { shop } });
  await db.brochureOrderRequest.deleteMany({ where: { shop } });
  return new Response();
};
