diff --git a/module-template/public/image24.png b/module-template/public/image24.png new file mode 100644 index 00000000..144c688d Binary files /dev/null and b/module-template/public/image24.png differ diff --git a/packages/nulp_elite/public/locales/be/translation.json b/packages/nulp_elite/public/locales/be/translation.json index 53e88aa2..e222c345 100644 --- a/packages/nulp_elite/public/locales/be/translation.json +++ b/packages/nulp_elite/public/locales/be/translation.json @@ -322,8 +322,10 @@ "NO_CHAT_REQUEST": "কোনো চ্যাট অনুরোধ নেই", "PHONE":"ফোন", "PHONE_NUMBER":"(+91 11) 24617517, 24617543, 24617595", - "LERN_title":"Learnathon 2.0", - "LERN_MESSAGE":"Learnathon 2.0 20/09/2024 থেকে 20/10/2024 পর্যন্ত শুরু হয়েছে। আপনি এখন আপনার জমাগুলি তৈরি এবং ভাগ করতে পারেন!", "CREATE_CONTENT":"সামগ্রী তৈরি করুন", - "REQUEST_TO_CREATE":"তৈরি করার অনুরোধ" + "REQUEST_TO_CREATE":"তৈরি করার অনুরোধ", + "PARTICIPATE_NOW":"এখনই অংশগ্রহণ করুন", + "LERN_title": "The Learnathon 2.0 শুরু হয়েছে!", + "LERN_MESSAGE": "যেখানে শহুরে অনুশীলনকারীরা সহযোগিতামূলক শিক্ষাকে উৎসাহিত করার জন্য সমাধানগুলি ভাগ করে নেয়।", + "LERN_MESSAGE_LINE_TWO":"Learnathon 2.0 18ই নভেম্বর 2024 এ চালু হয়েছে এবং 20শে ডিসেম্বর 2024 পর্যন্ত চলবে। এখনই আপনার শহুরে সমাধান জমা দিন!" } diff --git a/packages/nulp_elite/public/locales/en/translation.json b/packages/nulp_elite/public/locales/en/translation.json index f3c5d794..ea0703cd 100644 --- a/packages/nulp_elite/public/locales/en/translation.json +++ b/packages/nulp_elite/public/locales/en/translation.json @@ -319,8 +319,10 @@ "PHONE": "Phone", "PHONE_NUMBER": "(+91 11) 24617517, 24617543, 24617595", "SESSION_TIMEOUT_MESSAGE": "Failed to fetch data.please try again.", - "LERN_title": "Learnathon 2.0", - "LERN_MESSAGE": "Learnathon 2.0 has started from 20/09/2024 to 20/10/2024. You can now create and share your submissions!", "CREATE_CONTENT": "Create Content", - "REQUEST_TO_CREATE": "Request to Create" + "REQUEST_TO_CREATE": "Request to Create", + "PARTICIPATE_NOW":"Participate Now", + "LERN_title": "The Learnathon 2.0 Has Begun!", + "LERN_MESSAGE": "Where urban practitioners share solutions to foster collaborative learning.", + "LERN_MESSAGE_LINE_TWO":"Learnathon 2.0 launched on 18th November 2024 and will continue until 20th December 2024. Submit your urban solutions now!" } diff --git a/packages/nulp_elite/public/locales/gg/translation.json b/packages/nulp_elite/public/locales/gg/translation.json index af24cd87..b099cc22 100644 --- a/packages/nulp_elite/public/locales/gg/translation.json +++ b/packages/nulp_elite/public/locales/gg/translation.json @@ -325,8 +325,10 @@ "NO_CHAT_REQUEST": "કોઈ ચેટ વિનંતી નથી", "PHONE":"ફોન", "PHONE_NUMBER":"(+91 11) 24617517, 24617543, 24617595", - "LERN_title":"લર્નથોન 2.0", - "LERN_MESSAGE":"લર્નથોન 2.0 20/09/2024 થી 20/10/2024 સુધી શરૂ થઈ છે. તમે હવે તમારા સબમિશન બનાવી અને શેર કરી શકો છો!", "CREATE_CONTENT":"સામગ્રી બનાવો", - "REQUEST_TO_CREATE":"બનાવવાની વિનંતી" + "REQUEST_TO_CREATE":"બનાવવાની વિનંતી", + "PARTICIPATE_NOW":"હવે ભાગ લો", + "LERN_title": "ધ લર્નથોન 2.0 શરૂ થઈ ગયું છે!", + "LERN_MESSAGE": "જ્યાં શહેરી પ્રેક્ટિશનરો સહયોગી શિક્ષણને પ્રોત્સાહન આપવા માટે ઉકેલો શેર કરે છે.", + "LERN_MESSAGE_LINE_TWO":"Learnathon 2.0 18મી નવેમ્બર 2024 ના રોજ લોન્ચ થયું અને 20મી ડિસેમ્બર 2024 સુધી ચાલુ રહેશે. તમારા શહેરી ઉકેલો હમણાં જ સબમિટ કરો!" } diff --git a/packages/nulp_elite/public/locales/hi/translation.json b/packages/nulp_elite/public/locales/hi/translation.json index 9429b27a..716a1f4c 100644 --- a/packages/nulp_elite/public/locales/hi/translation.json +++ b/packages/nulp_elite/public/locales/hi/translation.json @@ -316,8 +316,10 @@ "NO_CHAT_REQUEST": "कोई चैट अनुरोध नहीं", "PHONE":"फोन", "PHONE_NUMBER":"(+91 11) 24617517, 24617543, 24617595", - "LERN_title":"लर्नथॉन 2.0", - "LERN_MESSAGE":"लर्नथॉन 2.0 20/09/2024 से 20/10/2024 तक शुरू हो चुका है। अब आप अपने सबमिशन बना और साझा कर सकते हैं!", "CREATE_CONTENT":"सामग्री बनाएँ", - "REQUEST_TO_CREATE":"बनाने का अनुरोध" + "REQUEST_TO_CREATE":"बनाने का अनुरोध", + "PARTICIPATE_NOW":"अभी भाग लें", + "LERN_title": "लर्नथॉन 2.0 शुरू हो गया है!", + "LERN_MESSAGE": "जहां शहरी व्यवसायी सहयोगात्मक शिक्षा को बढ़ावा देने के लिए समाधान साझा करते हैं।", + "LERN_MESSAGE_LINE_TWO":"लर्नथॉन 2.0 18 नवंबर 2024 को लॉन्च हुआ और 20 दिसंबर 2024 तक जारी रहेगा। अब अपना शहरी समाधान सबमिट करें!" } diff --git a/packages/nulp_elite/public/locales/ma/translation.json b/packages/nulp_elite/public/locales/ma/translation.json index 6aad9d48..35510d44 100644 --- a/packages/nulp_elite/public/locales/ma/translation.json +++ b/packages/nulp_elite/public/locales/ma/translation.json @@ -317,9 +317,11 @@ "NO_CHAT_REQUEST": "चॅट विनंती नाही", "PHONE":"फोन", "PHONE_NUMBER":"(+91 11) 24617517, 24617543, 24617595", - "LERN_title":"लर्नथॉन 2.0", - "LERN_MESSAGE":"लर्नथॉन 2.0 20/09/2024 ते 20/10/2024 पर्यंत सुरू झाली आहे. तुम्ही आता तुमचे सबमिशन तयार आणि शेअर करू शकता!", "CREATE_CONTENT":"सामग्री तयार करा", - "REQUEST_TO_CREATE":"तयार करण्याची विनंती" + "REQUEST_TO_CREATE":"तयार करण्याची विनंती", + "PARTICIPATE_NOW":"आता सहभागी व्हा", + "LERN_title": "लर्नथॉन २.० सुरु झाली आहे!", + "LERN_MESSAGE": "जेथे शहरी अभ्यासक सहयोगी शिक्षणाला चालना देण्यासाठी उपाय सामायिक करतात.", + "LERN_MESSAGE_LINE_TWO":"Learnathon 2.0 18 नोव्हेंबर 2024 ला लॉन्च झाला आणि 20 डिसेंबर 2024 पर्यंत सुरू राहील. तुमचे शहरी उपाय आता सबमिट करा!" } diff --git a/packages/nulp_elite/public/locales/mal/translation.json b/packages/nulp_elite/public/locales/mal/translation.json index 2d5115aa..fcb4a8df 100644 --- a/packages/nulp_elite/public/locales/mal/translation.json +++ b/packages/nulp_elite/public/locales/mal/translation.json @@ -317,8 +317,10 @@ "NO_CHAT_REQUEST": "ചാറ്റ് അഭ്യര്‍ത്ഥനയില്ല", "PHONE":"ഫോൺ", "PHONE_NUMBER":"(+91 11) 24617517, 24617543, 24617595", - "LERN_title":"ലേണത്തോൺ 2.0", - "LERN_MESSAGE":"ലേണത്തോൺ 2.0 20/09/2024 മുതൽ 20/10/2024 വരെ ആരംഭിച്ചു. നിങ്ങൾക്ക് ഇപ്പോൾ നിങ്ങളുടെ സമർപ്പിക്കലുകൾ സൃഷ്ടിക്കാനും പങ്കിടാനും കഴിയും!", "CREATE_CONTENT":"ഉള്ളടക്കം സൃഷ്ടിക്കുക", - "REQUEST_TO_CREATE":"സൃഷ്ടിക്കാനുള്ള അഭ്യർത്ഥന" + "REQUEST_TO_CREATE":"സൃഷ്ടിക്കാനുള്ള അഭ്യർത്ഥന", + "PARTICIPATE_NOW":"ഇപ്പോൾ പങ്കെടുക്കുക", + "LERN_title": "ലേണത്തോൺ 2.0 ആരംഭിച്ചു!", + "LERN_MESSAGE": "സഹകരണ പഠനം പ്രോത്സാഹിപ്പിക്കുന്നതിന് നഗരപരിശീലകർ പരിഹാരങ്ങൾ പങ്കിടുന്നിടത്ത്.", + "LERN_MESSAGE_LINE_TWO":"Learnathon 2.0 2024 നവംബർ 18-ന് സമാരംഭിച്ചു, 2024 ഡിസംബർ 20 വരെ തുടരും. നിങ്ങളുടെ നഗര പരിഹാരങ്ങൾ ഇപ്പോൾ സമർപ്പിക്കുക!" } diff --git a/packages/nulp_elite/public/locales/ta/translation.json b/packages/nulp_elite/public/locales/ta/translation.json index 89537f35..bc93f858 100644 --- a/packages/nulp_elite/public/locales/ta/translation.json +++ b/packages/nulp_elite/public/locales/ta/translation.json @@ -342,8 +342,10 @@ "NO_CHAT_REQUEST": "சாட் கோரிக்கை இல்லை", "PHONE":"தொலைபேசி", "PHONE_NUMBER":"(+91 11) 24617517, 24617543, 24617595", - "LERN_title":"கற்றல் 2.0", - "LERN_MESSAGE":"கற்றல் 2.0 20/09/2024 முதல் 20/10/2024 வரை தொடங்கியது. நீங்கள் இப்போது உங்கள் சமர்ப்பிப்புகளை உருவாக்கி பகிரலாம்!", "CREATE_CONTENT":"உள்ளடக்கத்தை உருவாக்கவும்", - "REQUEST_TO_CREATE":"உருவாக்க கோரிக்கை" + "REQUEST_TO_CREATE":"உருவாக்க கோரிக்கை", + "PARTICIPATE_NOW":"இப்போது பங்கேற்கவும்", + "LERN_title": "The Learnathon 2.0 Has Begun!", + "LERN_MESSAGE": "நகர்ப்புற பயிற்சியாளர்கள் கூட்டுக் கற்றலை வளர்ப்பதற்கான தீர்வுகளை எங்கே பகிர்ந்து கொள்கிறார்கள்.", + "LERN_MESSAGE_LINE_TWO":"Learnathon 2.0 18 நவம்பர் 2024 அன்று தொடங்கப்பட்டது மற்றும் 20 டிசம்பர் 2024 வரை தொடரும். உங்கள் நகர்ப்புற தீர்வுகளை இப்போதே சமர்ப்பிக்கவும்!" } diff --git a/packages/nulp_elite/public/locales/te/translation.json b/packages/nulp_elite/public/locales/te/translation.json index 442d41db..fde633d3 100644 --- a/packages/nulp_elite/public/locales/te/translation.json +++ b/packages/nulp_elite/public/locales/te/translation.json @@ -281,8 +281,10 @@ "PHONE":"ఫోన్", "PHONE_NUMBER":"(+91 11) 24617517, 24617543, 24617595", "WHAT_DO_YOU_WANT_TO_LEARN_TODAY":"ఈరోజు మీరు ఏమి నేర్చుకోవాలనుకుంటున్నారు", - "LERN_title":"లెర్నాథాన్ 2.0", - "LERN_MESSAGE":"లెర్నాథాన్ 2.0 20/09/2024 నుండి 20/10/2024 వరకు ప్రారంభమైంది. మీరు ఇప్పుడు మీ సమర్పణలను సృష్టించవచ్చు మరియు భాగస్వామ్యం చేయవచ్చు!", "CREATE_CONTENT":"కంటెంట్‌ని సృష్టించండి", - "REQUEST_TO_CREATE":"సృష్టించడానికి అభ్యర్థన" + "REQUEST_TO_CREATE":"సృష్టించడానికి అభ్యర్థన", + "PARTICIPATE_NOW":"ఇప్పుడే పాల్గొనండి", + "LERN_title": "లెర్నాథాన్ 2.0 ప్రారంభమైంది!", + "LERN_MESSAGE": "పట్టణ అభ్యాసకులు సహకార అభ్యాసాన్ని ప్రోత్సహించడానికి పరిష్కారాలను పంచుకునే చోట.", + "LERN_MESSAGE_LINE_TWO":"Learnathon 2.0 18 నవంబర్ 2024న ప్రారంభించబడింది మరియు 20 డిసెంబర్ 2024 వరకు కొనసాగుతుంది. మీ పట్టణ పరిష్కారాలను ఇప్పుడే సమర్పించండి!" } diff --git a/packages/nulp_elite/src/App.js b/packages/nulp_elite/src/App.js index 388de7dd..caccc0b4 100644 --- a/packages/nulp_elite/src/App.js +++ b/packages/nulp_elite/src/App.js @@ -41,6 +41,7 @@ import PopupForm from "pages/profileData"; import axios from "axios"; import ReactGA from "react-ga4"; import LernModal from "components/learnathon/LernModal"; +import LernSubmissionTable from "pages/learnathon/LernSubmissionTable"; function App() { // const [t] = useTranslation(); @@ -111,12 +112,6 @@ function App() { path: routeConfig.ROUTES.JOIN_COURSE_PAGE.JOIN_COURSE, component: JoinCourse, }, - // { - // moduleName: "nulp_elite", - // path: "/joinCourse/:contentId", - // component: JoinCourse, - // }, - { moduleName: "nulp_elite", path: routeConfig.ROUTES.PLAYER_PAGE.PLAYER, @@ -217,8 +212,14 @@ function App() { path: routeConfig.ROUTES.LEARNATHON.CREATELEARNCONTENT, component: LernCreatorForm, }, + { + moduleName: "nulp_elite", + path: routeConfig.ROUTES.LEARNATHON.MYLERNSUBMISSION, + component: LernSubmissionTable, + + }, ]; - createForm; + initializeI18n( ["translation"], `${process.env.PUBLIC_URL}/locales/{{lng}}/{{ns}}.json` @@ -327,6 +328,7 @@ function App() { + {/* */} {/* */} diff --git a/packages/nulp_elite/src/assets/image24.png b/packages/nulp_elite/src/assets/image24.png new file mode 100644 index 00000000..144c688d Binary files /dev/null and b/packages/nulp_elite/src/assets/image24.png differ diff --git a/packages/nulp_elite/src/components/Card.js b/packages/nulp_elite/src/components/Card.js index 81bbee96..8a12ec0d 100644 --- a/packages/nulp_elite/src/components/Card.js +++ b/packages/nulp_elite/src/components/Card.js @@ -18,7 +18,6 @@ export default function BoxCard({ items, index, onClick, continueLearning }) { const { t } = useTranslation(); useEffect(() => { - console.log("items-------", items); if (items.se_gradeLevels) { setSubdomain(processString(items.se_gradeLevels[0])); } else if (items.gradeLevel) { diff --git a/packages/nulp_elite/src/components/learnathon/LernModal.js b/packages/nulp_elite/src/components/learnathon/LernModal.js index 19b3248a..56c3f72a 100644 --- a/packages/nulp_elite/src/components/learnathon/LernModal.js +++ b/packages/nulp_elite/src/components/learnathon/LernModal.js @@ -1,13 +1,20 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Box, Typography, IconButton } from '@mui/material'; +import { Modal, Box, IconButton, Button, Grid } from '@mui/material'; import * as util from "services/utilService"; const urlConfig = require("../../configs/urlConfig.json"); import CloseIcon from "@mui/icons-material/Close"; import Divider from '@mui/material/Divider'; import { useTranslation } from "react-i18next"; +import { useNavigate } from 'react-router-dom'; +import axios from "axios"; +import ToasterCommon from 'pages/ToasterCommon'; const LernModal = () => { const { t } = useTranslation(); + const navigate = useNavigate(); + const [toasterMessage, setToasterMessage] = useState(""); + const [toasterOpen, setToasterOpen] = useState(false); + const [roleList, setRoleList] = useState([]); const [isModalOpen, setIsModalOpen] = useState(() => { // Check if the modal has been shown in the current session const isModalShown = sessionStorage.getItem('isModalShown'); @@ -15,24 +22,97 @@ const LernModal = () => { }); const [lernUser, setLernUser] = useState([]); + const [responseCode,setResponseCode] = useState([]); + const [orgId,setOrgId] = useState([]); const _userId = util.userId(); const handleClose = () => { setIsModalOpen(false); sessionStorage.setItem('isModalShown', 'true'); // Set flag to not show modal again }; + const fetchData = async () => { try { const url = `${urlConfig.URLS.LEARNER_PREFIX}${urlConfig.URLS.USER.GET_PROFILE}${_userId}`; const response = await fetch(url); const data = await response.json(); const rolesData = data.result.response.channel; + const roles =data.result.response.roles; + console.log(roles,'roles array'); + const organizationId=roles[0]?.scope[0]?.organisationId; + const extractedRoles = roles.map(roleObj => roleObj.role); + setRoleList(extractedRoles); + console.log(organizationId,'organizationId'); + setOrgId(organizationId); setLernUser(rolesData); } catch (error) { console.error("Error fetching user data:", error); } }; + const checkAccess = async () => { + try { + const url = `${urlConfig.URLS.CHECK_USER_ACCESS}`; + const response = await fetch(url); + const data = await response.json(); + + const userID = data.result.data; + const user = userID.find((user) => user.user_id === _userId); + + if (!user) { + console.log("User ID not found. Calling fetchUserAccess..."); + fetchUserAccess(); + } else if (user.creator_access === true) { + navigate('/webapp/mylernsubmissions'); + setIsModalOpen(false); + console.log("User ID found with creator access. No need to call fetchUserAccess."); + } else if (user.creator_access === false) { + console.log("User ID found but no creator access. Calling fetchUserAccess..."); + fetchUserAccess(); + } + } catch (error) { + console.error("Error fetching user data:", error); + } + }; + + + let responsecode; + const isCreator = roleList.includes("CONTENT_CREATOR"); + const fetchUserAccess = async () => { + try { + const url = `${urlConfig.URLS.PROVIDE_ACCESS}`; + const role = isCreator ? roleList : ["CONTENT_CREATOR", ...roleList]; + const requestPayload = { + request: { + organisationId: orgId, + roles: role, + userId: _userId, + }, + }; + + if (isCreator) { + requestPayload.isCreator = true; + } + + const response = await axios.post(url, requestPayload); + const data = await response.data; + const result = data.result.data.responseCode; + + responsecode = result; + setResponseCode(result); + + if (result === "OK") { + navigate('webapp/mylernsubmissions'); + setIsModalOpen(false); + } else { + setToasterMessage("Something went wrong! Please try again later"); + } + } catch (error) { + console.log('error', error); + } + }; + + // Fetch data when the component mounts or _userId changes useEffect(() => { if (_userId) { @@ -51,21 +131,44 @@ const LernModal = () => { boxShadow: 24, p: 4, overflow: "auto", + borderRadius:'10px', + width: { + xs: '100%', + sm: '100%', + md: '600px', + }, }; - console.log(lernUser,'lernUser form modal'); + + const handleCardClick = async () => { + if (lernUser === 'nulp-learn') { + navigate('/webapp/mylernsubmissions'); + setIsModalOpen(false); // Close the modal + } else{ + await checkAccess(); + } + }; + + return (
+ {toasterMessage && ( + + + + )} + - {t("LERN_title")} + {t("LERN_title")} @@ -75,20 +178,41 @@ const LernModal = () => { - - - - - {t("LERN_MESSAGE")} - - - - {lernUser === 'nulp-learn' ? ( - {t("CREATE_CONTENT")} - ) : ( - {t("REQUEST_TO_CREATE")} - )} + + + + + + + + + + + + {t("LERN_MESSAGE")} + + + {t("LERN_MESSAGE_LINE_TWO")} + + + + {lernUser === 'nulp-learn' ? ( + + ) : ( + + )} + + + +
diff --git a/packages/nulp_elite/src/configs/routeConfig.json b/packages/nulp_elite/src/configs/routeConfig.json index d923004c..4d884b00 100644 --- a/packages/nulp_elite/src/configs/routeConfig.json +++ b/packages/nulp_elite/src/configs/routeConfig.json @@ -85,7 +85,9 @@ "POLLS_VIEW_ALL": "/webapp/pollsDetails" }, "LEARNATHON": { - "CREATELEARNCONTENT": "/webapp/learnthon" + "CREATELEARNCONTENT": "/webapp/learnthon", + "SUBMISSIONLIST": "webapp/SubmissionList", + "MYLERNSUBMISSION": "/webapp/mylernsubmissions" } } } diff --git a/packages/nulp_elite/src/configs/urlConfig.json b/packages/nulp_elite/src/configs/urlConfig.json index 4650f216..2c2c0e31 100644 --- a/packages/nulp_elite/src/configs/urlConfig.json +++ b/packages/nulp_elite/src/configs/urlConfig.json @@ -49,8 +49,10 @@ "framework": "board,gradeLevel,medium,class,subject" }, "URLS": { - "CUSTOM_EVENT_FETCH_RECORDINGS":"/custom_event/fetch_recordings?event_id=", + "CUSTOM_EVENT_FETCH_RECORDINGS": "/custom_event/fetch_recordings?event_id=", "LEARNER_PREFIX": "/learner/", + "PROVIDE_ACCESS": "/learnathon/access/provide", + "CHECK_USER_ACCESS": "/learnathon/get/creators", "DISCUSSIONS_FORUM_PREFIX": "/discussion/", "DEVICE_PREFIX": "/device/", "CERT_REG_PREFIX": "/certreg/", @@ -144,6 +146,9 @@ "ATTACH_CERTIFICATE": "v1/template/add", "CREATE_CERT_TEMPLATE": "asset/v1/create", "UPLOAD_CERT_TEMPLATE": "asset/v1/upload" + "UPLOAD_CERT_TEMPLATE": "asset/v1/upload", + "CUSTOM_CERTIFICATE_CREATE": "/custom_event/certificate/create" + }, "COMPOSITE": { "SEARCH": "composite/v1/search", @@ -441,13 +446,19 @@ "USER_UPDATE": "/polls/user/update" }, "FEEDBACK": { - "CREATE" : "/custom_feedback/create", - "LIST" : "/custom_feedback/list" + "CREATE": "/custom_feedback/create", + "LIST": "/custom_feedback/list" }, - "NOTIFICATION" : { + "NOTIFICATION": { "READ": "notification/v1/feed/read/", - "UPDATE" : "notification/v1/feed/update", - "DELETE" : "notification/v1/feed/delete" + "UPDATE": "notification/v1/feed/update", + "DELETE": "notification/v1/feed/delete" + }, + "LEARNATHON": { + "LIST": "/learnathon/content/list", + "CREATE": "/learnathon/content/create", + "UPDATE": "/learnathon/content/update", + "DELETE": "/learnathon/content/delete" } } } diff --git a/packages/nulp_elite/src/pages/content/joinCourse.js b/packages/nulp_elite/src/pages/content/joinCourse.js index 09823174..f1515584 100644 --- a/packages/nulp_elite/src/pages/content/joinCourse.js +++ b/packages/nulp_elite/src/pages/content/joinCourse.js @@ -162,10 +162,11 @@ const JoinCourse = () => { setIsOwner(true); } let identifiers; - if(data?.result?.content?.children[0]?.children){ - identifiers = data?.result?.content?.children[0]?.children[0]?.identifier; - }else{ - identifiers = data?.result?.content?.children[0]?.identifier + if (data?.result?.content?.children[0]?.children) { + identifiers = + data?.result?.content?.children[0]?.children[0]?.identifier; + } else { + identifiers = data?.result?.content?.children[0]?.identifier; } console.log(identifiers, "setChildNode"); setChildNode(identifiers); @@ -617,18 +618,20 @@ const JoinCourse = () => { - + - {!isCompleted && + onClick={() => handleLinkClick(childnode)} + className="custom-btn-primary mr-5" + > + {t("START_LEARNING")} + + {!isCompleted && ( } @@ -693,7 +696,9 @@ const JoinCourse = () => { )}{" "} diff --git a/packages/nulp_elite/src/pages/learnathon/LernSubmissionTable.js b/packages/nulp_elite/src/pages/learnathon/LernSubmissionTable.js new file mode 100644 index 00000000..d9e92381 --- /dev/null +++ b/packages/nulp_elite/src/pages/learnathon/LernSubmissionTable.js @@ -0,0 +1,290 @@ +import React, { useState, useEffect } from "react"; +import { + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + TablePagination, + Paper, + TextField, + Button, + IconButton, + Typography, + Box, + DialogActions, +} from "@mui/material"; +import { useTranslation } from "react-i18next"; + +import * as util from "../../services/utilService"; +import Dialog from "@mui/material/Dialog"; +import DialogContent from "@mui/material/DialogContent"; +import { Edit, Visibility, Delete } from "@mui/icons-material"; +import SearchIcon from "@mui/icons-material/Search"; +import submissions from "./lernSubmission.json"; +import { useNavigate, useLocation } from "react-router-dom"; + +import Footer from "components/Footer"; +import Header from "components/header"; + +const LernSubmissionTable = () => { + const { t } = useTranslation(); + const navigate = useNavigate(); + const [data, setData] = useState([]); + const [page, setPage] = useState(0); + const [rowsPerPage, setRowsPerPage] = useState(5); + const [totalRows, setTotalRows] = useState(0); + const [search, setSearch] = useState(""); + const _userId = util.userId(); // Assuming util.userId() is defined + const urlConfig = require("../../configs/urlConfig.json"); + const [dialogOpen, setDialogOpen] = useState(false); + + const handleDialogOpen = () => { + setDialogOpen(true); + }; + + const routeConfig = require("../../configs/routeConfig.json"); + + useEffect(() => { + fetchData(); + }, [page, rowsPerPage, search]); + + const fetchData = async () => { + const assetBody = { + request: { + filters: { + created_by: _userId, + }, + sort_by: { + created_on: "desc", + }, + limit: rowsPerPage, + offset: page * rowsPerPage, + search: search, + }, + }; + try { + const response = await fetch(`${urlConfig.URLS.LEARNATHON.LIST}`, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(assetBody), + }); + + if (!response.ok) { + throw new Error("Failed to fetch polls"); + } + + const result = await response.json(); + console.log("suceesss----", result); + console.log(result.result); + setData(result.result.data); + setTotalRows(result.result.totalCount); + } catch (error) { + console.log("error---", error); + // setError(error.message); + } finally { + // setIsLoading(false); + } + + // Example API endpoint with limit, offset, and search params + // const apiUrl = `https://api.example.com/submissions?limit=${rowsPerPage}&offset=${ + // page * rowsPerPage + // }&search=${search}`; + // const response = await fetch(apiUrl); + + // const result = await response.json(); + // console.log(submissions); + // setData(submissions.result.data); + // setTotalRows(result.totalCount); + }; + + const handleSearchChange = (e) => { + setSearch(e.target.value); + setPage(0); // Reset to first page on search + }; + + const handleDialogClose = () => { + setDialogOpen(false); + }; + + const handleDeletePollConfirmed = async (id) => { + event.stopPropagation(); + try { + const response = await fetch( + `${urlConfig.URLS.LEARNATHON.DELETE}?id=${id}`, + { + method: "DELETE", + } + ); + + if (!response.ok) { + throw new Error("Failed to fetch polls"); + } + + const result = await response.json(); + console.log("suceesss----", result); + setDialogOpen(false); + } catch (error) { + console.log("error---", error); + // setError(error.message); + } finally { + // setIsLoading(false); + } + }; + + const deleteContent = async (id) => { + // show confirmation popup + }; + + const handlePageChange = (event, newPage) => { + setPage(newPage); + }; + + const handleRowsPerPageChange = (event) => { + setRowsPerPage(parseInt(event.target.value, 10)); + setPage(0); + }; + + return ( + <> +
+ + + Learnathon Submissions List + + + + + , + }} + size="small" + /> + + + + + + + Name + Last Updated + Status + Actions + + + + {data.map((row) => ( + + {row.title_of_submission} + + {new Date(row.updated_on).toLocaleDateString()} + + + {row.status} + + + {row.status == "draft" && ( + + (window.location.href = + routeConfig.ROUTES.LEARNATHON.CREATELEARNCONTENT + + "?" + + row.learnathon_content_id) + } + > + + + )} + { + + (window.location.href = + routeConfig.ROUTES.LEARNATHON.CREATELEARNCONTENT + + "?" + + row.learnathon_content_id) + } + > + + + } + {(row.status == "draft" || row.status == "review") && ( + handleDialogOpen()} + > + + + )} + + + ))} + +
+
+ + +
+ + + + Are you sure you want to delete this submission + + + + + + + +