import React from "react";
import _ from "underscore";
import { connect } from "react-redux";
import LanguageList from "../../../../components/languageSelector/languageList";
import { DatePickerComponent } from "@syncfusion/ej2-react-calendars";
import { _sampleBase } from "../sampleBase";
class USer extends _sampleBase {
constructor(props) {
super(props);
//get current language from store
this.lang = this.props.language; // the value does not change in spite of its update in the store
//get language list: ["en", "fr"]
this.languagesList = Object.keys(LanguageList);
// if language is equal to en datepicker laocal is english, vice versa
this.datePickerLocale = _.isEqual(this.lang, this.languagesList[0])
? this.languagesList[0]
: this.languagesList[1];
}
render() {
console.log("========language========", this.props.language); // the value does not change in spite of its update in the store
return (
<div>
<div className="identity">
<label className="identity-label">Identificationlabel>
<div className="identity-form">
<div className="form-fields">
<div className="birth-date">
<DatePickerComponent
format="dd-MM-yyyy"
placeholder="Date de naissance"
floatLabelType="Auto"
strictMode="true"
cssClass="wh-custom-calendar"
locale={this.datePickerLocale}
/>
div>
div>
{/* end form fields*/}
div>
{/* end identity form */}
div>
div>
);
}
}
const mapStateToProps = state => ({
// get language
language: state.languageReducer.language
});
export default connect(mapStateToProps)(USer);