diff --git a/packages/nulp_elite/src/App.js b/packages/nulp_elite/src/App.js index 035c072e..8308165c 100644 --- a/packages/nulp_elite/src/App.js +++ b/packages/nulp_elite/src/App.js @@ -29,6 +29,7 @@ import UserPrefData from "pages/UserPrefData"; import { ChakraProvider } from "@chakra-ui/react"; import Profile from "pages/Profile"; import FAQPage from "pages/FAQPage"; +import Certificate from "pages/Certificate"; function App() { const [search, setSearch] = React.useState(true); @@ -98,6 +99,11 @@ function App() { path: "/search", component: Search, }, + { + moduleName: "nulp_elite", + path: "/certificate", + component: Certificate, + }, ]; // return( diff --git a/packages/nulp_elite/src/pages/Certificate.js b/packages/nulp_elite/src/pages/Certificate.js new file mode 100644 index 00000000..6bc47a30 --- /dev/null +++ b/packages/nulp_elite/src/pages/Certificate.js @@ -0,0 +1,95 @@ +import React, { useState, useEffect } from "react"; +import { Box, Heading, Text, Button } from "@chakra-ui/react"; +import URLSConfig from "../configs/urlConfig.json"; +import { + validateCertificate, + fetchCertificatePreferences, + getBatchDetails, +} from "../services/cetificateService"; +const Certificate = () => { + const [data, setData] = useState({}); + const [bathId, setbatchId] = useState(""); + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(null); + const [organisationIds, setOrganisationIds] = useState(""); + useEffect(() => { + validateCertificatePage(); + fetchCertificatePreferencesPage(); + getBatchDetailsPage(); + }, []); + const headers = { + "content-type": "Application/json", + }; + + const validateCertificatePage = async () => { + try { + const url = + "http://localhost:3000/learner/" + + URLSConfig.URLS.USER.VALIDATE_CERTIFICATE; + const response = await validateCertificate(url, data); + console.log(response.data.result); + setData(response.data.result); + } catch (error) { + setError(error.message); + } + }; + + const fetchCertificatePreferencesPage = async () => { + try { + const url = + "http://localhost:3000/learner/" + + URLSConfig.URLS.TENANT_PREFERENCE.READ; + const response = await fetchCertificatePreferences(url, data); + console.log(response.data.result); + setData(response.data.result); + } catch (error) { + setError(error.message); + } + }; + + const getBatchDetailsPage = async () => { + try { + const url = + "http://localhost:3000/learner/" + + URLSConfig.URLS.BATCH.GET_DETAILS + + "/" + + `${bathId}`; + const response = await getBatchDetails(url); + console.log(response.data.result); + setData(response.data.result); + } catch (error) { + setError(error.message); + } + }; + + const handleFilterChange = (field, value) => { + // Handle filter change logic here + }; + + return ( + + + Welcome to Our Learning Portal Content + + + Enhance your knowledge and skills with our diverse range of courses and + content. + + + + {isLoading &&

Loading...

} + {error &&

Error: {error}

} + {Object.keys(data).map((key) => ( +
+

+ {key}: {JSON.stringify(data[key])} +

+
+ ))} +
+ ); +}; + +export default Certificate; diff --git a/packages/nulp_elite/src/services/cetificateService.js b/packages/nulp_elite/src/services/cetificateService.js new file mode 100644 index 00000000..22246c56 --- /dev/null +++ b/packages/nulp_elite/src/services/cetificateService.js @@ -0,0 +1,36 @@ +import { post, get } from "./RestClient.ts"; + +export const validateCertificate = async (url, data = {}, headers = {}) => { + const result = await post(url, data, { + headers, + }); + if (result) { + return result; + } else { + return []; + } +}; + +export const fetchCertificatePreferences = async ( + url, + data = {}, + headers = {} +) => { + const result = await post(url, data, { + headers, + }); + if (result) { + return result; + } else { + return []; + } +}; + +export const getBatchDetails = async (url, header = {}) => { + const result = await get(url, header); + if (result) { + return result; + } else { + return []; + } +};