client/src/components/NewGroupModal/NewGroupModal.js
// Creates new subgroup then calls functions to add appropriate data to other group and user documents
Creates new subgroup then calls functions to add appropriate data to other group and user documents
Creates new subgroup then calls functions to add appropriate data to other group and user documents
function handleFormSubmit(e) {
    e.preventDefault();
    console.log(newSubGroup);
    console.log(userFormState);
    API.createSubGroup(newSubGroup.subGroupName, userFormState)
      .then((res) => {
        console.log(res.data);
        let subGroupData = { name: res.data.name, _id: res.data._id };
        let subGroupUserData = {
          name: res.data.name,
          _id: res.data._id,
          subGroupMembers: res.data.groupMembers,
        };
        console.log(subGroupUserData);
        addSubGroupToUsers(res.data.groupMembers, subGroupData);
        addSubGroupToGroup(groupState._id, subGroupUserData);
        setUserFormState([]);
      })
      .catch((err) => console.log(err));
  }
function handleFormSubmit ( e ) { e . preventDefault ( ) ; console . log ( newSubGroup ) ; console . log ( userFormState ) ; API . createSubGroup ( newSubGroup . subGroupName , userFormState ) . then ( ( res ) => { console . log ( res . data ) ; let subGroupData = { name : res . data . name , _id : res . data . _id } ; let subGroupUserData = { name : res . data . name , _id : res . data . _id , subGroupMembers : res . data . groupMembers , } ; console . log ( subGroupUserData ) ; addSubGroupToUsers ( res . data . groupMembers , subGroupData ) ; addSubGroupToGroup ( groupState . _id , subGroupUserData ) ; setUserFormState ( [ ] ) ; } ) . catch ( ( err ) => console . log ( err ) ) ; }
Creates new subgroup then calls functions to add appropriate data to other group and user documents
Creates new subgroup then calls functions to add appropriate data to other group and user documents
// let subGroupName = res.data.name; // let subGroupId = res.data._id;