aboutsummaryrefslogtreecommitdiff
path: root/src/utils/users.ts
diff options
context:
space:
mode:
authorBrian Kim <brian@tagg.id>2021-06-15 12:28:32 +0900
committerBrian Kim <brian@tagg.id>2021-06-15 12:28:32 +0900
commitdb0678d647f774dcb1cd60513985d9b6fbd0e28b (patch)
tree00e62c1821d4973d214fdd47f8293749972c1925 /src/utils/users.ts
parenta249f2d027c9cd5d7f20602cf79ec2265f60a54c (diff)
parent78f32c1400eff46d4c768b78fbaf672826c74285 (diff)
Merge branch 'master' of https://github.com/TaggiD-Inc/Frontend
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
+ };
+};