From ecdbd000349d9d67af8ed9b3a19a938f32e2ebed Mon Sep 17 00:00:00 2001 From: Mahesh Mahajan Date: Thu, 4 Apr 2024 18:13:42 +0530 Subject: [PATCH 1/2] TASK : #216809 API integration on profile page --- .../nulp_elite/src/pages/profile/Profile.js | 483 ++++++++++++------ .../nulp_elite/src/services/utilService.js | 17 + 2 files changed, 335 insertions(+), 165 deletions(-) create mode 100644 packages/nulp_elite/src/services/utilService.js diff --git a/packages/nulp_elite/src/pages/profile/Profile.js b/packages/nulp_elite/src/pages/profile/Profile.js index e5eb4440..fa896c7a 100644 --- a/packages/nulp_elite/src/pages/profile/Profile.js +++ b/packages/nulp_elite/src/pages/profile/Profile.js @@ -1,196 +1,349 @@ -// Profile.js - -import React from "react"; +import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; -import Footer from "components/Footer"; -import Header from "components/header"; -import Container from '@mui/material/Container'; -import Box from '@mui/material/Box'; -import CardContent from '@mui/material/CardContent'; -import Card from '@mui/material/Card'; -import Typography from '@mui/material/Typography'; -import PersonIcon from '@mui/icons-material/Person'; -import ModeEditIcon from '@mui/icons-material/ModeEdit'; -import EmojiEventsOutlinedIcon from '@mui/icons-material/EmojiEventsOutlined'; -import TimelapseOutlinedIcon from '@mui/icons-material/TimelapseOutlined'; -import Grid from '@mui/material/Grid'; -import LibraryAddCheckOutlinedIcon from '@mui/icons-material/LibraryAddCheckOutlined'; -import ReceiptLongOutlinedIcon from '@mui/icons-material/ReceiptLongOutlined'; -import data from "../../assets/userDetail.json"; -import FloatingChatIcon from '../../components/FloatingChatIcon'; -import CircularProgressWithLabel from '../../components/CircularProgressWithLabel'; -import Chip from '@mui/material/Chip'; +import Footer from "components/Footer"; +import Header from "components/header"; +import Container from "@mui/material/Container"; +import Box from "@mui/material/Box"; +import CardContent from "@mui/material/CardContent"; +import Card from "@mui/material/Card"; +import Typography from "@mui/material/Typography"; +import PersonIcon from "@mui/icons-material/Person"; +import ModeEditIcon from "@mui/icons-material/ModeEdit"; +import EmojiEventsOutlinedIcon from "@mui/icons-material/EmojiEventsOutlined"; +import TimelapseOutlinedIcon from "@mui/icons-material/TimelapseOutlined"; +import Grid from "@mui/material/Grid"; +import LibraryAddCheckOutlinedIcon from "@mui/icons-material/LibraryAddCheckOutlined"; +import ReceiptLongOutlinedIcon from "@mui/icons-material/ReceiptLongOutlined"; +import FloatingChatIcon from "../../components/FloatingChatIcon"; +import CircularProgressWithLabel from "../../components/CircularProgressWithLabel"; +import Chip from "@mui/material/Chip"; import Button from "@mui/material/Button"; - - +import * as util from "../../services/utilService"; const Profile = () => { const { t } = useTranslation(); + const [userData, setUserData] = useState(null); const progressValue = 60; // Example value, you can set this dynamically based on your progress + useEffect(() => { + const fetchData = async () => { + try { + const _userId = util.UserID(); + const url = `http://localhost:3000/learner/user/v5/read/${_userId}?fields=organisations,roles,locations,declarations,externalIds`; + const header = "application/json"; + const response = await fetch(url, { + headers: { + "Content-Type": "application/json", + }, + }); + const data = await response.json(); + setUserData(data); + } catch (error) { + console.error("Error fetching user data:", error); + } + }; + + fetchData(); + }, []); return (
- -
- - +
- - - - {t("ABOUT_ME")} - + + + + + + + {t("ABOUT_ME")}{" "} - - - {/* Use require for the image source */} - - - - - {data.result.response.firstName} {data.result.response.lastName} - - - Designation | ID: {data.result.response.organisations.orgName} - - - A manager with the department of Revenue and taxes and has actively contributed to the growth and authenticity of the knowledge curated for the betterment of the department. - - {/* - {data.result.response.roles.map((role) => ( - - // {role.role} - ))} - - */} - {/* - ID: {data.result.response.organisations.orgName} + + + + + + {userData && ( + <> + + {userData.result.response.firstName}{" "} + {userData.result.response.lastName} - - - Categories: {data.result.response.framework.board} + + Designation |{" "} + ID: {" "} + {userData.result.response.organisations.orgName} - - Sub-Categories: {data.result.response.framework.gradeLevel} + + A manager with the department of Revenue and taxes and has + actively contributed to the growth and authenticity of the + knowledge curated for the betterment of the department. - - Language: {data.result.response.framework.board} + {/* Displaying the framework.board field */} + + + Categories:{" "} + {" "} + {userData.result.response.framework.board} - */} - - - - - + + )} + + - - - - - - + + + + + + - - {t("CONTINUE_LEARNNG")} - - - - - - - - - + + {t("CONTINUE_LEARNNG")} + + + + + + + + - - {t("DOWNLOAD_CERTIFICATES")} - - - - - - + + {t("DOWNLOAD_CERTIFICATES")} + + + + - - - - {t("LEARNING_TIME")} - + + + + + + {t("LEARNING_TIME")} + + - - - {t("COURSES")}
- - 14h 20m - -
- - {t("WEBINARS")}
- - 10h 15m - -
- -
- - + + + {t("COURSES")} +
+ + 14h 20m + +
+ + {t("WEBINARS")} +
+ + 10h 15m + +
+
- -
- - - - - {t("PERFORMANCE")} - - - - - - - - - - Certifications Received - - - - - - + - - Courses than last month - - + + + + + {" "} + {t("PERFORMANCE")} + + - - - + + + + + + + Certifications Received + + + + + + + + Courses than last month + + + - - -
+
+
- -
- -
- +