Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const AttemptAssessmentButton = () => {
status: ['Live'],
primaryCategory: ['Practice Question Set'],
assessmentType: 'Eligibility Test',
program: [TENANT_DATA.SECOND_CHANCE_PROGRAM, 'Second Chance'],
program: uiConfig?.program || [TENANT_DATA.SECOND_CHANCE_PROGRAM, 'Second Chance'],
...(preferredLanguage ? { contentLanguage: [preferredLanguage] } : {}),
},
sort_by: { lastUpdatedOn: 'desc' },
Expand Down
7 changes: 5 additions & 2 deletions src/components/ContinueLearning/ContinueLearning.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import CoursesBox from '../CoursesBox/CoursesBox';
import CourseCard from '../CourseCard/CourseCard';
import { useNavigation } from '@react-navigation/native';
import { getDataFromStorage } from '../../utils/JsHelper/Helper';
import { CONTENT_PLATFORM_IDS } from '../../utils/Constants/app-constants';

const ContinueLearning = ({ youthnet, t, userId }) => {
const [data, setData] = useState([]);
Expand Down Expand Up @@ -80,8 +81,10 @@ const ContinueLearning = ({ youthnet, t, userId }) => {

const channelId = tenantData?.[0]?.channelId;
let mergedFilter={}
if(channelId == 'scp-channel'){
mergedFilter.targetBoardIds = ["scp-framework_board_cocurricular"];
if (channelId == CONTENT_PLATFORM_IDS.SCP.channelId && CONTENT_PLATFORM_IDS.SCP.boardId) {
mergedFilter.targetBoardIds = [CONTENT_PLATFORM_IDS.SCP.boardId];
} else if (channelId == CONTENT_PLATFORM_IDS.SCP_PATHWAYS.channelId && CONTENT_PLATFORM_IDS.SCP_PATHWAYS.boardId) {
mergedFilter.targetBoardIds = [CONTENT_PLATFORM_IDS.SCP_PATHWAYS.boardId];
}
let data = await courseListApi_New({
inprogress_do_ids,
Expand Down
10 changes: 8 additions & 2 deletions src/components/FilterModal/FilterList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getDataFromStorage,
getPreferredContentLanguageSelection,
} from '../../utils/JsHelper/Helper';
import { CONTENT_PLATFORM_IDS } from '../../utils/Constants/app-constants';

const FilterList = ({
setParentFormData,
Expand Down Expand Up @@ -708,7 +709,10 @@ const FilterList = ({

// Remove grade from default form data, but keep board
const filteredDefaultFormData = { ...defaultFormData };
if (filteredDefaultFormData.gradeLevel && channelId === 'scp-channel') {
const isScpChannel =
channelId === CONTENT_PLATFORM_IDS.SCP.channelId ||
channelId === CONTENT_PLATFORM_IDS.SCP_PATHWAYS.channelId;
if (filteredDefaultFormData.gradeLevel && isScpChannel) {
delete filteredDefaultFormData.gradeLevel;
}
// Keep board if it exists
Expand Down Expand Up @@ -789,7 +793,9 @@ const FilterList = ({
)}

{/* Dynamic Filters (Categories/Subdomains) */}
{channelId !== 'scp-channel' && sortFilterSections(renderForm || []).map((item, key) => {
{channelId !== CONTENT_PLATFORM_IDS.SCP.channelId &&
channelId !== CONTENT_PLATFORM_IDS.SCP_PATHWAYS.channelId &&
sortFilterSections(renderForm || []).map((item, key) => {
return (
(item?.name !== 'Domain' || isExplore == true) && (
renderFilterSection(item, key, false)
Expand Down
31 changes: 30 additions & 1 deletion src/components/Layout/SecondaryHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import Logo from '../../assets/images/png/logo.png';
import PropTypes from 'prop-types';
import GlobalText from '@components/GlobalText/GlobalText';
import ProgramSwitch from '../ProgramSwitch/ProgramSwitch';
import { TENANT_DATA } from '../../utils/Constants/app-constants';

const SecondaryHeader = ({ logo }) => {
const navigation = useNavigation();
const { setLanguage, language, t } = useTranslation();
const [selectedIndex, setSelectedIndex] = useState();
const [value, setValue] = useState();
const [userType, setUserType] = useState('');
const [programName, setProgramName] = useState('');
const [userId, setUserId] = useState('');
const [showProgramSwitch, setShowProgramSwitch] = useState(false);

Expand Down Expand Up @@ -57,13 +59,40 @@ const SecondaryHeader = ({ logo }) => {
try {
const storedUserType = await getDataFromStorage('userType');
const storedUserId = await getDataFromStorage('userId');
const storedTenantData = JSON.parse(
(await getDataFromStorage('tenantData')) || '[]'
);
setUserType(storedUserType || '');
setUserId(storedUserId || '');
setProgramName(storedTenantData?.[0]?.tenantName || '');
} catch (error) {
console.error('Error fetching userType or userId:', error);
}
};

const normalizeName = (name) => (name || '').trim().toLowerCase();
const normalizedProgramName = normalizeName(programName);

let displayProgramLabel;
if (normalizedProgramName === normalizeName(TENANT_DATA.SECOND_CHANCE_PROGRAM)) {
displayProgramLabel = t('second_chance_program');
} else if (normalizedProgramName === normalizeName(TENANT_DATA.SECOND_CHANCE_PROGRAM_PATHWAYS)) {
displayProgramLabel = t('second_chance_program_pathways');
} else if (normalizedProgramName === normalizeName(TENANT_DATA.YOUTHNET)) {
displayProgramLabel = t('vocational_training');
} else if (programName) {
displayProgramLabel = programName;
} else if (userType === 'youthnet') {
displayProgramLabel = t('vocational_training');
} else if (userType === 'scp') {
// Tenant name unavailable — SCP and Pathways both map to userType
// 'scp', so we can't tell which one this is. Show nothing rather
// than guessing and risking the wrong program name.
displayProgramLabel = '';
} else {
displayProgramLabel = userType;
}

const onSelect = (index) => {
//setSelectedIndex(index);
const selectedValue = languages[index.row].value;
Expand Down Expand Up @@ -112,7 +141,7 @@ const SecondaryHeader = ({ logo }) => {
onPress={handleProgramSwitchToggle}
>
<GlobalText style={styles.userTypeText} numberOfLines={1}>
{userType === "scp" ? "Second Chance Program" : userType === "youthnet" ? "Vocational Training" : userType}
{displayProgramLabel}
</GlobalText>
<Ionicons
name="chevron-down"
Expand Down
37 changes: 33 additions & 4 deletions src/components/ProgramSwitch/ProgramSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { NotificationUnsubscribe } from '../../utils/Helper/JSHelper';
const ProgramSwitch = ({ userId, onSuccess, onError, onClose }) => {
const [loading, setLoading] = useState(false);
const [currentUserType, setCurrentUserType] = useState('');
const [currentProgramName, setCurrentProgramName] = useState('');
const [enrolledPrograms, setEnrolledPrograms] = useState([]);
const [tenantData, setTenantData] = useState([]);
const navigation = useNavigation();
Expand Down Expand Up @@ -91,6 +92,11 @@ const ProgramSwitch = ({ userId, onSuccess, onError, onClose }) => {
const allTenantData = response.userData.tenantData;
setTenantData(allTenantData);

const currentTenant = allTenantData.find(
(tenant) => tenant.tenantId === currentTenantId
);
setCurrentProgramName(currentTenant?.tenantName || '');

// Filter tenants where role is "Learner" and status is "active" or "pending"
// AND exclude the current program
const filteredPrograms = allTenantData.filter((tenant) => {
Expand Down Expand Up @@ -236,7 +242,7 @@ const ProgramSwitch = ({ userId, onSuccess, onError, onClose }) => {
?.map((item) => item?.tenantId);

const scpTenantIds = tenantDetails
?.filter((item) => item?.name === TENANT_DATA.SECOND_CHANCE_PROGRAM)
?.filter((item) => [TENANT_DATA.SECOND_CHANCE_PROGRAM, TENANT_DATA.SECOND_CHANCE_PROGRAM_PATHWAYS].includes(item?.name))
?.map((item) => item?.tenantId);

const campToClubTenantIds = tenantDetails
Expand Down Expand Up @@ -295,7 +301,7 @@ const ProgramSwitch = ({ userId, onSuccess, onError, onClose }) => {
index: 0,
routes: [{ name: 'SCPUserTabScreen' }],
});
} else if (selectedTenantName === TENANT_DATA.SECOND_CHANCE_PROGRAM) {
} else if ([TENANT_DATA.SECOND_CHANCE_PROGRAM, TENANT_DATA.SECOND_CHANCE_PROGRAM_PATHWAYS].includes(selectedTenantName)) {
console.log('#### Navigating to SCP (matched by tenant name)');
await setDataInStorage('userType', 'scp');
navigation.reset({
Expand Down Expand Up @@ -608,6 +614,29 @@ const ProgramSwitch = ({ userId, onSuccess, onError, onClose }) => {



const normalizeName = (name) => (name || '').trim().toLowerCase();
const normalizedCurrentProgramName = normalizeName(currentProgramName);

let headerProgramLabel;
if (normalizedCurrentProgramName === normalizeName(TENANT_DATA.SECOND_CHANCE_PROGRAM)) {
headerProgramLabel = t('second_chance_program');
} else if (normalizedCurrentProgramName === normalizeName(TENANT_DATA.SECOND_CHANCE_PROGRAM_PATHWAYS)) {
headerProgramLabel = t('second_chance_program_pathways');
} else if (normalizedCurrentProgramName === normalizeName(TENANT_DATA.YOUTHNET)) {
headerProgramLabel = t('vocational_training');
} else if (currentProgramName) {
headerProgramLabel = currentProgramName;
} else if (currentUserType === 'youthnet') {
headerProgramLabel = t('vocational_training');
} else if (currentUserType === 'scp') {
// Tenant name unavailable (e.g. fetch failed) — SCP and Pathways both
// map to userType 'scp', so we can't tell which one this is. Show
// nothing rather than guessing and risking the wrong program name.
headerProgramLabel = '';
} else {
headerProgramLabel = currentUserType;
}

return (
<View style={styles.container}>
{loading ? (
Expand All @@ -616,14 +645,14 @@ const ProgramSwitch = ({ userId, onSuccess, onError, onClose }) => {
<GlobalText style={styles.loadingText}>{t('loading_programs')}</GlobalText>
</View>
) : (
<ScrollView
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={styles.scrollContent}
>
{/* Current Program Header */}
<View style={styles.headerContainer}>
<GlobalText style={styles.currentProgramTitle}>
{currentUserType === 'scp' ? t('second_chance_program') : currentUserType === 'youthnet' ? t('vocational_training') : currentUserType}
{headerProgramLabel}
</GlobalText>
</View>

Expand Down
3 changes: 2 additions & 1 deletion src/context/locales/ba.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "কোনও ডেটা পাওয়া যায়নি",
"my_profile": "আমার প্রোফাইল",
"second_chance_program": "দ্বিতীয় সুযোগ প্রোগ্রাম",
"second_chance_program_pathways": "দ্বিতীয় সুযোগ কর্মসূচির পথসমূহ",
"logout": "লগ আউট",
"general_instructions": "সাধারণ নির্দেশিকা",
"test_medium": "পরীক্ষার মাধ্যম",
Expand Down Expand Up @@ -625,4 +626,4 @@
"attempt_assessment": "Attempt Assessment",
"come_back_later": "Come Back Later",
"assessment_unavailable_message": "No pending assessment available at this time."
}
}
1 change: 1 addition & 0 deletions src/context/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "No Data Found",
"my_profile": "My Profile",
"second_chance_program": "Second Chance Program",
"second_chance_program_pathways": "Second Chance Program Pathways",
"logout": "Log Out",
"general_instructions": "General Instructions",
"test_medium": "Test Medium",
Expand Down
3 changes: 2 additions & 1 deletion src/context/locales/gu.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "કોઈ ડેટા મળ્યો નથી",
"my_profile": "મારું પ્રોફાઈલ",
"second_chance_program": "સેકન્ડ ચાંસ પ્રોગ્રામ",
"second_chance_program_pathways": "બીજી તક કાર્યક્રમના માર્ગો",
"logout": "લોગઆઉટ",
"general_instructions": "સામાન્ય સૂચનાઓ",
"test_medium": "પરીક્ષા માધ્યમ",
Expand Down Expand Up @@ -637,4 +638,4 @@
"switched_to": "પર બદલાયું",
"failed_to_switch_program_please_try_again": "કાર્યક્રમ બદલવામાં નિષ્ફળ. કૃપા કરીને ફરી પ્રયાસ કરો.",
"show_all_programs": "બધા કાર્યક્રમો બતાવો"
}
}
3 changes: 2 additions & 1 deletion src/context/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "कोई डेटा नहीं मिला",
"my_profile": "मेरा प्रोफाइल",
"second_chance_program": "दूसरा मौका कार्यक्रम",
"second_chance_program_pathways": "दूसरा मौका कार्यक्रम के मार्ग",
"logout": "लॉगआउट करें",
"general_instructions": "सामान्य निर्देश",
"test_medium": "परीक्षण माध्यम",
Expand Down Expand Up @@ -637,4 +638,4 @@
"switched_to": "बदलकर किया गया",
"failed_to_switch_program_please_try_again": "कार्यक्रम बदलने में विफल। कृपया पुनः प्रयास करें।",
"show_all_programs": "सभी कार्यक्रम दिखाएँ"
}
}
3 changes: 2 additions & 1 deletion src/context/locales/ka.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "ಎ ಯಾವುದೇ ಡೇಟಾ ಕಂಡುಬಂದಿಲ್ಲ",
"my_profile": "ನನ್ನ ಪ್ರೊಫೈಲ್",
"second_chance_program": "ಸೆಕಂಡ್ ಚಾನ್ಸ್ ಪ್ರೋಗ್ರಾಂ",
"second_chance_program_pathways": "ಎರಡನೇ ಅವಕಾಶ ಕಾರ್ಯಕ್ರಮದ ಮಾರ್ಗಗಳು",
"logout": "ಲಾಗ್‌ಔಟ್",
"general_instructions": "ಸಾಮಾನ್ಯ ನಿರ್ದೇಶನಗಳು",
"test_medium": "ಪರೀಕ್ಷೆ ಮಾಧ್ಯಮ",
Expand Down Expand Up @@ -637,4 +638,4 @@
"switched_to": "ಗೆ ಬದಲಾಯಿಸಲಾಗಿದೆ",
"failed_to_switch_program_please_try_again": "ಕಾರ್ಯಕ್ರಮ ಬದಲಾಯಿಸಲು ವಿಫಲವಾಗಿದೆ. ದಯವಿಟ್ಟು ಮತ್ತೆ ಪ್ರಯತ್ನಿಸಿ.",
"show_all_programs": "ಎಲ್ಲಾ ಕಾರ್ಯಕ್ರಮಗಳನ್ನು ತೋರಿಸಿ"
}
}
3 changes: 2 additions & 1 deletion src/context/locales/ma.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "कोणतीही माहिती आढळली नाही",
"my_profile": "माझे प्रोफाइल",
"second_chance_program": "दुसरी संधी कार्यक्रम",
"second_chance_program_pathways": "दुसरी संधी कार्यक्रमाचे मार्ग",
"logout": "लॉगआउट करा",
"general_instructions": "सर्वसाधारण सूचना",
"test_medium": "चाचणी माध्यम",
Expand Down Expand Up @@ -637,4 +638,4 @@
"switched_to": "यावर बदलले",
"failed_to_switch_program_please_try_again": "कार्यक्रम बदलण्यात अयशस्वी. कृपया पुन्हा प्रयत्न करा.",
"show_all_programs": "सर्व कार्यक्रम दाखवा"
}
}
3 changes: 2 additions & 1 deletion src/context/locales/odia.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "କୌଣସି ତଥ୍ୟ ମିଳିଲା ନାହିଁ",
"my_profile": "ମୋ ପ୍ରୋଫାଇଲ",
"second_chance_program": "ସେକେଣ୍ଡ ଚାନ୍ସ ପ୍ରୋଗ୍ରାମ",
"second_chance_program_pathways": "ଦ୍ୱିତୀୟ ସୁଯୋଗ କାର୍ଯ୍ୟକ୍ରମର ପଥଗୁଡ଼ିକ",
"logout": "ଲଗ୍ ଆଉଟ",
"general_instructions": "ସାଧାରଣ ନିର୍ଦ୍ଦେଶ",
"test_medium": "ପରୀକ୍ଷା ମାଧ୍ୟମ",
Expand Down Expand Up @@ -637,4 +638,4 @@
"switched_to": "ବଦଳାଇ ଦିଆଗଲା",
"failed_to_switch_program_please_try_again": "କାର୍ଯ୍ୟକ୍ରମ ବଦଳାଇବାରେ ବିଫଳ। ଦୟାକରି ପୁନଃ ଚେଷ୍ଟା କରନ୍ତୁ।",
"show_all_programs": "ସମସ୍ତ କାର୍ଯ୍ୟକ୍ରମ ଦେଖାନ୍ତୁ"
}
}
3 changes: 2 additions & 1 deletion src/context/locales/ta.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "தரவு எதுவும் இல்லை",
"my_profile": "எனது புரொஃபைல்",
"second_chance_program": "செகண்ட் சான்ஸ் புரோகிராம்",
"second_chance_program_pathways": "இரண்டாவது வாய்ப்பு திட்டத்தின் வழிகள்",
"logout": "லாக்அவுட்",
"general_instructions": "பொதுவான வழிமுறைகள்",
"test_medium": "தேர்வு மொழி",
Expand Down Expand Up @@ -637,4 +638,4 @@
"switched_to": "மாற்றப்பட்டது",
"failed_to_switch_program_please_try_again": "திட்டத்தை மாற்ற முடியவில்லை. மீண்டும் முயற்சிக்கவும்.",
"show_all_programs": "அனைத்து திட்டங்களையும் காட்டு"
}
}
3 changes: 2 additions & 1 deletion src/context/locales/te.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "డేటా కనుగొనబడలేదు",
"my_profile": "నా ప్రొఫైల్",
"second_chance_program": "సెకండ్ ఛాన్స్ ప్రోగ్రామ్",
"second_chance_program_pathways": "రెండవ అవకాశం కార్యక్రమ మార్గాలు",
"logout": "లాగ్ అవుట్",
"general_instructions": "సాధారణ సూచనలు",
"test_medium": "పరీక్ష మాధ్యమం",
Expand Down Expand Up @@ -637,4 +638,4 @@
"switched_to": "కు మార్చబడింది",
"failed_to_switch_program_please_try_again": "ప్రోగ్రామ్‌ను మార్చడంలో విఫలమైంది. దయచేసి మళ్లీ ప్రయత్నించండి.",
"show_all_programs": "అన్ని ప్రోగ్రామ్‌లను చూపించు"
}
}
3 changes: 2 additions & 1 deletion src/context/locales/ur.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
"no_data_found": "کوئی ڈیٹا نہیں ملا",
"my_profile": "میرا پروفائل",
"second_chance_program": "سکنڈ چانس پروگرام",
"second_chance_program_pathways": "دوسرے موقع کے پروگرام کے راستے",
"logout": "لاگ آؤٹ",
"general_instructions": "عام ہدایات",
"test_medium": "ٹیسٹ کا ذریعہ",
Expand Down Expand Up @@ -637,4 +638,4 @@
"switched_to": "میں تبدیل کر دیا گیا",
"failed_to_switch_program_please_try_again": "پروگرام تبدیل کرنے میں ناکامی۔ براہ کرم دوبارہ کوشش کریں۔",
"show_all_programs": "تمام پروگرام دکھائیں"
}
}
9 changes: 2 additions & 7 deletions src/screens/Dashboard/Contents.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import SyncCard from '../../components/SyncComponent/SyncCard';
import BackButtonHandler from '../../components/BackNavigation/BackButtonHandler';
import {
capitalizeName,
getContentPlatformIds,
getDataFromStorage,
logEventFunction,
} from '../../utils/JsHelper/Helper';
Expand Down Expand Up @@ -165,13 +166,7 @@ const Contents = () => {
setLoadingMore(true);
}
console.log('refreshed');
let userType = await getDataFromStorage('userType');
const instant =
userType === 'youthnet'
? { frameworkId: 'pos-framework', channelId: 'pos-channel' }
: userType === 'scp'
? { frameworkId: 'scp-framework', channelId: 'scp-channel' }
: { frameworkId: 'pos-framework', channelId: 'pos-channel' };
const instant = await getContentPlatformIds();

const data = await contentListApi_Pratham({ searchText, instant, offset });
//found content progress
Expand Down
Loading