mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
fix(frontend): address review feedback on admin rate-limit components
- Replace legacy Button import and lucide Search icon with non-legacy Button and Phosphor MagnifyingGlass icon in AdminUserSearch - Trim search query before submitting in AdminUserSearch.handleSearch - Always set selectedUser with fallback when user_email is missing in RateLimitManager direct lookup - Replace placeholder string with empty string for missing userEmail in AdminUserGrantHistory
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { Input } from "@/components/__legacy__/ui/input";
|
||||
import { Button } from "@/components/__legacy__/ui/button";
|
||||
import { Search } from "lucide-react";
|
||||
import { Button } from "@/components/atoms/Button/Button";
|
||||
import { MagnifyingGlass } from "@phosphor-icons/react";
|
||||
|
||||
export interface AdminUserSearchProps {
|
||||
/** Current search query value (controlled). Falls back to internal state if omitted. */
|
||||
@@ -44,7 +44,7 @@ export function AdminUserSearch({
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
onSearch(currentValue);
|
||||
onSearch(currentValue.trim());
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -58,10 +58,12 @@ export function AdminUserSearch({
|
||||
/>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="small"
|
||||
onClick={handleSearch}
|
||||
disabled={isLoading || !currentValue.trim()}
|
||||
loading={isLoading}
|
||||
>
|
||||
{isLoading ? "Searching..." : <Search className="h-4 w-4" />}
|
||||
{isLoading ? "Searching..." : <MagnifyingGlass size={16} />}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -61,12 +61,10 @@ export function RateLimitManager() {
|
||||
throw new Error("Failed to fetch rate limit");
|
||||
}
|
||||
setRateLimitData(response.data);
|
||||
if (response.data.user_email) {
|
||||
setSelectedUser({
|
||||
user_id: response.data.user_id,
|
||||
user_email: response.data.user_email,
|
||||
});
|
||||
}
|
||||
setSelectedUser({
|
||||
user_id: response.data.user_id,
|
||||
user_email: response.data.user_email ?? response.data.user_id,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error fetching rate limit:", error);
|
||||
const hint = looksLikeEmail(trimmed)
|
||||
|
||||
@@ -151,15 +151,11 @@ export async function AdminUserGrantHistory({
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
<RateLimitModal
|
||||
userId={transaction.user_id}
|
||||
userEmail={
|
||||
transaction.user_email ?? "User Email wasn't attached"
|
||||
}
|
||||
userEmail={transaction.user_email ?? ""}
|
||||
/>
|
||||
<AdminAddMoneyButton
|
||||
userId={transaction.user_id}
|
||||
userEmail={
|
||||
transaction.user_email ?? "User Email wasn't attached"
|
||||
}
|
||||
userEmail={transaction.user_email ?? ""}
|
||||
currentBalance={transaction.current_balance}
|
||||
defaultAmount={
|
||||
transaction.transaction_type ===
|
||||
|
||||
Reference in New Issue
Block a user