Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

refactor: streamline external link handling by importing ExternalLink type and updating fetch logic

Andrej Acevski19356f3dc960
diff --git a/apps/web/src/components/external-links/external-links-accordion.tsx b/apps/web/src/components/external-links/external-links-accordion.tsx
index 9a1fe8d97..8194047e5 100644
--- a/apps/web/src/components/external-links/external-links-accordion.tsx
+++ b/apps/web/src/components/external-links/external-links-accordion.tsx
@@ -12,15 +12,7 @@ import {
CollapsibleContent,
CollapsibleTrigger,
} from "@/components/ui/collapsible";
-
-interface ExternalLink {
- id: string;
- resourceType: "issue" | "pull_request" | "branch";
- externalId: string;
- url: string;
- title?: string | null;
- metadata?: Record<string, unknown>;
-}
+import type { ExternalLink } from "@/types/external-link";
interface ExternalLinksAccordionProps {
externalLinks: ExternalLink[];
diff --git a/apps/web/src/fetchers/external-link/get-external-links.ts b/apps/web/src/fetchers/external-link/get-external-links.ts
index 5ca6f02d4..4fdfe0af5 100644
--- a/apps/web/src/fetchers/external-link/get-external-links.ts
+++ b/apps/web/src/fetchers/external-link/get-external-links.ts
@@ -1,18 +1,18 @@
-import type { ExternalLink } from "@/types/external-link";
+import { client } from "@kaneo/libs";
-async function getExternalLinks(taskId: string): Promise<ExternalLink[]> {
- const response = await fetch(
- `${import.meta.env.VITE_API_URL || "http://localhost:1337"}/api/external-link/task/${taskId}`,
- {
- credentials: "include",
- },
- );
+async function getExternalLinks(taskId: string) {
+ const response = await client["external-link"].task[":taskId"].$get({
+ param: { taskId },
+ });
if (!response.ok) {
- throw new Error("Failed to fetch external links");
+ const error = await response.text();
+ throw new Error(error);
}
- return response.json();
+ const data = await response.json();
+
+ return data;
}
export default getExternalLinks;
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/project/$projectId/task/$taskId_.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/project/$projectId/task/$taskId_.tsx
index cc005e78a..463eedbba 100644
--- a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/project/$projectId/task/$taskId_.tsx
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/project/$projectId/task/$taskId_.tsx
@@ -43,6 +43,7 @@ import { useGetActiveWorkspaceUsers } from "@/hooks/queries/workspace-users/use-
import { getColumnIcon } from "@/lib/column";
import { dueDateStatusColors, getDueDateStatus } from "@/lib/due-date-status";
import { getPriorityIcon } from "@/lib/priority";
+import type { ExternalLink } from "@/types/external-link";
export const Route = createFileRoute(
"/_layout/_authenticated/dashboard/workspace/$workspaceId/project/$projectId/task/$taskId_",
@@ -62,7 +63,7 @@ function slugify(text: string | undefined): string {
function generateBranchName(
pattern: string,
projectSlug: string | undefined,
- taskNumber: number | undefined,
+ taskNumber: number | null | undefined,
taskTitle: string | undefined,
): string {
if (!projectSlug || !taskNumber) return "";
@@ -343,7 +344,7 @@ function RouteComponent() {
{!isLoadingExternalLinks && externalLinks.length > 0 && (
<div className="mt-4">
<ExternalLinksAccordion
- externalLinks={externalLinks}
+ externalLinks={externalLinks as ExternalLink[]}
isLoading={isLoadingExternalLinks}
/>
</div>