aboutsummaryrefslogtreecommitdiff
path: root/src/utils/users.ts
diff options
context:
space:
mode:
authorShravya Ramesh <shravs1208@gmail.com>2021-01-15 03:33:59 -0800
committerShravya Ramesh <shravs1208@gmail.com>2021-01-15 03:33:59 -0800
commitdf6595694c678657fec30d881fb1edcd39b62f17 (patch)
tree2953fbbc222fc3f7f092ee61c6d4b0c3414d3f9d /src/utils/users.ts
parent82476e27fe6f5dc699370659d223dcd86fd5c76b (diff)
friend request
Diffstat (limited to 'src/utils/users.ts')
-rw-r--r--src/utils/users.ts20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/utils/users.ts b/src/utils/users.ts
index c54ea715..2a7db214 100644
--- a/src/utils/users.ts
+++ b/src/utils/users.ts
@@ -16,7 +16,7 @@ import {loadUserMomentCategories} from './../store/actions/momentCategories';
import {loadUserX} from './../store/actions/userX';
import {AppDispatch} from './../store/configureStore';
import {RootState} from './../store/rootReducer';
-import {ScreenType, UserType} from './../types/types';
+import {ProfilePreviewType, ProfileType, ScreenType, UserType} from './../types/types';
const loadData = async (dispatch: AppDispatch, user: UserType) => {
await Promise.all([
@@ -122,3 +122,21 @@ export const getTokenOrLogout = async (dispatch: Function): Promise<string> => {
}
return token;
};
+
+/**
+ * Creates ProfilePreviewType of a user using UserType && ProfileType
+ * @param passedInUser This is the UserType of the user
+ * @param passedInProfile This is the ProfileType of the user
+ */
+export const getUserAsProfilePreviewType = (
+ passedInUser: UserType,
+ passedInProfile: ProfileType,
+): ProfilePreviewType => {
+ const fullName = passedInProfile.name.split(' ');
+ return {
+ id: passedInUser.userId,
+ username: passedInUser.username,
+ first_name: fullName[0],
+ last_name: fullName[1],
+ };
+};