Skip to content

Commit

Permalink
Merge pull request Udyam#175 from NotAtitYet/master
Browse files Browse the repository at this point in the history
Created the user details update button
  • Loading branch information
Ankur-Agrawal-ece20 authored Mar 30, 2023
2 parents c448776 + f1d7e5d commit c5c447b
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 49 deletions.
5 changes: 1 addition & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import MashalSponsor from './Mashal/components/Sponsors/Sponsors';
// import MashalLeaderboard from './Mashal/components/MashalLeaderboard/MashalLeaderboard';
import MashalEvent from './Mashal/components/MashalEvent/mashalEvent';
import Navbar from './EES/Navbar/Navbar';
import Register from './EES/Register/Register';
// import Register from './EES/Register/Register';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import ComingSoon from './EES/ComingSoon/ComingSoon';
Expand All @@ -32,9 +32,6 @@ function App() {
<div className="App">
<ToastContainer />
<Router>
<Routes>
<Route path="/register" element={<Register />} />
</Routes>
<Routes>
<Route
path="/"
Expand Down
6 changes: 3 additions & 3 deletions src/EES/ContentCard/ContentCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
height: 48vh;
overflow-y: scroll !important;
margin: 20px;
display: flex; -ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
display: flex;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}

.description {
Expand All @@ -42,7 +43,6 @@
color: white;
text-align: justify;
font-family: Poppins;

}

@media screen and (max-width: 600px) {
Expand Down
4 changes: 4 additions & 0 deletions src/EES/Dashboard/DashBoard.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
padding: 2%;
border-radius: 5%;
}
.userDetailsEditButton {
display: flex;
justify-content: right;
}
.qr-and-name {
height: auto;
display: flex;
Expand Down
18 changes: 14 additions & 4 deletions src/EES/Dashboard/DashBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const DashBoard = () => {
const [showForm, setShowForm] = useState(0);
const [token, setToken] = useState('');
const [edit, setEdit] = useState(0);
const [updateuser, setUpdatesuser] = useState(false);
const [delete1, setDelete] = useState(0);
const [editing, setEditing] = useState({
id: null,
Expand All @@ -50,10 +51,11 @@ const DashBoard = () => {
});
// const [token, setToken] = useState('');
useEffect(() => {
// var newUser = { name: 'Ankur Agrawal', email: '[email protected]', college: 'IIT BHU', year: 'Part III', phone: '1234567890', referral: 'default#EES-10000', radianite_points: 0, token: 'd221d7afdf288fc097ff321d77154de4b3b6a24e' };
// var newUser = { id: 6, name: 'Ankur Agrawal', email: '[email protected]', college: 'IIT BHU', year: 'SECOND', phone: '1234567890', referral: 'default#EES-10000', radianite_points: 0, token: 'd221d7afdf288fc097ff321d77154de4b3b6a24e' };
// window.sessionStorage.setItem('profileData', newUser);

var newUser = JSON.parse(window.sessionStorage.getItem('profileData'));
// window.sessionStorage.setItem('profileData', JSON.stringify(newUser));
setUser(newUser);
setToken(newUser.token);
axios
Expand Down Expand Up @@ -90,7 +92,7 @@ const DashBoard = () => {
})
.catch((error) => console.log(error));
console.log('uuse');
}, [teamData]);
}, []);

