diff --git a/app/(app)/subscriptions/page.tsx b/app/(app)/subscriptions/page.tsx index 64aa035..cffbeec 100644 --- a/app/(app)/subscriptions/page.tsx +++ b/app/(app)/subscriptions/page.tsx @@ -1,157 +1,8 @@ "use client"; - -import { useQuery } from "@tanstack/react-query"; +import { useEffect } from "react"; import { useRouter } from "next/navigation"; -import { RefreshCw, Wifi, AlertCircle } from "lucide-react"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/Card"; -import { Table, TableHead, TableBody, TableRow, Th, Td } from "@/components/ui/Table"; -import { Badge } from "@/components/ui/Badge"; -import { Button } from "@/components/ui/Button"; -import { formatDate, formatCurrency } from "@/lib/utils"; -import api from "@/lib/api"; -import type { PaginatedResponse } from "@/types"; - -interface Subscription { - id: string; - clientId: string; - status: string; - startDate: string; - endDate?: string; - client?: { firstName: string; lastName: string; accountNumber: string }; - plan?: { name: string; type: string; monthlyPrice: number }; - planId?: string; - monthlyRate?: number; - mrc?: number; - type?: string; -} - -const statusVariant: Record = { - ACTIVE: "success", - active: "success", - SUSPENDED: "warning", - suspended: "warning", - CANCELLED: "danger", - cancelled: "danger", - DISCONNECTED: "danger", - disconnected: "danger", - PENDING: "muted", - pending: "muted", -}; - -export default function SubscriptionsPage() { +export default function SubscriptionsRedirect() { const router = useRouter(); - - const { data, isLoading, isError, error, refetch, isFetching } = useQuery>({ - queryKey: ["subscriptions"], - queryFn: async () => { - const res = await api.get>("/api/v1/subscriptions?page=1&limit=50"); - return res.data; - }, - retry: false, - }); - - const subscriptions = data?.data ?? []; - const meta = data?.meta; - - const isNotFound = - isError && - (error as { response?: { status?: number } })?.response?.status === 404; - - return ( -
-
-
-

Subscriptions

-

{meta?.total ?? 0} total subscriptions

-
- -
- - - - All Subscriptions - - - {isLoading ? ( -
- {Array.from({ length: 4 }).map((_, i) => ( -
- ))} -
- ) : isNotFound || (isError && !data) ? ( -
-
- -
-

Subscriptions Module Not Yet Available

-

- Subscription data will appear here once the module is deployed. -

-
- - API endpoint not yet available -
- -
- ) : subscriptions.length === 0 ? ( -
-
- -
-

No subscriptions yet.

- -
- ) : ( - - - - - - - - - - - - - {subscriptions.map((sub) => ( - sub.clientId && router.push(`/clients/${sub.clientId}`)} - > - - - - - - - - ))} - -
ClientPlanTypeStatusStart DateMRC - {sub.client ? ( -
-

{sub.client.firstName} {sub.client.lastName}

-

{sub.client.accountNumber}

-
- ) : ( - - )} -
{sub.plan?.name ?? sub.planId ?? "—"}{sub.plan?.type ?? sub.type ?? "—"} - {sub.status} - {formatDate(sub.startDate)}{formatCurrency(sub.plan?.monthlyPrice ?? sub.monthlyRate ?? sub.mrc ?? 0)}
- )} - - -
- ); + useEffect(() => { router.replace("/clients"); }, [router]); + return
Redirecting to clients…
; } diff --git a/app/(app)/tasks/page.tsx b/app/(app)/tasks/page.tsx index 30750fb..e4a2f5d 100644 --- a/app/(app)/tasks/page.tsx +++ b/app/(app)/tasks/page.tsx @@ -1,123 +1,8 @@ "use client"; - -import { useState } from "react"; -import { useQuery } from "@tanstack/react-query"; -import { ChevronLeft, ChevronRight, RefreshCw } from "lucide-react"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/Card"; -import { Table, TableHead, TableBody, TableRow, Th, Td, EmptyState } from "@/components/ui/Table"; -import { Badge } from "@/components/ui/Badge"; -import { Button } from "@/components/ui/Button"; -import { formatDate } from "@/lib/utils"; -import api from "@/lib/api"; -import type { Task, PaginatedResponse } from "@/types"; - -const statusVariant: Record = { - done: "success", - DONE: "success", - completed: "success", - COMPLETED: "success", - in_progress: "default", - IN_PROGRESS: "default", - pending: "warning", - PENDING: "warning", - cancelled: "muted", - CANCELLED: "muted", -}; - -export default function TasksPage() { - const [page, setPage] = useState(1); - - const { data, isLoading, refetch } = useQuery>({ - queryKey: ["tasks", page], - queryFn: async () => { - const res = await api.get>(`/api/v1/manual-tasks?page=${page}&limit=20`); - return res.data; - }, - }); - - const tasks = data?.data ?? []; - const meta = data?.meta; - - return ( -
-
-
-

