Skip to content

Commit

Permalink
Merge pull request #488 from AkshataKatwal16/reassign-cohorts
Browse files Browse the repository at this point in the history
Issue feat:Enable confirmation popup only when the user makes changes  in the Mark Attendance modal.
  • Loading branch information
itsvick authored Dec 2, 2024
2 parents 63e8ca4 + 6933fa9 commit 5ae80cb
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/MarkBulkAttendance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const MarkBulkAttendance: React.FC<MarkBulkAttendanceProps> = ({

const [updateAttendance, setUpdateAttendance] = React.useState(false);
const [confirmation, setConfirmation] = React.useState(false);
const [isConfirmation, setIsConfirmation] = React.useState(false);

const [modalOpen, setModalOpen] = React.useState(false);
const attendanceUpdate = () => {
setUpdateAttendance(true);
Expand Down Expand Up @@ -91,6 +93,7 @@ const MarkBulkAttendance: React.FC<MarkBulkAttendanceProps> = ({
};

const updateBulkAttendanceStatus = (arr: any[]) => {
setIsConfirmation(true);
const isAllPresent = arr.every(
(user: any) => user.attendance === 'present'
);
Expand All @@ -105,6 +108,8 @@ const MarkBulkAttendance: React.FC<MarkBulkAttendanceProps> = ({
status: string,
id?: string | undefined
) => {
setIsConfirmation(true);

const updatedAttendanceList = cohortMemberList?.map((user: any) => {
if (isBulkAction) {
user.attendance = status;
Expand Down Expand Up @@ -215,7 +220,10 @@ const MarkBulkAttendance: React.FC<MarkBulkAttendanceProps> = ({
// };

const getMessage = () => {
if (updateAttendance) return presentCount == 0 && absentCount == 0 ? t('COMMON.SURE_MARK') : t('COMMON.SURE_UPDATE');
if (updateAttendance)
return presentCount == 0 && absentCount == 0
? t('COMMON.SURE_MARK')
: t('COMMON.SURE_UPDATE');
if (confirmation) return t('COMMON.SURE_CLOSE');
return '';
};
Expand Down Expand Up @@ -306,7 +314,7 @@ const MarkBulkAttendance: React.FC<MarkBulkAttendanceProps> = ({
cursor: 'pointer',
color: theme.palette.warning['A200'],
}}
onClick={confirmationOpen}
onClick={isConfirmation ? confirmationOpen : onClose}
/>
</Box>
</Box>
Expand Down

0 comments on commit 5ae80cb

Please sign in to comment.