startx 0.0.1 → 0.1.1
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/.prettierignore +0 -13
- package/.prettierrc.js +52 -52
- package/.vscode/launch.json +32 -0
- package/.vscode/settings.json +9 -3
- package/apps/core-server/.env.example +18 -24
- package/apps/core-server/Dockerfile +35 -61
- package/apps/core-server/eslint.config.ts +7 -0
- package/apps/core-server/package.json +41 -52
- package/apps/core-server/src/config/custom-type.ts +2 -40
- package/apps/core-server/src/events/index.ts +37 -37
- package/apps/core-server/src/index.ts +4 -13
- package/apps/core-server/src/middlewares/auth-middleware.ts +24 -7
- package/apps/core-server/src/middlewares/cors-middleware.ts +7 -6
- package/apps/core-server/src/middlewares/error-middleware.ts +7 -4
- package/apps/core-server/src/middlewares/logger-middleware.ts +81 -21
- package/apps/core-server/src/middlewares/notfound-middleware.ts +6 -14
- package/apps/core-server/src/middlewares/serve-static.ts +30 -24
- package/apps/core-server/src/routes/files/router.ts +9 -7
- package/apps/core-server/src/routes/server.ts +30 -36
- package/apps/core-server/tsdown.config.ts +4 -3
- package/biome.json +58 -60
- package/configs/eslint-config/package.json +16 -19
- package/configs/eslint-config/src/configs/base.ts +185 -225
- package/configs/eslint-config/src/configs/extend.ts +3 -0
- package/configs/eslint-config/src/configs/frontend.ts +81 -56
- package/configs/eslint-config/src/configs/node.ts +6 -6
- package/configs/eslint-config/src/plugin.ts +1 -0
- package/configs/eslint-config/src/rules/index.ts +8 -12
- package/configs/eslint-config/src/rules/no-json-parse-json-stringify.test.ts +30 -17
- package/configs/eslint-config/src/rules/no-json-parse-json-stringify.ts +52 -49
- package/configs/eslint-config/src/rules/no-uncaught-json-parse.ts +43 -45
- package/configs/tsdown-config/package.json +10 -3
- package/configs/typescript-config/package.json +10 -1
- package/configs/typescript-config/tsconfig.common.json +3 -3
- package/configs/vitest-config/dist/base.mjs +1 -0
- package/configs/vitest-config/dist/frontend.mjs +1 -0
- package/configs/vitest-config/dist/node.mjs +1 -0
- package/configs/vitest-config/package.json +12 -0
- package/configs/vitest-config/src/base.ts +17 -29
- package/configs/vitest-config/src/index.ts +1 -0
- package/package.json +15 -26
- package/packages/@repo/constants/eslint.config.ts +4 -0
- package/packages/@repo/constants/package.json +16 -0
- package/packages/@repo/constants/src/index.ts +8 -8
- package/packages/@repo/db/eslint.config.ts +4 -0
- package/packages/@repo/db/package.json +16 -8
- package/packages/@repo/db/src/index.ts +26 -20
- package/packages/@repo/db/src/schema/common.ts +45 -49
- package/packages/@repo/env/eslint.config.ts +4 -0
- package/packages/@repo/env/package.json +39 -0
- package/packages/@repo/env/src/default-env.ts +12 -0
- package/packages/@repo/env/src/define-env.ts +70 -0
- package/packages/@repo/env/src/index.ts +2 -0
- package/packages/@repo/env/src/utils.ts +52 -0
- package/packages/@repo/env/tsconfig.json +7 -0
- package/packages/@repo/lib/eslint.config.ts +4 -0
- package/packages/@repo/lib/package.json +34 -34
- package/packages/@repo/lib/src/bucket-module/file-storage.ts +50 -49
- package/packages/@repo/lib/src/bucket-module/index.ts +3 -0
- package/packages/@repo/lib/src/bucket-module/s3-storage.ts +120 -114
- package/packages/@repo/lib/src/bucket-module/utils.ts +10 -11
- package/packages/@repo/lib/src/{cookie-module.ts → cookie-module/cookie-module.ts} +48 -42
- package/packages/@repo/lib/src/cookie-module/index.ts +1 -0
- package/packages/@repo/lib/src/extra/index.ts +1 -0
- package/packages/@repo/lib/src/extra/pagination-module.ts +35 -0
- package/packages/@repo/lib/src/{token-module.ts → extra/token-module.ts} +12 -5
- package/packages/@repo/lib/src/file-system-module/index.ts +170 -0
- package/packages/@repo/lib/src/{hashing-module.ts → hashing-module/index.ts} +9 -9
- package/packages/@repo/lib/src/index.ts +0 -26
- package/packages/@repo/lib/src/mail-module/index.ts +2 -0
- package/packages/@repo/lib/src/mail-module/mock.ts +8 -8
- package/packages/@repo/lib/src/mail-module/nodemailer.ts +17 -7
- package/packages/@repo/lib/src/notification-module/index.ts +1 -172
- package/packages/@repo/lib/src/notification-module/push-notification.ts +97 -90
- package/packages/@repo/lib/src/{oauth2-client.ts → oauth2-module/index.ts} +107 -109
- package/packages/@repo/lib/src/otp-module/index.ts +91 -0
- package/packages/@repo/lib/src/session-module/index.ts +113 -0
- package/packages/@repo/lib/src/utils.ts +43 -42
- package/packages/@repo/lib/src/validation-module/index.ts +242 -0
- package/packages/@repo/logger/eslint.config.ts +4 -0
- package/packages/@repo/logger/package.json +40 -0
- package/packages/@repo/logger/src/index.ts +2 -0
- package/packages/@repo/logger/src/logger.ts +72 -0
- package/packages/@repo/{lib/src/logger-module → logger/src}/memory-profiler.ts +64 -65
- package/packages/@repo/logger/tsconfig.json +7 -0
- package/packages/@repo/mail/eslint.config.ts +4 -0
- package/packages/@repo/mail/package.json +10 -3
- package/packages/@repo/mail/src/emails/admin/OtpEmail.tsx +169 -168
- package/packages/@repo/mail/src/index.ts +1 -2
- package/packages/@repo/mail/tsconfig.json +3 -3
- package/packages/@repo/redis/dist/index.d.mts +3 -0
- package/packages/@repo/redis/dist/index.mjs +5 -0
- package/packages/@repo/redis/dist/lib/redis-client.d.mts +7 -0
- package/packages/@repo/redis/dist/lib/redis-client.mjs +25 -0
- package/packages/@repo/redis/dist/lib/redis-client.mjs.map +1 -0
- package/packages/@repo/redis/dist/lib/redis-module.d.mts +5 -0
- package/packages/@repo/redis/dist/lib/redis-module.mjs +6 -0
- package/packages/@repo/redis/dist/lib/redis-module.mjs.map +1 -0
- package/packages/@repo/redis/eslint.config.ts +4 -0
- package/packages/@repo/redis/package.json +13 -10
- package/packages/@repo/redis/src/index.ts +2 -2
- package/packages/@repo/redis/src/lib/redis-client.ts +36 -23
- package/packages/@repo/redis/src/lib/redis-module.ts +69 -3
- package/packages/cli/dist/index.mjs +203 -0
- package/packages/cli/eslint.config.ts +4 -0
- package/packages/cli/package.json +44 -0
- package/packages/cli/tsconfig.json +12 -0
- package/packages/cli/tsdown.config.ts +17 -0
- package/packages/ui/components.json +0 -1
- package/packages/ui/eslint.config.ts +4 -0
- package/packages/ui/package.json +16 -3
- package/packages/ui/postcss.config.mjs +9 -9
- package/packages/ui/src/components/lib/utils.ts +53 -53
- package/packages/ui/src/components/ui/alert-dialog.tsx +118 -116
- package/packages/ui/src/components/ui/avatar.tsx +52 -53
- package/packages/ui/src/components/ui/badge.tsx +45 -46
- package/packages/ui/src/components/ui/breadcrumb.tsx +108 -109
- package/packages/ui/src/components/ui/card.tsx +91 -92
- package/packages/ui/src/components/ui/carousel.tsx +243 -243
- package/packages/ui/src/components/ui/checkbox.tsx +32 -32
- package/packages/ui/src/components/ui/command.tsx +144 -155
- package/packages/ui/src/components/ui/dialog.tsx +124 -127
- package/packages/ui/src/components/ui/form.tsx +166 -165
- package/packages/ui/src/components/ui/input-otp.tsx +74 -76
- package/packages/ui/src/components/ui/input.tsx +19 -21
- package/packages/ui/src/components/ui/multiple-select.tsx +4 -4
- package/packages/ui/src/{components/lucide.tsx → lucide.ts} +3 -3
- package/packages/ui/tailwind.config.ts +94 -94
- package/packages/ui/tsconfig.json +7 -1
- package/pnpm-workspace.yaml +41 -1
- package/startx.json +22 -0
- package/turbo.json +20 -27
- package/apps/core-server/eslint.config.mjs +0 -47
- package/configs/eslint-config/src/rules/no-dynamic-import-template.ts +0 -32
- package/configs/eslint-config/src/rules/no-plain-errors.ts +0 -50
- package/configs/eslint-config/tsdown.config.ts +0 -11
- package/packages/@repo/constants/eslint.config.mjs +0 -21
- package/packages/@repo/db/eslint.config.mjs +0 -21
- package/packages/@repo/lib/eslint.config.mjs +0 -49
- package/packages/@repo/lib/src/command-module.ts +0 -77
- package/packages/@repo/lib/src/constants.ts +0 -3
- package/packages/@repo/lib/src/custom-type.ts +0 -54
- package/packages/@repo/lib/src/env.ts +0 -13
- package/packages/@repo/lib/src/file-system/index.ts +0 -90
- package/packages/@repo/lib/src/logger-module/log-config.ts +0 -16
- package/packages/@repo/lib/src/logger-module/logger.ts +0 -78
- package/packages/@repo/lib/src/mail-module/api.ts +0 -0
- package/packages/@repo/lib/src/otp-module.ts +0 -98
- package/packages/@repo/lib/src/pagination-module.ts +0 -49
- package/packages/@repo/lib/src/user-session.ts +0 -117
- package/packages/@repo/lib/src/validation-module.ts +0 -187
- package/packages/@repo/mail/tsconfig.build.json +0 -14
- package/packages/@repo/mail/tsdown.config.ts +0 -9
- package/packages/@repo/redis/eslint.config.mjs +0 -8
- package/packages/ui/eslint.config.mjs +0 -18
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Cli powered by Commander.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"build": "tsdown --config-loader unrun",
|
|
10
|
+
"dev": "cross-env STARTX_ENV=development tsx src/index.ts"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"cross-env": "^10.1.0",
|
|
17
|
+
"eslint-config": "workspace:*",
|
|
18
|
+
"tsdown-config": "workspace:*",
|
|
19
|
+
"typescript-config": "workspace:*",
|
|
20
|
+
"vitest-config": "workspace:*"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@inquirer/prompts": "^8.3.0",
|
|
24
|
+
"@repo/lib": "workspace:*",
|
|
25
|
+
"@repo/logger": "workspace:*",
|
|
26
|
+
"@repo/env": "workspace:*",
|
|
27
|
+
"chokidar": "^4.0.3",
|
|
28
|
+
"commander": "^14.0.0",
|
|
29
|
+
"type-fest": "^5.4.4"
|
|
30
|
+
},
|
|
31
|
+
"startx": {
|
|
32
|
+
"tags": [
|
|
33
|
+
"node"
|
|
34
|
+
],
|
|
35
|
+
"requiredDeps": [
|
|
36
|
+
"@repo/env",
|
|
37
|
+
"@repo/lib",
|
|
38
|
+
"@repo/logger"
|
|
39
|
+
],
|
|
40
|
+
"requiredDevDeps": [
|
|
41
|
+
"typescript-config"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
import { baseConfig } from "tsdown-config";
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
...baseConfig,
|
|
6
|
+
platform: "node",
|
|
7
|
+
external: ["sharp"],
|
|
8
|
+
noExternal: [/(.*)/],
|
|
9
|
+
outputOptions: {
|
|
10
|
+
codeSplitting: false,
|
|
11
|
+
preserveModules: false,
|
|
12
|
+
legalComments: "none",
|
|
13
|
+
},
|
|
14
|
+
define: {
|
|
15
|
+
"process.env.NODE_ENV": JSON.stringify("production"),
|
|
16
|
+
},
|
|
17
|
+
});
|
package/packages/ui/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"name": "@repo/ui",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"private": true,
|
|
5
|
+
"type": "module",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"clean": "rimraf dist .turbo",
|
|
7
8
|
"watch:dev": "pnpm watch",
|
|
@@ -55,13 +56,25 @@
|
|
|
55
56
|
"react-icons": "^5.5.0",
|
|
56
57
|
"sonner": "^1.7.0",
|
|
57
58
|
"tailwind-merge": "^2.3.0",
|
|
58
|
-
"tailwindcss-animate": "^1.0.7"
|
|
59
|
-
"zod": "^3.23.8"
|
|
59
|
+
"tailwindcss-animate": "^1.0.7"
|
|
60
60
|
},
|
|
61
61
|
"exports": {
|
|
62
62
|
"./globals.css": "./src/globals.css",
|
|
63
63
|
"./postcss.config": "./postcss.config.mjs",
|
|
64
|
+
"./lucide": "./src/lucide.ts",
|
|
64
65
|
"./tailwind.config": "./tailwind.config.ts",
|
|
65
|
-
"
|
|
66
|
+
"./*/*": "./src/components/*/*"
|
|
67
|
+
},
|
|
68
|
+
"startx": {
|
|
69
|
+
"tags": [
|
|
70
|
+
"react",
|
|
71
|
+
"frontend"
|
|
72
|
+
],
|
|
73
|
+
"requiredDevDeps": [
|
|
74
|
+
"typescript-config"
|
|
75
|
+
],
|
|
76
|
+
"ignore": [
|
|
77
|
+
"vitest-config"
|
|
78
|
+
]
|
|
66
79
|
}
|
|
67
80
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/** @type {import('postcss-load-config').Config} */
|
|
2
|
-
const config = {
|
|
3
|
-
plugins: {
|
|
4
|
-
"@tailwindcss/postcss": {},
|
|
5
|
-
autoprefixer: {},
|
|
6
|
-
},
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export default config;
|
|
1
|
+
/** @type {import('postcss-load-config').Config} */
|
|
2
|
+
const config = {
|
|
3
|
+
plugins: {
|
|
4
|
+
"@tailwindcss/postcss": {},
|
|
5
|
+
autoprefixer: {},
|
|
6
|
+
},
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default config;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { type ClassValue, clsx } from
|
|
2
|
+
import { type ClassValue, clsx } from "clsx";
|
|
3
3
|
import {
|
|
4
|
+
differenceInDays,
|
|
5
|
+
differenceInYears,
|
|
4
6
|
format,
|
|
7
|
+
formatDistance,
|
|
8
|
+
isThisWeek,
|
|
5
9
|
isToday,
|
|
6
10
|
isYesterday,
|
|
7
|
-
isThisWeek,
|
|
8
|
-
differenceInDays,
|
|
9
|
-
formatDistance,
|
|
10
11
|
parseISO,
|
|
11
|
-
|
|
12
|
-
} from
|
|
13
|
-
import { twMerge } from 'tailwind-merge';
|
|
12
|
+
} from "date-fns";
|
|
13
|
+
import { twMerge } from "tailwind-merge";
|
|
14
14
|
|
|
15
|
-
import type { Store } from
|
|
15
|
+
import type { Store } from "../util/storage";
|
|
16
16
|
|
|
17
17
|
export function cn(...inputs: ClassValue[]) {
|
|
18
18
|
return twMerge(clsx(inputs));
|
|
@@ -42,29 +42,29 @@ export function getFormData(object: {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export function switchPath(pathname: string, tab: string) {
|
|
45
|
-
const fragments = pathname.split(
|
|
45
|
+
const fragments = pathname.split("/").filter(str => str);
|
|
46
46
|
fragments[2] = tab;
|
|
47
|
-
const path = `/${fragments.join(
|
|
47
|
+
const path = `/${fragments.join("/")}`;
|
|
48
48
|
return path;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export function getRelativeDate(date?: string | Date) {
|
|
52
52
|
const now = new Date();
|
|
53
|
-
if (!date) return
|
|
53
|
+
if (!date) return "";
|
|
54
54
|
if (isToday(date)) {
|
|
55
|
-
return format(date,
|
|
55
|
+
return format(date, "h:mm a");
|
|
56
56
|
} else if (isYesterday(date)) {
|
|
57
|
-
return
|
|
57
|
+
return "yesterday";
|
|
58
58
|
} else if (isThisWeek(date) && differenceInDays(now, date) <= 7) {
|
|
59
|
-
return format(date,
|
|
59
|
+
return format(date, "EEEE"); // EEEE gives the full name of the day like Sunday, Monday
|
|
60
60
|
} else {
|
|
61
|
-
return format(date,
|
|
61
|
+
return format(date, "dd/MM/yy");
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export function getRelativeDateWithTime(date?: string | Date) {
|
|
66
66
|
const now = new Date();
|
|
67
|
-
if (!date) return
|
|
67
|
+
if (!date) return "";
|
|
68
68
|
return formatDistance(new Date(date), now, { addSuffix: true });
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -73,12 +73,12 @@ export function getRelativeProDate(dateString: string) {
|
|
|
73
73
|
const date = parseISO(dateString);
|
|
74
74
|
const now = new Date();
|
|
75
75
|
const yearsDifference = differenceInYears(now, date);
|
|
76
|
-
const dateFormat = yearsDifference >= 1 ?
|
|
76
|
+
const dateFormat = yearsDifference >= 1 ? "dd MMM yyyy, h:mm a" : "dd MMM, h:mm a";
|
|
77
77
|
const formattedDate = format(date, dateFormat);
|
|
78
78
|
return formattedDate;
|
|
79
79
|
} catch (error) {
|
|
80
|
-
console.error(
|
|
81
|
-
return
|
|
80
|
+
console.error("Error formatting date:", error);
|
|
81
|
+
return "";
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
export function isValidId(str: string) {
|
|
@@ -88,54 +88,54 @@ export function isValidId(str: string) {
|
|
|
88
88
|
|
|
89
89
|
export function getRelativeDateOnly(date?: string | Date) {
|
|
90
90
|
const now = new Date();
|
|
91
|
-
if (!date) return
|
|
91
|
+
if (!date) return "";
|
|
92
92
|
if (isToday(date)) {
|
|
93
|
-
return
|
|
93
|
+
return "today";
|
|
94
94
|
} else if (isYesterday(date)) {
|
|
95
|
-
return
|
|
95
|
+
return "yesterday";
|
|
96
96
|
} else if (isThisWeek(date) && differenceInDays(now, date) <= 7) {
|
|
97
|
-
return format(date,
|
|
97
|
+
return format(date, "EEEE"); // EEEE gives the full name of the day like Sunday, Monday
|
|
98
98
|
} else {
|
|
99
|
-
return format(date,
|
|
99
|
+
return format(date, "dd/MM/yy");
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
export type SocialMediaUrlMetaData = {
|
|
103
|
-
platform:
|
|
103
|
+
platform: "youtube" | "x" | "instagram";
|
|
104
104
|
url: string;
|
|
105
105
|
contentId: string;
|
|
106
106
|
};
|
|
107
107
|
export function getUrlMetaData(urlString: string): SocialMediaUrlMetaData | null {
|
|
108
108
|
const url = new URL(urlString);
|
|
109
109
|
let contentId: string;
|
|
110
|
-
let platform:
|
|
110
|
+
let platform: "youtube" | "x" | "instagram";
|
|
111
111
|
switch (url.origin) {
|
|
112
|
-
case
|
|
113
|
-
platform =
|
|
114
|
-
contentId = url.pathname.replace(
|
|
112
|
+
case "https://youtu.be":
|
|
113
|
+
platform = "youtube";
|
|
114
|
+
contentId = url.pathname.replace("/", "");
|
|
115
115
|
break;
|
|
116
|
-
case
|
|
117
|
-
platform =
|
|
118
|
-
contentId = url.searchParams.get(
|
|
116
|
+
case "https://www.youtube.com":
|
|
117
|
+
platform = "youtube";
|
|
118
|
+
contentId = url.searchParams.get("v") as string;
|
|
119
119
|
break;
|
|
120
|
-
case
|
|
121
|
-
platform =
|
|
120
|
+
case "https://x.com":
|
|
121
|
+
platform = "x";
|
|
122
122
|
contentId = url.pathname
|
|
123
|
-
.split(
|
|
124
|
-
.filter(
|
|
123
|
+
.split("/")
|
|
124
|
+
.filter(str => str)
|
|
125
125
|
.at(-1) as string;
|
|
126
126
|
break;
|
|
127
|
-
case
|
|
128
|
-
platform =
|
|
127
|
+
case "https://www.instagram.com":
|
|
128
|
+
platform = "instagram";
|
|
129
129
|
contentId = url.pathname
|
|
130
|
-
.split(
|
|
131
|
-
.filter(
|
|
130
|
+
.split("/")
|
|
131
|
+
.filter(str => str)
|
|
132
132
|
.at(-1) as string;
|
|
133
133
|
break;
|
|
134
|
-
case
|
|
135
|
-
platform =
|
|
134
|
+
case "https://instagram.com":
|
|
135
|
+
platform = "instagram";
|
|
136
136
|
contentId = url.pathname
|
|
137
|
-
.split(
|
|
138
|
-
.filter(
|
|
137
|
+
.split("/")
|
|
138
|
+
.filter(str => str)
|
|
139
139
|
.at(-1) as string;
|
|
140
140
|
break;
|
|
141
141
|
default:
|
|
@@ -188,7 +188,7 @@ export function memoizeAsync<T extends (...args: any[]) => Promise<any>>(fn: T):
|
|
|
188
188
|
}
|
|
189
189
|
export function memoizePersistentAsync<T extends (...args: any[]) => Promise<any>>(
|
|
190
190
|
fn: T,
|
|
191
|
-
store: Store
|
|
191
|
+
store: Store
|
|
192
192
|
): T {
|
|
193
193
|
return (async (...args: Parameters<T>): Promise<ReturnType<T>> => {
|
|
194
194
|
const key = JSON.stringify(args);
|
|
@@ -197,7 +197,7 @@ export function memoizePersistentAsync<T extends (...args: any[]) => Promise<any
|
|
|
197
197
|
try {
|
|
198
198
|
return JSON.parse(cachedValue);
|
|
199
199
|
} catch (error) {
|
|
200
|
-
console.error(
|
|
200
|
+
console.error("Error parsing cached value:", error);
|
|
201
201
|
return await fn(...args);
|
|
202
202
|
}
|
|
203
203
|
} else {
|
|
@@ -209,8 +209,8 @@ export function memoizePersistentAsync<T extends (...args: any[]) => Promise<any
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
export function formatNumberWithKMB(num: number): string {
|
|
212
|
-
const formatter = new Intl.NumberFormat(
|
|
213
|
-
notation:
|
|
212
|
+
const formatter = new Intl.NumberFormat("en-US", {
|
|
213
|
+
notation: "compact",
|
|
214
214
|
minimumSignificantDigits: 1,
|
|
215
215
|
maximumSignificantDigits: 3,
|
|
216
216
|
});
|
|
@@ -219,14 +219,14 @@ export function formatNumberWithKMB(num: number): string {
|
|
|
219
219
|
}
|
|
220
220
|
export function currencyToNumber(formattedCurrency: string): number {
|
|
221
221
|
// Remove everything except digits, minus sign, and decimal point
|
|
222
|
-
const numericString = formattedCurrency.replace(/[^0-9.-]+/g,
|
|
222
|
+
const numericString = formattedCurrency.replace(/[^0-9.-]+/g, "");
|
|
223
223
|
|
|
224
224
|
// Convert the string back to a number
|
|
225
225
|
const parsedNumber = Number.parseFloat(numericString);
|
|
226
226
|
|
|
227
227
|
// Handle potential NaN if parsing fails
|
|
228
228
|
if (isNaN(parsedNumber)) {
|
|
229
|
-
throw new Error(
|
|
229
|
+
throw new Error("Invalid currency format");
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
return parsedNumber;
|
|
@@ -234,9 +234,9 @@ export function currencyToNumber(formattedCurrency: string): number {
|
|
|
234
234
|
|
|
235
235
|
export function createLabels(e: string) {
|
|
236
236
|
return e
|
|
237
|
-
.replaceAll(
|
|
238
|
-
.replace(/\b\w/g,
|
|
237
|
+
.replaceAll("_", " ")
|
|
238
|
+
.replace(/\b\w/g, char => char.toUpperCase())
|
|
239
239
|
.trim();
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
export { cva, type VariantProps } from
|
|
242
|
+
export { cva, type VariantProps } from "class-variance-authority";
|
|
@@ -1,116 +1,118 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<AlertDialogPrimitive.Overlay
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<AlertDialogPrimitive.Title
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<AlertDialogPrimitive.Description
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
<AlertDialogPrimitive.Action
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<AlertDialogPrimitive.Cancel
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
{
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
import { buttonVariants } from "@/components/ui/button";
|
|
7
|
+
|
|
8
|
+
import { cn } from "../lib/utils";
|
|
9
|
+
|
|
10
|
+
const AlertDialog = AlertDialogPrimitive.Root;
|
|
11
|
+
|
|
12
|
+
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
|
13
|
+
|
|
14
|
+
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
|
15
|
+
|
|
16
|
+
const AlertDialogOverlay = React.forwardRef<
|
|
17
|
+
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
|
18
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
|
19
|
+
>(({ className, ...props }, ref) => (
|
|
20
|
+
<AlertDialogPrimitive.Overlay
|
|
21
|
+
className={cn(
|
|
22
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
23
|
+
className
|
|
24
|
+
)}
|
|
25
|
+
{...props}
|
|
26
|
+
ref={ref}
|
|
27
|
+
/>
|
|
28
|
+
));
|
|
29
|
+
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
|
30
|
+
|
|
31
|
+
const AlertDialogContent = React.forwardRef<
|
|
32
|
+
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
|
33
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
|
34
|
+
>(({ className, ...props }, ref) => (
|
|
35
|
+
<AlertDialogPortal>
|
|
36
|
+
<AlertDialogOverlay />
|
|
37
|
+
<AlertDialogPrimitive.Content
|
|
38
|
+
ref={ref}
|
|
39
|
+
className={cn(
|
|
40
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
41
|
+
className
|
|
42
|
+
)}
|
|
43
|
+
{...props}
|
|
44
|
+
/>
|
|
45
|
+
</AlertDialogPortal>
|
|
46
|
+
));
|
|
47
|
+
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
|
48
|
+
|
|
49
|
+
const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
50
|
+
<div className={cn("flex flex-col space-y-2 text-center sm:text-left", className)} {...props} />
|
|
51
|
+
);
|
|
52
|
+
AlertDialogHeader.displayName = "AlertDialogHeader";
|
|
53
|
+
|
|
54
|
+
const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
|
|
55
|
+
<div
|
|
56
|
+
className={cn("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", className)}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
61
|
+
|
|
62
|
+
const AlertDialogTitle = React.forwardRef<
|
|
63
|
+
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
|
64
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
|
65
|
+
>(({ className, ...props }, ref) => (
|
|
66
|
+
<AlertDialogPrimitive.Title
|
|
67
|
+
ref={ref}
|
|
68
|
+
className={cn("text-lg font-semibold", className)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
71
|
+
));
|
|
72
|
+
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
|
73
|
+
|
|
74
|
+
const AlertDialogDescription = React.forwardRef<
|
|
75
|
+
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
|
76
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
|
77
|
+
>(({ className, ...props }, ref) => (
|
|
78
|
+
<AlertDialogPrimitive.Description
|
|
79
|
+
ref={ref}
|
|
80
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
));
|
|
84
|
+
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName;
|
|
85
|
+
|
|
86
|
+
const AlertDialogAction = React.forwardRef<
|
|
87
|
+
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
|
88
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
|
89
|
+
>(({ className, ...props }, ref) => (
|
|
90
|
+
<AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
|
|
91
|
+
));
|
|
92
|
+
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
|
93
|
+
|
|
94
|
+
const AlertDialogCancel = React.forwardRef<
|
|
95
|
+
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
|
96
|
+
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
|
97
|
+
>(({ className, ...props }, ref) => (
|
|
98
|
+
<AlertDialogPrimitive.Cancel
|
|
99
|
+
ref={ref}
|
|
100
|
+
className={cn(buttonVariants({ variant: "outline" }), "mt-2 sm:mt-0", className)}
|
|
101
|
+
{...props}
|
|
102
|
+
/>
|
|
103
|
+
));
|
|
104
|
+
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
AlertDialog,
|
|
108
|
+
AlertDialogPortal,
|
|
109
|
+
AlertDialogOverlay,
|
|
110
|
+
AlertDialogTrigger,
|
|
111
|
+
AlertDialogContent,
|
|
112
|
+
AlertDialogHeader,
|
|
113
|
+
AlertDialogFooter,
|
|
114
|
+
AlertDialogTitle,
|
|
115
|
+
AlertDialogDescription,
|
|
116
|
+
AlertDialogAction,
|
|
117
|
+
AlertDialogCancel,
|
|
118
|
+
};
|