Skip to content

Commit

Permalink
Fix issues in Toast component refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
julianguyen committed Nov 25, 2024
1 parent 163314f commit 6a803c6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions client/app/components/Toast/__tests__/Toast.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Toast', () => {
render(
<Toast
alert="Invalid username or password."
appendDashboardClass="true"
appendDashboardClass={true}
/>,
);
expect(screen).not.toBeNull();
Expand All @@ -21,7 +21,7 @@ describe('Toast', () => {
const { getByRole, container } = render(
<Toast
alert="Invalid username or password."
appendDashboardClass="true"
appendDashboardClass={true}
/>,
);

Expand All @@ -37,7 +37,7 @@ describe('Toast', () => {
const { getByRole } = render(
<Toast
alert="Invalid username or password."
appendDashboardClass="true"
appendDashboardClass={true}
/>,
);

Expand Down
6 changes: 5 additions & 1 deletion client/app/components/Toast/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ export const Toast = ({ alert, notice, appendDashboardClass }: Props): Node => {
};

useEffect(() => {
let timer;
if (showAlert || showNotice) {
setTimeout(() => {
timer = setTimeout(() => {
hideNotice();
hideAlert();
}, 7000);
}
return () => {
clearTimeout(timer);
};
}, [showAlert, showNotice]);

return (
Expand Down
2 changes: 1 addition & 1 deletion client/app/stories/Toast.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const noticeToast = Template.bind({});

noticeToast.args = {
notice: 'Login successful.',
appendDashboardClass: 'true',
appendDashboardClass: true,
};
noticeToast.storyName = 'Toast Type: Notice';

Expand Down

0 comments on commit 6a803c6

Please sign in to comment.