Skip to content

Commit

Permalink
PROD-2349 Fix messaging ui unresponsive. Fix warnings. (#5081)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucano Vera <lucanovera@ethyca.com>
  • Loading branch information
lucanovera and Lucano Vera authored Jul 15, 2024
1 parent 1957636 commit e02e6e1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ The types of changes are:

### Fixed
- Fixed bug with unescaped table names in mysql queries [#5072](https://github.com/ethyca/fides/pull/5072/)
- Fixed bug with unresponsive messaging ui [#5081](https://github.com/ethyca/fides/pull/5081/)


## [2.40.0](https://github.com/ethyca/fides/compare/2.39.2...2.40.0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getErrorMessage } from "common/helpers";
import { useToast } from "fidesui";
import { useCallback } from "react";

import { errorToastParams, successToastParams } from "~/features/common/toast";
import { usePatchMessagingTemplateByIdMutation } from "~/features/messaging-templates/messaging-templates.slice";
Expand All @@ -9,29 +10,32 @@ const useMessagingTemplateToggle = () => {
const toast = useToast();
const [patchMessagingTemplateById] = usePatchMessagingTemplateByIdMutation();

const toggleIsTemplateEnabled = async ({
isEnabled,
templateId,
}: {
isEnabled: boolean;
templateId: string;
}) => {
const result = await patchMessagingTemplateById({
const toggleIsTemplateEnabled = useCallback(
async ({
isEnabled,
templateId,
template: { is_enabled: isEnabled },
});
}: {
isEnabled: boolean;
templateId: string;
}) => {
const result = await patchMessagingTemplateById({
templateId,
template: { is_enabled: isEnabled },
});

if (isErrorResult(result)) {
toast(errorToastParams(getErrorMessage(result.error)));
return;
}
if (isErrorResult(result)) {
toast(errorToastParams(getErrorMessage(result.error)));
return;
}

toast(
successToastParams(
`Messaging template ${isEnabled ? "enabled" : "disabled"}`
)
);
};
toast(
successToastParams(
`Messaging template ${isEnabled ? "enabled" : "disabled"}`
)
);
},
[patchMessagingTemplateById, toast]
);

return { toggleIsTemplateEnabled };
};
Expand Down
7 changes: 4 additions & 3 deletions clients/admin-ui/src/pages/messaging/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ const MessagingPage: NextPage = () => {
cell: (props) => (
<Flex align="center" justifyContent="flex-start" w="full" h="full">
<Switch
name={`is_enabled_${props.row.original.id}`}
isChecked={props.getValue()}
colorScheme="complimentary"
onChange={async (e) => {
onChange={async (e: any) => {
toggleIsTemplateEnabled({
isEnabled: e.target.checked,
templateId: props.row.original.id,
Expand All @@ -154,7 +155,7 @@ const MessagingPage: NextPage = () => {
[toggleIsTemplateEnabled]
);

const sortedData = sortBy(data, "id");
const sortedData = useMemo(() => sortBy(data, "id"), [data]);
const tableInstance = useReactTable<MessagingTemplateWithPropertiesSummary>({
getCoreRowModel: getCoreRowModel(),
getFilteredRowModel: getFilteredRowModel(),
Expand Down Expand Up @@ -301,7 +302,7 @@ const MissingMessagesInfoBox = () => {
<InfoBox
title="Not all properties have messages configured."
text={
<Text>
<Text as="span">
You have properties that do not have messages configured. Users who
submit privacy requests for these properties may not receive the
necessary emails regarding their requests.{" "}
Expand Down

0 comments on commit e02e6e1

Please sign in to comment.