Skip to content

Commit

Permalink
Merge pull request #556 from AkshataKatwal16/reassign-cohorts
Browse files Browse the repository at this point in the history
Issue feat: add facilitator and learner counts over a tabs
  • Loading branch information
itsvick authored Dec 31, 2024
2 parents 5d19d3e + 85b76e5 commit af205e8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
5 changes: 2 additions & 3 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@
"NA": "N.A.",
"SORT_BY_NAMES": "Sort by Names",
"INCORRECT_DATA_ENTRY": "Incorrect Data Entry",
"DUPLICATED_USER": "Duplicated User",
"FACILITATOR_COUNT": "Facilitators Total count: {{count}}",
"LEARNER_COUNT": "Learners Total count: {{count}}"
"DUPLICATED_USER": "Duplicated User"


},
"LOGIN_PAGE": {
Expand Down
14 changes: 6 additions & 8 deletions src/components/CohortFacilitatorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import NoDataFound from './common/NoDataFound';
import Loader from './Loader';
import { showToastMessage } from './Toastify';
import SearchBar from './Searchbar';
import { useRouter } from 'next/router';
import useStore from '@/store/store';

interface UserDataProps {
name: string;
Expand All @@ -38,6 +40,8 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({

const [filteredData, setFilteredData] = React.useState(userData);
const [searchTerm, setSearchTerm] = React.useState('');
const setCohortFacilitatorsCount = useStore((state) => state.setCohortFacilitatorsCount);



const { t } = useTranslation();
Expand Down Expand Up @@ -77,6 +81,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({

console.log(`userDetails`, userDetails);
setUserData(userDetails);
setCohortFacilitatorsCount(userDetails.length)
setFilteredData(userDetails);

}
Expand Down Expand Up @@ -137,14 +142,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
}}
>

<Typography
style={{
width: '100%',
marginLeft: '20px',
}}
>
{t('COMMON.FACILITATOR_COUNT', { count: userData?.length})}
</Typography>


<Grid container>
{filteredData?.map((data: any) => {
Expand Down
14 changes: 5 additions & 9 deletions src/components/CohortLearnerList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Loader from './Loader';
import { showToastMessage } from './Toastify';
import NoDataFound from './common/NoDataFound';
import SearchBar from './Searchbar';
import useStore from '@/store/store';

interface UserDataProps {
name: string;
Expand Down Expand Up @@ -41,7 +42,8 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
const [userData, setUserData] = React.useState<UserDataProps[]>();
const [filteredData, setFilteredData] = useState(userData);


const setCohortLearnerCount = useStore((state) => state.setCohortLearnerCount);

const [isLearnerDeleted, setIsLearnerDeleted] =
React.useState<boolean>(false);

Expand Down Expand Up @@ -78,6 +80,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
});

console.log(`userDetails`, userDetails);
setCohortLearnerCount(userDetails.length);
setUserData(userDetails);
setFilteredData(userDetails);
}
Expand Down Expand Up @@ -138,14 +141,7 @@ const CohortLearnerList: React.FC<CohortLearnerListProp> = ({
},
}}
>
<Typography
style={{
width: '100%',
marginLeft: '20px',
}}
>
{t('COMMON.LEARNER_COUNT', { count: userData?.length})}
</Typography>

<Grid container>

{filteredData?.map((data: any) => {
Expand Down
26 changes: 23 additions & 3 deletions src/pages/centers/[cohortId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const CohortPage = () => {
(state: { setBlockId: any }) => state.setBlockId
);

const { tab} = router.query;
const [open, setOpen] = React.useState(false);
const theme = useTheme<any>();
const [selectedDate, setSelectedDate] =
Expand Down Expand Up @@ -188,7 +189,14 @@ const CohortPage = () => {
const [onEditEvent, setOnEditEvent] = useState(false);
const [sortedSessions, setSortedSessions] = useState<any>([]);
const [initialSlideIndex, setInitialSlideIndex] = useState<any>();

const [cohortFacilitatorListCount, setCohortFacilitatorListCount] = useState<any>();
const cohortFacilitatorsCount = useStore(
(state: { cohortFacilitatorsCount: any }) => state.cohortFacilitatorsCount
);
const [cohortLearnerListCount, setCohortLearnerListCount] = useState<any>();
const cohortLearnerCount = useStore(
(state: { cohortLearnerCount: any }) => state.cohortLearnerCount
);
const handleClick = (selection: string) => {
setDisableNextButton(false);
setClickedBox(selection);
Expand Down Expand Up @@ -224,6 +232,11 @@ const CohortPage = () => {
setCreateEvent(false);
}
}, [eventCreated, createEvent]);

useEffect(() => {
setCohortFacilitatorListCount(cohortFacilitatorsCount);
setCohortLearnerListCount(cohortLearnerCount)
},[cohortFacilitatorsCount, cohortLearnerCount]);

const handleOpen = () => {
setOpen(true);
Expand Down Expand Up @@ -729,9 +742,16 @@ const CohortPage = () => {
<Tab value={1} label={t('COMMON.CENTER_SESSIONS')} />
)}

<Tab value={2} label={t('COMMON.LEARNER_LIST')} />
<Tab value={2} label={t('COMMON.LEARNER_LIST')+
(tab === "2" ?"("+ cohortLearnerListCount+")": "")} />
{role === Role.TEAM_LEADER && (
<Tab value={3} label={t('COMMON.FACILITATOR_LIST')} />
<Tab
value={3}
label={
t('COMMON.FACILITATOR_LIST') +
(tab === "3" ? "("+cohortFacilitatorListCount+")": "")
}
/>
)}
</Tabs>
</Box>
Expand Down
4 changes: 4 additions & 0 deletions src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const useStore = create(
userRole: '',
pairs: [],
isActiveYearSelected: '',
cohortFacilitatorsCount:0,
setCohortFacilitatorsCount: (newValue) => set((state) => ({ cohortFacilitatorsCount: newValue })),
cohortLearnerCount:0,
setCohortLearnerCount: (newValue) => set((state) => ({ cohortLearnerCount: newValue })),
setValue: (newValue) => set((state) => ({ value: newValue })),
setBlock: (newBlock) => set((state) => ({ block: newBlock })),
setUserRole: (newRole) => set((state) => ({ userRole: newRole })),
Expand Down

0 comments on commit af205e8

Please sign in to comment.