Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src/screens/Dashboard/Preference/SCPDashboard/SubjectCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -73,26 +79,22 @@ const SubjectCard = ({ item }) => {
{/* Subject Name */}

<View style={{ padding: 15 }}>
<View
style={[globalStyles.flexrow, { justifyContent: 'space-between' }]}
>
<View style={[globalStyles.flexrow]}>
{!item?.onlineDetails ? (
<Icon name="building" size={20} color="#000" />
) : (
<SimpleIcon name="social-youtube" size={20} color="#000" />
)}
<GlobalText style={[globalStyles.subHeading, { marginLeft: 5 }]}>
{item?.metadata?.subject}
</GlobalText>
</View>

<GlobalText style={[globalStyles.text]}>
{formatDateTimeRange(item?.startDateTime)} -
{formatDateTimeRange(item?.endDateTime)}
<View style={[globalStyles.flexrow]}>
{!item?.onlineDetails ? (
<Icon name="building" size={20} color="#000" />
) : (
<SimpleIcon name="social-youtube" size={20} color="#000" />
)}
<GlobalText style={[globalStyles.subHeading, { marginLeft: 5 }]}>
{cardTitle}
</GlobalText>
</View>

<GlobalText style={[globalStyles.text, { marginTop: 5 }]}>
{formatDateTimeRange(item?.startDateTime)} -
{formatDateTimeRange(item?.endDateTime)}
</GlobalText>

<GlobalText
style={[globalStyles.text, { color: '#7C766F', marginTop: 5 }]}
>
Expand Down
15 changes: 10 additions & 5 deletions src/utils/API/AuthService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}' \\
Expand All @@ -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) {
Expand Down
14 changes: 6 additions & 8 deletions src/utils/JsHelper/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down