@myrjfa/ui 1.1.0 → 1.1.2

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.
Files changed (154) hide show
  1. package/dist/chat/ChatMain.d.ts +3 -1
  2. package/dist/chat/ChatMain.d.ts.map +1 -1
  3. package/dist/chat/ChatMain.js +174 -145
  4. package/dist/chat/ChatSidebar.js +7 -8
  5. package/dist/chat/ConversationList.d.ts.map +1 -1
  6. package/dist/chat/ConversationList.js +20 -18
  7. package/dist/chat/ExpensePanel.d.ts +4 -1
  8. package/dist/chat/ExpensePanel.d.ts.map +1 -1
  9. package/dist/chat/ExpensePanel.js +215 -195
  10. package/dist/chat/MessageBubble.d.ts +5 -3
  11. package/dist/chat/MessageBubble.d.ts.map +1 -1
  12. package/dist/chat/MessageBubble.js +185 -103
  13. package/dist/chat/MessageInput.d.ts +8 -1
  14. package/dist/chat/MessageInput.d.ts.map +1 -1
  15. package/dist/chat/MessageInput.js +182 -165
  16. package/dist/chat/MilestonePanel.d.ts +4 -1
  17. package/dist/chat/MilestonePanel.d.ts.map +1 -1
  18. package/dist/chat/MilestonePanel.js +150 -150
  19. package/dist/chat/components/ParticipantSelector.d.ts +11 -0
  20. package/dist/chat/components/ParticipantSelector.d.ts.map +1 -0
  21. package/dist/chat/components/ParticipantSelector.js +17 -0
  22. package/dist/chat/components/SplitInputs.d.ts +11 -0
  23. package/dist/chat/components/SplitInputs.d.ts.map +1 -0
  24. package/dist/chat/components/SplitInputs.js +83 -0
  25. package/dist/chat/components/SplitTypeSelector.d.ts +8 -0
  26. package/dist/chat/components/SplitTypeSelector.d.ts.map +1 -0
  27. package/dist/chat/components/SplitTypeSelector.js +13 -0
  28. package/dist/chat/dialogs/AddMemberDialog.js +30 -90
  29. package/dist/chat/dialogs/CameraDialog.js +38 -86
  30. package/dist/chat/dialogs/CreatePollDialog.d.ts +8 -0
  31. package/dist/chat/dialogs/CreatePollDialog.d.ts.map +1 -0
  32. package/dist/chat/dialogs/CreatePollDialog.js +38 -0
  33. package/dist/chat/dialogs/ExpenseAnalyticsDialog.d.ts +19 -0
  34. package/dist/chat/dialogs/ExpenseAnalyticsDialog.d.ts.map +1 -0
  35. package/dist/chat/dialogs/ExpenseAnalyticsDialog.js +52 -0
  36. package/dist/chat/dialogs/GroupInfoDialog.d.ts.map +1 -1
  37. package/dist/chat/dialogs/GroupInfoDialog.js +55 -92
  38. package/dist/chat/dialogs/GroupInfoViewDialog.js +5 -6
  39. package/dist/chat/dialogs/NewChatDialog.d.ts.map +1 -1
  40. package/dist/chat/dialogs/NewChatDialog.js +49 -113
  41. package/dist/chat/dialogs/NewGroupDialog.d.ts.map +1 -1
  42. package/dist/chat/dialogs/NewGroupDialog.js +49 -92
  43. package/dist/chat/dialogs/ParticipantsDialog.d.ts.map +1 -1
  44. package/dist/chat/dialogs/ParticipantsDialog.js +68 -118
  45. package/dist/dashboard/action-buttons.js +4 -5
  46. package/dist/dashboard/app-sidebar.js +47 -129
  47. package/dist/dashboard/card-header.js +1 -2
  48. package/dist/dashboard/dashboard-components.js +3 -5
  49. package/dist/dashboard/data-table.d.ts +2 -1
  50. package/dist/dashboard/data-table.d.ts.map +1 -1
  51. package/dist/dashboard/data-table.js +21 -33
  52. package/dist/dashboard/nav-main.js +4 -5
  53. package/dist/dashboard/nav-secondary.js +2 -25
  54. package/dist/dashboard/stats-card.js +1 -2
  55. package/dist/dashboard/table.js +8 -54
  56. package/dist/header/mobile-nav-item.js +1 -2
  57. package/dist/header/mobile-navbar.js +8 -9
  58. package/dist/header/nav-item.js +1 -2
  59. package/dist/index.d.ts +6 -0
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +7 -1
  62. package/dist/main/footer.js +5 -9
  63. package/dist/main/navbar.js +55 -138
  64. package/dist/main/paginationBar.js +12 -14
  65. package/dist/main/portfolio/portfolioItem.js +1 -2
  66. package/dist/main/portfolio/portfolioPopup.js +16 -17
  67. package/dist/main/review-page.d.ts.map +1 -1
  68. package/dist/main/review-page.js +132 -199
  69. package/dist/misc/accordion.js +8 -34
  70. package/dist/misc/alert-dialog.js +22 -55
  71. package/dist/misc/alert.js +7 -32
  72. package/dist/misc/alertdialogclaude.js +50 -125
  73. package/dist/misc/avatar.js +6 -31
  74. package/dist/misc/badge.js +4 -27
  75. package/dist/misc/button.js +4 -27
  76. package/dist/misc/card.js +12 -40
  77. package/dist/misc/carousel.js +37 -61
  78. package/dist/misc/checkbox.js +2 -25
  79. package/dist/misc/command.js +18 -49
  80. package/dist/misc/datepicker.js +66 -76
  81. package/dist/misc/dialog.js +20 -52
  82. package/dist/misc/document-upload-button.d.ts +12 -0
  83. package/dist/misc/document-upload-button.d.ts.map +1 -0
  84. package/dist/misc/document-upload-button.js +27 -0
  85. package/dist/misc/dropdown-menu.js +30 -67
  86. package/dist/misc/empty-state.d.ts +10 -0
  87. package/dist/misc/empty-state.d.ts.map +1 -0
  88. package/dist/misc/empty-state.js +5 -0
  89. package/dist/misc/faq.js +2 -3
  90. package/dist/misc/file-preview.js +43 -97
  91. package/dist/misc/filter.d.ts.map +1 -1
  92. package/dist/misc/filter.js +18 -21
  93. package/dist/misc/filterBar.js +136 -160
  94. package/dist/misc/form.js +39 -60
  95. package/dist/misc/image-compressor.d.ts +29 -0
  96. package/dist/misc/image-compressor.d.ts.map +1 -0
  97. package/dist/misc/image-compressor.js +70 -0
  98. package/dist/misc/image-cropper.d.ts +10 -0
  99. package/dist/misc/image-cropper.d.ts.map +1 -0
  100. package/dist/misc/image-cropper.js +44 -0
  101. package/dist/misc/input.d.ts.map +1 -1
  102. package/dist/misc/input.js +2 -25
  103. package/dist/misc/label.js +2 -25
  104. package/dist/misc/line-carousel.js +3 -13
  105. package/dist/misc/multiImageUploader.d.ts +2 -1
  106. package/dist/misc/multiImageUploader.d.ts.map +1 -1
  107. package/dist/misc/multiImageUploader.js +26 -3
  108. package/dist/misc/newsLetter.js +19 -79
  109. package/dist/misc/notification.d.ts +1 -2
  110. package/dist/misc/notification.d.ts.map +1 -1
  111. package/dist/misc/notification.js +89 -125
  112. package/dist/misc/pagination.js +16 -45
  113. package/dist/misc/password-eye.js +2 -3
  114. package/dist/misc/popover.d.ts.map +1 -1
  115. package/dist/misc/popover.js +8 -34
  116. package/dist/misc/progress.js +2 -25
  117. package/dist/misc/pwa-install-button.d.ts +9 -0
  118. package/dist/misc/pwa-install-button.d.ts.map +1 -0
  119. package/dist/misc/pwa-install-button.js +158 -0
  120. package/dist/misc/scroll-area.js +5 -29
  121. package/dist/misc/searchBar.js +27 -31
  122. package/dist/misc/searchBox.js +18 -22
  123. package/dist/misc/select.d.ts.map +1 -1
  124. package/dist/misc/select.js +22 -54
  125. package/dist/misc/separator.js +2 -25
  126. package/dist/misc/share.js +48 -104
  127. package/dist/misc/sheet.js +21 -53
  128. package/dist/misc/sidebar.js +112 -153
  129. package/dist/misc/skeleton.d.ts +36 -1
  130. package/dist/misc/skeleton.d.ts.map +1 -1
  131. package/dist/misc/skeleton.js +41 -27
  132. package/dist/misc/slider.js +3 -26
  133. package/dist/misc/starRating.js +5 -15
  134. package/dist/misc/stateCard.js +7 -8
  135. package/dist/misc/switch.d.ts +5 -0
  136. package/dist/misc/switch.d.ts.map +1 -0
  137. package/dist/misc/switch.js +8 -0
  138. package/dist/misc/tabs.js +8 -34
  139. package/dist/misc/textarea.js +2 -25
  140. package/dist/misc/tile.js +32 -93
  141. package/dist/misc/tooltip.js +8 -34
  142. package/dist/misc/whatsapp-help.d.ts +9 -0
  143. package/dist/misc/whatsapp-help.d.ts.map +1 -0
  144. package/dist/misc/whatsapp-help.js +13 -0
  145. package/dist/profile/socialLink.d.ts +1 -1
  146. package/dist/profile/socialLink.d.ts.map +1 -1
  147. package/dist/profile/socialLink.js +53 -69
  148. package/dist/utils/permissions.d.ts +7 -0
  149. package/dist/utils/permissions.d.ts.map +1 -0
  150. package/dist/utils/permissions.js +38 -0
  151. package/package.json +6 -4
  152. package/dist/main/portfolio/temp-page.d.ts +0 -2
  153. package/dist/main/portfolio/temp-page.d.ts.map +0 -1
  154. package/dist/main/portfolio/temp-page.js +0 -102
