Skip to content

Commit

Permalink
show error notification instead
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveDarsa committed Apr 11, 2024
1 parent f2fd330 commit 3eecf37
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/components/AddTask/components/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
import React, { FC } from 'react';
import React, { FC, useEffect } from 'react';

import { notification } from 'antd';

interface Props {
errMessage: string;
}
const Error: FC<Props> = ({ errMessage }) => {
return <div>{errMessage}</div>;
const [api, contextHolder] = notification.useNotification({ maxCount: 1 });

const showError = (errorMessage: string) => {
api['error']({
message: 'There was a problem running a task.',
description: errorMessage,
placement: 'top',
duration: 0,
style: { width: '500px' },
});
};

useEffect(() => {
if (errMessage) showError(errMessage);
}, [errMessage]);

return <>{contextHolder}</>;
};
export default Error;

0 comments on commit 3eecf37

Please sign in to comment.