🐛 Optionnal fields on update client
This commit is contained in:
parent
d81edc3525
commit
6bb370a716
@ -12,6 +12,11 @@ export type IProps = IBaseFieldProps & {
|
||||
|
||||
// @ts-ignore TODO: typing error on IProps (validator class?? cf Massi 22/02/23)
|
||||
export default class InputField extends BaseField<IProps> {
|
||||
static override defaultProps: Partial<IBaseFieldProps> = {
|
||||
...BaseField.defaultProps,
|
||||
required: true
|
||||
}
|
||||
|
||||
public override render(): ReactNode {
|
||||
let pattern;
|
||||
|
||||
@ -48,7 +53,7 @@ export default class InputField extends BaseField<IProps> {
|
||||
}
|
||||
value={value}
|
||||
/>
|
||||
<div className={classes["fake-placeholder"]}>{this.props.fakeplaceholder}</div>
|
||||
<div className={classes["fake-placeholder"]}>{this.props.fakeplaceholder} {!this.props.required && " (Facultatif)"}</div>
|
||||
</div>
|
||||
</Typography>
|
||||
);
|
||||
@ -69,7 +74,7 @@ export default class InputField extends BaseField<IProps> {
|
||||
}
|
||||
value={value}
|
||||
/>
|
||||
<div className={classes["fake-placeholder"]}>{this.props.fakeplaceholder}</div>
|
||||
<div className={classes["fake-placeholder"]}>{this.props.fakeplaceholder} {!this.props.required && " (Facultatif)"}</div>
|
||||
</div>
|
||||
</Typography>
|
||||
);
|
||||
|
@ -32,6 +32,8 @@ type IState = {
|
||||
inputPhoneNumberValue: string;
|
||||
isOpenLeavingModal: boolean;
|
||||
doesInputHaveValues: boolean;
|
||||
inputBirthdate: Date | null;
|
||||
inputAddress: string;
|
||||
};
|
||||
class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
||||
constructor(props: IPropsClass) {
|
||||
@ -44,6 +46,8 @@ class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
||||
inputPhoneNumberValue: "",
|
||||
isOpenLeavingModal: false,
|
||||
doesInputHaveValues: false,
|
||||
inputBirthdate: null,
|
||||
inputAddress: "",
|
||||
};
|
||||
this.onSelectedFolder = this.onSelectedFolder.bind(this);
|
||||
this.onChangeNameInput = this.onChangeNameInput.bind(this);
|
||||
@ -53,6 +57,8 @@ class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
||||
this.openLeavingModal = this.openLeavingModal.bind(this);
|
||||
this.closeLeavingModal = this.closeLeavingModal.bind(this);
|
||||
this.leavePage = this.leavePage.bind(this);
|
||||
this.onChangeBirthDateInput = this.onChangeBirthDateInput.bind(this);
|
||||
this.onChangeAddressInput = this.onChangeAddressInput.bind(this);
|
||||
}
|
||||
|
||||
private backwardPath = Module.getInstance()
|
||||
@ -79,6 +85,20 @@ class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
||||
onChange={this.onChangePhoneNumberInput}
|
||||
defaultValue={this.props.client?.phone_number}
|
||||
/>
|
||||
<InputField
|
||||
name="birthdate"
|
||||
type="date"
|
||||
fakeplaceholder="Date de naissance"
|
||||
required={false}
|
||||
onChange={this.onChangeBirthDateInput}
|
||||
/>
|
||||
<InputField
|
||||
name="address"
|
||||
type="text"
|
||||
fakeplaceholder="Adresse"
|
||||
required={false}
|
||||
onChange={this.onChangeAddressInput}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className={classes["button-container"]}>
|
||||
@ -121,6 +141,14 @@ class UpdateClientClass extends BasePage<IPropsClass, IState> {
|
||||
this.setState({ isOpenLeavingModal: false });
|
||||
}
|
||||
|
||||
private onChangeBirthDateInput(event: ChangeEvent<HTMLInputElement & HTMLSelectElement & HTMLTextAreaElement>) {
|
||||
this.setState({ inputBirthdate: new Date(event.target.value) });
|
||||
}
|
||||
|
||||
private onChangeAddressInput(event: ChangeEvent<HTMLInputElement & HTMLSelectElement & HTMLTextAreaElement>) {
|
||||
this.setState({ inputAddress: event.target.value });
|
||||
}
|
||||
|
||||
private onChangeNameInput(event: ChangeEvent<HTMLInputElement & HTMLSelectElement & HTMLTextAreaElement>) {
|
||||
this.setState({ inputNameValue: event.target.value });
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user