From 0662391b63e95f071d911c7078efe0d8f9e92384 Mon Sep 17 00:00:00 2001 From: ttpl-rt-214 Date: Wed, 21 Aug 2024 17:03:25 +0530 Subject: [PATCH] #PS-1317 fixPS-1527 UI Improvement --- src/components/CenterSessionModal.tsx | 3 ++- src/components/LearnersListItem.tsx | 2 ++ src/components/PlannedSession.tsx | 10 ++++----- src/components/SessionCard.tsx | 32 +++++++++++++++++++++++++-- src/utils/Interfaces.ts | 6 +++-- 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/components/CenterSessionModal.tsx b/src/components/CenterSessionModal.tsx index 7083bd57..fa9a51cc 100644 --- a/src/components/CenterSessionModal.tsx +++ b/src/components/CenterSessionModal.tsx @@ -20,6 +20,7 @@ const CenterSessionModal: React.FC = ({ date, secondary, handlePrimaryModel, + handleEditModal }) => { const theme = useTheme(); const { t } = useTranslation(); @@ -164,7 +165,7 @@ const CenterSessionModal: React.FC = ({ width: '100%', }, }} - onClick={handlePrimaryModel} + onClick={handlePrimaryModel || handleEditModal} > {primary} diff --git a/src/components/LearnersListItem.tsx b/src/components/LearnersListItem.tsx index 21e204fb..e14dcc6e 100644 --- a/src/components/LearnersListItem.tsx +++ b/src/components/LearnersListItem.tsx @@ -356,6 +356,8 @@ const LearnersListItem: React.FC = ({ const handleMenuOpen = (event: any) => { setAnchorEl(event.currentTarget); + setCohortLearnerDeleteId(cohortMembershipId); + setReassignId(userId); }; const renderCustomContent = () => { diff --git a/src/components/PlannedSession.tsx b/src/components/PlannedSession.tsx index 92083096..b55d4f24 100644 --- a/src/components/PlannedSession.tsx +++ b/src/components/PlannedSession.tsx @@ -82,7 +82,9 @@ const PlannedSession: React.FC = ({ cohortName, cohortId, onCloseModal, - editSession + editSession, + handleEditSelection, + editSelection }) => { const [mode, setMode] = useState(sessionMode.OFFLINE); const [eventType, setEventType] = useState(sessionType.REPEATING); @@ -92,7 +94,7 @@ const PlannedSession: React.FC = ({ const [modalOpen, setModalOpen] = React.useState(false); const [selectedSubject, setSelectedSubject] = useState(); const [selectedBlockId, setSelectedBlockId] = useState(0); - const [editSelection, setEditSelection] = React.useState('EDIT_SESSION'); + const [subjects, setSubjects] = useState(); dayjs.extend(utc); const [startDate, setStartDate] = useState(dayjs()); @@ -127,9 +129,7 @@ const PlannedSession: React.FC = ({ const handleCloseModal =() => { setModalOpen(false); } - const handleEditSelection = (selection: string) => { - setEditSelection(selection); - }; + useEffect(() => { const initialStartDateTime = combineDateAndTime(startDate, startTime); diff --git a/src/components/SessionCard.tsx b/src/components/SessionCard.tsx index c15c8cb7..5da0477d 100644 --- a/src/components/SessionCard.tsx +++ b/src/components/SessionCard.tsx @@ -10,6 +10,8 @@ import { useTheme } from '@mui/material/styles'; import { convertUTCToIST } from '@/utils/Helper'; import { useTranslation } from 'next-i18next'; import CalendarMonthIcon from '@mui/icons-material/CalendarMonth'; +import ConfirmationModal from './ConfirmationModal'; + const SessionsCard: React.FC = ({ data, children }) => { const theme = useTheme(); @@ -20,8 +22,15 @@ const SessionsCard: React.FC = ({ data, children }) => { const [endTime, setEndTime] = React.useState(''); const [startDate, setStartDate] = React.useState(''); const [editSession, setEditSession] = React.useState(''); + const [modalOpen, setModalOpen] = React.useState(false); + const [editSelection, setEditSelection] = React.useState('EDIT_SESSION'); + + const handleEditSelection = (selection: string) => { + setEditSelection(selection); + }; + const handleOpen = (selection: string) => { setOpen(true) setEditSession(selection); @@ -57,6 +66,14 @@ const SessionsCard: React.FC = ({ data, children }) => { console.log(startDate, startTime, endDate, endTime); }, [data]); + const handleCloseModal = () => { + setModalOpen(false); + } + + const handleEditModal = () => { + setModalOpen(true); + } + return ( = ({ data, children }) => { open={open} handleClose={handleClose} title={'Home Science'} - primary={'Schedule'} + primary={editSession === 'EDIT_SESSION' ? "Update" : 'Schedule'} + handleEditModal={handleEditModal} > - + {children} @@ -152,8 +170,18 @@ const SessionsCard: React.FC = ({ data, children }) => { onClose={handleSnackbarClose} message="URL copied to clipboard" /> + ); + }; export default SessionsCard; diff --git a/src/utils/Interfaces.ts b/src/utils/Interfaces.ts index e058b20d..6cdc5937 100644 --- a/src/utils/Interfaces.ts +++ b/src/utils/Interfaces.ts @@ -140,6 +140,7 @@ export interface SessionsModalProps { date?: string; handlePrimaryModel?: () => void; secondary?: string; + handleEditModal?: () => void; } export interface PlannedModalProps { @@ -149,8 +150,9 @@ export interface PlannedModalProps { cohortName?: string; cohortId?: string; onCloseModal?: () => void | undefined; - editSession?: string; - + editSelection: string; + handleEditSelection: (selection: string) => void; + editSession: string; } export interface ScheduleModalProps {