Skip to content

Commit

Permalink
feat: add users button
Browse files Browse the repository at this point in the history
  • Loading branch information
PRKKILLER committed Mar 31, 2021
1 parent 4bf143e commit 7e281b4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
45 changes: 38 additions & 7 deletions Frontend/client/src/components/CreateGroup/creategroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class creategroup extends Component {
selected: [],
UserId: localStorage.getItem('EmailId'),
// selectedUser:'',
memberSelect: [],
};
}

Expand All @@ -53,6 +54,20 @@ class creategroup extends Component {
// event.preventDefault();
// }

addMoreUsers = () => {
this.setState({
memberSelect: [...this.state.memberSelect,
<div className=" d-flex flex-row bd-highlight mb-3 fields ">
<Select
className="names"
options={this.state.users}
onChange={(opt) => this.handleSelect(opt)}
/>
</div>,
],
});
}

componentDidMount = async () => {
const email = localStorage.getItem('EmailId');
let userListRes = await axios.get(`http://localhost:3002/group/getAllUsersExceptCurrent/${email}`);
Expand Down Expand Up @@ -107,6 +122,9 @@ class creategroup extends Component {
GroupId: groupCreateRes.data.Groupdetails.GroupId,
UserIds: selUsers,
});
if (addusergrp.status === 200) {
window.location.href = '/dashboard';
}
}
} catch (err) {
alert(err);
Expand All @@ -115,11 +133,23 @@ class creategroup extends Component {

render() {
// console.log(this.state.selected);
let EmailId = localStorage.getItem('EmailId');
let redirectVar = null;
let currentURL = '';
if (EmailId === false || EmailId === undefined || EmailId === null) {
redirectVar = <Redirect to="/login" />;
} else {
EmailId = EmailId.charAt(0).toUpperCase() + EmailId.slice(1);
const urlstring = EmailId.replace('@', '%40');
currentURL = `https://splitwisebucket.s3.us-east-2.amazonaws.com/${urlstring}`;
console.log('Current User url', currentURL);
}
return (
<div>
{redirectVar}
<UpperNavbar />
<div className="content-block">
<img className="envelope" src="https://assets.splitwise.com/assets/core/logo-square-65a6124237868b1d2ce2f5db2ab0b7c777e2348b797626816400534116ae22d7.svg" alt="No img" width="200" height="200" />
<img className="envelope" name="grouppic" src="https://assets.splitwise.com/assets/core/logo-square-65a6124237868b1d2ce2f5db2ab0b7c777e2348b797626816400534116ae22d7.svg" alt="No img" width="200" height="200" />
<h2>Start a new group</h2>
<form id="new_group" className="form" onSubmit={this.handleSubmit}>
<div id="group_avatar_upload">
Expand All @@ -131,38 +161,39 @@ class creategroup extends Component {
<input tabIndex="1" placeholder="Home Expenses" name="groupName" autoComplete="off" type="text" id="group_name" />
<hr />
<h2>Group Memebers</h2>
<div className=" d-flex flex-row bd-highlight mb-3 fields ">
<img className="rounded-circle profile-pic" alt="usrprofile" src="https://s3.amazonaws.com/splitwise/uploads/user/default_avatars/avatar-blue23-50px.png" />
{/* <div className=" d-flex flex-row bd-highlight mb-3 fields ">
<Select
className="names"
options={this.state.users}
onChange={(opt) => this.handleSelect(opt)}
/>
</div>
</div> */}
<div className=" d-flex flex-row bd-highlight mb-3 fields ">
<img className="rounded-circle profile-pic" alt="usrprofile" src="https://s3.amazonaws.com/splitwise/uploads/user/default_avatars/avatar-blue23-50px.png" />
<Select
className="names"
options={this.state.users}
onChange={(opt) => this.handleSelect(opt)}
/>
</div>
<div className=" d-flex flex-row bd-highlight mb-3 fields ">
<img className="rounded-circle profile-pic" alt="usrprofile" src="https://s3.amazonaws.com/splitwise/uploads/user/default_avatars/avatar-blue23-50px.png" />
<Select
className="names"
options={this.state.users}
onChange={(opt) => this.handleSelect(opt)}
/>
</div>
<div className=" d-flex flex-row bd-highlight mb-3 fields ">
<img className="rounded-circle profile-pic" alt="usrprofile" src="https://s3.amazonaws.com/splitwise/uploads/user/default_avatars/avatar-blue23-50px.png" />
<Select
className="names"
options={this.state.users}
onChange={(opt) => this.handleSelect(opt)}
/>
</div>
{this.state.memberSelect}
<Button type="submit" className="btn-outline-info" onClick={this.addMoreUsers}> + Add more users </Button>
<br />
<br />
<br />
<Button type="submit" value="Submit" style={{ backgroundColor: '#ff652f' }} className="btn btn-secondary btn-lg">SAVE</Button>
</form>
</div>
Expand Down
5 changes: 4 additions & 1 deletion Frontend/client/src/styles/creategroup.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ h2{
height: 40px;
margin: 4px;
padding:10px;
}
}
.btn-outline-info{
background-color: white;
}

0 comments on commit 7e281b4

Please sign in to comment.