Skip to content

Commit a9231ef

Browse files
committed
Fix normalizer mapping
1 parent b2b1f94 commit a9231ef

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

frontend/src/services/Normalizer.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
// map api response into our custom format
22

33
export const userMapper = user => ({
4-
...user,
4+
id: user.id,
5+
avatar: user.avatar,
6+
email: user.email,
7+
nickname: user.nickname,
58
firstName: user.first_name,
69
lastName: user.last_name,
710
});
811

912
export const emptyUser = () => ({
1013
id: null,
14+
avatar: null,
1115
email: '',
16+
nickname: '',
1217
firstName: '',
1318
lastName: '',
14-
avatar: null,
15-
nickname: '',
1619
});
1720

1821
export const commentMapper = comment => ({
19-
...comment,
22+
id: comment.id,
23+
body: comment.body,
2024
authorId: comment.author_id,
25+
tweetId: comment.tweet_id,
2126
created: comment.created_at,
2227
updated: comment.updated_at,
2328
author: userMapper(comment.author),
@@ -28,7 +33,8 @@ export const likeMapper = like => ({
2833
});
2934

3035
export const tweetMapper = tweet => ({
31-
...tweet,
36+
id: tweet.id,
37+
text: tweet.text,
3238
imageUrl: tweet.image_url,
3339
created: tweet.created_at,
3440
author: userMapper(tweet.author),

0 commit comments

Comments
 (0)