@devtron-labs/devtron-fe-common-lib 0.0.9-beta-7 → 0.0.9-beta-8
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/Common/Helper.d.ts +1 -0
- package/dist/index.js +5711 -0
- package/package.json +2 -1
- package/src/Common/Helper.tsx +15 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devtron-labs/devtron-fe-common-lib",
|
|
3
|
-
"version": "0.0.9-beta-
|
|
3
|
+
"version": "0.0.9-beta-8",
|
|
4
4
|
"description": "Supporting common component library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@svgr/rollup": "6.5.1",
|
|
34
34
|
"@rollup/plugin-url": "8.0.1",
|
|
35
35
|
"@rollup/plugin-commonjs": "24.0.1",
|
|
36
|
+
"moment": "^2.29.4",
|
|
36
37
|
"typescript": "^4.9.4",
|
|
37
38
|
"react-toastify": "^8.2.0",
|
|
38
39
|
"@tippyjs/react": "^4.2.0",
|
package/src/Common/Helper.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import * as Sentry from '@sentry/browser'
|
|
|
5
5
|
import { toastAccessDenied } from './ToastBody'
|
|
6
6
|
import { ERROR_EMPTY_SCREEN, TOKEN_COOKIE_NAME } from './Constants'
|
|
7
7
|
import { ReactComponent as FormError } from '../Assets/Icon/ic-warning.svg'
|
|
8
|
+
import moment from 'moment';
|
|
8
9
|
|
|
9
10
|
toast.configure({
|
|
10
11
|
autoClose: 3000,
|
|
@@ -331,3 +332,17 @@ export function CustomInput({
|
|
|
331
332
|
</div>
|
|
332
333
|
)
|
|
333
334
|
}
|
|
335
|
+
|
|
336
|
+
export function handleUTCTime(ts: string, isRelativeTime = false) {
|
|
337
|
+
let timestamp = "";
|
|
338
|
+
try {
|
|
339
|
+
if (ts && ts.length) {
|
|
340
|
+
let date = moment(ts);
|
|
341
|
+
if (isRelativeTime) timestamp = date.fromNow();
|
|
342
|
+
else timestamp = date.format("ddd DD MMM YYYY HH:mm:ss");
|
|
343
|
+
}
|
|
344
|
+
} catch (error) {
|
|
345
|
+
console.error("Error Parsing Date:", ts);
|
|
346
|
+
}
|
|
347
|
+
return timestamp;
|
|
348
|
+
}
|