feat(admin): add book borrowing dialog and root redirect

- Add admin book borrowing dialog with user selection
- Add useAdminBorrowBook mutation with success/error toasts
- Fix sidebar z-index layering on admin layout
- Add RootRedirect component that routes based on admin role
This commit is contained in:
2026-05-24 20:59:18 +08:00
parent 78ebd0b62e
commit 9780083476
10 changed files with 65 additions and 17 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
import { getAllBooks } from "@/api/books"
import { borrowBookForMe } from "@/api/borrows"
import { toast } from "sonner"
import { getErrorMessage } from "@/lib/errors"
export function useBooks() {
return useQuery({
@@ -21,7 +22,7 @@ export function useBorrowBook() {
toast.success("借阅成功")
},
onError: (err) => {
toast.error(err instanceof Error ? err.message : "借阅失败")
toast.error(getErrorMessage(err, "借阅失败"))
},
})
}