From 14f1d12e2866d71f4501d63c938cf36fcf640fea Mon Sep 17 00:00:00 2001 From: mayura-andrew Date: Tue, 1 Oct 2024 01:53:27 +0530 Subject: [PATCH] Refactor code: Update badge styling in ToggleButton component --- .../MonthlyChecking/MenteeMonthlyChecking.tsx | 2 +- .../MentorFeedbackForm.component.tsx | 4 +- .../MonthlyChecking/MentorMonthlyChecking.tsx | 4 +- .../MonthlyChecking/MonthlyCheckingHeader.tsx | 34 +--- src/components/Toggle/ButtonToggle.tsx | 11 +- src/pages/MenteeDashboard/index.tsx | 95 ++++++---- src/pages/MyMentees/MyMentees.component.tsx | 169 ++++++++++++------ 7 files changed, 183 insertions(+), 136 deletions(-) diff --git a/src/components/MonthlyChecking/MenteeMonthlyChecking.tsx b/src/components/MonthlyChecking/MenteeMonthlyChecking.tsx index cfd28a39..418a41f2 100644 --- a/src/components/MonthlyChecking/MenteeMonthlyChecking.tsx +++ b/src/components/MonthlyChecking/MenteeMonthlyChecking.tsx @@ -18,7 +18,7 @@ const CheckInItem: React.FC = ({ checkIn }) => (
-

+

{' '} {checkIn.title}

diff --git a/src/components/MonthlyChecking/MentorFeedbackForm.component.tsx b/src/components/MonthlyChecking/MentorFeedbackForm.component.tsx index 5a99b715..3c6fc8cc 100644 --- a/src/components/MonthlyChecking/MentorFeedbackForm.component.tsx +++ b/src/components/MonthlyChecking/MentorFeedbackForm.component.tsx @@ -83,11 +83,11 @@ const MentorFeedbackForm: React.FC = ({ - )} -
@@ -113,11 +90,6 @@ const MonthlyCheckInHeader: React.FC = ({
)} - ); }; diff --git a/src/components/Toggle/ButtonToggle.tsx b/src/components/Toggle/ButtonToggle.tsx index 6c036d4f..3ea47b4b 100644 --- a/src/components/Toggle/ButtonToggle.tsx +++ b/src/components/Toggle/ButtonToggle.tsx @@ -24,6 +24,7 @@ const ToggleButton: React.FC = ({ className="flex items-center justify-between w-full text-left text-xl font-bold text-gray-900 mb-4 focus:outline-none hover:text-blue-600 transition-colors duration-200" > + {isOpen ? : } {text} {badgeCount !== undefined && badgeCount >= 0 && @@ -35,16 +36,6 @@ const ToggleButton: React.FC = ({ ))} - - {isOpen ? ( - <> - - - ) : ( - <> - - - )} ); diff --git a/src/pages/MenteeDashboard/index.tsx b/src/pages/MenteeDashboard/index.tsx index af19f34e..17de4cba 100644 --- a/src/pages/MenteeDashboard/index.tsx +++ b/src/pages/MenteeDashboard/index.tsx @@ -4,6 +4,7 @@ import useMyApplications from '../../hooks/useMyApplications'; import MentorCard from '../../components/MentorCard/MentorCard.component'; import MonthlyCheckInHeader from '../../components/MonthlyChecking/MonthlyCheckingHeader'; import MenteeMonthlyChecking from '../../components/MonthlyChecking/MenteeMonthlyChecking'; +import MonthlyCheckInModal from '../../components/MonthlyChecking/MenteeCheckInFormModal.component'; const MenteeDashboard: React.FC = () => { const [showGuidelines, setShowGuidelines] = useState(true); @@ -19,56 +20,84 @@ const MenteeDashboard: React.FC = () => { const toggleGuidelines = () => { setShowGuidelines((prev) => !prev); }; + const [isModalOpen, setIsModalOpen] = useState(false); + + const closeModal = () => { + setIsModalOpen(false); + }; + + const openModal = () => { + setIsModalOpen(true); + }; const isApproved = approvedApplications.length > 0; const menteeId = isApproved ? approvedApplications[0].uuid : ''; return ( -
-
-
- {isApproved ? ( - <> - - - - ) : ( -
+ <> +
+
+
+ {isApproved ? ( + <> +
+

+ Monthly Check-Ins +

+
+ +
+ + +
+ + ) : ( +
+

+ Your pending mentee applications: +

+
+ {pendingApplications.length > 0 + ? pendingApplications.map(({ mentor, uuid }) => ( + + )) + : 'No mentors'} +
+
+ )} +
+
+

- Your pending mentee applications: + Your approved mentee applications:

- {pendingApplications.length > 0 - ? pendingApplications.map(({ mentor, uuid }) => ( + {approvedApplications.length > 0 + ? approvedApplications.map(({ mentor, uuid }) => ( )) : 'No mentors'}
- )} -
-
-
-

- Your approved mentee applications: -

-
- {approvedApplications.length > 0 - ? approvedApplications.map(({ mentor, uuid }) => ( - - )) - : 'No mentors'} -
-
+ + ); }; diff --git a/src/pages/MyMentees/MyMentees.component.tsx b/src/pages/MyMentees/MyMentees.component.tsx index ca43a649..7e7b1190 100644 --- a/src/pages/MyMentees/MyMentees.component.tsx +++ b/src/pages/MyMentees/MyMentees.component.tsx @@ -1,6 +1,6 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect } from 'react'; import { useMentees } from '../../hooks/useMentees'; -import { Link, Route, Routes, useParams } from 'react-router-dom'; +import { Link, Route, Routes, useParams, useNavigate } from 'react-router-dom'; import MenteeProfile from '../../components/MenteeProfile'; import UserIcon from '../../assets/svg/Icons/UserIcon'; import MonthlyCheckInHeader from '../../components/MonthlyChecking/MonthlyCheckingHeader'; @@ -11,12 +11,22 @@ import { Mentee } from '../../types'; const MyMentees: React.FC = () => { const { data: menteeApplications } = useMentees(); - const [activeTab, setActiveTab] = useState( ApplicationStatus.APPROVED ); + const [isMobile, setIsMobile] = useState(window.innerWidth < 768); + const navigate = useNavigate(); + + useEffect(() => { + const handleResize = () => { + setIsMobile(window.innerWidth < 768); + }; - const [isMenteeSelected, setIsMenteeSelected] = useState(false); + window.addEventListener('resize', handleResize); + return () => { + window.removeEventListener('resize', handleResize); + }; + }, []); const filteredApplications = menteeApplications?.filter((mentee) => mentee.state === activeTab) || []; @@ -31,9 +41,6 @@ const MyMentees: React.FC = () => { key={mentee.uuid} className="bg-white border-sky-100 rounded border p-2 text-black flex items-center cursor-pointer mb-2 hover:bg-gray-50 transition-colors duration-200" to={`/mentor/dashboard/${mentee.uuid}`} - onClick={() => { - setIsMenteeSelected(true); - }} >
@@ -60,62 +67,97 @@ const MyMentees: React.FC = () => { ); - return ( -
-
-
-

Mentee Applications

-
-
- {tabData.map((tab) => ( - - ))} -
-
- {filteredApplications.map(renderMenteeLink)} - {filteredApplications.length === 0 && ( -

No mentee applications available.

- )} -
+ const renderMenteeList = () => ( +
+
+

Mentee Applications

-
- {!isMenteeSelected && ( -
-

- Welcome to the ScholarX Mentee Dashboard! -

-

- Here, you can view your mentees and provide feedback on their - monthly check-ins. Click on a mentee to view their profile and - their monthly check-in submissions. -

-
+
+ {tabData.map((tab) => ( + + ))} +
+
+ {filteredApplications.map(renderMenteeLink)} + {filteredApplications.length === 0 && ( +

No mentee applications available.

)} +
+
+ ); + + return ( +
+ {isMobile ? ( - } /> + + { + navigate('/mentor/dashboard'); + }} + isMobile={isMobile} + /> + } + /> -
+ ) : ( + <> + {renderMenteeList()} +
+ + } /> + {}} isMobile={isMobile} /> + } + /> + +
+ + )}
); }; -const MenteeDetails: React.FC = () => { +const WelcomeMessage: React.FC = () => ( +
+

+ Welcome to the ScholarX Mentee Dashboard! +

+

+ Here, you can view your mentees and provide feedback on their monthly + check-ins. Click on a mentee to view their profile and their monthly + check-in submissions. +

+
+); + +const MenteeDetails: React.FC<{ onBack: () => void; isMobile: boolean }> = ({ + onBack, + isMobile, +}) => { const { menteeId } = useParams<{ menteeId: string }>(); const [showGuidelines, setShowGuidelines] = useState(true); @@ -130,9 +172,22 @@ const MenteeDetails: React.FC = () => { } = useMonthlyCheckIns(menteeId ?? ''); return ( -
+
+ {isMobile && ( + + )} -
+
+
+

+ Monthly Check-Ins +

+