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
…shiksha-2.0
  • Loading branch information
itsvick committed Jun 18, 2024
2 parents 1823c32 + 0114864 commit 10eca47
Show file tree
Hide file tree
Showing 12 changed files with 737 additions and 449 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"react-circular-progressbar": "^2.1.0",
"react-dom": "^18",
"react-ga4": "^2.1.0",
"react-joyride": "^2.8.2",
"react-toastify": "^10.0.5",
"sharp": "^0.33.3"
},
Expand Down
12 changes: 12 additions & 0 deletions public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,17 @@
"MOBILISATION_METHOD": "How Was the Learner Mobilized?",
"MONTH_MOBILISATION": "Month of Mobilisation",
"DROP_OUT_REASON": "Reason for Drop Out From School"
},
"GUIDE_TOUR": {
"STEP_1": "Welcome! let’s get you familiar with the dashboard",
"STEP_2": "Use the calendar to view day-wise attendance of learners",
"STEP_3": "Check daily attendance percentage for each Center",
"STEP_4": "Mark each day’s attendance of learners",
"STEP_5": "Check Center attendance over the last 7 days",
"STEP_6": "View learners with low attendance in the past 7 days",
"PREVIOUS": "Previous",
"NEXT": "Next",
"SKIP": "Skip",
"FINISH": "Finish"
}
}
12 changes: 12 additions & 0 deletions public/locales/hi/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,17 @@
"MOBILISATION_METHOD": "शिक्षार्थी को कैसे जोड़ा गया?",
"MONTH_MOBILISATION": "जोड़ने का महीना",
"DROP_OUT_REASON": "स्कूल छोड़ने का कारण"
},
"GUIDE_TOUR": {
"STEP_1": "स्वागत है! आइए आपको डैशबोर्ड से परिचित कराते हैं",
"STEP_2": "शिक्षार्थियों की दिन-वार उपस्थिति देखने के लिए कैलेंडर का उपयोग करें",
"STEP_3": "प्रत्येक केंद्र के लिए दैनिक उपस्थिति प्रतिशत की जाँच करें",
"STEP_4": "शिक्षार्थियों की प्रत्येक दिन की उपस्थिति को चिह्नित करें",
"STEP_5": "पिछले 7 दिनों में केंद्र की उपस्थिति की जाँच करें",
"STEP_6": "पिछले 7 दिनों में कम उपस्थिति वाले शिक्षार्थियों को देखें",
"PREVIOUS": "पिछला",
"NEXT": "अगला",
"SKIP": "छोड़ें",
"FINISH": "समाप्त"
}
}
12 changes: 12 additions & 0 deletions public/locales/mr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,17 @@
"MOBILISATION_METHOD": "शिकणाऱ्याला कसे एकत्रित केले गेले?",
"MONTH_MOBILISATION": "एकत्रीकरणाचा महिना",
"DROP_OUT_REASON": "शाळा सोडण्याचे कारण"
},
"GUIDE_TOUR": {
"STEP_1": "स्वागत आहे! चला तुम्हाला डॅशबोर्डशी परिचित करून देतो",
"STEP_2": "शिक्षार्थ्यांची दिवसवार उपस्थिती पाहण्यासाठी कॅलेंडर वापरा",
"STEP_3": "प्रत्येक केंद्रासाठी दैनंदिन उपस्थिती टक्केवारी तपासा",
"STEP_4": "शिक्षार्थ्यांची प्रत्येक दिवसाची उपस्थिती चिन्हांकित करा",
"STEP_5": "शेवटच्या 7 दिवसांत केंद्राची उपस्थिती तपासा",
"STEP_6": "शेवटच्या 7 दिवसांत कमी उपस्थिती असलेले शिक्षार्थी पहा",
"PREVIOUS": "मागील",
"NEXT": "पुढे",
"SKIP": "वगळा",
"FINISH": "पूर्ण"
}
}
123 changes: 123 additions & 0 deletions src/components/GuideTour.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import React, { useEffect, useState } from 'react';
import Joyride from 'react-joyride';
import { getSteps } from '../utils/tourGuideSteps';
import { useTheme } from '@mui/material/styles';
import { useTranslation } from 'next-i18next';
import { logEvent } from '@/utils/googleAnalytics';

interface JoyrideCallbackData {
action: string;
index: number;
type: string;
status: string;
}

const GuideTour = () => {
const theme = useTheme<any>();
const { t } = useTranslation();
const steps = getSteps(t);
const totalSteps = steps.length;
const [runTour, setRunTour] = useState(true);
const [stepIndex, setStepIndex] = useState(1);

useEffect(() => {
setRunTour(true);
setStepIndex(stepIndex);
const hasSeenTutorial = localStorage.getItem('hasSeenTutorial');

setRunTour(!hasSeenTutorial);
}, []);

const handleTourEnd = () => {
if (typeof window !== 'undefined' && window.localStorage) {
localStorage.setItem('hasSeenTutorial', 'true');
}
};

const handleJoyrideCallback = (data: JoyrideCallbackData) => {
const { action, index, type, status } = data;

if (status === 'finished' || status === 'skipped') {
setRunTour(false);
handleTourEnd();
logEvent({
action: 'skip-guide-tour/finished-guide-tour',
category: 'Dashboard Page',
label: 'Skip/ Finish Button Click',
});
} else if (type === 'step:after' || type === 'tour:start') {
if (action === 'next') {
setStepIndex((prevIndex) => prevIndex + 1);
logEvent({
action: 'next-button-clicked',
category: 'Dashboard Page',
label: 'Next Button Click',
});
} else if (action === 'prev') {
setStepIndex((prevIndex) => prevIndex - 1);
logEvent({
action: 'previous-button-clicked',
category: 'Dashboard Page',
label: 'Previous Button Click',
});
}
}
};

return (
<>
{runTour && (
<Joyride
steps={getSteps(t)}
run={runTour}
stepIndex={stepIndex}
showSkipButton={true}
continuous={true}
styles={{
options: {
arrowColor: theme?.palette?.warning['A400'],
backgroundColor: theme?.palette?.warning['A400'],
overlayColor: 'rgba(0, 0, 0, 0.5)',
primaryColor: theme?.palette?.primary?.main,
textColor: theme?.palette?.warning['400'],
width: 350,
zIndex: 1000,
},
tooltipContent: {
fontWeight: 500,
},
buttonNext: {
padding: '0.5rem 1rem',
backgroundColor: theme?.palette?.primary?.main,
borderRadius: '5rem',
color: theme?.palette?.warning['100'],
border: '1px solid #FDBE16',
},
buttonBack: {
padding: '0.5rem 1rem',
borderRadius: '5rem',
color:
stepIndex === 1
? 'transparent'
: theme?.palette?.warning['100'],
border: stepIndex === 1 ? 'none' : '1px solid black',
},
buttonSkip: {
padding: '0.5rem 1rem',
color: theme?.palette?.info?.main,
},
}}
callback={handleJoyrideCallback}
locale={{
back: stepIndex === 1 ? '' : t('GUIDE_TOUR.PREVIOUS'),
last: t('GUIDE_TOUR.FINISH'),
next: `${t('GUIDE_TOUR.NEXT')} (${stepIndex}/${totalSteps - 1})`,
skip: t('GUIDE_TOUR.SKIP'),
}}
/>
)}
</>
);
};

export default GuideTour;
9 changes: 8 additions & 1 deletion src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,21 @@ const Header: React.FC = () => {
}, []);

const [language, setLanguage] = React.useState(selectedLanguage);
let hasSeenTutorial = false;
if (typeof window !== 'undefined' && window.localStorage) {
const storedValue = localStorage.getItem('hasSeenTutorial');
if (storedValue !== null) {
hasSeenTutorial = storedValue === 'true'; // Convert string 'true' or 'false' to boolean
}
}

return (
<Box sx={{ marginBottom: '4rem' }}>
<Box
sx={{
display: 'flex',
justifyContent: 'center',
position: 'fixed',
position: hasSeenTutorial ? 'fixed' : 'relative',
top: '0px',
zIndex: '999',
width: '100%',
Expand Down
44 changes: 1 addition & 43 deletions src/components/MarkAttendance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const MarkAttendance: React.FC<MarkAttendanceProps> = ({
const { t } = useTranslation();

const [updatedStatus, setUpdatedStatus] = React.useState(currentStatus);

useEffect(() => {
if (isOpen) {
setUpdatedStatus(currentStatus);
Expand All @@ -73,7 +74,6 @@ const MarkAttendance: React.FC<MarkAttendanceProps> = ({
const { vertical, horizontal, openModal } = modal;

const submitUpdateAttendance = async () => {
console.log(updatedStatus);
try {
const learnerId = localStorage.getItem('learnerId');
const classId = localStorage.getItem('classId');
Expand All @@ -100,50 +100,17 @@ const MarkAttendance: React.FC<MarkAttendanceProps> = ({
setModal({ ...newState, openModal: true });
};

// const submitClearAttendance = () => {
// setStatus(ATTENDANCE_ENUM.NOT_MARKED);
// handleClose();
// handleMarkClearAttendanceModal();
// };

// const submitAttendance = (newState: SnackbarOrigin) => () => {
// handleSubmit(date, status);
// // setOpenMarkUpdateAttendance(!openMarkUpdateAttendance);
// setModal({ ...newState, openModal: true });
// setTimeout(() => {
// handleSnackbarClose();
// }, SNACKBAR_AUTO_HIDE_DURATION);
// };

// const submitConfirmAttendance = (newState: SnackbarOrigin) => () => {
// // setOpenMarkClearAttendance(!openMarkClearAttendance);
// handleMarkUpdateAttendanceModal();
// handleSubmit(date, status);

// setModal({ ...newState, openModal: true });
// setTimeout(() => {
// handleSnackbarClose();
// }, SNACKBAR_AUTO_HIDE_DURATION);
// };

const handleSnackbarClose = () => {
setModal({ ...modal, openModal: false });
};

// const handleClear = () => {
// if (status !== ATTENDANCE_ENUM.NOT_MARKED) {
// setStatus(ATTENDANCE_ENUM.NOT_MARKED);
// }
// };

const getButtonComponent = (
value: string,
icon1: IconType,
icon2: IconType,
text: string
) => {
// setStatus(currentStatus);

return (
<Box
display="flex"
Expand Down Expand Up @@ -251,16 +218,7 @@ const MarkAttendance: React.FC<MarkAttendanceProps> = ({
<Button
variant="contained"
onClick={() => {
// if (currentStatus === ATTENDANCE_ENUM.NOT_MARKED) {
// {
// submitAttendance({
// vertical: 'bottom',
// horizontal: 'center',
// })();
// }
// } else {
submitUpdateAttendance();
// }
}}
disabled={
updatedStatus === ATTENDANCE_ENUM.NOT_MARKED ||
Expand Down
1 change: 0 additions & 1 deletion src/components/MarkBulkAttendance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ const MarkBulkAttendance: React.FC<MarkBulkAttendanceProps> = ({
filters,
});
const resp = response?.result?.results?.userDetails;

if (resp) {
const nameUserIdArray = resp?.map((entry: any) => ({
userId: entry.userId,
Expand Down
Loading

0 comments on commit 10eca47

Please sign in to comment.