Skip to content

Commit

Permalink
Merge pull request #163 from Hexastack/fix/i18n-customblock-settings
Browse files Browse the repository at this point in the history
fix: i18n custom blocks settings
  • Loading branch information
marrouchi authored Oct 6, 2024
2 parents fa49158 + 123f9bf commit e70c705
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions api/src/setting/schemas/setting.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/components/settings/SettingInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/setting.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface ISettingAttributes {
config?: Record<string, any>;
weight?: number;
title?: string;
help?: string;
}

export interface ISettingStub extends IBaseSchema, ISettingAttributes {}
Expand Down

0 comments on commit e70c705

Please sign in to comment.