Skip to content

Commit

Permalink
crazy update on mark attendance button
Browse files Browse the repository at this point in the history
  • Loading branch information
Diwakar-Gupta committed Dec 3, 2023
1 parent e352944 commit 2475547
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/components/ClassView/MarkAttendanceButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import markAttendance from '../../backend/markAttendance';
import {showMessage} from 'react-native-flash-message';
import DidContext from '../../contexts/DidContext';

const MarkAttendanceButton = ({ClassData}) => {
const MarkAttendanceButton = ({ClassData, onSuccessMark}) => {
const did = useContext(DidContext);
const [markingAttendance, setMarkingAttendance] = useState(false);

Expand All @@ -25,6 +25,7 @@ const MarkAttendanceButton = ({ClassData}) => {
floating: true,
duration: 4000,
});
onSuccessMark();
})
.catch(err => {
setMarkingAttendance(false);
Expand Down
20 changes: 15 additions & 5 deletions src/screens/CurrentClassScreen/CurrentClassScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ const CurrentClassScreen = () => {
const {userName, userEmail} = useContext(UserContext);

useEffect(() => {
fetchClass();
}, []);

function fetchClass() {
fetchCurrentClass(did)
.then(classs => {
setCurrentClass(classs);
})
.catch(err => {
// console.error(err);
});
}, []);
.catch(err => {});
}

function onSuccessMark() {
setCurrentClass(null);
fetchClass();
}
return (
<View>
<StatusBar animated={true} backgroundColor="#1a1a1a" />
Expand All @@ -43,7 +50,10 @@ const CurrentClassScreen = () => {

{/* Class Display */}
<ClassView ClassData={currentClass} />
<MarkAttendanceButton ClassData={currentClass} />
<MarkAttendanceButton
ClassData={currentClass}
onSuccessMark={onSuccessMark}
/>
</LinearGradient>
</View>
);
Expand Down

0 comments on commit 2475547

Please sign in to comment.