Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -0,0 +1,77 @@
import { type ActionFunctionArgs, type LoaderFunctionArgs, Form, redirect, useActionData, useLoaderData } from "react-router";
import { useTranslation } from "react-i18next";
import { badRequestResponse, leadActionErrorResponse, loadLeadContext, requireLeadPermission } from "~/utils/integrations/leads/leadAccess.server";
import { auditLeadEvent } from "~/utils/integrations/leads/leadAudit.server";
import { leadAntiSpamAdminPath, LEADS_MODULE_KEY } from "~/utils/integrations/leads/leadRoutePaths";
import { getLeadAntiSpamConfig, updateLeadAntiSpamConfig, type LeadAntiSpamConfigRow, type LeadAntiSpamMode } from "~/utils/integrations/leads/leadService.server";
import ServerError from "~/components/ui/errors/ServerError";
type LoaderData = { config: LeadAntiSpamConfigRow };
const MODES = new Set<LeadAntiSpamMode>(["quarantine", "spam"]);
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
const ctx = await loadLeadContext({ request, params, requireModule: true });
requireLeadPermission(ctx, "leads.admin");
return Response.json({ config: await getLeadAntiSpamConfig(ctx.tenantId) } satisfies LoaderData);
};
function intValue(form: FormData, name: string): number | undefined {
const value = Number.parseInt(form.get(name)?.toString() ?? "", 10);
return Number.isFinite(value) ? value : undefined;
}
export const action = async ({ request, params }: ActionFunctionArgs) => {
const ctx = await loadLeadContext({ request, params, requireModule: true });
requireLeadPermission(ctx, "leads.admin");
const form = await request.formData();
if (form.get("intent")?.toString() !== "save") throw badRequestResponse();
const mode = form.get("mode")?.toString() as LeadAntiSpamMode | undefined;
if (!mode || !MODES.has(mode)) throw badRequestResponse();
try {
const config = await updateLeadAntiSpamConfig({
tenantId: ctx.tenantId,
mode,
perSourcePerHourLimit: intValue(form, "perSourcePerHourLimit"),
perIpPerHourLimit: intValue(form, "perIpPerHourLimit"),
anomalySpikeFactor: intValue(form, "anomalySpikeFactor"),
lostAutoDeleteDays: intValue(form, "lostAutoDeleteDays"),
disposableDomainEnabled: form.get("disposableDomainEnabled") === "on",
honeypotEnabled: form.get("honeypotEnabled") === "on",
fastSubmitEnabled: form.get("fastSubmitEnabled") === "on",
});
await auditLeadEvent({ ctx, action: "lead.anti_spam_updated", targetType: "lead_anti_spam", targetId: config.id });
return redirect(leadAntiSpamAdminPath(params.tenant ?? ""));
} catch (error) {
return leadActionErrorResponse(error);
}
};
export default function LeadAntiSpamRoute() {
const { t } = useTranslation();
const { config } = useLoaderData<LoaderData>();
const actionData = useActionData<{ error?: string }>();
return (
<main className="mx-auto max-w-3xl px-4 py-10" data-ui-id="ui.leads.antiSpam">
<h1 className="text-foreground text-xl font-semibold">{t("leads.antiSpam.title")}</h1>
{actionData?.error ? <p className="mt-4 text-sm text-red-600">{t(actionData.error)}</p> : null}
<Form method="post" className="mt-6 grid gap-4 rounded-md border p-4">
<input type="hidden" name="intent" value="save" />
<label className="grid gap-1 text-sm">{t("leads.antiSpam.field.mode")}<select name="mode" defaultValue={config.mode} className="rounded border px-3 py-2">{Array.from(MODES).map((mode) => <option key={mode} value={mode}>{t(`leads.antiSpam.mode.${mode}`)}</option>)}</select></label>
<label className="grid gap-1 text-sm">{t("leads.antiSpam.field.perSource")}<input name="perSourcePerHourLimit" type="number" defaultValue={config.perSourcePerHourLimit} className="rounded border px-3 py-2" /></label>
<label className="grid gap-1 text-sm">{t("leads.antiSpam.field.perIp")}<input name="perIpPerHourLimit" type="number" defaultValue={config.perIpPerHourLimit} className="rounded border px-3 py-2" /></label>
<label className="grid gap-1 text-sm">{t("leads.antiSpam.field.spike")}<input name="anomalySpikeFactor" type="number" defaultValue={config.anomalySpikeFactor} className="rounded border px-3 py-2" /></label>
<label className="grid gap-1 text-sm">{t("leads.antiSpam.field.lostDelete")}<input name="lostAutoDeleteDays" type="number" defaultValue={config.lostAutoDeleteDays} className="rounded border px-3 py-2" /></label>
<label className="flex items-center gap-2 text-sm"><input type="checkbox" name="disposableDomainEnabled" defaultChecked={config.disposableDomainEnabled} />{t("leads.antiSpam.field.disposable")}</label>
<label className="flex items-center gap-2 text-sm"><input type="checkbox" name="honeypotEnabled" defaultChecked={config.honeypotEnabled} />{t("leads.antiSpam.field.honeypot")}</label>
<label className="flex items-center gap-2 text-sm"><input type="checkbox" name="fastSubmitEnabled" defaultChecked={config.fastSubmitEnabled} />{t("leads.antiSpam.field.fastSubmit")}</label>
<button className="bg-foreground text-background rounded px-4 py-2 text-sm font-medium">{t("leads.actions.save")}</button>
</Form>
</main>
);
}
export function ErrorBoundary() {
return <ServerError />;
}
export const handle = { moduleKey: LEADS_MODULE_KEY };