Skip to content

Commit 05a8bf5

Browse files
committed
fix: approachFromtime undefined
1 parent 7e0929d commit 05a8bf5

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

mobile/services/auth.service.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ export const refreshUserData = async (
3535
// Note: We still save the accessToken into the user context to avoid reading from secure storage all the time when making api requests (performance, security, ..)
3636
const payload: Partial<IUserData> = {
3737
...user,
38-
approachFromTime: new Date(user.approachFromTime),
39-
approachToTime: new Date(user.approachToTime),
40-
blacklistedRegions: user.blacklistedRegions
41-
.map((br) => {
42-
return mapBlacklistedRegionDTOToMapRegion(br);
43-
})
44-
.filter((br) => br) as MapRegion[],
38+
approachFromTime: user ? new Date(user.approachFromTime) : undefined,
39+
approachToTime: user ? new Date(user.approachToTime) : undefined,
40+
blacklistedRegions: user
41+
? (user.blacklistedRegions
42+
.map((br) => {
43+
return mapBlacklistedRegionDTOToMapRegion(br);
44+
})
45+
.filter((br) => br) as MapRegion[])
46+
: [],
4547
clearPassword: "",
46-
imageURIs: Object.fromEntries(
47-
user.imageURIs.map((value, index) => [index, value]),
48-
),
48+
imageURIs: user
49+
? Object.fromEntries(
50+
user.imageURIs.map((value, index) => [index, value]),
51+
)
52+
: {},
4953
};
5054

5155
dispatch({

0 commit comments

Comments
 (0)