fix: i18n custom blocks settings

This commit is contained in:
Mohamed Marrouchi 2024-10-06 21:01:00 +01:00
parent fa491584ac
commit 123f9bf1a9
3 changed files with 14 additions and 3 deletions

View File

@ -7,6 +7,7 @@
*/
import { Prop, Schema, SchemaFactory, ModelDefinition } from '@nestjs/mongoose';
import { Transform } from 'class-transformer';
import { IsArray, IsIn } from 'class-validator';
import { BaseSchema } from '@/utils/generics/base-schema';
@ -45,6 +46,13 @@ export class Setting extends BaseSchema {
@Prop({ type: JSON, default: {} })
config?: Record<string, any>;
@Prop({
type: String,
default: '',
})
@Transform(({ obj }) => obj.help || undefined)
help?: string;
@Prop({
type: Number,
default: 0,

View File

@ -36,9 +36,11 @@ const SettingInput: React.FC<RenderSettingInputProps> = ({
}) => {
const { t } = useTranslate();
const nestedLabel = setting.label as TNestedTranslation<"label">;
const nestedHelp = setting.label as TNestedTranslation<"help">;
const label = t("label", nestedLabel);
const helperText = t("help", nestedHelp);
const nestedHelp = setting.help as TNestedTranslation<"help">;
const label = t("label", nestedLabel, { defaultValue: nestedLabel });
const helperText = nestedHelp
? t("help", nestedHelp, { defaultValue: nestedHelp })
: "";
switch (setting.type) {
case "text":

View File

@ -93,6 +93,7 @@ export interface ISettingAttributes {
config?: Record<string, any>;
weight?: number;
title?: string;
help?: string;
}
export interface ISettingStub extends IBaseSchema, ISettingAttributes {}