Deleting options and colors at the same time

This commit is contained in:
Emmanuel Watila
2023-03-10 00:30:30 +01:00
parent 5e9b211ff9
commit b0b897efd7
3 changed files with 8 additions and 7 deletions

View File

@@ -100,6 +100,7 @@ export const updateColumnAtom = atom(
// Reduce array into single object with updated indexes
const updatedColumns = tableColumnsOrdered.reduce(tableColumnsReducer, {});
await updateTableSchema({ columns: updatedColumns });
console.log(updatedColumns); // Testing Purpose Only @devsgnr
}
);

View File

@@ -78,8 +78,9 @@ export default function ColumnConfigModal({
) {
setShowRebuildPrompt(true);
}
const updatedConfig = set({ ...newConfig }, key, update);
const updatedConfig = set(newConfig, key, update); // Modified by @devsgnr, spread operator `{...newConfig}` instead of just `newConfig` was preventing multiple calls from running properly
setNewConfig(updatedConfig);
console.log(updatedConfig); // Testing Purpose Only @devsgnr
validateSettings();
};

View File

@@ -38,11 +38,11 @@ const getItemStyle = (
export default function Settings({ onChange, config }: ISettingsProps) {
const listEndRef: any = useRef(null);
let options = config.options ?? [];
const options = config.options ?? [];
const [newOption, setNewOption] = useState("");
/* State for holding Chip Colors for Select and MultiSelect */
const colors = config.colors ?? {};
let colors = config.colors ?? {};
const handleAdd = () => {
if (newOption.trim() !== "") {
@@ -145,10 +145,9 @@ export default function Settings({ onChange, config }: ISettingsProps) {
<IconButton
aria-label="Remove"
onClick={() =>
handleItemDelete(option).then(() => {
handleChipColorChange("delete", option);
console.log(options, colors); // Here for debugging purposes
})
handleItemDelete(option).then(
() => handleChipColorChange("delete", option) //@devsgnr
)
}
>
{<RemoveIcon />}