feat: customize search placeholder based on user role
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m10s
All checks were successful
Build and Deploy / build-and-push (push) Successful in 1m10s
- Agents see 'Buscar atendimentos...' - Super admins see 'Buscar membros, equipes, atendimentos ou organizações...' - Admin and managers see 'Buscar membros, equipes ou atendimentos...'
This commit is contained in:
@@ -53,6 +53,12 @@ export const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) =>
|
|||||||
return () => clearTimeout(delayDebounceFn);
|
return () => clearTimeout(delayDebounceFn);
|
||||||
}, [searchQuery]);
|
}, [searchQuery]);
|
||||||
|
|
||||||
|
const getSearchPlaceholder = () => {
|
||||||
|
if (currentUser?.role === 'super_admin') return 'Buscar membros, equipes, atendimentos ou organizações...';
|
||||||
|
if (currentUser?.role === 'agent') return 'Buscar atendimentos...';
|
||||||
|
return 'Buscar membros, equipes ou atendimentos...';
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchCurrentUser = async () => {
|
const fetchCurrentUser = async () => {
|
||||||
const storedUserId = localStorage.getItem('ctms_user_id');
|
const storedUserId = localStorage.getItem('ctms_user_id');
|
||||||
@@ -207,7 +213,7 @@ export const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) =>
|
|||||||
{isSearching ? <Loader2 size={18} className="text-brand-yellow animate-spin" /> : <Search size={18} className="text-zinc-400 dark:text-dark-muted" />}
|
{isSearching ? <Loader2 size={18} className="text-brand-yellow animate-spin" /> : <Search size={18} className="text-zinc-400 dark:text-dark-muted" />}
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Buscar membros, equipes ou atendimentos..."
|
placeholder={getSearchPlaceholder()}
|
||||||
value={searchQuery}
|
value={searchQuery}
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
onChange={(e) => setSearchQuery(e.target.value)}
|
||||||
onFocus={() => searchQuery.length >= 2 && setShowSearchResults(true)}
|
onFocus={() => searchQuery.length >= 2 && setShowSearchResults(true)}
|
||||||
|
|||||||
Reference in New Issue
Block a user