@@ -1,40 +1,4 @@
1
1
  "use client";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
39
3
  import { useState } from "react";
40
4
  import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../../misc/dialog";
@@ -46,98 +10,84 @@ import { Input } from "../../misc/input";
46
10
  import { Badge } from "../../misc/badge";
47
11
  import { AddMemberDialog } from "./AddMemberDialog";
48
12
  import { useRouter } from "next/navigation";
49
- export function ParticipantsDialog(_a) {
50
- var _this = this;
51
- var _b;
52
- var open = _a.open, onOpenChange = _a.onOpenChange, conversation = _a.conversation, currentUserId = _a.currentUserId, onUpdate = _a.onUpdate;
53
- var _c = useState(""), search = _c[0], setSearch = _c[1];
54
- var _d = useState([]), selectedUsers = _d[0], setSelectedUsers = _d[1];
55
- var router = useRouter();
56
- var isAdmin = ((_b = conversation.participants.find(function (p) { return p.userId === currentUserId; })) === null || _b === void 0 ? void 0 : _b.chatRole) === "admin";
13
+ import { confirmActions, showAlert } from "../../misc/alertdialogclaude";
14
+ export function ParticipantsDialog({ open, onOpenChange, conversation, currentUserId, onUpdate }) {
15
+ var _a;
16
+ const [search, setSearch] = useState("");
17
+ const [selectedUsers, setSelectedUsers] = useState([]);
18
+ const [participants, setParticipants] = useState(conversation.participants || []);
19
+ const router = useRouter();
20
+ const isAdmin = ((_a = participants.find(p => p.userId === currentUserId)) === null || _a === void 0 ? void 0 : _a.chatRole) === "admin";
57
21
  // Filter participants based on search query
58
- var filteredParticipants = conversation.participants.filter(function (p) {
22
+ const filteredParticipants = participants.filter(p => {
59
23
  var _a;
60
24
  return p.userId.toLowerCase().includes(search.toLowerCase()) ||
61
25
  ((_a = p.role) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(search.toLowerCase()));
62
26
  });
63
- var handleRemoveMember = function (userId) { return __awaiter(_this, void 0, void 0, function () {
64
- var res, err_1;
65
- return __generator(this, function (_a) {
66
- switch (_a.label) {
67
- case 0:
68
- if (!window.confirm("Are you sure you want to remove this member?")) return [3 /*break*/, 4];
69
- _a.label = 1;
70
- case 1:
71
- _a.trys.push([1, 3, , 4]);
72
- return [4 /*yield*/, chatApi.removeParticipant(conversation._id, userId)];
73
- case 2:
74
- res = _a.sent();
75
- if (res) {
76
- onUpdate();
77
- }
78
- return [3 /*break*/, 4];
79
- case 3:
80
- err_1 = _a.sent();
81
- console.error("Failed to remove member:", err_1);
82
- return [3 /*break*/, 4];
83
- case 4: return [2 /*return*/];
27
+ const handleRemoveMember = async (userId) => {
28
+ let confirmRemove = true;
29
+ await showAlert("Are you sure you want to remove this member?", undefined, confirmActions(() => confirmRemove = false));
30
+ if (!confirmRemove)
31
+ return;
32
+ if (confirmRemove) {
33
+ try {
34
+ const res = await chatApi.removeParticipant(conversation._id, userId);
35
+ if (res) {
36
+ setParticipants(participants.filter(p => p.userId !== userId));
37
+ onUpdate();
38
+ }
84
39
  }
85
- });
86
- }); };
40
+ catch (err) {
41
+ console.error("Failed to remove member:", err);
42
+ await showAlert("Failed to remove member");
43
+ }
44
+ }
45
+ };
87
46
  function handleCancel() {
88
47
  setSelectedUsers([]);
48
+ onOpenChange(false);
89
49
  }
90
- var handleToggleAdmin = function (userId, currentRole) { return __awaiter(_this, void 0, void 0, function () {
91
- var newRole, actionText, res, err_2;
92
- return __generator(this, function (_a) {
93
- switch (_a.label) {
94
- case 0:
95
- newRole = currentRole === "admin" ? "member" : "admin";
96
- actionText = newRole === "admin" ? "make admin" : "remove admin privileges from";
97
- if (!window.confirm("Are you sure you want to ".concat(actionText, " this user?"))) return [3 /*break*/, 4];
98
- _a.label = 1;
99
- case 1:
100
- _a.trys.push([1, 3, , 4]);
101
- return [4 /*yield*/, chatApi.updateParticipant(conversation._id, userId, { chatRole: newRole })];
102
- case 2:
103
- res = _a.sent();
104
- if (res) {
105
- onUpdate();
106
- }
107
- return [3 /*break*/, 4];
108
- case 3:
109
- err_2 = _a.sent();
110
- console.error("Failed to update user role:", err_2);
111
- return [3 /*break*/, 4];
112
- case 4: return [2 /*return*/];
50
+ const handleToggleAdmin = async (userId, currentRole) => {
51
+ const newRole = currentRole === "admin" ? "member" : "admin";
52
+ const actionText = newRole === "admin" ? "make admin" : "remove admin privileges from";
53
+ let confirmChange = true;
54
+ await showAlert(`Are you sure you want to ${actionText} this user?`, undefined, confirmActions(() => confirmChange = false));
55
+ if (confirmChange) {
56
+ try {
57
+ const res = await chatApi.updateParticipant(conversation._id, userId, { chatRole: newRole });
58
+ if (res) {
59
+ setParticipants(participants.map(p => p.userId === userId ? { ...p, chatRole: newRole } : p));
60
+ onUpdate();
61
+ }
62
+ }
63
+ catch (err) {
64
+ console.error(`Failed to update user role:`, err);
65
+ await showAlert("Failed to update user role");
66
+ }
67
+ }
68
+ };
69
+ const handleMembersSelected = async () => {
70
+ try {
71
+ const userIds = selectedUsers.map(u => u.username || "").filter(Boolean);
72
+ const res = await chatApi.addParticipants(conversation._id, userIds);
73
+ if (res.error) {
74
+ throw new Error(res.error);
113
75
  }
114
- });
115
- }); };
116
- var handleMembersSelected = function () { return __awaiter(_this, void 0, void 0, function () {
117
- var userIds, res, err_3;
118
- return __generator(this, function (_a) {
119
- switch (_a.label) {
120
- case 0:
121
- _a.trys.push([0, 2, , 3]);
122
- userIds = selectedUsers.map(function (u) { return u.username || ""; }).filter(Boolean);
123
- return [4 /*yield*/, chatApi.addParticipants(conversation._id, userIds)];
124
- case 1:
125
- res = _a.sent();
126
- if (res) {
127
- onUpdate();
128
- }
129
- router.refresh();
130
- return [3 /*break*/, 3];
131
- case 2:
132
- err_3 = _a.sent();
133
- console.error("Failed to add members:", err_3);
134
- return [3 /*break*/, 3];
135
- case 3: return [2 /*return*/];
76
+ else {
77
+ setParticipants(prev => [...prev, ...res.data]);
78
+ onUpdate();
136
79
  }
137
- });
138
- }); };
139
- var existingUsernames = conversation.participants.map(function (p) { return p.userId; });
140
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "sm:max-w-[500px]", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: isAdmin ? "Manage Participants" : "Group Members" }) }), _jsxs("div", { className: "space-y-4 py-4", children: [_jsxs("div", { className: "relative", children: [_jsx(Search, { className: "absolute left-3 top-3 w-4 h-4 text-gray-400" }), _jsx(Input, { value: search, onChange: function (e) { return setSearch(e.target.value); }, placeholder: "Search members by name or role..." })] }), _jsxs("div", { className: "max-h-64 overflow-y-auto space-y-2 pr-2 custom-scrollbar border rounded-lg p-3 bg-gray-50 dark:bg-gray-900/30", children: [_jsxs("p", { className: "text-[10px] font-bold text-gray-400 uppercase tracking-widest pl-1 sticky top-0", children: [isAdmin ? "Manage Members" : "Members", " (", filteredParticipants.length, ")"] }), filteredParticipants.map(function (p) { return (_jsxs("div", { className: "flex items-center justify-between p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800/70 transition-colors", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsxs(Avatar, { className: "w-8 h-8", children: [_jsx(AvatarImage, { src: p.profilePic }), _jsx(AvatarFallback, { className: "bg-indigo-100 text-indigo-600 text-xs", children: p.userId.charAt(0).toUpperCase() })] }), _jsxs("div", { children: [_jsxs("p", { className: "text-sm font-medium text-gray-900 dark:text-white flex items-center gap-1", children: [p.userId, p.chatRole === "admin" && _jsx(ShieldCheck, { className: "w-3 h-3 text-indigo-500" }), p.userId === currentUserId && _jsx(Badge, { variant: "secondary", className: "text-[10px] px-1.5 py-0.5 ml-1", children: "You" })] }), _jsx("p", { className: "text-[10px] text-gray-400 capitalize", children: p.role })] })] }), isAdmin && p.userId !== currentUserId && (_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "ghost", size: "icon", className: "".concat(p.chatRole === "admin"
80
+ }
81
+ catch (err) {
82
+ console.error("Failed to add members:", err);
83
+ await showAlert("Failed to add members");
84
+ }
85
+ finally {
86
+ setSelectedUsers([]);
87
+ }
88
+ };
89
+ const existingUsernames = participants.map(p => p.userId);
90
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "sm:max-w-[500px]", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: isAdmin ? "Manage Participants" : "Group Members" }) }), _jsxs("div", { className: "space-y-4 py-4", children: [_jsxs("div", { className: "relative", children: [_jsx(Search, { className: "absolute left-3 top-3 w-4 h-4 text-gray-400" }), _jsx(Input, { value: search, onChange: (e) => setSearch(e.target.value), placeholder: "Search members by name or role..." })] }), _jsxs("div", { className: "max-h-64 overflow-y-auto space-y-2 pr-2 custom-scrollbar border rounded-lg p-3 bg-gray-50 dark:bg-gray-900/30", children: [_jsxs("p", { className: "text-[10px] font-bold text-gray-400 uppercase tracking-widest pl-1 sticky top-0", children: [isAdmin ? "Manage Members" : "Members", " (", filteredParticipants.length, ")"] }), filteredParticipants.map((p) => (_jsxs("div", { className: "flex items-center justify-between p-2 rounded-xl hover:bg-gray-100 dark:hover:bg-gray-800/70 transition-colors", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsxs(Avatar, { className: "w-8 h-8", children: [_jsx(AvatarImage, { src: p.profilePic }), _jsx(AvatarFallback, { className: "bg-indigo-100 text-indigo-600 text-xs", children: p.userId.charAt(0).toUpperCase() })] }), _jsxs("div", { children: [_jsxs("p", { className: "text-sm font-medium text-gray-900 dark:text-white flex items-center gap-1", children: [p.userId, p.chatRole === "admin" && _jsx(ShieldCheck, { className: "w-3 h-3 text-indigo-500" }), p.userId === currentUserId && _jsx(Badge, { variant: "secondary", className: "text-[10px] px-1.5 py-0.5 ml-1", children: "You" })] }), _jsx("p", { className: "text-[10px] text-gray-400 capitalize", children: p.role })] })] }), isAdmin && p.userId !== currentUserId && (_jsxs("div", { className: "flex items-center gap-1", children: [_jsx(Button, { variant: "ghost", size: "icon", className: `${p.chatRole === "admin"
141
91
  ? "text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50 dark:hover:bg-yellow-900/20"
142
- : "text-blue-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20"), onClick: function () { return handleToggleAdmin(p.userId, p.chatRole); }, title: p.chatRole === "admin" ? "Remove admin" : "Make admin", children: p.chatRole === "admin" ? (_jsx(ShieldCheck, { className: "w-4 h-4" })) : (_jsx(Shield, { className: "w-4 h-4" })) }), _jsx(Button, { variant: "ghost", size: "icon", className: "text-red-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20", onClick: function () { return handleRemoveMember(p.userId); }, title: "Remove member", children: _jsx(UserMinus, { className: "w-4 h-4" }) })] }))] }, p.userId)); })] }), isAdmin && (_jsxs("div", { className: "border-t pt-4", children: [_jsxs("p", { className: "text-sm font-medium mb-3 flex items-center gap-2", children: [_jsx(UserPlus, { className: "w-4 h-4" }), "Add New Members"] }), _jsx(AddMemberDialog, { selectedUsers: selectedUsers, setSelectedUsers: setSelectedUsers, excludeUsernames: existingUsernames }), _jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [_jsx(Button, { variant: "outline", onClick: handleCancel, children: "Cancel" }), _jsx(Button, { onClick: handleMembersSelected, disabled: selectedUsers.length === 0, children: "Add Members" })] })] }))] })] }) }));
92
+ : "text-blue-400 hover:text-blue-500 hover:bg-blue-50 dark:hover:bg-blue-900/20"}`, onClick: () => handleToggleAdmin(p.userId, p.chatRole), title: p.chatRole === "admin" ? "Remove admin" : "Make admin", children: p.chatRole === "admin" ? (_jsx(ShieldCheck, { className: "w-4 h-4" })) : (_jsx(Shield, { className: "w-4 h-4" })) }), _jsx(Button, { variant: "ghost", size: "icon", className: "text-red-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20", onClick: () => handleRemoveMember(p.userId), title: "Remove member", children: _jsx(UserMinus, { className: "w-4 h-4" }) })] }))] }, p.userId)))] }), isAdmin && (_jsxs("div", { className: "border-t pt-4", children: [_jsxs("p", { className: "text-sm font-medium mb-3 flex items-center gap-2", children: [_jsx(UserPlus, { className: "w-4 h-4" }), "Add New Members"] }), _jsx(AddMemberDialog, { selectedUsers: selectedUsers, setSelectedUsers: setSelectedUsers, excludeUsernames: existingUsernames }), _jsxs("div", { className: "flex justify-end gap-2 pt-2", children: [_jsx(Button, { variant: "outline", onClick: handleCancel, children: "Cancel" }), _jsx(Button, { onClick: handleMembersSelected, disabled: selectedUsers.length === 0, children: "Add Members" })] })] }))] })] }) }));
143
93
  }
