@ 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 [searching, setSearching] = useState(false);
|
||||||
const [sharing, setSharing] = useState(false);
|
const [sharing, setSharing] = useState(false);
|
||||||
|
|
||||||
// Search users
|
// Search users - only when input starts with @
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen || !searchTerm.trim()) {
|
if (!isOpen) {
|
||||||
setUsers([]);
|
setUsers([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only trigger search when using @ sign
|
||||||
|
if (!searchTerm || !searchTerm.startsWith('@') || searchTerm.length < 2) {
|
||||||
|
setUsers([]);
|
||||||
|
setSearching(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const searchTimeout = setTimeout(async () => {
|
const searchTimeout = setTimeout(async () => {
|
||||||
try {
|
try {
|
||||||
setSearching(true);
|
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 || [];
|
const results = response?.data?.data || response?.data || [];
|
||||||
setUsers(Array.isArray(results) ? results : []);
|
setUsers(Array.isArray(results) ? results : []);
|
||||||
} catch (error) {
|
} 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" />
|
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400" />
|
||||||
<Input
|
<Input
|
||||||
id="user-search"
|
id="user-search"
|
||||||
placeholder="Search by name or email..."
|
placeholder="Type @ to search users..."
|
||||||
value={searchTerm}
|
value={searchTerm}
|
||||||
onChange={(e) => setSearchTerm(e.target.value)}
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
className="pl-10"
|
className="pl-10"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
|
|
||||||
{searching && (
|
{searching && (
|
||||||
@ -163,12 +176,18 @@ export function ShareSummaryModal({ isOpen, onClose, summaryId, requestTitle, on
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!searching && searchTerm && users.length === 0 && (
|
{!searching && searchTerm && searchTerm.startsWith('@') && users.length === 0 && (
|
||||||
<div className="text-center py-8 text-gray-500 text-sm">
|
<div className="text-center py-8 text-gray-500 text-sm">
|
||||||
No users found
|
No users found
|
||||||
</div>
|
</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 && (
|
{selectedUserIds.size > 0 && (
|
||||||
<div className="border rounded-lg p-3 bg-blue-50">
|
<div className="border rounded-lg p-3 bg-blue-50">
|
||||||
<p className="text-sm font-medium text-gray-700 mb-2">
|
<p className="text-sm font-medium text-gray-700 mb-2">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user