Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/components/accounts/ui/input/AccountsInput.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import { TextField } from '@mui/material';
import { grey } from '@mui/material/colors';
import React from 'react';
import React, { useDeferredValue, useState, useEffect } from 'react';
import SearchIcon from '@mui/icons-material/Search';
import HighlightOffIcon from '@mui/icons-material/HighlightOff';

export const AccountsInput = ({
search,
setsearch,
placeholder,
width = 200,
}) => {
export const AccountsInput = ({ setsearch, placeholder, width = 200 }) => {
const [internalSearch, setInternalSearch] = useState('');
const deferredSearch = useDeferredValue(internalSearch);

const handleChange = (e) => {
setsearch(e.target.value);
setInternalSearch(e.target.value);
};

const clearInput = () => {
setsearch('');
setInternalSearch('');
};

useEffect(() => {
setsearch(deferredSearch);
}, [deferredSearch, setsearch]);

return (
<TextField
sx={(theme) => ({
Expand All @@ -28,11 +32,11 @@ export const AccountsInput = ({
})}
size="small"
placeholder={placeholder}
value={search}
value={internalSearch}
onChange={(e) => handleChange(e)}
InputProps={{
startAdornment: <SearchIcon color="disabled" />,
endAdornment: search && (
endAdornment: internalSearch && (
<HighlightOffIcon
fontSize="small"
color="primary"
Expand Down
2 changes: 1 addition & 1 deletion src/components/globals/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11509,7 +11509,7 @@ export const navigationCustom = [
title: 'Hybrid CMS',
zuid: '7-f0bbf4b083-v2pnsn',
children: [],
}
},
Comment thread
finnar-bin marked this conversation as resolved.
],
},
{
Expand Down
1 change: 0 additions & 1 deletion src/pages/instances/[zuid]/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export default function Support() {
<Grid container>
<AccountsHeader {...headerProps}>
<AccountsInput
search={search}
setsearch={setsearch}
placeholder=" Search subjects, ticket #"
width={250}
Expand Down
14 changes: 9 additions & 5 deletions src/pages/instances/[zuid]/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,16 @@ export default function UsersPage() {
userInfo,
);

const filteredUsers = instanceUserWithRoles?.filter((e) => {
const name = `${e?.firstName?.toLowerCase() || '-'} ${
e?.lastName?.toLowerCase() || '-'
}`;
return name?.includes(search?.toLowerCase());
const filteredUsers = instanceUserWithRoles?.filter((user) => {
const formattedSearchKeyword = search?.toLowerCase()?.trim();
const userFullName = `${user?.firstName || '-'} ${user?.lastName || '-'}`;

return (
userFullName?.toLowerCase()?.includes(formattedSearchKeyword) ||
user?.email?.toLowerCase()?.includes(formattedSearchKeyword)
);
});

const userProps = {
updateRole,
roles: filteredUsers,
Expand Down
7 changes: 1 addition & 6 deletions src/views/accounts/instances/Apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ export const Apis = ({
// arrToSubmit,
// setarrToSubmit,
// updateSetting,
search,
setsearch,
}) => {
const handleCreateTokenModal = () => {
Expand Down Expand Up @@ -494,11 +493,7 @@ export const Apis = ({
return (
<Grid container>
<AccountsHeader {...headerProps}>
<AccountsInput
search={search}
setsearch={setsearch}
placeholder=" Seach tokens"
/>
<AccountsInput setsearch={setsearch} placeholder=" Seach tokens" />
Comment thread
finnar-bin marked this conversation as resolved.
Outdated
{isInstanceOwner && (
<Button
onClick={handleCreateTokenModal}
Expand Down
6 changes: 1 addition & 5 deletions src/views/accounts/instances/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,7 @@ export const Settings = ({
<Grid container>
<AccountsHeader {...headerProps}>
<Stack>
<AccountsInput
search={search}
setsearch={setsearch}
placeholder=" Search settings"
/>
<AccountsInput setsearch={setsearch} placeholder=" Search settings" />
</Stack>

<Stack>
Expand Down
2 changes: 0 additions & 2 deletions src/views/accounts/instances/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ const Index = ({
isOwner,
instanceZUID,
loading,
search,
setsearch,
respondToInvite,
pendingUsers,
Expand Down Expand Up @@ -320,7 +319,6 @@ const Index = ({
<Grid container>
<AccountsHeader {...headerProps}>
<AccountsInput
search={search}
setsearch={setsearch}
placeholder=" Search users"
width={250}
Expand Down
Loading