-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Progress on Workspace Member Management
- Loading branch information
1 parent
b7a032c
commit 5449bed
Showing
33 changed files
with
330 additions
and
96 deletions.
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
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
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
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
.profile { | ||
button { | ||
background: indianred; | ||
color: white; | ||
margin-top: 8vh; | ||
} | ||
} |
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,44 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useNavigate, useParams } from 'react-router-dom'; | ||
import useAuthService from '@services/auth/useAuthService'; | ||
import { User } from '@notespace/shared/src/users/types'; | ||
import { formatDate } from '@/utils/utils'; | ||
import { useAuth } from '@ui/contexts/auth/useAuth'; | ||
import './Profile.scss'; | ||
|
||
function Profile() { | ||
const { id } = useParams(); | ||
const { getUser, deleteUser } = useAuthService(); | ||
const [user, setUser] = useState<User | null>(null); | ||
const { currentUser } = useAuth(); | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
if (!id) return; | ||
async function fetchUser() { | ||
const user = await getUser(id!); | ||
setUser(user); | ||
} | ||
fetchUser(); | ||
}, [id, getUser]); | ||
|
||
async function onDeleteAccount() { | ||
if (!currentUser || currentUser.uid !== user?.id) return; | ||
await currentUser.delete(); | ||
await deleteUser(user.id); | ||
navigate('/'); | ||
} | ||
|
||
return ( | ||
user && ( | ||
<div className="profile"> | ||
<h2>{user.name}</h2> | ||
<p>{user.email}</p> | ||
<p>Joined {formatDate(user.createdAt)}</p> | ||
{currentUser?.uid === user.id && <button onClick={onDeleteAccount}>Delete Account</button>} | ||
</div> | ||
) | ||
); | ||
} | ||
|
||
export default Profile; |
44 changes: 44 additions & 0 deletions
44
code/client/src/ui/pages/workspace/components/ManageMembersDialog.tsx
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,44 @@ | ||
import Dialog from '@ui/components/dialog/Dialog'; | ||
import { FaCross, FaUsers } from 'react-icons/fa6'; | ||
import { UserData } from '@notespace/shared/src/users/types'; | ||
|
||
type ManageMembersDialog = { | ||
members: UserData[]; | ||
onAddMember: (email: string) => void; | ||
onRemoveMember: (email: string) => void; | ||
}; | ||
|
||
function ManageMembersDialog({ members, onAddMember, onRemoveMember }: ManageMembersDialog) { | ||
return ( | ||
<Dialog | ||
title="Manage members in workspace" | ||
fields={[{ name: 'Add new member', label: 'User email' }]} | ||
onSubmit={values => { | ||
onAddMember(values['Add new member']); | ||
}} | ||
submitText="Add Member" | ||
extraContent={ | ||
<div> | ||
<h3>Members</h3> | ||
<ul> | ||
{members?.map(member => ( | ||
<li key={member.email}> | ||
<p>{member.email}</p> | ||
<button onClick={() => onRemoveMember(member.email)}> | ||
<FaCross /> | ||
</button> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
} | ||
> | ||
<div> | ||
<FaUsers /> | ||
Members | ||
</div> | ||
</Dialog> | ||
); | ||
} | ||
|
||
export default ManageMembersDialog; |
Oops, something went wrong.