From 04551c910d542c568a8e1146e826974e01a5768e Mon Sep 17 00:00:00 2001 From: Vitor George Date: Fri, 29 Apr 2022 13:25:44 +0100 Subject: [PATCH] Display better error message when the user already has the badge --- pages/badges-assignment/new.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pages/badges-assignment/new.js b/pages/badges-assignment/new.js index 3441ccaf..e083c673 100644 --- a/pages/badges-assignment/new.js +++ b/pages/badges-assignment/new.js @@ -139,7 +139,12 @@ export default class NewBadgeAssignment extends Component { ) } catch (error) { console.log(error) - toast.error(`Unexpected error, please try again later.`) + + if (error.message === 'User is already assigned to badge.') { + toast.error(`User is already assigned to this badge, please select a different one.`) + } else { + toast.error(`Unexpected error, please try again later.`) + } } }} render={({ isSubmitting, values, errors, touched }) => {