Path: blob/master/src/packages/frontend/admin/users/user-search.tsx
1496 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45/*6Functionality and UI to ensure a user with given email (or account_id) is sync'd with stripe.7*/89import { Button, Input, InputNumber, Flex } from "antd";10import { User } from "@cocalc/frontend/frame-editors/generic/client";11import { actions } from "./actions";12import { UserResult } from "./user";13import { useTypedRedux } from "@cocalc/frontend/app-framework";14import { ADMIN_SEARCH_LIMIT } from "@cocalc/util/db-schema/accounts";1516export function UserSearch({}) {17const status = useTypedRedux("admin-users", "status");18const query = useTypedRedux("admin-users", "query");19const limit = useTypedRedux("admin-users", "limit");20const result = useTypedRedux("admin-users", "result");2122function renderUser(user: User) {23return <UserResult key={user.account_id} {...user} />;24}2526return (27<div style={{ margin: "0 30px" }}>28<div>29<Flex style={{ maxWidth: "100%" }}>30<Input.Search31allowClear32autoFocus33style={{ flex: 1, marginRight: "15px" }}34value={query}35placeholder="Search for users by partial name, email, account_id or project_id..."36onChange={(e) => actions.set_query(e.target.value)}37onKeyDown={(e) => {38if (e.keyCode === 13) {39actions.search();40}41}}42enterButton="Search"43size="large"44onSearch={() => {45actions.search();46}}47/>48<InputNumber49style={{ width: "150px" }}50size="large"51defaultValue={limit}52min={1}53max={ADMIN_SEARCH_LIMIT}54step={10}55onChange={(limit) => {56if (limit) {57actions.setState({ limit });58}59}}60addonAfter="Limit"61/>62</Flex>63{!!status && (64<div>65<pre>{status}</pre>66<Button onClick={() => actions.clear_status()}>Clear</Button>67</div>68)}69{(result?.size ?? 0) > 0 &&70result.map((user) => renderUser(user.toJS()))}71</div>72</div>73);74}757677