Skip to content

Commit

Permalink
fix(exams): add confirmation dialog when accepting or rejecting a pro…
Browse files Browse the repository at this point in the history
…visional grade
  • Loading branch information
lpezzolla authored and Bri74 committed Feb 6, 2024
1 parent 4d11475 commit 4501998
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,11 @@
"trainingOffer": "Training offer"
},
"provisionalGradeScreen": {
"acceptGradeConfirmMessage": "By accepting this evaluation you will no longer be able to change your decision",
"acceptGradeCta": "Request immediate registration",
"acceptGradeFeedback": "The evaluation has been recorded, it will appear in the transcript",
"contactProfessorCta": "Contact the teacher",
"rejectGradeConfirmMessage": "By rejecting this evaluation you will no longer be able to change your decision",
"rejectGradeCta": "Reject the evaluation",
"rejectGradeFeedback": "Evaluation rejected, it will be recorded in the next few hours",
"title": "Evaluation"
Expand Down
2 changes: 2 additions & 0 deletions assets/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,11 @@
"trainingOffer": "Offerta formativa"
},
"provisionalGradeScreen": {
"acceptGradeConfirmMessage": "Accettando il voto non potrai più cambiare la tua decisione",
"acceptGradeCta": "Richiedi la registrazione immediata",
"acceptGradeFeedback": "Valutazione registrata, verrà visualizzata nel libretto",
"contactProfessorCta": "Contatta il docente",
"rejectGradeConfirmMessage": "Rifiutando il voto non potrai più cambiare la tua decisione",
"rejectGradeCta": "Rifiuta la valutazione",
"rejectGradeFeedback": "Valutazione rifiutata, verrà registrata nelle prossime ore",
"title": "Valutazione"
Expand Down
27 changes: 21 additions & 6 deletions src/features/transcript/screens/ProvisionalGradeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { NativeStackScreenProps } from '@react-navigation/native-stack';

import { BottomBarSpacer } from '../../../core/components/BottomBarSpacer';
import { useFeedbackContext } from '../../../core/contexts/FeedbackContext';
import { useConfirmationDialog } from '../../../core/hooks/useConfirmationDialog';
import { useOfflineDisabled } from '../../../core/hooks/useOfflineDisabled';
import {
useAcceptProvisionalGrade,
Expand All @@ -35,6 +36,16 @@ export const ProvisionalGradeScreen = ({ navigation, route }: Props) => {
const styles = useStylesheet(createStyles);
const { setFeedback } = useFeedbackContext();

const confirmAcceptance = useConfirmationDialog({
title: t('common.areYouSure?'),
message: t('provisionalGradeScreen.acceptGradeConfirmMessage'),
});

const confirmRejection = useConfirmationDialog({
title: t('common.areYouSure?'),
message: t('provisionalGradeScreen.rejectGradeConfirmMessage'),
});

const { id } = route.params;

const gradesQuery = useGetProvisionalGrades();
Expand Down Expand Up @@ -119,9 +130,11 @@ export const ProvisionalGradeScreen = ({ navigation, route }: Props) => {
<CtaButton
title={t('provisionalGradeScreen.acceptGradeCta')}
action={() =>
acceptGradeQuery
.mutateAsync(grade.id)
.then(() => provideFeedback(true))
confirmAcceptance().then(() =>
acceptGradeQuery
.mutateAsync(grade.id)
.then(() => provideFeedback(true)),
)
}
variant="outlined"
absolute={false}
Expand All @@ -136,9 +149,11 @@ export const ProvisionalGradeScreen = ({ navigation, route }: Props) => {
<CtaButton
title={t('provisionalGradeScreen.rejectGradeCta')}
action={() =>
rejectGradeQuery
.mutateAsync(grade.id)
.then(() => provideFeedback(false))
confirmRejection().then(() =>
rejectGradeQuery
.mutateAsync(grade.id)
.then(() => provideFeedback(false)),
)
}
absolute={false}
loading={rejectGradeQuery.isLoading}
Expand Down

0 comments on commit 4501998

Please sign in to comment.