Correction des variables en constantes
This commit is contained in:
parent
4d5251c724
commit
952b1b6a8d
|
@ -51,23 +51,23 @@ export const OptionsSection: FunctionComponent<OptionsSectionProps> = ({ dsf, up
|
||||||
}
|
}
|
||||||
|
|
||||||
const onAddOptionClick = (evt: MouseEvent) => {
|
const onAddOptionClick = (evt: MouseEvent) => {
|
||||||
var options = JSON.parse(JSON.stringify(state.section.options))
|
const options = JSON.parse(JSON.stringify(state.section.options))
|
||||||
var option = newOption("Décision", "", "");
|
const option = newOption("Décision", "", "");
|
||||||
options.push(option);
|
options.push(option);
|
||||||
setState(state => ({ ...state, changed: true, section: { ...state.section, options }}));
|
setState(state => ({ ...state, changed: true, section: { ...state.section, options }}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOptionChange = (id: string, attrName: string, evt: ChangeEvent<HTMLInputElement>) => {
|
const onOptionChange = (id: number, attrName: string, evt: ChangeEvent<HTMLInputElement>) => {
|
||||||
const target = evt.currentTarget;
|
const target = evt.currentTarget;
|
||||||
const value = target.hasOwnProperty('checked') ? target.checked : target.value;
|
const value = target.hasOwnProperty('checked') ? target.checked : target.value;
|
||||||
var options = JSON.parse(JSON.stringify(state.section.options))
|
const options = JSON.parse(JSON.stringify(state.section.options))
|
||||||
options[id][attrName] = value;
|
options[id][attrName] = value;
|
||||||
setState(state => ({ ...state, changed: true, section: { ...state.section, options }}));
|
setState(state => ({ ...state, changed: true, section: { ...state.section, options }}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const onRemoveOptionClick = (id: string, evt: MouseEvent) => {
|
const onRemoveOptionClick = (id: number, evt: MouseEvent) => {
|
||||||
if(confirm('Voulez-vous supprimer cette option ?')){
|
if(confirm('Voulez-vous supprimer cette option ?')){
|
||||||
var options = JSON.parse(JSON.stringify(state.section.options))
|
const options = JSON.parse(JSON.stringify(state.section.options))
|
||||||
options.splice(id, 1);
|
options.splice(id, 1);
|
||||||
setState(state => ({ ...state, changed: true, section: { ...state.section, options }}));
|
setState(state => ({ ...state, changed: true, section: { ...state.section, options }}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue