-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(front): add profile deletion (#73)
* feat(front): add logout button to the profile page * feat(front): add profile deletion request button * feat(front): decode the JWT to get admin status * feat(front): add admin user deletion page * feat(front): allow admin to delete users
- Loading branch information
Showing
18 changed files
with
429 additions
and
11 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
67 changes: 67 additions & 0 deletions
67
front/src/components/administration/UserRequestingDeletionItem.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,67 @@ | ||
import { FC } from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
import { Icon, Text, TouchableRipple } from 'react-native-paper'; | ||
|
||
import ProfileHeaderDescription from '@/components/profile/header/ProfileHeaderDescription'; | ||
import { Profile } from '@/models/entities/profile'; | ||
|
||
/** | ||
* The styles for the UserRequestingDeletionItem component. | ||
*/ | ||
const styles = StyleSheet.create({ | ||
container: { | ||
alignItems: 'center', | ||
flexDirection: 'row', | ||
gap: 4, | ||
}, | ||
iconContainer: { | ||
paddingHorizontal: 8, | ||
}, | ||
nameContainer: { | ||
flex: 1, | ||
flexDirection: 'column', | ||
gap: 8, | ||
}, | ||
}); | ||
|
||
/** | ||
* The props for the UserRequestingDeletionList component. | ||
*/ | ||
type UserRequestingDeletionItemProps = { | ||
/** | ||
* The profile to display. | ||
*/ | ||
profile: Profile; | ||
|
||
/** | ||
* The function to call when an item is pressed. | ||
*/ | ||
onItemPress?: (profile: Profile) => void; | ||
}; | ||
|
||
/** | ||
* Displays a user requesting their deletion. | ||
* @constructor | ||
*/ | ||
export const UserRequestingDeletionItem: FC< | ||
UserRequestingDeletionItemProps | ||
> = ({ profile, onItemPress }) => { | ||
return ( | ||
<TouchableRipple onPress={() => onItemPress?.(profile)}> | ||
<View style={styles.container}> | ||
<View style={styles.nameContainer}> | ||
<Text variant='headlineSmall'> | ||
{profile.firstName} {profile.lastName} | ||
</Text> | ||
<ProfileHeaderDescription shortBiography={profile.shortBiography} /> | ||
</View> | ||
|
||
<View style={styles.iconContainer}> | ||
<Icon size={30} source='trash-can-outline' /> | ||
</View> | ||
</View> | ||
</TouchableRipple> | ||
); | ||
}; | ||
|
||
export default UserRequestingDeletionItem; |
58 changes: 58 additions & 0 deletions
58
front/src/components/administration/UserRequestingDeletionList.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,58 @@ | ||
import { FC } from 'react'; | ||
import { StyleSheet, View } from 'react-native'; | ||
import { Divider } from 'react-native-paper'; | ||
|
||
import UserRequestingDeletionItem from '@/components/administration/UserRequestingDeletionItem'; | ||
import { Profile } from '@/models/entities/profile'; | ||
|
||
/** | ||
* The styles for the ExperienceList component. | ||
*/ | ||
const styles = StyleSheet.create({ | ||
divider: { | ||
height: 1, | ||
marginVertical: 8, | ||
width: '100%', | ||
}, | ||
}); | ||
|
||
/** | ||
* The props for the UserRequestingDeletionList component. | ||
*/ | ||
type UserRequestingDeletionListProps = { | ||
/** | ||
* The list of profiles to display. | ||
*/ | ||
profiles: Profile[]; | ||
|
||
/** | ||
* The function to call when an item is pressed. | ||
*/ | ||
onItemPress?: (profile: Profile) => void; | ||
}; | ||
|
||
/** | ||
* Displays a list of users requesting their deletion. | ||
* @constructor | ||
*/ | ||
const UserRequestingDeletionList: FC<UserRequestingDeletionListProps> = ({ | ||
profiles, | ||
onItemPress, | ||
}) => { | ||
return ( | ||
<View> | ||
{profiles?.map((profile) => ( | ||
<View key={profile.id}> | ||
<UserRequestingDeletionItem | ||
profile={profile} | ||
onItemPress={onItemPress} | ||
/> | ||
|
||
<Divider style={styles.divider} /> | ||
</View> | ||
))} | ||
</View> | ||
); | ||
}; | ||
|
||
export default UserRequestingDeletionList; |
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
Oops, something went wrong.