@@ -2,9 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { MoreHorizontal } from 'lucide-react';
3
3
  import { Button } from '../misc/button';
4
4
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '../misc/dropdown-menu';
5
- export function ActionButtons(_a) {
6
- var actions = _a.actions, _b = _a.includeMoreMenu, includeMoreMenu = _b === void 0 ? true : _b, _c = _a.maxDisplayed, maxDisplayed = _c === void 0 ? 0 : _c;
7
- var displayedActions = actions.slice(0, maxDisplayed);
8
- var menuActions = includeMoreMenu ? actions.slice(maxDisplayed) : [];
9
- return (_jsxs("div", { className: "flex items-center gap-2", children: [displayedActions.map(function (action, index) { return (_jsxs(Button, { variant: action.variant || 'outline', size: "sm", onClick: action.action, className: 'cursor-pointer', children: [action.icon, _jsx("span", { className: "ml-1", children: action.label })] }, index)); }), menuActions.length > 0 && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "outline", size: "sm", children: _jsx(MoreHorizontal, { className: "h-4 w-4 cursor-pointer" }) }) }), _jsx(DropdownMenuContent, { align: "end", children: menuActions.map(function (action, index) { return (_jsxs(DropdownMenuItem, { onClick: action.action, children: [action.icon, _jsx("span", { className: "ml-2", children: action.label })] }, index)); }) })] }))] }));
5
+ export function ActionButtons({ actions, includeMoreMenu = true, maxDisplayed = 0 }) {
6
+ const displayedActions = actions.slice(0, maxDisplayed);
7
+ const menuActions = includeMoreMenu ? actions.slice(maxDisplayed) : [];
8
+ return (_jsxs("div", { className: "flex items-center gap-2", children: [displayedActions.map((action, index) => (_jsxs(Button, { variant: action.variant || 'outline', size: "sm", onClick: action.action, className: 'cursor-pointer', children: [action.icon, _jsx("span", { className: "ml-1", children: action.label })] }, index))), menuActions.length > 0 && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { variant: "outline", size: "sm", children: _jsx(MoreHorizontal, { className: "h-4 w-4 cursor-pointer" }) }) }), _jsx(DropdownMenuContent, { align: "end", children: menuActions.map((action, index) => (_jsxs(DropdownMenuItem, { onClick: action.action, children: [action.icon, _jsx("span", { className: "ml-2", children: action.label })] }, index))) })] }))] }));
10
9
  }
