export const changeData = (action, name, id, payload) => {
  const newData = {
    ...data,
    [name]: [...data[name]],
  };

  switch (action) {
    case "update":
      newData[name][id] = payload;
      break;

    case "add":
      newData[name].push(payload);
      break;

    case "delete":
      newData[name].splice(id, 1);
      break;

    default:
      console.warn(`Unknown action: ${action}`);
      return;
  }
  setData(newData);
};
