Skip to content

Commit

Permalink
fix(notif-provider): make success notification title customisable
Browse files Browse the repository at this point in the history
  • Loading branch information
lorumic committed Mar 6, 2024
1 parent 1c5ce39 commit 708f189
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("NotificationProvider", () => {

const TriggerComponent = () => {
const notify = useNotify();
const handleSuccess = () => notify.success("My success!");
const handleSuccess = () => notify.success("My success!", "Test success");
const handleClear = () => notify.clear();
const handleInfo = () => notify.info("Some more details", "Test info");
const handleError = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const NotificationProvider: FC<NotifyProviderProps> = ({
failure: (title, error, message, actions) =>
setDeduplicated(failure(title, error, message, actions)),
info: (message, title) => setDeduplicated(info(message, title)),
success: (message) => setDeduplicated(success(message)),
success: (message, title) => setDeduplicated(success(message, title)),
setDeduplicated,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ exports[`NotificationProvider stores and renders notifications 1`] = `
class="p-notification__title"
data-testid="notification-title"
>
Success
Test success
</h5>
<p
class="p-notification__message"
Expand Down
6 changes: 5 additions & 1 deletion src/components/NotificationProvider/messageBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ export const info = (message: ReactNode, title?: string): NotificationType => {
};
};

export const success = (message: ReactNode): NotificationType => {
export const success = (
message: ReactNode,
title?: string
): NotificationType => {
return {
message,
title,
type: NotificationSeverity.POSITIVE,
};
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/NotificationProvider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface NotificationHelper {
actions?: NotificationAction[]
) => NotificationType;
info: (message: ReactNode, title?: string) => NotificationType;
success: (message: ReactNode) => NotificationType;
success: (message: ReactNode, title?: string) => NotificationType;
queue: (notification: NotificationType) => QueuedNotification;
setDeduplicated: (value: NotificationType) => NotificationType;
}

0 comments on commit 708f189

Please sign in to comment.