@@ -1,73 +1,6 @@
1
1
  "use client";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __rest = (this && this.__rest) || function (s, e) {
50
- var t = {};
51
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
52
- t[p] = s[p];
53
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
54
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
55
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
56
- t[p[i]] = s[p[i]];
57
- }
58
- return t;
59
- };
60
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
61
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
62
- if (ar || !(i in from)) {
63
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
64
- ar[i] = from[i];
65
- }
66
- }
67
- return to.concat(ar || Array.prototype.slice.call(from));
68
- };
69
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
70
- import { logoutUser } from "@myrjfa/state/dist/lib/auth";
3
+ import { logoutUser } from "@myrjfa/state/dist/lib/actions/auth";
71
4
  import { isLoggedInAtom, userAtom, userLoadingAtom } from "@myrjfa/state/dist/lib/userAtom";
72
5
  import { useAtom, useAtomValue, useSetAtom } from "jotai";
73
6
  import { FileText, HelpCircleIcon, Inbox, LayoutDashboardIcon, LogOutIcon, Package, User } from "lucide-react";
@@ -80,56 +13,55 @@ import { Avatar, AvatarFallback, AvatarImage } from "../misc/avatar";
80
13
  import { Label } from "../misc/label";
81
14
  import { Sidebar, SidebarContent, SidebarFooter, SidebarMenuButton } from "../misc/sidebar";
