Skip to content

Commit

Permalink
Merge branch 'shiksha-2.0' of github.com:tekdi/shiksha-frontend into …
Browse files Browse the repository at this point in the history
…merge-shiksha2
  • Loading branch information
itsvick committed Jun 14, 2024
2 parents 1b7ab85 + e0ccaa5 commit b00a8b0
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 90 deletions.
18 changes: 10 additions & 8 deletions src/components/MarkBulkAttendance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,17 @@ const MarkBulkAttendance: React.FC<MarkBulkAttendanceProps> = ({
if (resp) {
setShowUpdateButton(true);
setLoading(false);
}
if (onSaveSuccess) {
if (presentCount === 0 && absentCount === 0) {
onSaveSuccess(false);
} else {
onSaveSuccess(true);
if (onSaveSuccess) {
if (presentCount === 0 && absentCount === 0) {
onSaveSuccess(false);
} else {
onSaveSuccess(true);
}

onClose();
}
onClose();
} else {
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
}
} catch (error) {
console.error('Error fetching cohort list:', error);
Expand Down
8 changes: 3 additions & 5 deletions src/pages/attendance-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ import { usePathname } from 'next/navigation';
import { useRouter } from 'next/router';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';
import ToastMessage from '@/components/ToastMessage';
import { logEvent } from '@/utils/googleAnalytics';
import { showToastMessage } from '@/components/Toastify';

interface user {
userId: string;
Expand Down Expand Up @@ -86,7 +86,6 @@ const UserAttendanceHistory = () => {
const [open, setOpen] = useState(false);
const [handleSaveHasRun, setHandleSaveHasRun] = React.useState(false);
const searchRef = useRef<HTMLDivElement>(null);
const [isError, setIsError] = React.useState<boolean>(false);

const pathname = usePathname();
let userId: string;
Expand Down Expand Up @@ -168,7 +167,7 @@ const UserAttendanceHistory = () => {
}
} catch (error) {
console.error('Error fetching cohort list:', error);
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
setLoading(false);
}
};
Expand Down Expand Up @@ -337,7 +336,7 @@ const UserAttendanceHistory = () => {
}
} catch (error) {
console.error('Error fetching cohort list:', error);
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
setLoading(false);
} finally {
setLoading(false);
Expand Down Expand Up @@ -884,7 +883,6 @@ const UserAttendanceHistory = () => {
</Box>
</Box>
{displayStudentList.length >= 1 ? <UpDownButton /> : null}
{isError && <ToastMessage message={t('COMMON.SOMETHING_WENT_WRONG')} />}
</Box>
);
};
Expand Down
9 changes: 3 additions & 6 deletions src/pages/attendance-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import OverviewCard from '@/components/OverviewCard';
import SearchIcon from '@mui/icons-material/Search';
import SortingModal from '@/components/SortingModal';
import StudentsStatsList from '@/components/LearnerAttendanceStatsListView';
import ToastMessage from '@/components/ToastMessage';
import UpDownButton from '@/components/UpDownButton';
import { cohortList } from '@/services/CohortServices';
import { getMyCohortMemberList } from '@/services/MyClassDetailsService';
Expand All @@ -52,6 +51,7 @@ import { useRouter } from 'next/router';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';
import { logEvent } from '@/utils/googleAnalytics';
import { showToastMessage } from '@/components/Toastify';

interface AttendanceOverviewProps {
// buttonText: string;
Expand Down Expand Up @@ -91,7 +91,6 @@ const AttendanceOverview: React.FC<AttendanceOverviewProps> = () => {
const [numberOfDaysAttendanceMarked, setNumberOfDaysAttendanceMarked] =
useState(0);
const [dateRange, setDateRange] = React.useState<Date | string>('');
const [isError, setIsError] = React.useState<boolean>(false);

const theme = useTheme<any>();
const pathname = usePathname();
Expand Down Expand Up @@ -238,10 +237,9 @@ const AttendanceOverview: React.FC<AttendanceOverviewProps> = () => {
}
}
setLoading(false);
setIsError(false);
} catch (error) {
console.error('Error fetching cohort list:', error);
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
setLoading(false);
}
};
Expand Down Expand Up @@ -439,7 +437,7 @@ const AttendanceOverview: React.FC<AttendanceOverviewProps> = () => {
}
} catch (error) {
console.error('Error fetching cohort list:', error);
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
setLoading(false);
} finally {
setLoading(false);
Expand Down Expand Up @@ -918,7 +916,6 @@ const AttendanceOverview: React.FC<AttendanceOverviewProps> = () => {
<Typography>{t('COMMON.NO_DATA_FOUND')}</Typography>
</Box>
)}
{isError && <ToastMessage message={t('COMMON.SOMETHING_WENT_WRONG')} />}
</Box>
);
};
Expand Down
19 changes: 3 additions & 16 deletions src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {

import MarkBulkAttendance from '@/components/MarkBulkAttendance';
import OverviewCard from '@/components/OverviewCard';
import ToastMessage from '@/components/ToastMessage';
import { showToastMessage } from '@/components/Toastify';
import WeekCalender from '@/components/WeekCalender';
import { getMyCohortMemberList } from '@/services/MyClassDetailsService';
Expand Down Expand Up @@ -87,13 +86,6 @@ const Dashboard: React.FC<DashboardProps> = () => {
const [dateRange, setDateRange] = React.useState<Date | string>('');
const [allCenterAttendanceData, setAllCenterAttendanceData] =
React.useState<any>(cohortsData);
const [isError, setIsError] = React.useState<boolean>(false);
// const [state, setState] = React.useState<State>({
// openModal: false,
// vertical: 'top',
// horizontal: 'center',
// });
// const { vertical, horizontal, openModal } = state;

const router = useRouter();
const theme = useTheme<any>();
Expand Down Expand Up @@ -187,7 +179,7 @@ const Dashboard: React.FC<DashboardProps> = () => {
}
} catch (error) {
console.error('Error fetching cohort list:', error);
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
setLoading(false);
}
};
Expand Down Expand Up @@ -322,14 +314,13 @@ const Dashboard: React.FC<DashboardProps> = () => {
filters,
facets,
});
setIsError(false);
return { cohortId, data: response?.data?.result };
} catch (error) {
console.error(
`Error fetching data for cohortId ${cohortId}:`,
error
);
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
return { cohortId, error };
}
});
Expand Down Expand Up @@ -366,11 +357,10 @@ const Dashboard: React.FC<DashboardProps> = () => {
.filter((item) => item.presentPercentage !== null); // Filter out items with no valid percentage

// console.log('Filtered and merged data:', nameIDAttendanceArray);
setIsError(false);
setAllCenterAttendanceData(nameIDAttendanceArray);
} catch (error) {
console.error('Error fetching attendance data:', error);
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
}
};

