Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
46 changes: 16 additions & 30 deletions apps/app/components/core/modals/existing-issues-list-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const ExistingIssuesListModal: React.FC<Props> = ({
}) => {
const [searchTerm, setSearchTerm] = useState("");
const [issues, setIssues] = useState<ISearchIssueResponse[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [isSearching, setIsSearching] = useState(false);
const [selectedIssues, setSelectedIssues] = useState<ISearchIssueResponse[]>([]);
const [isSubmitting, setIsSubmitting] = useState(false);
Expand Down Expand Up @@ -97,31 +96,18 @@ export const ExistingIssuesListModal: React.FC<Props> = ({
};

useEffect(() => {
if (!workspaceSlug || !projectId) return;
if (!isOpen || !workspaceSlug || !projectId) return;

setIsLoading(true);
setIsSearching(true);

if (debouncedSearchTerm) {
setIsSearching(true);

projectService
.projectIssuesSearch(workspaceSlug as string, projectId as string, {
search: debouncedSearchTerm,
...searchParams,
})
.then((res) => {
setIssues(res);
})
.finally(() => {
setIsLoading(false);
setIsSearching(false);
});
} else {
setIssues([]);
setIsLoading(false);
setIsSearching(false);
}
}, [debouncedSearchTerm, workspaceSlug, projectId, searchParams]);
projectService
.projectIssuesSearch(workspaceSlug as string, projectId as string, {
search: debouncedSearchTerm,
...searchParams,
})
.then((res) => setIssues(res))
.finally(() => setIsSearching(false));
}, [debouncedSearchTerm, isOpen, projectId, searchParams, workspaceSlug]);

return (
<>
Expand Down Expand Up @@ -169,7 +155,7 @@ export const ExistingIssuesListModal: React.FC<Props> = ({
aria-hidden="true"
/>
<Combobox.Input
className="h-12 w-full border-0 bg-transparent pl-11 pr-4 text-custom-text-100 outline-none focus:ring-0 sm:text-sm"
className="h-12 w-full border-0 bg-transparent pl-11 pr-4 text-custom-text-100 outline-none focus:ring-0 sm:text-sm placeholder:text-custom-text-400"
placeholder="Type to search..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
Expand Down Expand Up @@ -206,20 +192,20 @@ export const ExistingIssuesListModal: React.FC<Props> = ({
)}
</div>

<Combobox.Options static className="max-h-80 scroll-py-2 overflow-y-auto mt-2">
{debouncedSearchTerm !== "" && (
<Combobox.Options static className="max-h-80 scroll-py-2 overflow-y-auto">
{searchTerm !== "" && (
<h5 className="text-[0.825rem] text-custom-text-200 mx-2">
Search results for{" "}
<span className="text-custom-text-100">
{'"'}
{debouncedSearchTerm}
{searchTerm}
{'"'}
</span>{" "}
in project:
</h5>
)}

{!isLoading &&
{!isSearching &&
issues.length === 0 &&
searchTerm !== "" &&
debouncedSearchTerm !== "" && (
Expand All @@ -235,7 +221,7 @@ export const ExistingIssuesListModal: React.FC<Props> = ({
</div>
)}

{isLoading || isSearching ? (
{isSearching ? (
<Loader className="space-y-3 p-3">
<Loader.Item height="40px" />
<Loader.Item height="40px" />
Expand Down
49 changes: 16 additions & 33 deletions apps/app/components/issues/parent-issues-list-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type Props = {
onChange: (issue: ISearchIssueResponse) => void;
projectId: string;
issueId?: string;
customDisplay?: JSX.Element;
};

export const ParentIssuesListModal: React.FC<Props> = ({
Expand All @@ -34,11 +33,9 @@ export const ParentIssuesListModal: React.FC<Props> = ({
onChange,
projectId,
issueId,
customDisplay,
}) => {
const [searchTerm, setSearchTerm] = useState("");
const [issues, setIssues] = useState<ISearchIssueResponse[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [isSearching, setIsSearching] = useState(false);

const debouncedSearchTerm: string = useDebounce(searchTerm, 500);
Expand All @@ -52,32 +49,19 @@ export const ParentIssuesListModal: React.FC<Props> = ({
};

useEffect(() => {
if (!workspaceSlug || !projectId) return;
if (!isOpen || !workspaceSlug || !projectId) return;

setIsLoading(true);
setIsSearching(true);

if (debouncedSearchTerm) {
setIsSearching(true);

projectService
.projectIssuesSearch(workspaceSlug as string, projectId as string, {
search: debouncedSearchTerm,
parent: true,
issue_id: issueId,
})
.then((res) => {
setIssues(res);
})
.finally(() => {
setIsLoading(false);
setIsSearching(false);
});
} else {
setIssues([]);
setIsLoading(false);
setIsSearching(false);
}
}, [debouncedSearchTerm, workspaceSlug, projectId, issueId]);
projectService
.projectIssuesSearch(workspaceSlug as string, projectId as string, {
search: debouncedSearchTerm,
parent: true,
issue_id: issueId,
})
.then((res) => setIssues(res))
.finally(() => setIsSearching(false));
}, [debouncedSearchTerm, isOpen, issueId, projectId, workspaceSlug]);

return (
<>
Expand Down Expand Up @@ -124,28 +108,27 @@ export const ParentIssuesListModal: React.FC<Props> = ({
aria-hidden="true"
/>
<Combobox.Input
className="h-12 w-full border-0 bg-transparent pl-11 pr-4 text-custom-text-100 outline-none focus:ring-0 sm:text-sm"
className="h-12 w-full border-0 bg-transparent pl-11 pr-4 text-custom-text-100 outline-none focus:ring-0 sm:text-sm placeholder:text-custom-text-400"
placeholder="Type to search..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
displayValue={() => ""}
/>
</div>
{customDisplay && <div className="p-2">{customDisplay}</div>}
<Combobox.Options static className="max-h-80 scroll-py-2 overflow-y-auto mt-2">
{debouncedSearchTerm !== "" && (
{searchTerm !== "" && (
<h5 className="text-[0.825rem] text-custom-text-200 mx-2">
Search results for{" "}
<span className="text-custom-text-100">
{'"'}
{debouncedSearchTerm}
{searchTerm}
{'"'}
</span>{" "}
in project:
</h5>
)}

{!isLoading &&
{!isSearching &&
issues.length === 0 &&
searchTerm !== "" &&
debouncedSearchTerm !== "" && (
Expand All @@ -161,7 +144,7 @@ export const ParentIssuesListModal: React.FC<Props> = ({
</div>
)}

{isLoading || isSearching ? (
{isSearching ? (
<Loader className="space-y-3 p-3">
<Loader.Item height="40px" />
<Loader.Item height="40px" />
Expand Down