aboutsummaryrefslogtreecommitdiff
path: root/src/utils/users.ts
diff options
context:
space:
mode:
authorBrian Kim <brian@tagg.id>2021-06-15 17:15:43 +0900
committerBrian Kim <brian@tagg.id>2021-06-15 17:15:43 +0900
commit4a422e43c6a6deaeff5d8fcc692138454653e4b9 (patch)
tree2e86ab879ea35e879581eb64be955d0e5481ff80 /src/utils/users.ts
parentc57b4959c90cec90dd0936f75a9086a4430b66b1 (diff)
parentdb0678d647f774dcb1cd60513985d9b6fbd0e28b (diff)
Merge with master
Diffstat (limited to 'src/utils/users.ts')
-rw-r--r--src/utils/users.ts18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/utils/users.ts b/src/utils/users.ts
index 64ad10e9..c1c3b8bc 100644
--- a/src/utils/users.ts
+++ b/src/utils/users.ts
@@ -306,3 +306,21 @@ export const patchProfile = async (
return false;
});
};
+
+/**
+ * Returns the logged-in user's info in ProfilePreviewType from redux store.
+ * @param state the current state of the redux store
+ * @returns logged-in user in ProfilePreviewType
+ */
+export const getLoggedInUserAsProfilePreview: (
+ state: RootState,
+) => ProfilePreviewType = (state) => {
+ const nameSplit = state.user.profile.name.split(' ');
+ return {
+ id: state.user.user.userId,
+ username: state.user.user.username,
+ first_name: nameSplit[0],
+ last_name: nameSplit[1],
+ thumbnail_url: state.user.avatar ?? '', // in full res
+ };
+};