Guest User

Untitled

a guest
Sep 12th, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. import React from "react";
  2. import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
  3. import { BusRequest, QuotationStatus } from "@/lib/types/BusRequest";
  4. import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
  5. import { formatDate } from "@/lib/utils";
  6. import Link from "next/link";
  7. import { Badge } from "@/components/ui/badge";
  8.  
  9. // Take in parameters that contains data
  10. //
  11. interface OrdersTableProps {
  12. bookings: BusRequest[];
  13. }
  14.  
  15. function getBadgeVariant(status: QuotationStatus | undefined): "default" | "secondary" | "destructive" | "outline" {
  16. switch (status) {
  17. case QuotationStatus.Accepted:
  18. return "default";
  19. case QuotationStatus.Declined:
  20. return "destructive";
  21. case QuotationStatus.Pending:
  22. return "secondary";
  23. default:
  24. return "outline";
  25. }
  26. }
  27.  
  28.  
  29. export default async function OrdersTable({ bookings }: OrdersTableProps) {
  30. return (
  31. <Card className="w-full">
  32. <CardHeader className="flex flex-col sm:flex-row items-center justify-between space-y-2 sm:space-y-0">
  33. <CardTitle className="text-2xl font-bold">Orders List</CardTitle>
  34. </CardHeader>
  35.  
  36. <CardContent>
  37. <Table>
  38. <TableCaption>End of page</TableCaption>
  39. <TableHeader>
  40. <TableRow>
  41. <TableHead>Name</TableHead>
  42. <TableHead>Contact</TableHead>
  43. <TableHead>Bus Type</TableHead>
  44. <TableHead>Travel Date</TableHead>
  45. <TableHead>Travel Time</TableHead>
  46. <TableHead>Quotation Status</TableHead>
  47. </TableRow>
  48. </TableHeader>
  49. <TableBody>
  50. {bookings.map((booking) => (
  51. <TableRow
  52. key={booking.$id}
  53. className="hover:bg-primary-light hover:cursor-pointer"
  54. >
  55. <TableCell>
  56. <Link
  57. href={`/dashboard/orders/${booking.$id}`}
  58. passHref
  59. >
  60. {booking.name}
  61. </Link>
  62. </TableCell>
  63. <TableCell>
  64. <Link
  65. href={`/dashboard/orders/${booking.$id}`}
  66. passHref
  67. >
  68. {booking.email}, {booking.contactNumber}
  69. </Link>
  70. </TableCell>
  71. <TableCell>
  72. <Link
  73. href={`/dashboard/orders/${booking.$id}`}
  74. passHref
  75. >
  76. {booking.busType}
  77. </Link>
  78. </TableCell>
  79. <TableCell>
  80. <Link
  81. href={`/dashboard/orders/${booking.$id}`}
  82. passHref
  83. >
  84. {formatDate(booking.travelDate)}
  85. </Link>
  86. </TableCell>
  87. <TableCell>
  88. <Link
  89. href={`/dashboard/orders/${booking.$id}`}
  90. passHref
  91. >
  92. {booking.travelTime}
  93. </Link>
  94. </TableCell>
  95. <TableCell>
  96. <Link
  97. href={`/dashboard/orders/${booking.$id}`}
  98. passHref
  99. >
  100. {booking.quotationStatus ? (
  101. <Badge variant={getBadgeVariant(booking.quotationStatus)}>
  102. {booking.quotationStatus}
  103. </Badge>
  104. ) : (
  105. "-"
  106. )}
  107. </Link>
  108. </TableCell>
  109. </TableRow>
  110. ))}
  111. </TableBody>
  112. </Table>
  113. </CardContent>
  114. </Card>
  115. );
  116. }
  117.  
Advertisement
Add Comment
Please, Sign In to add comment