fix build error
This commit is contained in:
@@ -3,6 +3,18 @@ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/com
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { entities } from "@/lib/nvwa";
|
||||
|
||||
interface Cat {
|
||||
id: number;
|
||||
is_available: boolean;
|
||||
grade: string;
|
||||
}
|
||||
|
||||
interface Reservation {
|
||||
id: number;
|
||||
status: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
interface CatInventoryStats {
|
||||
totalCats: number;
|
||||
availableCats: number;
|
||||
@@ -56,8 +68,8 @@ export default function DashboardPage() {
|
||||
const { data: cats } = await entities.from("cat").select("id, is_available, grade");
|
||||
if (cats) {
|
||||
const totalCats = cats.length;
|
||||
const availableCats = cats.filter(cat => cat.is_available).length;
|
||||
const gradeDistribution = cats.reduce((acc, cat) => {
|
||||
const availableCats = cats.filter((cat: Cat) => cat.is_available).length;
|
||||
const gradeDistribution = cats.reduce((acc: { [key: string]: number }, cat: Cat) => {
|
||||
acc[cat.grade] = (acc[cat.grade] || 0) + 1;
|
||||
return acc;
|
||||
}, {} as { [key: string]: number });
|
||||
@@ -69,7 +81,7 @@ export default function DashboardPage() {
|
||||
const { data: reservations } = await entities.from("reservation").select("id, status, created_at");
|
||||
if (reservations) {
|
||||
const totalReservations = reservations.length;
|
||||
const statusDistribution = reservations.reduce((acc, res) => {
|
||||
const statusDistribution = reservations.reduce((acc: { [key: string]: number }, res: Reservation) => {
|
||||
acc[res.status] = (acc[res.status] || 0) + 1;
|
||||
return acc;
|
||||
}, {} as { [key: string]: number });
|
||||
@@ -77,7 +89,7 @@ export default function DashboardPage() {
|
||||
// 计算最近7天的预约
|
||||
const sevenDaysAgo = new Date();
|
||||
sevenDaysAgo.setDate(sevenDaysAgo.getDate() - 7);
|
||||
const recentReservations = reservations.filter(res =>
|
||||
const recentReservations = reservations.filter((res: Reservation) =>
|
||||
new Date(res.created_at) >= sevenDaysAgo
|
||||
).length;
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ const ReservationView: React.FC = () => {
|
||||
}
|
||||
|
||||
// 处理数据
|
||||
const reservationsWithDetails: Reservation[] = (reservationData || []).map((res) => ({
|
||||
const reservationsWithDetails: Reservation[] = (reservationData || []).map((res: any) => ({
|
||||
id: res.id,
|
||||
userId: res.user_id,
|
||||
userName: res.user?.name || 'Unknown',
|
||||
@@ -144,7 +144,7 @@ const ReservationView: React.FC = () => {
|
||||
cancelled: '已取消',
|
||||
};
|
||||
|
||||
const statusColors = {
|
||||
const statusColors: Record<Reservation['status'], "default" | "destructive" | "outline" | "secondary"> = {
|
||||
queuing: 'secondary',
|
||||
reserved: 'default',
|
||||
completed: 'outline',
|
||||
|
||||
Reference in New Issue
Block a user