const [event, setEvent] = useState('Mosaic');
const registerHandler = (i) => {
Expand Down Expand Up @@ -236,8 +238,8 @@ const DashBoard = () => {
};
return (
<>
{user.college == null ? (
<Register />
{user.college == null || updateuser === true ? (
<Register userEditing={updateuser} />
) : (
<div className="dashboard-main">
<div className="db-main-container">
Expand Down Expand Up @@ -271,6 +273,14 @@ const DashBoard = () => {
<div className="textSmall">Referral Code</div>
<div className="textLarge">{user.referral}</div>
</div>
<div className="userDetailsEditButton">
<FaEdit
className="team-btn"
onClick={() => {
setUpdatesuser(true);
}}
/>
</div>
</div>
</div>
<div className="db-radianite">
Expand Down
5 changes: 4 additions & 1 deletion src/EES/Register/Register.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ select {
.form-container > form {
width: 100vw;
}
.form-container h1 {
.signUpText {
font-size: 1.2rem;
}
.updateUserText {
font-size: 3rem;
}
}
79 changes: 52 additions & 27 deletions src/EES/Register/Register.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { useNavigate } from 'react-router-dom';
import { toast } from 'react-toastify';
import RegisterLogo from './RegisterLogo';

const Register = () => {
const Register = (props) => {
console.log(props.userEditing);
const navigate = useNavigate();
const {
register,
Expand Down Expand Up @@ -41,16 +42,16 @@ const Register = () => {
return;
}
axios({
url: 'https://ees23.pythonanywhere.com/auth/google-login/',
method: 'post',
headers: { Authorization: window.sessionStorage.getItem('tokenId') },
url: props.userEditing === true ? 'https://ees23.pythonanywhere.com/auth/user-update/' + JSON.parse(profileData).id + '/' : 'https://ees23.pythonanywhere.com/auth/google-login/',
method: props.userEditing === true ? 'patch' : 'post',
headers: { Authorization: props.userEditing === false ? window.sessionStorage.getItem('tokenId') : `Token ${JSON.parse(profileData).token}` },
data: profdata
})
.then((res) => {
console.log(res);

setTimeout(() => {
toast.success('Registered Successfully', {
toast.success(props.userEditing === true ? 'Updated Successfully' : 'Registered Successfully', {
theme: 'dark',
position: window.innerWidth < 600 ? toast.POSITION.BOTTOM_CENTER : toast.POSITION.BOTTOM_RIGHT,
autoClose: 1200
Expand Down Expand Up @@ -126,28 +127,52 @@ const Register = () => {
<div className="form-container">
<div className="form"></div>

<form action=" " onSubmit={handleSubmit((data) => postData(data))}>
<h1>SIGN UP!</h1>
<input type="text" {...register('name')} value={JSON.parse(profileData).givenName} placeholder={JSON.parse(profileData).givenName} readOnly />
<input type="text" {...register('email')} value={JSON.parse(profileData).email} placeholder={JSON.parse(profileData).email} readOnly />
<input type="text" {...register('phone_number', { valueAsNumber: true })} placeholder="Whatsapp Number" pattern="^[6-9]\d{9}$" title="A valid number is required" required />
<input type="text" list="all_colleges" {...register('college_name')} placeholder="College/Institute" name="college_name" required />
<Collegelist id="all_colleges" />
<select id="years" className="givebgcolor" {...register('year')} required>
<option id="select-heading" value="Choose Year" disabled selected hidden>
Year
</option>
<option value="FIRST">First</option>
<option value="SECOND">Second</option>
<option value="THIRD">Third</option>
<option value="FOURTH">Fourth</option>
<option value="FIFTH">Fifth</option>
</select>
<input type="text" {...register('referral')} placeholder="Referral" />
<button type="submit" className="form-submit">
<span>SIGN UP</span>
</button>
</form>
{props.userEditing === true ? (
<form action=" " onSubmit={handleSubmit((data) => postData(data))}>
<h1 className="upadateUserText">Update User!</h1>
<input type="text" {...register('name')} value={JSON.parse(profileData).name} placeholder={JSON.parse(profileData).name} readOnly />
<input type="text" {...register('email')} value={JSON.parse(profileData).email} placeholder={JSON.parse(profileData).email} readOnly />
<input type="text" {...register('phone_number', { valueAsNumber: true })} defaultValue={JSON.parse(profileData).phone} placeholder={JSON.parse(profileData).phone} pattern="^[6-9]\d{9}$" title="A valid number is required" required />
<input type="text" list="all_colleges" {...register('college_name')} defaultValue={JSON.parse(profileData).college} placeholder={JSON.parse(profileData).college} required />
<Collegelist id="all_colleges" />
<select id="years" className="givebgcolor" {...register('year')} defaultValue={JSON.parse(profileData).year} required>
<option id="select-heading" value="Choose Year" disabled selected hidden>
Year
</option>
<option value="FIRST">First</option>
<option value="SECOND">Second</option>
<option value="THIRD">Third</option>
<option value="FOURTH">Fourth</option>
<option value="FIFTH">Fifth</option>
</select>
<button type="submit" className="form-submit">
<span>Update</span>
</button>
</form>
) : (
<form action=" " onSubmit={handleSubmit((data) => postData(data))}>
<h1 className="signUpText">Sign Up!</h1>
<input type="text" {...register('name')} value={JSON.parse(profileData).givenName} placeholder={JSON.parse(profileData).givenName} readOnly />
<input type="text" {...register('email')} value={JSON.parse(profileData).email} placeholder={JSON.parse(profileData).email} readOnly />
<input type="text" {...register('phone_number', { valueAsNumber: true })} placeholder="Whatsapp Number" pattern="^[6-9]\d{9}$" title="A valid number is required" required />
<input type="text" list="all_colleges" {...register('college_name')} placeholder="College/Institute" name="college_name" required />
<Collegelist id="all_colleges" />
<select id="years" className="givebgcolor" {...register('year')} required>
<option id="select-heading" value="Choose Year" disabled selected hidden>
Year
</option>
<option value="FIRST">First</option>
<option value="SECOND">Second</option>
<option value="THIRD">Third</option>
<option value="FOURTH">Fourth</option>
<option value="FIFTH">Fifth</option>
</select>
<input type="text" {...register('referral')} placeholder="Referral" />
<button type="submit" className="form-submit">
<span>SIGN UP</span>
</button>
</form>
)}
</div>
{window.innerWidth > 600 && (
<div className="register_logo_cont">
Expand Down
27 changes: 18 additions & 9 deletions src/EES/Teams/Teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,63 +38,72 @@ const Teams = () => {
className="circle-box circle-active"
onClick={() => {
changeTeam(0);
}}>
}}
>
<div className="circle-content">CORE TEAM</div>
</div>
<div
className="circle-box"
onClick={() => {
changeTeam(1);
}}>
}}
>
<div className="circle-content">SENIOR ADVISORS</div>
</div>
<div
className="circle-box"
onClick={() => {
changeTeam(2);
}}>
}}
>
<div className="circle-content">DEVELOPERS</div>
</div>
<div
className="circle-box"
onClick={() => {
changeTeam(3);
}}>
}}
>
<div className="circle-content">DESIGNERS</div>
</div>
<div
className="circle-box"
onClick={() => {
changeTeam(4);
}}>
}}
>
<div className="circle-content">CONTENT & CREATIVE</div>
</div>
<div
className="circle-box"
onClick={() => {
changeTeam(5);
}}>
}}
>
<div className="circle-content">MARKETING</div>
</div>
<div
className="circle-box"
onClick={() => {
changeTeam(6);
}}>
}}
>
<div className="circle-content">EXTERNAL AFFAIRS</div>
</div>
<div
className="circle-box"
onClick={() => {
changeTeam(7);
}}>
}}
>
<div className="circle-content">PUBLIC RELATIONS</div>
</div>
<div
className="circle-box"
onClick={() => {
changeTeam(8);
}}>
}}
>
<div className="circle-content">EVENT CO-ORDINATORS</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Udyam/components/Events/events.css
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,4 @@
.register-link {
height: 3.8vh;
}
}
}

0 comments on commit c5c447b

Please sign in to comment.