Correction des variables en constantes

This commit is contained in:
Teddy Cornaut 2020-08-31 15:29:38 +02:00
parent 4d5251c724
commit 952b1b6a8d

View File

@ -51,23 +51,23 @@ export const OptionsSection: FunctionComponent<OptionsSectionProps> = ({ dsf, up
}
const onAddOptionClick = (evt: MouseEvent) => {
var options = JSON.parse(JSON.stringify(state.section.options))
var option = newOption("Décision", "", "");
const options = JSON.parse(JSON.stringify(state.section.options))
const option = newOption("Décision", "", "");
options.push(option);
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 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;
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 ?')){
var options = JSON.parse(JSON.stringify(state.section.options))
const options = JSON.parse(JSON.stringify(state.section.options))
options.splice(id, 1);
setState(state => ({ ...state, changed: true, section: { ...state.section, options }}));
}