@apptimate/ui 2.5.0 → 2.7.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apptimate/ui",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "main": "src/index.tsx",
5
5
  "types": "src/index.tsx",
6
6
  "dependencies": {
@@ -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
+ };
@@ -10,15 +10,22 @@ interface HintIconProps {
10
10
 
11
11
  export function HintIcon({ text }: HintIconProps) {
12
12
  const [show, setShow] = useState(false);
13
- const [pos, setPos] = useState({ top: 0, left: 0 });
13
+ const [pos, setPos] = useState({ top: 0, left: 0, isBelow: false });
14
14
  const iconRef = React.useRef<HTMLSpanElement>(null);
15
15
 
16
16
  const handleMouseEnter = () => {
17
17
  if (iconRef.current) {
18
18
  const rect = iconRef.current.getBoundingClientRect();
19
19
  // Try to keep tooltip within upper bounds if possible
20
- const y = rect.top - 6;
21
- setPos({ top: y, left: rect.left + rect.width / 2 });
20
+ const spaceAbove = rect.top;
21
+
22
+ if (spaceAbove < 150) {
23
+ // Not enough space above, position below
24
+ setPos({ top: rect.bottom + 6, left: rect.left + rect.width / 2, isBelow: true });
25
+ } else {
26
+ // Default position above
27
+ setPos({ top: rect.top - 6, left: rect.left + rect.width / 2, isBelow: false });
28
+ }
22
29
  }
23
30
  setShow(true);
24
31
  };
@@ -38,7 +45,11 @@ export function HintIcon({ text }: HintIconProps) {
38
45
  {show && typeof document !== 'undefined' && ReactDOM.createPortal(
39
46
  <div
40
47
  className="fixed z-[9999] px-3 py-2 text-[12px] leading-relaxed text-white bg-foreground-0 rounded-[6px] shadow-lg max-w-[320px] whitespace-pre-wrap pointer-events-none"
41
- style={{ top: pos.top, left: pos.left, transform: 'translate(-50%, -100%)' }}
48
+ style={{
49
+ top: pos.top,
50
+ left: pos.left,
51
+ transform: pos.isBelow ? 'translate(-50%, 0)' : 'translate(-50%, -100%)'
52
+ }}
42
53
  >
43
54
  {text}
44
55
  </div>,
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';