Skip to content

Commit

Permalink
[#220] changes after CR
Browse files Browse the repository at this point in the history
- refactor determining StatusPill colors
- add Sentry.captureException on delegate error
  • Loading branch information
j-dyczka committed Mar 27, 2024
1 parent 7c4501e commit ec64235
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
32 changes: 10 additions & 22 deletions govtool/frontend/src/components/atoms/StatusPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions govtool/frontend/src/hooks/useDelegateToDrep.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCallback, useState } from "react";
import * as Sentry from "@sentry/react";
import { useTranslation } from "@hooks";
import { useCardano, useSnackbar } from "@/context";

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ec64235

Please sign in to comment.