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