From 6801ab4ea95cd28bdba597e63c00c5b72343a5e0 Mon Sep 17 00:00:00 2001 From: Nandana-pradeep33 Date: Tue, 23 Jul 2024 22:39:39 +0530 Subject: [PATCH 1/5] fix():Replaced Magazine link in Navbar with new one --- src/Components/Navbar/Mylinks.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Navbar/Mylinks.jsx b/src/Components/Navbar/Mylinks.jsx index 30bb9249f..611661b97 100644 --- a/src/Components/Navbar/Mylinks.jsx +++ b/src/Components/Navbar/Mylinks.jsx @@ -122,7 +122,7 @@ export const links = [ name: "Magazine", submenu: false, sublinks: [], - link: "https://online.fliphtml5.com/blxtf/bicl/#p=1", + link: "https://online.fliphtml5.com/slydm/hrgi/", foreign: true, }, { From 5a7e2cb865f28e12e5215a42268cd5ac3ded283c Mon Sep 17 00:00:00 2001 From: karivarkey Date: Thu, 25 Jul 2024 19:25:26 +0530 Subject: [PATCH 2/5] feat (wadhwani) : added wadhwani course page --- src/App.js | 2 + src/Pages/Wadhwani/Modules/Wadhwani/index.jsx | 99 ++++ .../Modules/Wadhwani/index.module.css | 104 +++++ .../Wadhwani/Modules/Wadhwani/services/api.ts | 104 +++++ .../Modules/Wadhwani/services/types.d.ts | 25 + src/Pages/Wadhwani/Wadhwani.jsx | 118 +++++ src/Pages/Wadhwani/Wadhwani.module.css | 86 ++++ src/Pages/Wadhwani/Wadhwani2.module.css | 433 ++++++++++++++++++ src/Pages/Wadhwani/assets/Leader.gif | Bin 0 -> 374480 bytes 9 files changed, 971 insertions(+) create mode 100644 src/Pages/Wadhwani/Modules/Wadhwani/index.jsx create mode 100644 src/Pages/Wadhwani/Modules/Wadhwani/index.module.css create mode 100644 src/Pages/Wadhwani/Modules/Wadhwani/services/api.ts create mode 100644 src/Pages/Wadhwani/Modules/Wadhwani/services/types.d.ts create mode 100644 src/Pages/Wadhwani/Wadhwani.jsx create mode 100644 src/Pages/Wadhwani/Wadhwani.module.css create mode 100644 src/Pages/Wadhwani/Wadhwani2.module.css create mode 100644 src/Pages/Wadhwani/assets/Leader.gif diff --git a/src/App.js b/src/App.js index 84c03e7c7..746468799 100644 --- a/src/App.js +++ b/src/App.js @@ -14,6 +14,7 @@ import Career from "./Pages/Career/Career"; import LeaderBoard from "./Pages/LeaderBoard/leaderBoard"; import WikiSyllabus from "./Pages/WikiSyllabus/WikiSyllabus"; import HacktoberFest from "./Pages/Events/HacktoberFest/HacktoberFest"; +import Wadhwani from "./Pages/Wadhwani/Wadhwani"; // import Yip from "./Pages/YIP/Yip"; import CampusChapters from "./Pages/CampusChapters/CampusChapters"; import BlogLanding from "./Pages/CampusChapters/Blogs/BlogLanding"; @@ -122,6 +123,7 @@ function App() { } /> } /> } /> + } /> } /> diff --git a/src/Pages/Wadhwani/Modules/Wadhwani/index.jsx b/src/Pages/Wadhwani/Modules/Wadhwani/index.jsx new file mode 100644 index 000000000..812d8eb99 --- /dev/null +++ b/src/Pages/Wadhwani/Modules/Wadhwani/index.jsx @@ -0,0 +1,99 @@ +import React, { useEffect, useState } from "react"; +import toast from "react-hot-toast"; +import styles from "./index.module.css"; +import MuLoader from "@/MuLearnComponents/MuLoader/MuLoader"; +import axios from "axios"; +const Wadhwani = () => { + const [data, setData] = useState<[]>([]); + const [clientToken, setClientToken] = useState(""); + const [isLoading, setIsLoading] = useState(true); + const [sheet, setSheet] = useState<[]>([]); + + + useEffect(() => { + fetchData(); + }, []); + + const fetchData = async () => { + const { response, error } = await getWadhwaniClientToken(); + if (error) { + toast.error(error); + } else if (response) { + setClientToken(response.access_token); + const { response: courses, error } = await getWadhwaniCourses( + response.access_token + ); + if (error) { + toast.error(error); + } else if (courses) { + try { + setIsLoading(true); + const response = await axios.get( + "https://opensheet.elk.sh/1LEvZozIVVquXjSvtptQcjiU0_WFaxVuEYBCYyCdsCtY/sheet" + ); + setSheet(response.data); + } catch (error) { + console.log(error); + } finally { + setIsLoading(false); + } + setData(courses); + } + setIsLoading(false) + } + }; + + const handleCourseSelection = async (courseRootId) => { + const { response, error } = await getWadhwaniCourseLink(clientToken, courseRootId); + if (error) { + toast.error(error); + return null; + } else if (response) { + console.log(response.data) + window.open(response.data, "_blank"); + } + }; + + + const CourseCard = ({ title, desc, duration, rootId }) => { + return ( +
+
+

{title}

+

{desc}

+

{duration}hrs

+
+
handleCourseSelection(rootId)} className={styles.cta}> + Checkout Courses +
+
+ ); + }; + if (isLoading) { + return ; + } + return ( +
+

Wadhwani Foundation Courses

+
+
+
+
+ {sheet.map((sheet) => ( + + ))} +
+
+
+
+
+ ); +}; + +export default Wadhwani; \ No newline at end of file diff --git a/src/Pages/Wadhwani/Modules/Wadhwani/index.module.css b/src/Pages/Wadhwani/Modules/Wadhwani/index.module.css new file mode 100644 index 000000000..023487c11 --- /dev/null +++ b/src/Pages/Wadhwani/Modules/Wadhwani/index.module.css @@ -0,0 +1,104 @@ +.wrapper h1 { + font-weight: bold; + font-size: 3rem; +} + +.course { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); + gap: 1rem; /* Combines row-gap and column-gap */ + justify-items: center; +} + + + + +.cardHeading{ + font-size: bold; + size: 10rem; +} + +.container { + display: flex; + flex-wrap: wrap; + justify-content: center; + width: 100%; + max-height: 20v; +} + + + +@media screen and (max-width: 1300px) { + .container { + width: 30vw; + height: 45vw; /* Adjust height to maintain aspect ratio */ + } +} + +@media screen and (max-width: 700px) { + .wrapper h1 { + font-size: 2rem; + } + .container { + width: 70vw; + height: 105vw; /* Adjust height to maintain aspect ratio */ + } +} + +@media screen and (max-width: 500px) { + .container { + width: 85vw; + height: 127.5vw; /* Adjust height to maintain aspect ratio */ + } +} + + +.second_view_container { + margin-top: 3rem; + padding: 2rem; + background-color: #ffffff; +} + + + +.containercard { + font-family: Poppins, sans-serif; + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + padding: 2rem; + border-radius: 10px; + gap: 1.5rem; + + box-shadow: 1px 1px 45px -5px rgb(0 0 0 / 8%); + -webkit-box-shadow: 1px 1px 45px -5px rgb(0 0 0 / 8%); + -moz-box-shadow: 1px 1px 45px -5px rgba(0, 0, 0, 0.08); +} + +.title { + font-weight: 500; + font-size: 30px; + margin-bottom: 0.5rem; +} + +.desc { + color: #404d61; + font-size: 0.9rem; +} + +.duration { + color: #404d61; + opacity: 0.5; + font-weight: 500; + margin-top: 0.5rem; + font-size: 0.9rem; +} + +.cta { + background: #456ff6; + color: white; + padding: 0.5rem 1rem; + border-radius: 5px; + cursor: pointer; +} \ No newline at end of file diff --git a/src/Pages/Wadhwani/Modules/Wadhwani/services/api.ts b/src/Pages/Wadhwani/Modules/Wadhwani/services/api.ts new file mode 100644 index 000000000..16f695298 --- /dev/null +++ b/src/Pages/Wadhwani/Modules/Wadhwani/services/api.ts @@ -0,0 +1,104 @@ +import { privateGateway } from "@/MuLearnServices/apiGateways"; +import { dashboardRoutes } from "@/MuLearnServices/urls"; +import { AxiosError } from "axios"; +import toast from "react-hot-toast"; +export const getWadhwaniClientToken = async () => { + try { + const response = await privateGateway.post( + dashboardRoutes.getWadhwaniClientToken + ); + const message: WadhwaniTokenResponse = response?.data?.response; + return { response: message, error: null }; + } catch (err: unknown) { + const error = err as AxiosError; + if (error?.response) { + throw error; + } else { + return { response: null, error: error.message }; + } + } +}; + +export const getWadhwaniCourses = async (clientToken: string) => { + try { + const response = await privateGateway.post( + dashboardRoutes.getWadhwaniCourses, + { + "Client-Auth-Token": clientToken + }, + { + maxBodyLength: Infinity + } + ); + const message: wadhwaniCourseResponse[] = + response?.data?.response?.data; + return { response: message, error: null }; + } catch (err: unknown) { + const error = err as AxiosError; + if (error?.response) { + throw error; + } else { + return { response: null, error: error.message }; + } + } +}; + +export const getWadhwaniCourseLink = async ( + clientToken: string, + courseId: string +) => { + const toastId=toast.loading("Fetching course link...") + try { + const response = await privateGateway.post( + dashboardRoutes.getWadhwaniCourseLink, + { + "Client-Auth-Token": clientToken, + course_root_id: courseId + }, + { + maxBodyLength: Infinity + } + ); + const message: wadhwaniCourseRedirectResponse = response?.data?.response; + if (message.data?.error?.code) { + return { response: null, error: message.data.error.description }; + }else{ + toast.success("Course link opened successfully!",{id:toastId}) + } + return { response: message, error: null }; + } catch (err: unknown) { + toast.error("Please try again later.",{id:toastId}) + const error = err as AxiosError; + if (error?.response) { + throw error; + + } else { + return { response: null, error: error.message }; + } + } +}; + +// const axios = require('axios'); +// const FormData = require('form-data'); +// let data = new FormData(); +// data.append('course_root_id', '64931a5571b86329790efb76'); +// data.append('Client-Auth-Token', 'eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJyekdBUjZCX0dpU21zRFJZT2syczZXOE0xSnlUckpPUGd0bFQwVGZSVGswIn0.eyJleHAiOjE3MTQyMTg4MjMsImlhdCI6MTcxNDIxODIyMywianRpIjoiYjkxZDU0OWYtYzg2ZC00ZDBhLTljZjEtYmNmODBmZTgzZDZhIiwiaXNzIjoiaHR0cHM6Ly93b2Rldi5pYW0ud2ZnbG9iYWwub3JnL2F1dGgvcmVhbG1zL3dmLW9wcG9ydHVuaXR5IiwiYXVkIjoiYWNjb3VudCIsInN1YiI6ImJkMDhiNWM4LWMxNjUtNDQzNi05NjVmLWEwY2U3ODYxNTkyMiIsInR5cCI6IkJlYXJlciIsImF6cCI6Im11bGVhcm4iLCJhY3IiOiIxIiwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImRlZmF1bHQtcm9sZXMtd2Ytb3Bwb3J0dW5pdHkiLCJvZmZsaW5lX2FjY2VzcyIsInVtYV9hdXRob3JpemF0aW9uIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJtYW5hZ2UtYWNjb3VudCIsIm1hbmFnZS1hY2NvdW50LWxpbmtzIiwidmlldy1wcm9maWxlIl19fSwic2NvcGUiOiJwcm9maWxlIGVtYWlsIiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJjbGllbnRJZCI6Im11bGVhcm4iLCJjbGllbnRIb3N0IjoiNDMuMjA1LjEwNi4xMzkiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJzZXJ2aWNlLWFjY291bnQtbXVsZWFybiIsImNsaWVudEFkZHJlc3MiOiI0My4yMDUuMTA2LjEzOSJ9.jOE2n-5Ig2IlxU2wONqd7E202mvOvH_Ifhv9Iz_A80JKzMx29um2_kj6e0tadC-UDWBKi6oxkekPXKKpJNrl0JRXZysSoWQHK47zCaKDo9oP6MGEewQgpSAzf1NGWsPiOQN36MGoijR-VE9p5CWfDmgSHiUKxlMx3t2ORYg15bfkSeOmt6vVb4pdJsJQfaCmQH5xDV5dVRRisGYqnv7QRTRzLKkLbd-MIc8YSAsAXWMv5msIiiFEsjIyU2R-OKSinCxThP6RszkHz0Ek_HI5DXJEDfxIRjDiqKRmIJnP0c6f_8tqq5UA9Y_Dbgt-ffkGBBvkNWTkxeDhnDbdwj23NQ'); + +// let config = { +// method: 'post', +// maxBodyLength: Infinity, +// url: 'https://dev.mulearn.org/api/v1/integrations/wadhwani/user-login/', +// headers: { +// 'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjdlZDlmNjFlLTY3YzUtNDBiMy1iYTkyLWRmN2Q4NzEyNzA5MCIsIm11aWQiOiJhZG5hbmthdHRla2FkZW5AbXVsZWFybiIsInJvbGVzIjpbIlpvbmFsIENhbXB1cyBMZWFkIiwiRGlzdHJpY3QgQ2FtcHVzIExlYWQiLCJTdHVkZW50IiwiQWRtaW5zIiwiQWRtaW5zIiwiQ2FtcHVzIExlYWQiXSwiZXhwaXJ5IjoiMjAyNC0wNC0yNyAxNDo0MzowMCswMDowMCIsInRva2VuVHlwZSI6ImFjY2VzcyJ9.85KZ1PIldLS2awJi66CHCd754pUrcwbwomZw6xORe7w', +// ...data.getHeaders() +// }, +// data : data +// }; + +// axios.request(config) +// .then((response) => { +// console.log(JSON.stringify(response.data)); +// }) +// .catch((error) => { +// console.log(error); +// }); diff --git a/src/Pages/Wadhwani/Modules/Wadhwani/services/types.d.ts b/src/Pages/Wadhwani/Modules/Wadhwani/services/types.d.ts new file mode 100644 index 000000000..19a9621a3 --- /dev/null +++ b/src/Pages/Wadhwani/Modules/Wadhwani/services/types.d.ts @@ -0,0 +1,25 @@ +interface WadhwaniTokenResponse { + access_token: string; + expires_in: number; + refresh_expires_in: number; + token_type: string; + "not-before-policy": number; + scope: string; +} + +interface wadhwaniCourseResponse { + courseId: string; + courseName: string; + servingMode: string[]; + courseRootId: string; + description: string; + version: string; + thumbnail: string; + language: string; + enrollStatus: boolean; +} + +interface wadhwaniCourseRedirectResponse { + status: string; + data: any; +} \ No newline at end of file diff --git a/src/Pages/Wadhwani/Wadhwani.jsx b/src/Pages/Wadhwani/Wadhwani.jsx new file mode 100644 index 000000000..5fdf9d9fc --- /dev/null +++ b/src/Pages/Wadhwani/Wadhwani.jsx @@ -0,0 +1,118 @@ +import React, { useEffect, useState } from "react"; + +import Card from "@mui/material/Card"; +import CardContent from "@mui/material/CardContent"; + +import Typography from "@mui/material/Typography"; +import { CircularProgress } from "@mui/material"; +import axios from "axios"; + +import styles from "./Wadhwani2.module.css"; +import styles2 from "./Wadhwani.module.css"; +import Navbar from "../../Components/Navbar/Navbar"; +import Footer from "../../Components/Footer/Footer"; +import leader from "./assets/Leader.gif"; + +import { ThemeProvider, createTheme } from "@mui/material/styles"; +const theme = createTheme({ + palette: { + primary: { + main: "#f78c40", + }, + }, +}); + +const Wadhwani = () => { + const [data, setData] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + axios + .get( + "https://opensheet.elk.sh/1LEvZozIVVquXjSvtptQcjiU0_WFaxVuEYBCYyCdsCtY/sheet" + ) + .then((response) => { + setData(response.data); + setLoading(false); + console.log(data); + }) + .catch((error) => { + console.error("Error fetching data:", error); + setLoading(false); + }); + }, []); + + if (loading) { + return ( +
+ + Loading... +
+ ); + } + + return ( + + +
+
+
+
+

+ Wadhwani Is Here! +

+

+ Wadhwani helps students learn and grow holistically by focusing + on the soft skills of the person. +

+

Feel free to check out our courses!

+ + Explore Wadhwani + +
+
+ Leader +
+
+ +
+ {data.map((item, index) => ( +
+ + + + {item.courseName} + + + {item.description.substring(0, 120)}... + + + Duration: {item.CourseDuration} hrs + + + +
+ ))} +
+
+
+