diff --git a/app/src/components/admin/ChargeWidget.tsx b/app/src/components/admin/ChargeWidget.tsx index 96b93f1..70662ce 100644 --- a/app/src/components/admin/ChargeWidget.tsx +++ b/app/src/components/admin/ChargeWidget.tsx @@ -74,7 +74,7 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog.tsx"; -import { getUniqueList, parseNumber } from "@/utils/base.ts"; +import { getUniqueList, isEnter, parseNumber } from "@/utils/base.ts"; import { defaultChannelModels } from "@/admin/channel.ts"; import { getPricing } from "@/admin/datasets/charge.ts"; import { useAllModels } from "@/admin/hook.tsx"; @@ -102,9 +102,9 @@ function reducer(state: ChargeProps, action: any): ChargeProps { if (action.payload.trim().length === 0) return state; return state.models.includes(action.payload) ? { - ...state, - models: state.models.filter((model) => model !== action.payload), - } + ...state, + models: state.models.filter((model) => model !== action.payload), + } : { ...state, models: [...state.models, action.payload] }; case "remove-model": return { @@ -469,7 +469,7 @@ function ChargeEditor({ onChange={(e) => setModel(e.target.value)} placeholder={t("admin.channels.model")} onKeyDown={(e) => { - if (e.key === "Enter") { + if (isEnter(e)) { dispatch({ type: "add-model", payload: model }); setModel(""); } diff --git a/app/src/components/admin/UserTable.tsx b/app/src/components/admin/UserTable.tsx index 57056d9..bf21a44 100644 --- a/app/src/components/admin/UserTable.tsx +++ b/app/src/components/admin/UserTable.tsx @@ -53,7 +53,7 @@ import { } from "lucide-react"; import { Input } from "@/components/ui/input.tsx"; import PopupDialog, { popupTypes } from "@/components/PopupDialog.tsx"; -import { getNumber, parseNumber } from "@/utils/base.ts"; +import { getNumber, isEnter, parseNumber } from "@/utils/base.ts"; import { useSelector } from "react-redux"; import { selectUsername } from "@/store/auth.ts"; import { PaginationAction } from "@/components/ui/pagination.tsx"; @@ -378,7 +378,7 @@ function UserTable() { value={search} onChange={(e) => setSearch(e.target.value)} onKeyDown={async (e) => { - if (e.key === "Enter") await update(); + if (isEnter(e)) await update(); }} />