From ec64235f93b13a91378b6f5e21ba331a66cedcbf Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Wed, 27 Mar 2024 01:19:34 +0100 Subject: [PATCH] [#220] changes after CR - refactor determining StatusPill colors - add Sentry.captureException on delegate error --- .../src/components/atoms/StatusPill.tsx | 32 ++++++------------- .../frontend/src/hooks/useDelegateToDrep.ts | 2 ++ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/govtool/frontend/src/components/atoms/StatusPill.tsx b/govtool/frontend/src/components/atoms/StatusPill.tsx index ff08844d2..b09fcebf9 100644 --- a/govtool/frontend/src/components/atoms/StatusPill.tsx +++ b/govtool/frontend/src/components/atoms/StatusPill.tsx @@ -24,33 +24,21 @@ export const StatusPill = ({ /> ); -const getBgColor = (status: Status): string => { - switch (status) { - case 'Active': - return successGreen.c200; - case 'Inactive': - return cyan.c100; - case 'Retired': - return errorRed.c100; - // no default - } +const bgColor = { + Active: successGreen.c200, + Inactive: cyan.c100, + Retired: errorRed.c100, }; -const getTextColor = (status: Status): string => { - switch (status) { - case 'Active': - return successGreen.c700; - case 'Inactive': - return cyan.c500; - case 'Retired': - return errorRed.c500; - // no default - } +const textColor = { + Active: successGreen.c700, + Inactive: cyan.c500, + Retired: errorRed.c500, }; const StyledChip = styled(Chip)<{ status: Status }>(({ theme, status }) => ({ - backgroundColor: getBgColor(status), - color: getTextColor(status), + backgroundColor: bgColor[status], + color: textColor[status], border: `2px solid ${theme.palette.neutralWhite}`, fontSize: '0.75rem', textTransform: 'capitalize', diff --git a/govtool/frontend/src/hooks/useDelegateToDrep.ts b/govtool/frontend/src/hooks/useDelegateToDrep.ts index 0183e82de..db43104a5 100644 --- a/govtool/frontend/src/hooks/useDelegateToDrep.ts +++ b/govtool/frontend/src/hooks/useDelegateToDrep.ts @@ -1,4 +1,5 @@ import { useCallback, useState } from "react"; +import * as Sentry from "@sentry/react"; import { useTranslation } from "@hooks"; import { useCardano, useSnackbar } from "@/context"; @@ -26,6 +27,7 @@ export const useDelegateTodRep = () => { addSuccessAlert(t("alerts.delegate.success")); } } catch (error) { + Sentry.captureException(error); addErrorAlert(t("alerts.delegate.failed")); } finally { setIsDelegating(false);