Skip to content

Commit

Permalink
fix: regression
Browse files Browse the repository at this point in the history
  • Loading branch information
sakul-budhathoki committed Feb 28, 2024
1 parent a43cf04 commit 52da131
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
9 changes: 8 additions & 1 deletion packages/components/toasts/NormalToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ export const NormalToast: React.FC<NormalToastProps> = ({
{type === "error" && (
<>
<SpacerRow size={3} />
<SVG width={24} height={24} source={warningSVG} />
<SVG
width={24}
height={24}
source={warningSVG}
style={{
flexShrink: 0,
}}
/>
</>
)}
<SpacerRow size={3} />
Expand Down
19 changes: 6 additions & 13 deletions packages/context/FeedbacksProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const FeedbacksContextProvider: React.FC<{ children: ReactNode }> = ({
const clearToast = () => setToast(initialToast);

useEffect(() => {
const toastDuration = toast.duration || 8000;
const toastDuration = toast.duration || initialToast.duration;

const timeoutID = setTimeout(() => {
// If the toast is in "mini" mode and showAlways flag is enabled, do not clear the toast
Expand Down Expand Up @@ -120,14 +120,14 @@ export const FeedbacksContextProvider: React.FC<{ children: ReactNode }> = ({
return async () => {
try {
await cb();
handleSetToast({
setToast({
mode: "normal",
type: "success",
message: "",
...success,
});
} catch (err) {
handleSetToast({
setToast({
mode: "normal",
type: "error",
message: "",
Expand All @@ -146,29 +146,22 @@ export const FeedbacksContextProvider: React.FC<{ children: ReactNode }> = ({
}
};

const handleSetToast = ({ ...restArgs }: Toast) => {
setToast({
...restArgs,
});
};
console.log(toast);

return (
<FeedbacksContext.Provider
value={{
loadingFullScreen,
setLoadingFullScreen,
setToastError: ({ title = "", ...args }) =>
handleSetToast({ mode: "normal", type: "error", title, ...args }),
setToast({ mode: "normal", type: "error", title, ...args }),
setToastSuccess: ({ title = "", ...args }) =>
handleSetToast({
setToast({
mode: "normal",
type: "success",
title,
...args,
}),
wrapWithFeedback,
setToast: handleSetToast,
setToast,
}}
>
{/*==== Loader full screen*/}
Expand Down

0 comments on commit 52da131

Please sign in to comment.