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:
@@ -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, "借阅失败"))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user