Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+24
-2
@@ -1,11 +1,14 @@
|
||||
import { ActionFunction, LoaderFunctionArgs, MetaFunction, useLoaderData } from "react-router";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { getTenantWithProfile, updateTenantTheme, TenantWithProfile } from "~/utils/db/tenants.db.server";
|
||||
import { getTenantWithProfile, updateTenantTheme, updateTenantAnrede, TenantWithProfile } from "~/utils/db/tenants.db.server";
|
||||
import { getTenantIdFromUrl } from "~/utils/services/.server/urlService";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import EditPageLayout from "~/components/ui/layouts/EditPageLayout";
|
||||
import UpdateTenantFormTheme from "~/components/core/tenants/forms/UpdateTenantFormTheme";
|
||||
import UpdateTenantFormAnrede from "~/components/core/tenants/forms/UpdateTenantFormAnrede";
|
||||
import { validateCSRFToken } from "~/utils/session.server";
|
||||
import { isAnrede } from "@hivegrid/i18n";
|
||||
import { anredeCookie } from "~/locale/anrede.server";
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
@@ -55,6 +58,22 @@ export const action: ActionFunction = async ({ request, params }) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (action === "update-anrede") {
|
||||
const anrede = form.get("anrede")?.toString();
|
||||
if (!isAnrede(anrede)) {
|
||||
return badRequest({ error: t("shared.invalidForm") });
|
||||
}
|
||||
try {
|
||||
// Persist the tenant-wide default and pin the choice for this browser via
|
||||
// the `_anrede` cookie so it takes effect immediately on revalidation.
|
||||
await updateTenantAnrede(tenantId, anrede);
|
||||
return Response.json({ success: t("shared.updated") }, { headers: { "Set-Cookie": await anredeCookie.serialize(anrede) } });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return badRequest({ error: t("shared.unexpectedError") });
|
||||
}
|
||||
}
|
||||
|
||||
return badRequest({ error: t("shared.invalidForm") });
|
||||
};
|
||||
|
||||
@@ -65,7 +84,10 @@ export default function ThemeSettingsRoute() {
|
||||
|
||||
return (
|
||||
<EditPageLayout>
|
||||
<UpdateTenantFormTheme tenant={data.tenant} />
|
||||
<div className="space-y-6">
|
||||
<UpdateTenantFormAnrede tenant={data.tenant} />
|
||||
<UpdateTenantFormTheme tenant={data.tenant} />
|
||||
</div>
|
||||
</EditPageLayout>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user