@asaleh37/ui-base 1.2.19 → 1.2.21
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/dist/index.d.ts +2 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/administration/dev/NotificationGrid.tsx +432 -0
- package/src/components/administration/dev/NotificationQueueGrid.tsx +222 -0
- package/src/components/common/Home.tsx +22 -24
- package/src/components/common/MyNotificationsPanel.tsx +104 -0
- package/src/components/common/NotificationItem.tsx +138 -0
- package/src/components/templates/workflow/WorkflowRouteComponent.tsx +14 -0
- package/src/hooks/useAxios.tsx +4 -1
- package/src/hooks/useInterval.tsx +23 -0
- package/src/layout/Layout.tsx +7 -1
- package/src/layout/NotificationButton.tsx +207 -0
- package/src/layout/TopBar.tsx +2 -0
- package/src/locales/arabic/devLocalsAr.json +28 -3
- package/src/locales/english/devLocalsEn.json +26 -1
- package/src/redux/features/administration/AdministrationStoresMetaData.ts +13 -0
- package/src/routes/administration/devRoutes.tsx +15 -0
- package/src/util/AppUtils.ts +30 -0
- package/src/assets/logo.png +0 -0
package/src/util/AppUtils.ts
CHANGED
|
@@ -21,3 +21,33 @@ export function isValidEmail(email) {
|
|
|
21
21
|
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
22
22
|
return re.test(email);
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
export function timeAgo(dateInput, appDirection: "ltr" | "rtl") {
|
|
26
|
+
const date = new Date(dateInput);
|
|
27
|
+
const now = new Date();
|
|
28
|
+
const diffInSeconds = Math.floor((date - now) / 1000); // Note: future is positive
|
|
29
|
+
const absDiff = Math.abs(diffInSeconds);
|
|
30
|
+
|
|
31
|
+
const locale = appDirection === "rtl" ? "ar" : "en";
|
|
32
|
+
|
|
33
|
+
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" });
|
|
34
|
+
|
|
35
|
+
const units = [
|
|
36
|
+
{ unit: "year", seconds: 31536000 },
|
|
37
|
+
{ unit: "month", seconds: 2592000 },
|
|
38
|
+
{ unit: "week", seconds: 604800 },
|
|
39
|
+
{ unit: "day", seconds: 86400 },
|
|
40
|
+
{ unit: "hour", seconds: 3600 },
|
|
41
|
+
{ unit: "minute", seconds: 60 },
|
|
42
|
+
{ unit: "second", seconds: 1 },
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
for (const { unit, seconds } of units) {
|
|
46
|
+
const delta = Math.floor(diffInSeconds / seconds);
|
|
47
|
+
if (Math.abs(delta) > 1) {
|
|
48
|
+
return rtf.format(delta, unit);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return locale === "ar" ? "الآن" : "just now";
|
|
53
|
+
}
|
package/src/assets/logo.png
DELETED
|
Binary file
|