fix instrument proficiency chage
update the state correctly of the instrument list when proficiency is changed
This commit is contained in:
parent
1a11cc331c
commit
9dc101d3f6
|
|
@ -250,20 +250,32 @@ function JKEditProfile() {
|
|||
};
|
||||
|
||||
const handleInstrumentProficiencyChange = (option, musicInstrument) => {
|
||||
let updatedInstruments = [];
|
||||
const userInstrument = getValues('instruments').find(instrument => instrument.instrument_id === musicInstrument.id);
|
||||
if (!userInstrument) {
|
||||
const updatedInstruments = [...getValues('instruments'), { ...musicInstrument, proficiency_level: option.value }];
|
||||
setValue('instruments', updatedInstruments);
|
||||
updatedInstruments = [...getValues('instruments'), { ...musicInstrument, proficiency_level: option.value }];
|
||||
//setValue('instruments', updatedInstruments);
|
||||
} else {
|
||||
const updatedInstruments = getValues('instruments').map(instrument => {
|
||||
updatedInstruments = getValues('instruments').map(instrument => {
|
||||
if (instrument.instrument_id === musicInstrument.id) {
|
||||
instrument.proficiency_level = option.value;
|
||||
}
|
||||
return instrument;
|
||||
});
|
||||
setValue('instruments', updatedInstruments);
|
||||
//setValue('instruments', updatedInstruments);
|
||||
}
|
||||
forceUpdate();
|
||||
setValue('instruments', updatedInstruments);
|
||||
|
||||
const updatedMusicInstruments = musicInstruments.map(instrument => {
|
||||
if (instrument.id === musicInstrument.id) {
|
||||
instrument.proficiency_level = option.value;
|
||||
}
|
||||
return instrument;
|
||||
});
|
||||
|
||||
setMusicInstruments(updatedMusicInstruments);
|
||||
|
||||
//forceUpdate();
|
||||
handleChange();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue