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
@@ -1,6 +1,7 @@
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
import { getAllMyBorrows, returnBookForMe } from "@/api/borrows"
import { toast } from "sonner"
import { getErrorMessage } from "@/lib/errors"
export function useMyBorrows() {
return useQuery({
@@ -18,7 +19,7 @@ export function useReturnBook() {
toast.success("归还成功")
},
onError: (err) => {
toast.error(err instanceof Error ? err.message : "归还失败")
toast.error(getErrorMessage(err, "归还失败"))
},
})
}