82
15
  import { Skeleton } from "../misc/skeleton";
83
- export function AppSidebar(_a) {
84
- var _this = this;
85
- var _b, _c, _d, _e, _f, _g, _h, _j, _k;
86
- var props = __rest(_a, []);
87
- var router = useRouter();
88
- var _l = useAtom(userAtom), user = _l[0], setUser = _l[1];
89
- var setIsLoggedIn = useSetAtom(isLoggedInAtom);
90
- var loading = useAtomValue(userLoadingAtom);
16
+ export function AppSidebar({ ...props }) {
17
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
18
+ const router = useRouter();
19
+ const [user, setUser] = useAtom(userAtom);
20
+ const setIsLoggedIn = useSetAtom(isLoggedInAtom);
21
+ const loading = useAtomValue(userLoadingAtom);
91
22
  // Redirect to login if user is null after loading finishes
92
- useEffect(function () {
23
+ useEffect(() => {
93
24
  if (!loading && !user) {
94
25
  router.push('/auth/login');
95
26
  }
96
27
  }, [loading, user, router]);
97
28
  // Navigation data
98
- var navData = {
99
- navMain: __spreadArray(__spreadArray(__spreadArray([
29
+ const navData = {
30
+ navMain: [
100
31
  {
101
32
  title: "Profile",
102
- url: user ? "/profile/".concat((_b = user.role) !== null && _b !== void 0 ? _b : "user", "/").concat(user.username) : "#",
33
+ url: user ? `/profile/${(_a = user.role) !== null && _a !== void 0 ? _a : "user"}/${user.username}` : "#",
103
34
  icon: User,
104
35
  },
105
36
  {
106
- title: "Dashboard",
107
- url: user ? "/overview/".concat((_c = user.role) !== null && _c !== void 0 ? _c : "user") : "#",
37
+ title: "My Opportunities",
38
+ url: user ? `/overview/${(_b = user.role) !== null && _b !== void 0 ? _b : "user"}` : "#",
108
39
  icon: LayoutDashboardIcon
109
- }
110
- ], ((user === null || user === void 0 ? void 0 : user.role) === "admin" || (user === null || user === void 0 ? void 0 : user.role) === "host"
111
- ? [
112
- {
113
- title: "My Tours",
114
- url: "/overview/".concat(user.role, "/packages"),
115
- icon: Package,
116
- },
117
- ]
118
- : []), true), ((user === null || user === void 0 ? void 0 : user.role) === "admin" || (user === null || user === void 0 ? void 0 : user.role) === "host"
119
- ? [
120
- {
121
- title: "Blogs",
122
- url: "/overview/".concat(user.role, "/blogs"),
123
- icon: FileText,
124
- },
125
- ]
126
- : []), true), [
40
+ },
41
+ ...((user === null || user === void 0 ? void 0 : user.role) === "admin" || (user === null || user === void 0 ? void 0 : user.role) === "host"
42
+ ? [
43
+ {
44
+ title: "My Tours",
45
+ url: `/overview/${user.role}/packages`,
46
+ icon: Package,
47
+ },
48
+ ]
49
+ : []),
50
+ ...((user === null || user === void 0 ? void 0 : user.role) === "admin" || (user === null || user === void 0 ? void 0 : user.role) === "host"
51
+ ? [
52
+ {
53
+ title: "Blogs",
54
+ url: `/overview/${user.role}/blogs`,
55
+ icon: FileText,
56
+ },
57
+ ]
58
+ : []),
127
59
  {
128
60
  title: "Inbox",
129
61
  url: "/inbox",
130
62
  icon: Inbox
131
63
  },
132
- ], false),
64
+ ],
133
65
  navSecondary: [
134
66
  {
135
67
  title: "Get Help",
@@ -139,33 +71,19 @@ export function AppSidebar(_a) {
139
71
  ]
140
72
  };
141
73
  // Loading skeleton for user info
142
- var UserInfoSkeleton = function () { return (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "h-8 w-8 rounded-full" }), _jsxs("div", { className: "grid flex-1 gap-1 text-left", children: [_jsx(Skeleton, { className: "h-4 w-24" }), _jsx(Skeleton, { className: "h-3 w-32" })] })] })); };
143
- var handleLogout = function () { return __awaiter(_this, void 0, void 0, function () {
144
- var role, response;
74
+ const UserInfoSkeleton = () => (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "h-8 w-8 rounded-full" }), _jsxs("div", { className: "grid flex-1 gap-1 text-left", children: [_jsx(Skeleton, { className: "h-4 w-24" }), _jsx(Skeleton, { className: "h-3 w-32" })] })] }));
75
+ const handleLogout = async () => {
145
76
  var _a;
146
- return __generator(this, function (_b) {
147
- switch (_b.label) {
148
- case 0:
149
- role = (user === null || user === void 0 ? void 0 : user.role) || "user";
150
- setUser(null);
151
- setIsLoggedIn(false);
152
- return [4 /*yield*/, logoutUser(role)];
153
- case 1:
154
- response = _b.sent();
155
- if (!(response === null || response === void 0 ? void 0 : response.error)) return [3 /*break*/, 3];
156
- return [4 /*yield*/, showAlert(response.error)];
157
- case 2:
158
- _b.sent();
159
- return [3 /*break*/, 5];
160
- case 3: return [4 /*yield*/, showAlert((_a = response.message) !== null && _a !== void 0 ? _a : "")];
161
- case 4:
162
- _b.sent();
163
- _b.label = 5;
164
- case 5:
165
- router.push('/auth/login?role=' + role);
166
- return [2 /*return*/];
167
- }
168
- });
169
- }); };
170
- return (_jsxs(Sidebar, __assign({ collapsible: "icon" }, props, { children: [_jsxs(SidebarContent, { children: [_jsx(NavMain, { items: navData.navMain }), _jsx(NavSecondary, { items: navData.navSecondary, className: "mt-auto" })] }), _jsxs(SidebarFooter, { children: [_jsx(SidebarMenuButton, { size: "lg", className: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", children: loading ? (_jsx(UserInfoSkeleton, {})) : user ? (_jsxs(_Fragment, { children: [_jsxs(Avatar, { className: "h-8 w-8 rounded-full", children: [_jsx(AvatarImage, { src: (_d = user.profilePic) !== null && _d !== void 0 ? _d : "/images/profile_placeholder.webp", alt: "".concat((_e = user.firstName) !== null && _e !== void 0 ? _e : "Guest", " ").concat(user.lastName) }), _jsxs(AvatarFallback, { className: "rounded-full", children: [(_g = (_f = user.firstName) === null || _f === void 0 ? void 0 : _f.charAt(0)) !== null && _g !== void 0 ? _g : "D", (_j = (_h = user.lastName) === null || _h === void 0 ? void 0 : _h.charAt(0)) !== null && _j !== void 0 ? _j : "P"] })] }), _jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [_jsxs("span", { className: "truncate font-medium", children: [(_k = user.firstName) !== null && _k !== void 0 ? _k : "Guest", " ", user.lastName] }), user.email && (_jsx("span", { className: "truncate text-xs text-muted-foreground", children: user.email }))] })] })) : (_jsxs(_Fragment, { children: [_jsx(Avatar, { className: "h-8 w-8 rounded-full", children: _jsx(AvatarFallback, { className: "rounded-full", children: "GU" }) }), _jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [_jsx("span", { className: "truncate font-medium", children: "Guest User" }), _jsx("span", { className: "truncate text-xs text-muted-foreground", children: "Not signed in" })] })] })) }), _jsxs(SidebarMenuButton, { size: "lg", className: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", onClick: handleLogout, disabled: loading, children: [_jsx(LogOutIcon, { className: "mx-2" }), _jsx(Label, { className: "cursor-pointer", children: "Log out" })] })] })] })));
77
+ const role = (user === null || user === void 0 ? void 0 : user.role) || "user";
78
+ setUser(null);
79
+ setIsLoggedIn(false);
80
+ const response = await logoutUser(role);
81
+ if (response === null || response === void 0 ? void 0 : response.error) {
82
+ await showAlert(response.error);
83
+ }
84
+ else
85
+ await showAlert((_a = response.message) !== null && _a !== void 0 ? _a : "");
86
+ router.push('/auth/login?role=' + role);
87
+ };
88
+ return (_jsxs(Sidebar, { collapsible: "icon", ...props, children: [_jsxs(SidebarContent, { children: [_jsx(NavMain, { items: navData.navMain }), _jsx(NavSecondary, { items: navData.navSecondary, className: "mt-auto" })] }), _jsxs(SidebarFooter, { children: [_jsx(SidebarMenuButton, { size: "lg", className: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", children: loading ? (_jsx(UserInfoSkeleton, {})) : user ? (_jsxs(_Fragment, { children: [_jsxs(Avatar, { className: "h-8 w-8 rounded-full", children: [_jsx(AvatarImage, { src: (_c = user.profilePic) !== null && _c !== void 0 ? _c : "/images/profile_placeholder.webp", alt: `${(_d = user.firstName) !== null && _d !== void 0 ? _d : "Guest"} ${user.lastName}` }), _jsxs(AvatarFallback, { className: "rounded-full", children: [(_f = (_e = user.firstName) === null || _e === void 0 ? void 0 : _e.charAt(0)) !== null && _f !== void 0 ? _f : "D", (_h = (_g = user.lastName) === null || _g === void 0 ? void 0 : _g.charAt(0)) !== null && _h !== void 0 ? _h : "P"] })] }), _jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [_jsxs("span", { className: "truncate font-medium", children: [(_j = user.firstName) !== null && _j !== void 0 ? _j : "Guest", " ", user.lastName] }), user.email && (_jsx("span", { className: "truncate text-xs text-muted-foreground", children: user.email }))] })] })) : (_jsxs(_Fragment, { children: [_jsx(Avatar, { className: "h-8 w-8 rounded-full", children: _jsx(AvatarFallback, { className: "rounded-full", children: "GU" }) }), _jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [_jsx("span", { className: "truncate font-medium", children: "Guest User" }), _jsx("span", { className: "truncate text-xs text-muted-foreground", children: "Not signed in" })] })] })) }), _jsxs(SidebarMenuButton, { size: "lg", className: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground", onClick: handleLogout, disabled: loading, children: [_jsx(LogOutIcon, { className: "mx-2" }), _jsx(Label, { className: "cursor-pointer", children: "Log out" })] })] })] }));
171
89
  }
