diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 61aa914c..65688afb 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -9,7 +9,7 @@ "version": "0.1.0", "dependencies": { "@aws-amplify/ui-react": "^5.0.0", - "@bcgov-nr/nr-fsa-theme": "^1.0.7", + "@bcgov-nr/nr-fsa-theme": "^1.0.10", "@carbon/react": "^1.27.0", "@testing-library/jest-dom": "^6.1.2", "@testing-library/react": "^14.0.0", @@ -7767,9 +7767,9 @@ } }, "node_modules/@bcgov-nr/nr-fsa-theme": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/@bcgov-nr/nr-fsa-theme/-/nr-fsa-theme-1.1.5.tgz", - "integrity": "sha512-gQ7k76PXcTlWDOo6lrYNujgc5t7cY4r6gVS8m4bvkIbbgKQNux4kV5BuEtx616fubl61FZp+zDxRSMfrZz1Dog==" + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@bcgov-nr/nr-fsa-theme/-/nr-fsa-theme-1.0.10.tgz", + "integrity": "sha512-3YGie8ITDyCUNWRMJhJNNEa5W61WotxjaeMLiBXCsNwrWh+9BeBvlLBN8etxqnCyCbx1QkUAlADGZf05gSYwnQ==" }, "node_modules/@bcoe/v8-coverage": { "version": "0.2.3", diff --git a/frontend/package.json b/frontend/package.json index 173cd333..6cc122b3 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,7 +4,7 @@ "private": true, "dependencies": { "@aws-amplify/ui-react": "^5.0.0", - "@bcgov-nr/nr-fsa-theme": "^1.0.7", + "@bcgov-nr/nr-fsa-theme": "^1.0.10", "@carbon/react": "^1.27.0", "@testing-library/jest-dom": "^6.1.2", "@testing-library/react": "^14.0.0", diff --git a/frontend/src/actions/userAction.ts b/frontend/src/actions/userAction.ts index 792c315e..5eef46f6 100644 --- a/frontend/src/actions/userAction.ts +++ b/frontend/src/actions/userAction.ts @@ -1,21 +1,26 @@ import { USER_DETAILS_REQUEST, USER_DETAILS_SUCCESS, USER_DETAILS_FAIL } from '../constants/userConstants' import { isCurrentAuthUser } from '../services/AuthService' +const FAM_LOGIN_USER = 'famLoginUser'; export const getUserDetails = () => async (dispatch: any) => { try { dispatch({ - type: USER_DETAILS_REQUEST - }) - // readt the localStorage Here - const data = await isCurrentAuthUser() + type: USER_DETAILS_REQUEST, + }); + //first call the isCurrent and only after that extract the JSON + const data = await isCurrentAuthUser(); + + const userJSON = localStorage.getItem(FAM_LOGIN_USER); // Retrieve the JSON string from local storage + const user = userJSON ? JSON.parse(userJSON) : null; // Parse the JSON string to a JavaScript object + dispatch({ type: USER_DETAILS_SUCCESS, - payload: { TestUser: 'Jazz as always', isLoggedIn: data } - }) + payload: { ...user, isLoggedIn: data}, + }); } catch (error) { dispatch({ type: USER_DETAILS_FAIL, - payload: { error } - }) + payload: { error: error }, + }); } -} +}; \ No newline at end of file diff --git a/frontend/src/components/AvatarImage/AvatarImage.scss b/frontend/src/components/AvatarImage/AvatarImage.scss index e48ff6d4..32db062c 100644 --- a/frontend/src/components/AvatarImage/AvatarImage.scss +++ b/frontend/src/components/AvatarImage/AvatarImage.scss @@ -1,5 +1,12 @@ .profile-image { border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; + font-weight: bold; + background-color: #c7d4e7; + color: #072251; + font-size: 1.4rem; } .small { @@ -10,4 +17,5 @@ .large { width: 4rem; height: 4rem; -} \ No newline at end of file +} + diff --git a/frontend/src/components/AvatarImage/index.tsx b/frontend/src/components/AvatarImage/index.tsx index a1e79c19..b7603fa8 100644 --- a/frontend/src/components/AvatarImage/index.tsx +++ b/frontend/src/components/AvatarImage/index.tsx @@ -1,18 +1,32 @@ import React from 'react'; -import emptyUser from '../../assets/img/emptyUser.jpg'; import './AvatarImage.scss'; type Size = 'small' | 'large'; interface AvatarImageProps { userName: string; - source?: string; size: Size; } -const AvatarImage = ({ userName, source, size }: AvatarImageProps) => ( - -); +const getInitials = (userName: string) => { + const nameParts = userName.split(' '); + if (nameParts.length >= 2) { + return nameParts[0][0] + nameParts[1][0]; + } else if (nameParts.length === 1) { + return nameParts[0][0]; + } + return ''; +}; + +const AvatarImage = ({ userName, size }: AvatarImageProps) => { + const initials = getInitials(userName); + + return ( +
{`${userData.firstName} ${userData.lastName}`}
-{`IDIR: ${userData.idirUsername}`}
-{userData.email}
+{`${userDetails.user.firstName} ${userDetails.user.lastName}`}
+{`IDIR: ${userDetails.user.userName}`}
+{`Email:${userDetails.user.email}`}
+