Tasks

-

{meta?.total ?? 0} total tasks

-
- -
- - - All Tasks - - - - - - - - - - - - - - {isLoading ? ( - Array.from({ length: 5 }).map((_, i) => ( - - {Array.from({ length: 6 }).map((_, j) => ( - - ))} - - )) - ) : tasks.length === 0 ? ( - - ) : ( - tasks.map((task) => ( - - - - - - - - - )) - )} - -
TitleTypeStatusAssigned ToDue DateLinked Ticket
{task.type?.replace(/_/g," ")}{task.type} - - {task.status} - - - {task.assignedUser - ? `${task.assignedUser.firstName} ${task.assignedUser.lastName}` - : task.assignedTo ?? "—"} - - {task.dueDate ? formatDate(task.dueDate) : "—"} - - {task.ticket?.subject ?? (task.ticketId ? task.ticketId.slice(0, 8) : "—")} -
- - {meta && meta.totalPages > 1 && ( -
-

Page {meta.page} of {meta.totalPages}

-
- - -
-
- )} -
-
-
- ); +import { useEffect } from "react"; +import { useRouter } from "next/navigation"; +export default function TasksRedirect() { + const router = useRouter(); + useEffect(() => { router.replace("/tickets"); }, [router]); + return
Redirecting to tickets…
; } diff --git a/app/(app)/users/page.tsx b/app/(app)/users/page.tsx index 21ff38a..5d71d13 100644 --- a/app/(app)/users/page.tsx +++ b/app/(app)/users/page.tsx @@ -1,110 +1,8 @@ "use client"; - -import { useQuery } from "@tanstack/react-query"; -import { RefreshCw } from "lucide-react"; -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/Card"; -import { Table, TableHead, TableBody, TableRow, Th, Td, EmptyState } from "@/components/ui/Table"; -import { Badge } from "@/components/ui/Badge"; -import { Button } from "@/components/ui/Button"; -import { formatDate } from "@/lib/utils"; -import api from "@/lib/api"; -import type { User, UsersResponse } from "@/types"; - -export default function UsersPage() { - const { data: users, isLoading, refetch } = useQuery({ - queryKey: ["users"], - queryFn: async () => { - const res = await api.get("/api/v1/users?page=1&limit=20"); - // Handle both array and paginated response - const d = res.data; - if (Array.isArray(d)) return d; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const anyD = d as any; - if (anyD.data) return anyD.data as UsersResponse; - return []; - }, - }); - - const userList: User[] = users ?? []; - - return ( -
-
-
-

Users

-

{userList.length} total users

-
- -
- - - All Users - - - - - - - - - - - - - - {isLoading ? ( - Array.from({ length: 3 }).map((_, i) => ( - - {Array.from({ length: 6 }).map((_, j) => ( - - ))} - - )) - ) : userList.length === 0 ? ( - - ) : ( - userList.map((user) => { - const roles = user.roleAssignments?.map((r) => r.role) ?? []; - return ( - - - - - - - - - ); - }) - )} - -
NameEmailRoleStatusLast LoginJoined
{user.firstName} {user.lastName}{user.email} -
- {roles.length === 0 ? ( - No role - ) : ( - roles.map((role) => ( - - {role} - - )) - )} -
-
- - {user.isActive ? "Active" : "Inactive"} - - - {user.lastLoginAt ? formatDate(user.lastLoginAt) : "Never"} - {formatDate(user.createdAt)}
-
-
-
- ); +import { useEffect } from "react"; +import { useRouter } from "next/navigation"; +export default function UsersRedirect() { + const router = useRouter(); + useEffect(() => { router.replace("/settings"); }, [router]); + return
Redirecting to settings…
; }