generated from freeCodeCamp/template
-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat : added a new profile page to help teachers create their profile. #254
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { useState, useEffect } from 'react'; | ||
import Navbar from '../components/navbar'; | ||
import Link from 'next/link'; | ||
|
||
function Profile() { | ||
// Set up initial user data | ||
const [userData, setUserData] = useState({ | ||
name: '', | ||
email: '', | ||
university: '', | ||
bio: '' | ||
}); | ||
|
||
// Load user data from localStorage if available. | ||
useEffect(() => { | ||
if (localStorage.getItem('userData')) { | ||
setUserData(JSON.parse(localStorage.getItem('userData'))); | ||
} | ||
}, []); | ||
|
||
// Update user data and localStorage | ||
function handleSave() { | ||
localStorage.setItem('userData', JSON.stringify(userData)); | ||
} | ||
|
||
return ( | ||
<div className='bg-zinc-200 opacity-100 fixed inset-0 z-50'> | ||
<Navbar> | ||
<div className='border-solid border-2 pl-4 pr-4'> | ||
<Link href={'/classes'}>Classes</Link> | ||
</div> | ||
<div className='border-solid border-2 pl-4 pr-4'> | ||
<Link href={'/'}> Menu</Link> | ||
</div> | ||
</Navbar> | ||
<div className='flex h-screen justify-center items-center'> | ||
<div className='flex-col justify-center bg-[#0a0a23] py-12 px-24 border-4 border-sky-500 rounded-x1 overflow-auto max-h-screen'> | ||
<div className='flex text-lg text-white justify-center items-center'> | ||
<div className='profile'> | ||
<div className='profile-pic'> | ||
<img | ||
src={`https://via.placeholder.com/150x150?text=${userData.name | ||
.charAt(0) | ||
.toUpperCase()}`} | ||
alt='Profile picture' | ||
/> | ||
</div> | ||
<div className='username'>{userData.name} </div> | ||
<form className='mt-8 space-y-8'> | ||
<div className='rounded-md text-white shadow-sm -space-y-px'> | ||
<label htmlFor='name'>Name: </label> | ||
<div className='text-black'> | ||
<input | ||
id='name' | ||
type='text' | ||
value={userData.name} | ||
onChange={e => | ||
setUserData({ ...userData, name: e.target.value }) | ||
} | ||
/> | ||
</div> | ||
</div> | ||
<div className='rounded-md shadow-sm -space-y-px'> | ||
<label htmlFor='email'>Email: </label> | ||
<div className='text-black'> | ||
<input | ||
id='email' | ||
type='email' | ||
value={userData.email} | ||
onChange={e => | ||
setUserData({ ...userData, email: e.target.value }) | ||
} | ||
/> | ||
</div> | ||
</div> | ||
<div className='rounded-md shadow-sm -space-y-px'> | ||
<label htmlFor='university'>University: </label> | ||
<div className='text-black'> | ||
<input | ||
id='university' | ||
type='text' | ||
value={userData.university} | ||
onChange={e => | ||
setUserData({ ...userData, university: e.target.value }) | ||
} | ||
/> | ||
</div> | ||
</div> | ||
<div className='rounded-md shadow-sm -space-y-px'> | ||
<label htmlFor='bio'>Bio: </label> | ||
<div className='text-black'> | ||
<textarea | ||
id='bio' | ||
value={userData.bio} | ||
onChange={e => | ||
setUserData({ ...userData, bio: e.target.value }) | ||
} | ||
></textarea> | ||
</div> | ||
</div> | ||
<button | ||
type='submit' | ||
onClick={handleSave} | ||
className=' rounded px-4 py-2 text-white bg-green-700' | ||
> | ||
Save changes | ||
</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Profile; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use next/image as pointed out by codefactor