From 7e03278c37d6b3deffd8abe8b76c3bd7d92b99c1 Mon Sep 17 00:00:00 2001
From: BenjaminNH <1249376374@qq.com>
Date: Tue, 24 Jun 2025 20:08:52 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E6=88=91=E7=9A=84=E9=A2=84=E7=BA=A6=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/config/menuConfig.js | 8 ++-
src/layouts/CommonLayout.jsx | 28 +---------
src/pages/user/MyReservation.jsx | 96 ++++++++++++++++++++++++++++++++
src/router/index.jsx | 5 ++
4 files changed, 111 insertions(+), 26 deletions(-)
create mode 100644 src/pages/user/MyReservation.jsx
diff --git a/src/config/menuConfig.js b/src/config/menuConfig.js
index 0c60aef..6f96d07 100644
--- a/src/config/menuConfig.js
+++ b/src/config/menuConfig.js
@@ -1,4 +1,4 @@
-import { DesktopOutlined } from "@ant-design/icons";
+import { DesktopOutlined, UnorderedListOutlined } from "@ant-design/icons";
const menuConfig = [
{
@@ -7,6 +7,12 @@ const menuConfig = [
icon: DesktopOutlined,
roles: ["USER"],
},
+ {
+ path: "/user/my-reservation",
+ label: "我的预约",
+ icon: UnorderedListOutlined,
+ roles: ["USER"],
+ },
];
export default menuConfig;
diff --git a/src/layouts/CommonLayout.jsx b/src/layouts/CommonLayout.jsx
index 1732665..b03d5b6 100644
--- a/src/layouts/CommonLayout.jsx
+++ b/src/layouts/CommonLayout.jsx
@@ -9,37 +9,14 @@ import { Layout, Menu, theme } from "antd";
import { Content, Header } from "antd/es/layout/layout";
import Sider from "antd/es/layout/Sider";
import React, { useState } from "react";
-import { Outlet, useLocation } from "react-router-dom";
+import { Outlet, useLocation, useNavigate } from "react-router-dom";
import menuConfig from "../config/menuConfig";
import { useSelector } from "react-redux";
import { selectUserRole } from "../features/auth/authSlice";
-function getItem(label, key, icon, children) {
- return {
- key,
- icon,
- children,
- label,
- };
-}
-
-const items = [
- getItem("Option 1", "1", ),
- getItem("Option 2", "2", ),
- getItem("User", "sub1", , [
- getItem("Tom", "3"),
- getItem("Bill", "4"),
- getItem("Alex", "5"),
- ]),
- getItem("Team", "sub2", , [
- getItem("Team 1", "6"),
- getItem("Team 2", "8"),
- ]),
- getItem("Files", "9", ),
-];
-
export default function CommonLayout() {
const location = useLocation();
+ const naviagte = useNavigate();
const [collapsed, setCollapsed] = useState(false);
const {
@@ -69,6 +46,7 @@ export default function CommonLayout() {
label: item.label,
icon: React.createElement(item.icon),
}))}
+ onClick={({ key }) => naviagte(key)}
/>
diff --git a/src/pages/user/MyReservation.jsx b/src/pages/user/MyReservation.jsx
new file mode 100644
index 0000000..1e2f006
--- /dev/null
+++ b/src/pages/user/MyReservation.jsx
@@ -0,0 +1,96 @@
+import { Table, Tag } from "antd";
+import { useEffect, useState } from "react";
+import axiosInstance from "../../api/axios";
+import { useSelector } from "react-redux";
+import Column from "antd/es/table/Column";
+import dayjs from "dayjs";
+
+export default function MyReservation() {
+ const [reservations, setReservations] = useState([]);
+ const [pagination, setPagination] = useState({
+ current: 1,
+ pageSize: 10,
+ total: 0,
+ });
+
+ const userId = useSelector((state) => state.auth.userId);
+
+ const fetchData = async (pagination) => {
+ const data = await axiosInstance.get(`/reservation/${userId}`, {
+ params: {
+ page: pagination.current,
+ size: pagination.pageSize,
+ },
+ });
+ setReservations(data.records);
+ setPagination({
+ ...pagination,
+ total: data.total,
+ });
+ };
+
+ useEffect(() => {
+ fetchData(pagination);
+ }, []);
+
+ const handlePageChange = (pagination) => {
+ fetchData(pagination);
+ };
+
+ return (
+ <>
+
+ {
+ return deviceName ? (
+ deviceName
+ ) : (
+ 该设备已被删除
+ );
+ }}
+ />
+
+
+
+
+ {
+ const color = statusLabel === "通过" ? "green" : "yellow";
+ return (
+
+ {statusLabel}
+
+ );
+ }}
+ />
+ {
+ return dayjs(createdTime).format("YYYY-MM-DD HH:mm");
+ }}
+ />
+
+ >
+ );
+}
diff --git a/src/router/index.jsx b/src/router/index.jsx
index ae00469..13452d2 100644
--- a/src/router/index.jsx
+++ b/src/router/index.jsx
@@ -3,6 +3,7 @@ import Login from "../pages/Login";
import ProtectedRoute from "./ProtectedRoute";
import CommonLayout from "../layouts/CommonLayout";
import Reserve from "../pages/user/Reserve";
+import MyReservation from "../pages/user/MyReservation";
const router = createBrowserRouter([
{
@@ -25,6 +26,10 @@ const router = createBrowserRouter([
path: "reserve",
element: ,
},
+ {
+ path: "my-reservation",
+ element: ,
+ },
],
},
],