@@ -2,7 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // components/ui/card-header.tsx
3
3
  import { PlusCircle } from 'lucide-react';
4
4
  import { Button } from '../misc/button';
5
- export function CardHeader(_a) {
6
- var title = _a.title, description = _a.description, action = _a.action;
5
+ export function CardHeader({ title, description, action }) {
7
6
  return (_jsxs("div", { className: "flex flex-col sm:flex-row justify-between items-start sm:items-center mb-6 gap-4", children: [_jsxs("div", { children: [_jsx("h2", { className: "text-2xl font-bold tracking-tight", children: title }), description && _jsx("p", { className: "text-muted-foreground mt-1", children: description })] }), action && (_jsxs(Button, { onClick: action.onClick, children: [_jsx(PlusCircle, { className: "mr-2 h-4 w-4" }), action.label] }))] }));
8
7
  }
@@ -1,12 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn, getStatusColor } from '@myrjfa/state/dist/lib/utils';
3
3
  import { Progress } from '../misc/progress';
4
- export function StatusBadge(_a) {
5
- var status = _a.status, className = _a.className;
6
- var statusColor = getStatusColor(status);
4
+ export function StatusBadge({ status, className }) {
5
+ const statusColor = getStatusColor(status);
7
6
  return (_jsx("span", { className: cn('inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium', statusColor, className), children: status.charAt(0).toUpperCase() + status.slice(1) }));
8
7
  }
9
- export function ProgressWithText(_a) {
10
- var value = _a.value, label = _a.label, _b = _a.showPercentage, showPercentage = _b === void 0 ? true : _b;
8
+ export function ProgressWithText({ value, label, showPercentage = true }) {
11
9
  return (_jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center justify-between", children: [label && _jsx("p", { className: "text-sm text-muted-foreground", children: label }), showPercentage && _jsxs("p", { className: "text-sm text-muted-foreground", children: [value, "%"] })] }), _jsx(Progress, { value: value, className: "h-2" })] }));
12
10
  }
@@ -10,10 +10,11 @@ interface DataTableProps<T> {
10
10
  columns: Column<T>[];
11
11
  actions?: (item: T) => JSX.Element;
12
12
  onRowClick?: (id: string) => void;
13
+ getRowClass?: (item: T) => string;
13
14
  }
14
15
  export declare function DataTable<T extends {
15
16
  slug?: string;
16
17
  _id?: string;
17
- }>({ data, columns, actions, onRowClick, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
18
+ }>({ data, columns, actions, onRowClick, getRowClass, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
18
19
  export {};
19
20
  //# sourceMappingURL=data-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../src/dashboard/data-table.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,GAAG,EAAqB,MAAM,OAAO,CAAC;AAYtD,MAAM,WAAW,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC,CAAC;IACrB,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,cAAc,CAAC,CAAC;IACtB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;IACnC,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACjE,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,GACb,EAAE,cAAc,CAAC,CAAC,CAAC,2CAuNnB"}
1
+ {"version":3,"file":"data-table.d.ts","sourceRoot":"","sources":["../../src/dashboard/data-table.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,GAAG,EAAqB,MAAM,OAAO,CAAC;AAYtD,MAAM,WAAW,MAAM,CAAC,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC,CAAC;IACrB,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,SAAS,CAAC;IACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,cAAc,CAAC,CAAC;IACtB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;IACnC,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;CACrC;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACjE,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,GACd,EAAE,cAAc,CAAC,CAAC,CAAC,2CAuNnB"}
@@ -1,47 +1,35 @@
1
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
- if (ar || !(i in from)) {
4
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5
- ar[i] = from[i];
6
- }
7
- }
8
- return to.concat(ar || Array.prototype.slice.call(from));
9
- };
10
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
2
  import { ChevronDown, ChevronUp, Inbox } from 'lucide-react';
12
3
  import { useMemo, useState } from 'react';
13
4
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '../dashboard/table';
14
5
  import { Input } from '../misc/input';
15
- export function DataTable(_a) {
16
- var data = _a.data, columns = _a.columns, actions = _a.actions, onRowClick = _a.onRowClick;
17
- var _b = useState(''), searchQuery = _b[0], setSearchQuery = _b[1];
18
- var _c = useState(null), sortColumn = _c[0], setSortColumn = _c[1];
19
- var _d = useState('asc'), sortDirection = _d[0], setSortDirection = _d[1];
6
+ export function DataTable({ data, columns, actions, onRowClick, getRowClass, }) {
7
+ const [searchQuery, setSearchQuery] = useState('');
8
+ const [sortColumn, setSortColumn] = useState(null);
9
+ const [sortDirection, setSortDirection] = useState('asc');
20
10
  // Global search across all string fields
21
- var filteredData = useMemo(function () {
11
+ const filteredData = useMemo(() => {
22
12
  if (!searchQuery)
23
13
  return data;
24
- return data.filter(function (item) {
25
- var searchLower = searchQuery.toLowerCase();
26
- return Object.values(item).some(function (value) {
27
- return typeof value === 'string' && value.toLowerCase().includes(searchLower);
28
- });
14
+ return data.filter((item) => {
15
+ const searchLower = searchQuery.toLowerCase();
16
+ return Object.values(item).some((value) => typeof value === 'string' && value.toLowerCase().includes(searchLower));
29
17
  });
30
18
  }, [searchQuery, data]);
31
19
  // Sort logic
32
- var sortedData = useMemo(function () {
20
+ const sortedData = useMemo(() => {
33
21
  if (!sortColumn)
34
22
  return filteredData;
35
- return __spreadArray([], filteredData, true).sort(function (a, b) {
36
- var aValue = a[sortColumn];
37
- var bValue = b[sortColumn];
23
+ return [...filteredData].sort((a, b) => {
24
+ const aValue = a[sortColumn];
25
+ const bValue = b[sortColumn];
38
26
  if (typeof aValue === 'number' && typeof bValue === 'number') {
39
27
  return sortDirection === 'asc' ? aValue - bValue : bValue - aValue;
40
28
  }
41
29
  return String(aValue).localeCompare(String(bValue)) * (sortDirection === 'asc' ? 1 : -1);
42
30
  });
43
31
  }, [filteredData, sortColumn, sortDirection]);
44
- var toggleSort = function (accessorKey) {
32
+ const toggleSort = (accessorKey) => {
45
33
  if (sortColumn === accessorKey) {
46
34
  setSortDirection(sortDirection === 'asc' ? 'desc' : 'asc');
47
35
  }
@@ -50,17 +38,17 @@ export function DataTable(_a) {
50
38
  setSortDirection('asc');
51
39
  }
52
40
  };
53
- return (_jsxs("div", { className: "w-full", children: [_jsx("div", { className: "p-2", children: _jsx(Input, { placeholder: "Search...", className: "mb-4 max-w-sm", value: searchQuery, onChange: function (e) { return setSearchQuery(e.target.value); } }) }), _jsx("div", { className: "hidden lg:block overflow-auto", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [columns.map(function (column) { return (_jsx(TableHead, { className: "cursor-pointer select-none", onClick: function () { return column.sortable && toggleSort(column.accessorKey); }, children: _jsxs("div", { className: "flex items-center gap-1", children: [column.header, column.sortable && (sortColumn === column.accessorKey ? (sortDirection === 'asc' ? (_jsx(ChevronUp, { className: "w-4 h-4 text-black" })) : (_jsx(ChevronDown, { className: "w-4 h-4 text-black" }))) : (_jsxs("div", { className: "flex flex-col text-gray-400 leading-none", children: [_jsx(ChevronUp, { className: "w-3 h-3 -mb-1" }), _jsx(ChevronDown, { className: "w-3 h-3" })] })))] }) }, column.accessorKey)); }), actions && _jsx(TableHead, { children: "Actions" })] }) }), _jsx(TableBody, { children: sortedData.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + (actions ? 1 : 0), className: "h-40 text-center text-gray-500", children: _jsxs("div", { className: "flex flex-col items-center justify-center gap-2", children: [_jsx(Inbox, { className: "w-8 h-8 text-gray-400" }), _jsx("span", { className: "text-base font-medium", children: "No data available" })] }) }) })) : (sortedData.map(function (item) {
54
- var key = item.slug || item._id || Math.random().toString();
55
- return (_jsxs(TableRow, { onClick: function () { return onRowClick && onRowClick(key); }, className: onRowClick ? 'hover:bg-accent cursor-pointer' : '', children: [columns.map(function (column) { return (_jsx(TableCell, { children: column.cell
41
+ return (_jsxs("div", { className: "w-full", children: [_jsx("div", { className: "p-2", children: _jsx(Input, { placeholder: "Search...", className: "mb-4 max-w-sm", value: searchQuery, onChange: (e) => setSearchQuery(e.target.value) }) }), _jsx("div", { className: "hidden lg:block overflow-auto", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [columns.map((column) => (_jsx(TableHead, { className: "cursor-pointer select-none", onClick: () => column.sortable && toggleSort(column.accessorKey), children: _jsxs("div", { className: "flex items-center gap-1", children: [column.header, column.sortable && (sortColumn === column.accessorKey ? (sortDirection === 'asc' ? (_jsx(ChevronUp, { className: "w-4 h-4 text-black" })) : (_jsx(ChevronDown, { className: "w-4 h-4 text-black" }))) : (_jsxs("div", { className: "flex flex-col text-gray-400 leading-none", children: [_jsx(ChevronUp, { className: "w-3 h-3 -mb-1" }), _jsx(ChevronDown, { className: "w-3 h-3" })] })))] }) }, column.accessorKey))), actions && _jsx(TableHead, { children: "Actions" })] }) }), _jsx(TableBody, { children: sortedData.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + (actions ? 1 : 0), className: "h-40 text-center text-gray-500", children: _jsxs("div", { className: "flex flex-col items-center justify-center gap-2", children: [_jsx(Inbox, { className: "w-8 h-8 text-gray-400" }), _jsx("span", { className: "text-base font-medium", children: "No data available" })] }) }) })) : (sortedData.map((item) => {
42
+ const key = item.slug || item._id || Math.random().toString();
43
+ return (_jsxs(TableRow, { onClick: () => onRowClick && onRowClick(key), className: `${onRowClick ? 'hover:bg-accent cursor-pointer' : ''} ${getRowClass ? getRowClass(item) : ''}`, children: [columns.map((column) => (_jsx(TableCell, { children: column.cell
56
44
  ? column.cell(item)
57
- : item[column.accessorKey] }, column.accessorKey)); }), actions && (_jsx(TableCell, { onClick: function (e) { return e.stopPropagation(); }, children: actions(item) }))] }, key));
58
- })) })] }) }), _jsx("div", { className: "lg:hidden", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsx(TableRow, { children: columns.slice(1).map(function (column) { return (_jsx(TableHead, { className: "cursor-pointer select-none", onClick: function () { return column.sortable && toggleSort(column.accessorKey); }, children: _jsxs("div", { className: "flex items-center gap-1", children: [column.header, column.sortable && (sortColumn === column.accessorKey ? (sortDirection === 'asc' ? (_jsx(ChevronUp, { className: "w-4 h-4 text-black" })) : (_jsx(ChevronDown, { className: "w-4 h-4 text-black" }))) : (_jsxs("div", { className: "flex flex-col text-gray-400 leading-none", children: [_jsx(ChevronUp, { className: "w-3 h-3 -mb-1" }), _jsx(ChevronDown, { className: "w-3 h-3" })] })))] }) }, column.accessorKey)); }) }) }), _jsx(TableBody, { children: sortedData.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + (actions ? 1 : 0), className: "h-40 text-center text-gray-500", children: _jsxs("div", { className: "flex flex-col items-center justify-center gap-2", children: [_jsx(Inbox, { className: "w-8 h-8 text-gray-400" }), _jsx("span", { className: "text-base font-medium", children: "No data available" })] }) }) })) : (sortedData.map(function (item) {
59
- var key = item.slug || item._id || Math.random().toString();
45
+ : item[column.accessorKey] }, column.accessorKey))), actions && (_jsx(TableCell, { onClick: (e) => e.stopPropagation(), children: actions(item) }))] }, key));
46
+ })) })] }) }), _jsx("div", { className: "lg:hidden", children: _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsx(TableRow, { children: columns.slice(1).map((column) => (_jsx(TableHead, { className: "cursor-pointer select-none", onClick: () => column.sortable && toggleSort(column.accessorKey), children: _jsxs("div", { className: "flex items-center gap-1", children: [column.header, column.sortable && (sortColumn === column.accessorKey ? (sortDirection === 'asc' ? (_jsx(ChevronUp, { className: "w-4 h-4 text-black" })) : (_jsx(ChevronDown, { className: "w-4 h-4 text-black" }))) : (_jsxs("div", { className: "flex flex-col text-gray-400 leading-none", children: [_jsx(ChevronUp, { className: "w-3 h-3 -mb-1" }), _jsx(ChevronDown, { className: "w-3 h-3" })] })))] }) }, column.accessorKey))) }) }), _jsx(TableBody, { children: sortedData.length === 0 ? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + (actions ? 1 : 0), className: "h-40 text-center text-gray-500", children: _jsxs("div", { className: "flex flex-col items-center justify-center gap-2", children: [_jsx(Inbox, { className: "w-8 h-8 text-gray-400" }), _jsx("span", { className: "text-base font-medium", children: "No data available" })] }) }) })) : (sortedData.map((item) => {
47
+ const key = item.slug || item._id || Math.random().toString();
60
48
  return (_jsxs(_Fragment, { children: [_jsx(TableRow, { className: "bg-gray-100", children: _jsx(TableCell, { colSpan: columns.length - 1, className: "py-3", children: _jsx("div", { className: "font-semibold text-gray-900", children: columns[0].cell
61
49
  ? columns[0].cell(item)
62
- : item[columns[0].accessorKey] }) }) }), _jsx(TableRow, { onClick: function () { return onRowClick && onRowClick(key); }, className: onRowClick ? 'hover:bg-accent cursor-pointer' : '', children: columns.slice(1).map(function (column) { return (_jsx(TableCell, { children: column.cell
50
+ : item[columns[0].accessorKey] }) }) }), _jsx(TableRow, { onClick: () => onRowClick && onRowClick(key), className: `${onRowClick ? 'hover:bg-accent cursor-pointer' : ''} ${getRowClass ? getRowClass(item) : ''}`, children: columns.slice(1).map((column) => (_jsx(TableCell, { children: column.cell
63
51
  ? column.cell(item)
64
- : item[column.accessorKey] }, column.accessorKey)); }) }, key), actions && (_jsx(TableRow, { className: "bg-gray-30", children: _jsx(TableCell, { colSpan: columns.length - 1, className: "py-3", onClick: function (e) { return e.stopPropagation(); }, children: actions(item) }) }))] }));
52
+ : item[column.accessorKey] }, column.accessorKey))) }, key), actions && (_jsx(TableRow, { className: "bg-gray-30", children: _jsx(TableCell, { colSpan: columns.length - 1, className: "py-3", onClick: (e) => e.stopPropagation(), children: actions(item) }) }))] }));
65
53
  })) })] }) })] }));
66
54
  }