Skip to content

Commit

Permalink
Trimmed alert messages to only display 200 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
kliu57 committed Mar 30, 2024
1 parent 52c90ca commit d5a51e5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/hooks/use-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ type AlertArguments = {
message?: string;
};

function trimMessage(message?: string): string {
if (!message) {
return "";
}

if (message.length > 200) {
return `${message.substring(0, 200)}...`;
}

return message;
}

export function useAlert() {
const toast = useToast();

Expand Down Expand Up @@ -46,7 +58,7 @@ export function useAlert() {
toast({
id,
title,
description: message,
description: trimMessage(message),
status: "success",
position: "top",
isClosable: true,
Expand All @@ -60,7 +72,7 @@ export function useAlert() {
toast({
id,
title,
description: message,
description: trimMessage(message),
status: "warning",
position: "top",
isClosable: true,
Expand Down

0 comments on commit d5a51e5

Please sign in to comment.