Skip to content

Commit

Permalink
fix user index in popup | fix new entities with unregistered user whe…
Browse files Browse the repository at this point in the history
…n scanning
  • Loading branch information
pcournut committed Jul 5, 2023
1 parent 7fcb42f commit 81223ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export interface Authentication {

export interface User {
_id: string
first_name: string
last_name: string
first_name?: string
last_name?: string
authentication?: Authentication
email?: string
}
Expand Down
11 changes: 5 additions & 6 deletions views/ListTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ export const ListTab = ({ route }) => {
// Components
type EnrichedUserItemProps = {
enrichedUser: EnrichedUser;
index: number;
};
const EnrichedUserItem = ({ enrichedUser, index }: EnrichedUserItemProps) => (
const EnrichedUserItem = ({ enrichedUser }: EnrichedUserItemProps) => (
<TouchableOpacity
onPress={() => {
setSelectedUserIndex(index);
setSelectedUserIndex(
enrichedUsers.findIndex((user) => user.email === enrichedUser.email)
);
handleCallFunction();
}}
>
Expand Down Expand Up @@ -131,9 +132,7 @@ export const ListTab = ({ route }) => {
.toLowerCase()
.includes(searchParticipantText.toLowerCase())
)}
renderItem={({ item, index }) => (
<EnrichedUserItem enrichedUser={item} index={index} />
)}
renderItem={({ item }) => <EnrichedUserItem enrichedUser={item} />}
keyExtractor={(item) => item._id}
/>
<ScanBottomSheet route={route} ref={ref}></ScanBottomSheet>
Expand Down
10 changes: 8 additions & 2 deletions views/ScanScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@ export const ScanScreen = ({ navigation, route }) => {
};
const enrichedUser: EnrichedUser = {
// _id: updatedEntity.owner._id,
first_name: updatedEntity.owner.first_name,
last_name: updatedEntity.owner.last_name,
first_name:
"first_name" in updatedEntity.owner
? updatedEntity.owner.first_name
: updatedEntity.owner.email,
last_name:
"last_name" in updatedEntity.owner
? updatedEntity.owner.last_name
: "",
email: updatedEntity.owner.email,
kentoEntities: [kentoEntity],
};
Expand Down

0 comments on commit 81223ba

Please sign in to comment.