diff --git a/src/front/Components/DesignSystem/Form/BaseField.tsx b/src/front/Components/DesignSystem/Form/BaseField.tsx index e36ed0f2..acdc4d05 100644 --- a/src/front/Components/DesignSystem/Form/BaseField.tsx +++ b/src/front/Components/DesignSystem/Form/BaseField.tsx @@ -90,8 +90,10 @@ export default abstract class BaseField

{ public override render(): JSX.Element { const selectedOption = this.state.selectedOption ?? this.props.selectedOption; return ( -

- {selectedOption && } - +
+
+ {selectedOption && } + -
    - {this.props.options.map((option, index) => ( -
  • this.onSelect(option, e)}> -
    {option.icon}
    - {option.label} -
  • - ))} -
+
    + {this.props.options.map((option, index) => ( +
  • this.onSelect(option, e)}> +
    {option.icon}
    + {option.label} +
  • + ))} +
- {this.state.isOpen &&
} + {this.state.isOpen &&
} +
{this.state.errors !== null &&
{this.renderErrors()}
}
); @@ -172,16 +177,12 @@ export default class SelectField extends React.Component { this.toggle(e); } - private renderErrors(): JSX.Element[] | null { - if (!this.state.errors || !this.state.errors.constraints) return null; - let errors: JSX.Element[] = []; - Object.entries(this.state.errors.constraints).forEach(([key, value]) => { - errors.push( - - {value} - , - ); - }); - return errors; + private renderErrors(): JSX.Element | null { + if (!this.state.errors) return null; + return ( + + {this.props.placeholder} est requis + + ); } } diff --git a/src/front/Components/DesignSystem/Form/index.tsx b/src/front/Components/DesignSystem/Form/index.tsx index e3ab0f3e..94a9f082 100644 --- a/src/front/Components/DesignSystem/Form/index.tsx +++ b/src/front/Components/DesignSystem/Form/index.tsx @@ -10,6 +10,7 @@ export type IFormContext = { onFieldChange: (name: string, field: IBaseField) => void; onFieldFocusChange: (name: string, field: IBaseField, focused: boolean) => void; isInputFocused: (name: string) => boolean; + hasOneFocusedInput: () => boolean; }; type IFields = { @@ -32,7 +33,14 @@ export type IProps = { children?: ReactNode; }; -export const FormContext = React.createContext({ setField: () => {}, unSetField: () => {}, onFieldChange: () => {}, onFieldFocusChange: () => {}, isInputFocused: () => false}); +export const FormContext = React.createContext({ + setField: () => {}, + unSetField: () => {}, + onFieldChange: () => {}, + onFieldFocusChange: () => {}, + isInputFocused: () => false, + hasOneFocusedInput: () => false, +}); export default class Form extends React.Component { protected fields: IFields = {}; @@ -56,6 +64,7 @@ export default class Form extends React.Component { this.formRef = React.createRef(); this.onFieldFocusChange = this.onFieldFocusChange.bind(this); this.isInputFocused = this.isInputFocused.bind(this); + this.hasOneFocusedInput = this.hasOneFocusedInput.bind(this); } public override render() { @@ -67,6 +76,7 @@ export default class Form extends React.Component { onFieldChange: this.onFieldChange, onFieldFocusChange: this.onFieldFocusChange, isInputFocused: this.isInputFocused, + hasOneFocusedInput: this.hasOneFocusedInput, }}>
{this.props.children} @@ -125,8 +135,11 @@ export default class Form extends React.Component { delete this.fields[name]; } + protected hasOneFocusedInput() { + return this.state.inputFocused.focused; + } + protected isInputFocused(name: string) { - console.log(this.state.inputFocused); return this.state.inputFocused.name === name && this.state.inputFocused.focused; } diff --git a/src/front/Components/Layouts/DesignSystem/index.tsx b/src/front/Components/Layouts/DesignSystem/index.tsx index 05a1af1c..20a6108e 100644 --- a/src/front/Components/Layouts/DesignSystem/index.tsx +++ b/src/front/Components/Layouts/DesignSystem/index.tsx @@ -200,6 +200,7 @@ export default class DesignSystem extends BasePage {
{ /> error.property === "deed")} diff --git a/src/front/Components/Layouts/Folder/UpdateFolderMetadata/index.tsx b/src/front/Components/Layouts/Folder/UpdateFolderMetadata/index.tsx index 5fb1b8f2..3f480fe7 100644 --- a/src/front/Components/Layouts/Folder/UpdateFolderMetadata/index.tsx +++ b/src/front/Components/Layouts/Folder/UpdateFolderMetadata/index.tsx @@ -58,7 +58,7 @@ class UpdateFolderMetadataClass extends BasePage { placeholder="Numéro de dossier" defaultValue={this.state.selectedFolder?.folder_number} /> -
diff --git a/src/front/Components/Layouts/FolderArchived/UpdateFolderMetadata/index.tsx b/src/front/Components/Layouts/FolderArchived/UpdateFolderMetadata/index.tsx index f71fa184..5c48f290 100644 --- a/src/front/Components/Layouts/FolderArchived/UpdateFolderMetadata/index.tsx +++ b/src/front/Components/Layouts/FolderArchived/UpdateFolderMetadata/index.tsx @@ -50,6 +50,7 @@ class UpdateFolderMetadataClass extends BasePage {