@ added in share summary
This commit is contained in:
parent
638e91671e
commit
2c0378c63a
@ -24,17 +24,25 @@ export function ShareSummaryModal({ isOpen, onClose, summaryId, requestTitle, on
|
||||
const [searching, setSearching] = useState(false);
|
||||
const [sharing, setSharing] = useState(false);
|
||||
|
||||
// Search users
|
||||
// Search users - only when input starts with @
|
||||
useEffect(() => {
|
||||
if (!isOpen || !searchTerm.trim()) {
|
||||
if (!isOpen) {
|
||||
setUsers([]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Only trigger search when using @ sign
|
||||
if (!searchTerm || !searchTerm.startsWith('@') || searchTerm.length < 2) {
|
||||
setUsers([]);
|
||||
setSearching(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const searchTimeout = setTimeout(async () => {
|
||||
try {
|
||||
setSearching(true);
|
||||
const response = await searchUsers(searchTerm);
|
||||
const term = searchTerm.slice(1); // Remove @ prefix
|
||||
const response = await searchUsers(term, 10);
|
||||
const results = response?.data?.data || response?.data || [];
|
||||
setUsers(Array.isArray(results) ? results : []);
|
||||
} catch (error) {
|
||||
@ -111,12 +119,17 @@ export function ShareSummaryModal({ isOpen, onClose, summaryId, requestTitle, on
|
||||
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400" />
|
||||
<Input
|
||||
id="user-search"
|
||||
placeholder="Search by name or email..."
|
||||
placeholder="Type @ to search users..."
|
||||
value={searchTerm}
|
||||
onChange={(e) => setSearchTerm(e.target.value)}
|
||||
className="pl-10"
|
||||
/>
|
||||
</div>
|
||||
{searchTerm && !searchTerm.startsWith('@') && (
|
||||
<p className="text-xs text-gray-500 mt-1 ml-1">
|
||||
Start with @ to search users (e.g., @john)
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{searching && (
|
||||
@ -163,11 +176,17 @@ export function ShareSummaryModal({ isOpen, onClose, summaryId, requestTitle, on
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!searching && searchTerm && users.length === 0 && (
|
||||
{!searching && searchTerm && searchTerm.startsWith('@') && users.length === 0 && (
|
||||
<div className="text-center py-8 text-gray-500 text-sm">
|
||||
No users found
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!searching && searchTerm && !searchTerm.startsWith('@') && (
|
||||
<div className="text-center py-8 text-gray-500 text-sm">
|
||||
Start typing with @ to search users
|
||||
</div>
|
||||
)}
|
||||
|
||||
{selectedUserIds.size > 0 && (
|
||||
<div className="border rounded-lg p-3 bg-blue-50">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user