@apptimate/ui 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import toast from "react-hot-toast";
|
|
3
|
+
import { Button } from "./Button";
|
|
4
|
+
|
|
5
|
+
export const handleFinanceError = (error: any, defaultMessage: string = "An error occurred") => {
|
|
6
|
+
const errMsg = typeof error === "string" ? error : (error?.message || defaultMessage);
|
|
7
|
+
|
|
8
|
+
if (errMsg.toLowerCase().includes("fiscal year")) {
|
|
9
|
+
toast.error((t) => (
|
|
10
|
+
<div className="flex flex-col gap-2 mt-1">
|
|
11
|
+
<span>{errMsg}</span>
|
|
12
|
+
<Button size="small" variant="solid" color="primary" className="w-fit mt-1" onClick={() => {
|
|
13
|
+
toast.dismiss(t.id);
|
|
14
|
+
window.open("/finance/fiscal-years", "_blank");
|
|
15
|
+
}}>
|
|
16
|
+
Open Fiscal Years
|
|
17
|
+
</Button>
|
|
18
|
+
</div>
|
|
19
|
+
), { duration: 8000 });
|
|
20
|
+
} else {
|
|
21
|
+
toast.error(errMsg);
|
|
22
|
+
}
|
|
23
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -33,3 +33,4 @@ export type { ImageUploadComponentProps, ItemImage } from './components/shared/I
|
|
|
33
33
|
export * from './common-components/DashboardLayout';
|
|
34
34
|
export * from './common-components/charts';
|
|
35
35
|
export * from './common-components/PaymentSection';
|
|
36
|
+
export * from './base-components/FinanceErrorToast';
|