diff --git a/src/features/issues/components/issue-finder.tsx b/src/features/issues/components/issue-finder.tsx
index 28d21e5..f3c26bd 100644
--- a/src/features/issues/components/issue-finder.tsx
+++ b/src/features/issues/components/issue-finder.tsx
@@ -1061,6 +1061,102 @@ function IssueFinderSidebar({
);
}
+function getSelectedContentTab(activeTab: ContentTab, authenticated: boolean) {
+ return authenticated ? activeTab : "results";
+}
+
+function getTokenStatus(data: SearchResponse | null) {
+ if (!data) return "unknown";
+ return data.tokenConfigured ? "configured" : "not set";
+}
+
+function getRetryHandler(
+ errorSource: "search" | "loadMore" | null,
+ search: () => void,
+ loadMore: () => void,
+) {
+ return errorSource === "loadMore" ? loadMore : search;
+}
+
+function getOpportunityCallbacks(
+ authenticated: boolean,
+ onOpen: (issue: Issue) => void,
+ onSaveChange: (issue: Issue, saved: boolean) => void,
+) {
+ if (!authenticated) return {};
+ return { onIssueOpen: onOpen, onIssueSaveChange: onSaveChange };
+}
+
+function SearchSubmitButton({
+ isLoading,
+ cooldown,
+}: Readonly<{ isLoading: boolean; cooldown: boolean }>) {
+ const label = cooldown && !isLoading ? "Cooldown..." : "Search";
+
+ return (
+
+ );
+}
+
+function SearchOverview({
+ label,
+ sort,
+ linkedPr,
+ hacktoberfest,
+ experience,
+ contributionType,
+ scope,
+ responsiveness,
+ data,
+ tokenStatus,
+}: Readonly<{
+ label: string;
+ sort: string;
+ linkedPr: string;
+ hacktoberfest: string;
+ experience: string;
+ contributionType: string;
+ scope: string;
+ responsiveness: string;
+ data: SearchResponse | null;
+ tokenStatus: string;
+}>) {
+ return (
+
+
+ Search overview
+ Current filters and GitHub search coverage.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
export function IssueFinder() {
const { data: session, isPending: isSessionPending } =
authClient.useSession();
@@ -1110,7 +1206,11 @@ export function IssueFinder() {
const [opportunityRevision, setOpportunityRevision] = useState(0);
const [activeContentTab, setActiveContentTab] =
useState("results");
- const selectedContentTab = session?.user.id ? activeContentTab : "results";
+ const authenticated = Boolean(session?.user.id);
+ const selectedContentTab = getSelectedContentTab(
+ activeContentTab,
+ authenticated,
+ );
useEffect(() => {
// Hydration must start with the server's empty snapshot before reading browser storage.
@@ -1647,15 +1747,17 @@ export function IssueFinder() {
}
}
- let tokenStatus = "unknown";
- if (data) {
- tokenStatus = data.tokenConfigured ? "configured" : "not set";
- }
-
- const handleRetry =
- errorSource === "loadMore"
- ? () => void loadMoreIssues()
- : () => void searchIssues();
+ const tokenStatus = getTokenStatus(data);
+ const handleRetry = getRetryHandler(
+ errorSource,
+ () => void searchIssues(),
+ () => void loadMoreIssues(),
+ );
+ const opportunityCallbacks = getOpportunityCallbacks(
+ authenticated,
+ handleOpportunityOpen,
+ (selectedIssue, saved) => void handleOpportunitySave(selectedIssue, saved),
+ );
return (
@@ -1865,56 +1967,22 @@ export function IssueFinder() {
-
+
-
-
- Search overview
-
- Current filters and GitHub search coverage.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -1923,7 +1991,7 @@ export function IssueFinder() {
tech={tech}
savedSearchName={savedSearchName}
savedSearches={savedSearches}
- authenticated={Boolean(session?.user.id)}
+ authenticated={authenticated}
linkedEmail={session?.user.email}
alertEmail={alertEmail}
digestEnabled={digestEnabled}
@@ -1943,7 +2011,7 @@ export function IssueFinder() {
- void handleOpportunitySave(selectedIssue, saved)
- : undefined
- }
+ {...opportunityCallbacks}
onLoadMore={() => void loadMoreIssues()}
/>
}