diff --git a/src/screens/Dashboard/Preference/SCPDashboard/SubjectCard.js b/src/screens/Dashboard/Preference/SCPDashboard/SubjectCard.js index eeeeb063..354b8fc1 100644 --- a/src/screens/Dashboard/Preference/SCPDashboard/SubjectCard.js +++ b/src/screens/Dashboard/Preference/SCPDashboard/SubjectCard.js @@ -48,6 +48,12 @@ const SubjectCard = ({ item }) => { const { t } = useTranslation(); const navigation = useNavigation(); + // "Subject - Short description", as the web UI shows it. Either part can be + // empty on events created without one, so only join what is actually there. + const cardTitle = [item?.metadata?.subject, item?.shortDescription] + .filter(Boolean) + .join(' - '); + const handleCopyLink = (zoomLink) => { Clipboard.setString(zoomLink); // Copy the Zoom link to the clipboard setShowToast(true); // Show toast message @@ -73,26 +79,22 @@ const SubjectCard = ({ item }) => { {/* Subject Name */} - - - {!item?.onlineDetails ? ( - - ) : ( - - )} - - {item?.metadata?.subject} - - - - - {formatDateTimeRange(item?.startDateTime)} - - {formatDateTimeRange(item?.endDateTime)} + + {!item?.onlineDetails ? ( + + ) : ( + + )} + + {cardTitle} + + {formatDateTimeRange(item?.startDateTime)} - + {formatDateTimeRange(item?.endDateTime)} + + diff --git a/src/utils/API/AuthService.js b/src/utils/API/AuthService.js index 50a71b68..4d6822cd 100644 --- a/src/utils/API/AuthService.js +++ b/src/utils/API/AuthService.js @@ -1789,21 +1789,26 @@ export const eventList = async ({ startDate, endDate }) => { const user_id = await getDataFromStorage('userId'); // Ensure this is defined const url = `${EndUrls.eventList}`; // Define the URL const headers = await getHeaders(); + const academicYearId = await getDataFromStorage('academicYearId'); const cohort = JSON.parse(await getDataFromStorage('cohortData')); const payload = { limit: 0, offset: 0, filters: { - date: { + // cohortData holds the learner's active BATCH cohort, so this scopes + // events to their own batch only. Omitted entirely when no batch is + // selected, so the server never receives [null]. + ...(cohort?.cohortId ? { cohortIds: [cohort.cohortId] } : {}), + startDate: { after: startDate, + }, + endDate: { before: endDate, }, - // cohortData holds the learner's active BATCH cohort, so this scopes - // events to their own batch only - cohortIds: [cohort?.cohortId], status: ['live'], }, }; + try { // const curlCommand = ` // curl -X POST '${url}' \\ @@ -1817,7 +1822,7 @@ export const eventList = async ({ startDate, endDate }) => { // Make the actual request const result = await post(url, payload, { - headers: headers || {}, + headers: { ...headers, academicyearid: academicYearId }, }); if (result) { diff --git a/src/utils/JsHelper/Helper.js b/src/utils/JsHelper/Helper.js index 9f60bbe1..be7fa987 100644 --- a/src/utils/JsHelper/Helper.js +++ b/src/utils/JsHelper/Helper.js @@ -947,16 +947,14 @@ export const categorizeEvents = async (events) => { const plannedSessions = []; const extraSessions = []; + // The teacher app marks the session kind on metadata.type ('planned' or + // 'extra'); a one-off planned session is still planned, so isRecurring is not + // the right signal. Anything without a recognised type falls back to planned. events?.forEach((event) => { - // metadata.type ('planned' | 'extra') is the source of truth; a planned - // session can be non-recurring. Fall back to isRecurring for older events - // created without a type. - const type = event?.metadata?.type?.toLowerCase(); - const isPlanned = type ? type === 'planned' : event?.isRecurring; - if (isPlanned) { - plannedSessions.push(event); - } else { + if (event?.metadata?.type === 'extra') { extraSessions.push(event); + } else { + plannedSessions.push(event); } });