diff --git a/CommonUI/src/Components/Toast/Toast.tsx b/CommonUI/src/Components/Toast/Toast.tsx index 079569c8ee..6a6c8096fd 100644 --- a/CommonUI/src/Components/Toast/Toast.tsx +++ b/CommonUI/src/Components/Toast/Toast.tsx @@ -1,5 +1,6 @@ -import OneUptimeDate from "Common/Types/Date"; import React, { FunctionComponent, ReactElement, useState } from "react"; +import Icon from "../Icon/Icon"; +import IconProp from "Common/Types/Icon/IconProp"; export enum ToastType { DANGER, @@ -14,6 +15,7 @@ export interface ComponentProps { description: string; onClose?: undefined | (() => void); type?: undefined | ToastType; + icon?: IconProp | undefined; createdAt?: undefined | Date; } @@ -21,64 +23,69 @@ const Component: FunctionComponent = ( props: ComponentProps, ): ReactElement => { const [show, setShow] = useState(true); - let typeCssClass: string = "text-info"; + let typeCssClass: string = "text-gray-400"; + let iconType: IconProp = IconProp.Info; if (props.type === ToastType.NORMAL) { - typeCssClass = "text-normal"; + typeCssClass = "text-gray-400"; + iconType = IconProp.Info; } if (props.type === ToastType.DANGER) { - typeCssClass = "text-danger"; + typeCssClass = "text-red-400"; + iconType = IconProp.Error; } if (props.type === ToastType.WARNING) { - typeCssClass = "text-warning"; + typeCssClass = "text-yellow-400"; + iconType = IconProp.Alert; } if (props.type === ToastType.SUCCESS) { - typeCssClass = "text-success"; + typeCssClass = "text-green-400"; + iconType = IconProp.CheckCircle; } if (props.type === ToastType.INFO) { - typeCssClass = "text-info"; + typeCssClass = "text-blue-400"; + iconType = IconProp.Info; } + if(props.icon){ + iconType = props.icon; + } + + + + if (show) { return ( -
-
-
- {props.type && ( -
- Loading... -
- )} - - {props.title} - - {props.createdAt && ( - - {OneUptimeDate.fromNow(props.createdAt)} - - )} +
+
- -
-
- {props.description} +
+
+
+
+ +
+
+

{props.title}

+

{props.description}

+ {/*
+ + +
*/} +
+
+ +
+
+
diff --git a/CommonUI/src/Components/Toast/ToastInit.tsx b/CommonUI/src/Components/Toast/ToastInit.tsx index d6c0876c53..87970a1cca 100644 --- a/CommonUI/src/Components/Toast/ToastInit.tsx +++ b/CommonUI/src/Components/Toast/ToastInit.tsx @@ -30,8 +30,8 @@ const ToastLayout: FunctionComponent = ( return (
- {currentToasts.map((toast: ToastComponentProps, index: number) => ( - { + return ( - ))} + )})}
); }; diff --git a/Dashboard/src/App.tsx b/Dashboard/src/App.tsx index 2dc4b4a0d7..3b3c142dca 100644 --- a/Dashboard/src/App.tsx +++ b/Dashboard/src/App.tsx @@ -454,6 +454,8 @@ const App: () => JSX.Element = () => { } /> + + ); }; diff --git a/Dashboard/src/Components/UserTimezone/UserTimezoneInit.tsx b/Dashboard/src/Components/UserTimezone/UserTimezoneInit.tsx index 23df2f7e1c..9a0638ac75 100644 --- a/Dashboard/src/Components/UserTimezone/UserTimezoneInit.tsx +++ b/Dashboard/src/Components/UserTimezone/UserTimezoneInit.tsx @@ -9,6 +9,7 @@ import ConfirmModal from "CommonUI/src/Components/Modal/ConfirmModal"; import ModelAPI from "CommonUI/src/Utils/ModelAPI/ModelAPI"; import UserModel from "Model/Models/User"; import useAsyncEffect from "use-async-effect"; +import BadDataException from "Common/Types/Exception/BadDataException"; const UseTimezoneInitElement: FunctionComponent = ( @@ -31,6 +32,8 @@ const UseTimezoneInitElement: FunctionComponent = ( modelType: UserModel }); + throw new BadDataException("Test Error"); + } catch (err) { ShowToastNotification({ title: "Error Saving Timezone", diff --git a/Dashboard/src/Pages/Global/UserProfile/Index.tsx b/Dashboard/src/Pages/Global/UserProfile/Index.tsx index ce480300f7..bf50211b48 100644 --- a/Dashboard/src/Pages/Global/UserProfile/Index.tsx +++ b/Dashboard/src/Pages/Global/UserProfile/Index.tsx @@ -12,6 +12,7 @@ import UserUtil from "CommonUI/src/Utils/User"; import User from "Model/Models/User"; import React, { FunctionComponent, ReactElement } from "react"; import TimezoneElement from "../../../Components/Timezone/TimezoneElement"; +import Toast from "CommonUI/src/Components/Toast/Toast"; const Home: FunctionComponent = (): ReactElement => { return ( @@ -31,6 +32,11 @@ const Home: FunctionComponent = (): ReactElement => { ]} sideMenu={} > + + = (): ReactElement => { }} name="User Profile > Basic Info" onSaveSuccess={(user: User) => { - if(user.timezone){ + if (user.timezone) { UserUtil.setSavedUserTimezone(user.timezone); } }} @@ -110,7 +116,7 @@ const Home: FunctionComponent = (): ReactElement => { } }, ], - + modelId: UserUtil.getUserId(), }} />