Expand Down Expand Up @@ -931,9 +921,6 @@ const Dashboard: React.FC<DashboardProps> = () => {
</Box>
</Box>
</Box>
{isError && (
<ToastMessage message={t('COMMON.SOMETHING_WENT_WRONG')} />
)}

{/* <Box sx={{ background: '#fff' }}>
<Typography
Expand Down
9 changes: 2 additions & 7 deletions src/pages/learner-attendance-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { shortDateFormat } from '@/utils/Helper';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';
import ToastMessage from '@/components/ToastMessage';
import { logEvent } from '@/utils/googleAnalytics';
import { showToastMessage } from '@/components/Toastify';

type LearnerAttendanceData = {
[date: string]: {
Expand All @@ -42,7 +42,6 @@ const LearnerAttendanceHistory = () => {
const [learnerAttendance, setLearnerAttendance] = useState<
LearnerAttendanceData | undefined
>(undefined);
const [isError, setIsError] = React.useState<boolean>(false);

useEffect(() => {
if (typeof window !== 'undefined' && window.localStorage) {
Expand Down Expand Up @@ -140,11 +139,10 @@ const LearnerAttendanceHistory = () => {
{}
);
setLearnerAttendance(attendanceData);
setIsError(false)
setLoading(false);
}
} catch (err) {
setIsError(true)
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
setLoading(false);
} finally {
setLoading(false);
Expand Down Expand Up @@ -240,9 +238,6 @@ const LearnerAttendanceHistory = () => {
handleClose={handleModalClose}
onAttendanceUpdate={() => setAttendanceUpdated(!attendanceUpdated)}
/>
{ isError &&
<ToastMessage message={t('COMMON.SOMETHING_WENT_WRONG')} />
}
</Box>
);
};
Expand Down
5 changes: 4 additions & 1 deletion src/pages/learner/[userId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useRouter } from 'next/router';
import { useTranslation } from 'next-i18next';
import { logEvent } from '@/utils/googleAnalytics';
import { showToastMessage } from '@/components/Toastify';

// import { UserData, updateCustomField } from '../utils/Interfaces';

Expand Down Expand Up @@ -285,6 +286,7 @@ const LearnerProfile: React.FC = () => {
setIsError(false);
} catch (error) {
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
setLoading(false);
console.error('Error fetching user details:', error);
}
Expand Down Expand Up @@ -377,6 +379,7 @@ const LearnerProfile: React.FC = () => {
setIsError(false);
} catch (error) {
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
console.error(
'Error fetching getDoIdForAssesmentDetails results:',
error
Expand Down Expand Up @@ -676,6 +679,7 @@ const LearnerProfile: React.FC = () => {
}
} catch (error) {
setIsError(true);
showToastMessage(t('COMMON.SOMETHING_WENT_WRONG'), 'error');
console.error('Error:', error);
}
};
Expand Down Expand Up @@ -1599,7 +1603,6 @@ const LearnerProfile: React.FC = () => {
</Box>
</Box>
</Modal>
{isError && <ToastMessage message={t('COMMON.SOMETHING_WENT_WRONG')} />}
</>
);
};
Expand Down
Loading

0 comments on commit b00a8b0

Please sign in to comment.