@emberai-engg/task-board 0.3.0 → 0.3.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.
package/dist/index.d.mts CHANGED
@@ -296,6 +296,7 @@ interface TaskBoardService {
296
296
  addComment(taskId: string, data: CreateCommentPayload): Promise<Comment>;
297
297
  editComment(taskId: string, commentId: string, data: EditCommentPayload): Promise<Comment>;
298
298
  deleteComment(taskId: string, commentId: string): Promise<void>;
299
+ listProjects(): Promise<Project[]>;
299
300
  searchMentionUsers(query: string): Promise<MentionUser[]>;
300
301
  getNotificationCount(): Promise<number>;
301
302
  listNotifications(limit?: number): Promise<Notification[]>;
package/dist/index.d.ts CHANGED
@@ -296,6 +296,7 @@ interface TaskBoardService {
296
296
  addComment(taskId: string, data: CreateCommentPayload): Promise<Comment>;
297
297
  editComment(taskId: string, commentId: string, data: EditCommentPayload): Promise<Comment>;
298
298
  deleteComment(taskId: string, commentId: string): Promise<void>;
299
+ listProjects(): Promise<Project[]>;
299
300
  searchMentionUsers(query: string): Promise<MentionUser[]>;
300
301
  getNotificationCount(): Promise<number>;
301
302
  listNotifications(limit?: number): Promise<Notification[]>;
package/dist/index.js CHANGED
@@ -135,6 +135,11 @@ function createTaskBoardService(apiClient, basePath = "/api/v1/taskboard") {
135
135
  async deleteComment(taskId, commentId) {
136
136
  await apiClient.delete(`${basePath}/tasks/${taskId}/comments/${commentId}`);
137
137
  },
138
+ // ─── Projects ───
139
+ async listProjects() {
140
+ const { data } = await apiClient.get(`${basePath}/projects`);
141
+ return data;
142
+ },
138
143
  // ─── Mentions ───
139
144
  async searchMentionUsers(query) {
140
145
  const { data } = await apiClient.get(
@@ -257,68 +262,24 @@ function TaskBoardProvider({
257
262
 
258
263
  // src/hooks/useTaskBoard.ts
259
264
  var import_react2 = require("react");
260
-
261
- // src/utils/helpers.ts
262
- function getPriorityStyle(priority) {
263
- return DEFAULT_PRIORITIES.find((p) => p.value === priority) ?? DEFAULT_PRIORITIES[2];
264
- }
265
- function getTagStyle(tag) {
266
- const predefined = PREDEFINED_TAGS.find((t) => t.value === tag);
267
- if (predefined) return predefined;
268
- const label = tag.charAt(0).toUpperCase() + tag.slice(1).replace(/-/g, " ");
269
- return { value: tag, label, className: "bg-neutral-100 text-neutral-500 border-neutral-200" };
270
- }
271
- function getInitials(name) {
272
- return name.split(" ").map((w) => w[0]).join("").toUpperCase().slice(0, 2);
273
- }
274
- function parseDate(dateStr) {
275
- if (!dateStr) return /* @__PURE__ */ new Date();
276
- const d = new Date(dateStr);
277
- if (isNaN(d.getTime()) && !dateStr.endsWith("Z") && !dateStr.includes("+")) {
278
- return /* @__PURE__ */ new Date(dateStr + "Z");
279
- }
280
- return d;
281
- }
282
- function formatDate(dateStr) {
283
- if (!dateStr) return "";
284
- const d = parseDate(dateStr);
285
- return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
286
- }
287
- function formatDateTime(dateStr) {
288
- if (!dateStr) return "";
289
- const d = parseDate(dateStr);
290
- return d.toLocaleDateString("en-US", {
291
- month: "short",
292
- day: "numeric",
293
- hour: "numeric",
294
- minute: "2-digit"
295
- });
296
- }
297
- function getDescriptionPreview(desc) {
298
- if (!desc) return "";
299
- if (typeof desc === "string") return desc;
300
- for (const section of DESCRIPTION_SECTIONS) {
301
- if (desc[section.key]?.trim()) return desc[section.key].trim();
302
- }
303
- return "";
304
- }
305
- function hasDescription(desc) {
306
- if (!desc) return false;
307
- if (typeof desc === "string") return desc.trim().length > 0;
308
- return DESCRIPTION_SECTIONS.some((s) => desc[s.key]?.trim());
309
- }
310
- function getUserProjects(apps, allProjects) {
311
- if (apps.includes("all")) return allProjects;
312
- return allProjects.filter((p) => apps.includes(p.slug));
313
- }
314
-
315
- // src/hooks/useTaskBoard.ts
316
265
  function useTaskBoard() {
317
266
  const { service, user, projects: configProjects, columns, config } = useTaskBoardContext();
318
- const projects = (0, import_react2.useMemo)(
319
- () => configProjects.length > 0 ? configProjects : getUserProjects(user.apps, []),
320
- [configProjects, user.apps]
321
- );
267
+ const [fetchedProjects, setFetchedProjects] = (0, import_react2.useState)([]);
268
+ (0, import_react2.useEffect)(() => {
269
+ if (configProjects.length > 0) return;
270
+ let cancelled = false;
271
+ (async () => {
272
+ try {
273
+ const data = await service.listProjects();
274
+ if (!cancelled) setFetchedProjects(data);
275
+ } catch {
276
+ }
277
+ })();
278
+ return () => {
279
+ cancelled = true;
280
+ };
281
+ }, [configProjects, service]);
282
+ const projects = configProjects.length > 0 ? configProjects : fetchedProjects;
322
283
  const [selectedProject, setSelectedProject] = (0, import_react2.useState)("");
323
284
  const [tasks, setTasks] = (0, import_react2.useState)({});
324
285
  const [columnTotals, setColumnTotals] = (0, import_react2.useState)({});
@@ -541,6 +502,60 @@ var import_dnd2 = require("@hello-pangea/dnd");
541
502
  var import_react5 = require("react");
542
503
  var import_dnd = require("@hello-pangea/dnd");
543
504
 
505
+ // src/utils/helpers.ts
506
+ function getPriorityStyle(priority) {
507
+ return DEFAULT_PRIORITIES.find((p) => p.value === priority) ?? DEFAULT_PRIORITIES[2];
508
+ }
509
+ function getTagStyle(tag) {
510
+ const predefined = PREDEFINED_TAGS.find((t) => t.value === tag);
511
+ if (predefined) return predefined;
512
+ const label = tag.charAt(0).toUpperCase() + tag.slice(1).replace(/-/g, " ");
513
+ return { value: tag, label, className: "bg-neutral-100 text-neutral-500 border-neutral-200" };
514
+ }
515
+ function getInitials(name) {
516
+ return name.split(" ").map((w) => w[0]).join("").toUpperCase().slice(0, 2);
517
+ }
518
+ function parseDate(dateStr) {
519
+ if (!dateStr) return /* @__PURE__ */ new Date();
520
+ const d = new Date(dateStr);
521
+ if (isNaN(d.getTime()) && !dateStr.endsWith("Z") && !dateStr.includes("+")) {
522
+ return /* @__PURE__ */ new Date(dateStr + "Z");
523
+ }
524
+ return d;
525
+ }
526
+ function formatDate(dateStr) {
527
+ if (!dateStr) return "";
528
+ const d = parseDate(dateStr);
529
+ return d.toLocaleDateString("en-US", { month: "short", day: "numeric" });
530
+ }
531
+ function formatDateTime(dateStr) {
532
+ if (!dateStr) return "";
533
+ const d = parseDate(dateStr);
534
+ return d.toLocaleDateString("en-US", {
535
+ month: "short",
536
+ day: "numeric",
537
+ hour: "numeric",
538
+ minute: "2-digit"
539
+ });
540
+ }
541
+ function getDescriptionPreview(desc) {
542
+ if (!desc) return "";
543
+ if (typeof desc === "string") return desc;
544
+ for (const section of DESCRIPTION_SECTIONS) {
545
+ if (desc[section.key]?.trim()) return desc[section.key].trim();
546
+ }
547
+ return "";
548
+ }
549
+ function hasDescription(desc) {
550
+ if (!desc) return false;
551
+ if (typeof desc === "string") return desc.trim().length > 0;
552
+ return DESCRIPTION_SECTIONS.some((s) => desc[s.key]?.trim());
553
+ }
554
+ function getUserProjects(apps, allProjects) {
555
+ if (apps.includes("all")) return allProjects;
556
+ return allProjects.filter((p) => apps.includes(p.slug));
557
+ }
558
+
544
559
  // src/components/PriorityBadge.tsx
545
560
  var import_jsx_runtime3 = require("react/jsx-runtime");
546
561
  function PriorityBadge({ priority, size = "sm" }) {