Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 0 additions & 101 deletions frontend/app/(dashboard)/invoices/[id]/loading.tsx

This file was deleted.

107 changes: 105 additions & 2 deletions frontend/app/(dashboard)/invoices/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { InformationCircleIcon } from "@heroicons/react/24/outline";
import { Ban, CircleAlert, MoreHorizontal, Printer, SquarePen, Trash2 } from "lucide-react";
import Link from "next/link";
import { useParams, useRouter } from "next/navigation";
import React, { useState } from "react";
import React, { Suspense, useState } from "react";
import AttachmentListCard from "@/components/AttachmentsList";
import { DashboardHeader } from "@/components/DashboardHeader";
import { linkClasses } from "@/components/Link";
Expand All @@ -20,6 +20,7 @@ import {
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { useCurrentCompany, useCurrentUser } from "@/global";
import { PayRateType, trpc } from "@/trpc/client";
Expand Down Expand Up @@ -101,7 +102,101 @@ const PrintTotalRow = ({ children, className }: { children: React.ReactNode; cla
</div>
);

export default function InvoicePage() {
function InvoiceLoadingSkeleton() {
return (
<div>
<DashboardHeader
title={<Skeleton className="h-8 w-48" />}
className="pb-4"
headerActions={
<div className="flex gap-2">
<Skeleton className="h-10 w-10 md:h-10 md:w-20" />
<Skeleton className="hidden h-10 w-24 md:block" />
</div>
}
/>
<div className="space-y-4">
<div className="mx-4">
<Skeleton className="mb-2 h-4 w-16" />
<Skeleton className="h-5 w-40" />
</div>
<section className="mx-4">
<div className="grid gap-4 pb-28">
<div className="grid auto-cols-fr gap-3 p-4 md:grid-flow-col">
{Array.from({ length: 5 }).map((_, i) => (
<div key={i}>
<Skeleton className="mb-2 h-4 w-20" />
<Skeleton className="h-5 w-32" />
</div>
))}
</div>
<div className="w-full overflow-x-auto">
<Table className="w-full min-w-fit">
<TableHeader>
<TableRow>
<TableHead className="w-[40%] md:w-[50%]">
<Skeleton className="h-4 w-24" />
</TableHead>
<TableHead className="w-[20%] text-right md:w-[15%]">
<Skeleton className="ml-auto h-4 w-20" />
</TableHead>
<TableHead className="w-[20%] text-right md:w-[15%]">
<Skeleton className="ml-auto h-4 w-20" />
</TableHead>
<TableHead className="w-[20%] text-right">
<Skeleton className="ml-auto h-4 w-20" />
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{Array.from({ length: 3 }).map((_, i) => (
<TableRow key={i}>
<TableCell className="w-[50%] align-top md:w-[60%]">
<Skeleton className="h-4 w-full max-w-md" />
</TableCell>
<TableCell className="w-[20%] text-right align-top md:w-[15%]">
<Skeleton className="ml-auto h-4 w-16" />
</TableCell>
<TableCell className="w-[20%] text-right align-top md:w-[15%]">
<Skeleton className="ml-auto h-4 w-20" />
</TableCell>
<TableCell className="w-[10%] text-right align-top">
<Skeleton className="ml-auto h-4 w-20" />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
<footer className="flex flex-col justify-between gap-3 px-4 lg:flex-row">
<div className="flex-1">
<Skeleton className="mb-2 h-5 w-16" />
<Skeleton className="h-16 w-full max-w-md" />
</div>
<Card className="self-start">
<CardContent>
<div className="space-y-3">
<div className="flex justify-between gap-8">
<Skeleton className="h-4 w-24" />
<Skeleton className="h-4 w-20" />
</div>
<Separator />
<div className="flex justify-between gap-8">
<Skeleton className="h-4 w-24" />
<Skeleton className="h-4 w-20" />
</div>
</div>
</CardContent>
</Card>
</footer>
</div>
</section>
</div>
</div>
);
}

function InvoicePageContent() {
const { id } = useParams<{ id: string }>();
const user = useCurrentUser();
const company = useCurrentCompany();
Expand Down Expand Up @@ -476,3 +571,11 @@ export default function InvoicePage() {
</div>
);
}

export default function InvoicePage() {
return (
<Suspense fallback={<InvoiceLoadingSkeleton />}>
<InvoicePageContent />
</Suspense>
);
}