Improve admin UX: hub i18n, dynamic topbar, settings strings, staff logs DataTable.
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
||||
Shield,
|
||||
UserPlus,
|
||||
} from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useState } from "react";
|
||||
import { saveManagedSettings } from "@/actions/admin-settings";
|
||||
import { Button } from "@/components/ui/button";
|
||||
@@ -45,6 +46,7 @@ export function CmsSettingsForm({
|
||||
}) {
|
||||
const [values, setValues] = useState(initialValues);
|
||||
const { isPending, run } = useServerAction();
|
||||
const t = useTranslations("pages.admin.settings");
|
||||
|
||||
function handleChange(key: string, value: string) {
|
||||
setValues((prev) => ({ ...prev, [key]: value }));
|
||||
@@ -58,8 +60,8 @@ export function CmsSettingsForm({
|
||||
normalized[key] = values[key] === "1" ? "1" : "0";
|
||||
}
|
||||
run(() => saveManagedSettings({ settings: normalized }), {
|
||||
successMessage: "Settings saved.",
|
||||
errorMessage: "Could not save settings.",
|
||||
successMessage: t("saved"),
|
||||
errorMessage: t("saveFailed"),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,13 +85,11 @@ export function CmsSettingsForm({
|
||||
) : (
|
||||
<Save className="mr-2 h-4 w-4" />
|
||||
)}
|
||||
Save settings
|
||||
{isPending ? t("form.saving") : t("saveSettings")}
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
You can view settings but need edit permission to change them.
|
||||
</p>
|
||||
<p className="text-sm text-muted-foreground">{t("viewOnly")}</p>
|
||||
)}
|
||||
</form>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user