Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: [##215331] :Added Certificate API calls #12

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/nulp_elite/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Home from "pages/Home";
import Courses from "pages/Courses";
import Contents from "pages/Contents";
import Framework from "pages/Frmework";
import Certificate from "pages/Certificate";

import User from "pages/User";
import { extendTheme, NativeBaseProvider } from "native-base";
// import dotenv from "dotenv";
Expand Down Expand Up @@ -45,6 +47,21 @@ function App() {
path: "/registration",
component: Registration,
},
{
moduleName: "nulp_elite",
path: "/User",
component: User,
},
{
moduleName: "nulp_elite",
path: "/Certificate",
component: Certificate,
},
{
moduleName: "nulp_elite",
path: "/Search",
component: Search,
},
];
// const LoginComponent = React.lazy(() => import("core/Login"));

Expand Down
92 changes: 92 additions & 0 deletions packages/nulp_elite/src/pages/Certificate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import React, { useState, useEffect } from "react";
import { Box, Heading, Text, Button } from "@chakra-ui/react";
import URLSConfig from "../configs/urlConfig.json";
import { post, get } from "@shiksha/common-lib";

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(() => {
validateCertificate();
fetchCertificatePreferences();
getBatchDetails();
}, []);
const headers = {
"content-type": "Application/json",
};

const validateCertificate = async () => {
try {
const url =
"http://localhost:3000/learner/" +
URLSConfig.URLS.USER.VALIDATE_CERTIFICATE;
const response = await post(url, data);
console.log(response.data.result);
setData(response.data.result);
} catch (error) {
setError(error.message);
}
};

const fetchCertificatePreferences = async () => {
try {
const url =
"http://localhost:3000/learner/" +
URLSConfig.URLS.TENANT_PREFERENCE.READ;
const response = await post(url, data);
console.log(response.data.result);
setData(response.data.result);
} catch (error) {
setError(error.message);
}
};

const getBatchDetails = async () => {
try {
const url =
"http://localhost:3000/learner/" +
URLSConfig.URLS.BATCH.GET_DETAILS +
"/" +
`${bathId}`;
const response = await get(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 (
<Box textAlign="center" padding="10">
<Heading as="h1" size="2xl" marginBottom="4">
Welcome to Our Learning Portal Content
</Heading>
<Text fontSize="xl" marginBottom="8">
Enhance your knowledge and skills with our diverse range of courses and
content.
</Text>
<Button colorScheme="blue" size="lg" onClick={validateCertificate}>
Get User Data
</Button>

{isLoading && <p>Loading...</p>}
{error && <p>Error: {error}</p>}
{Object.keys(data).map((key) => (
<div key={key}>
<p>
{key}: {JSON.stringify(data[key])}
</p>
</div>
))}
</Box>
);
};

export default Certificate;
Loading