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

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

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

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

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