Skip to content

Commit ec4e757

Browse files
committed
Adjust BackButton prop handling and update cache duration
Refactored BackButton to use a default href value and handle optional href prop more robustly. Increased cache duration in VariableSearchAutocomplete to 24 hours and fixed type for cache key generation. Removed unused import in researcher.test.ts. Took 13 minutes
1 parent c33ab21 commit ec4e757

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

app/dfda/components/BackButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import { ArrowLeft } from 'lucide-react'
44
import Link from 'next/link'
55

66
interface BackButtonProps {
7-
href: string;
7+
href?: string;
88
label?: string;
99
}
1010

11-
export default function BackButton({ href, label = 'Back to dFDA' }: BackButtonProps) {
11+
export default function BackButton({ href='/dfda', label = 'Back' }: BackButtonProps) {
12+
if(!href) {href = '/dfda'}
1213
return (
1314
<Link
1415
href={href}

app/dfda/components/VariableSearchAutocomplete.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ interface SearchCache {
1717
results: GlobalVariable[]
1818
}
1919

20-
// Add cache duration constant (e.g., 1 hour)
21-
const CACHE_DURATION = 60 * 60 * 1000
20+
// Add cache duration constant (e.g., 24 hours)
21+
const CACHE_DURATION = 24 * 60 * 60 * 1000
2222

2323
function getCachedResults(key: string): GlobalVariable[] | null {
2424
try {
@@ -81,7 +81,7 @@ export default function VariableSearchAutocomplete({
8181
try {
8282
// Create a cache key based on search term and params
8383
const cacheKey = `dfda-variable-search:${searchTerm}:${
84-
JSON.stringify(Object.keys(searchParams).sort().reduce((obj, key) => {
84+
JSON.stringify(Object.keys(searchParams).sort().reduce<Record<string, string>>((obj, key) => {
8585
obj[key] = searchParams[key]
8686
return obj
8787
}, {}))

tests/researcher.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
deleteArticleByPromptedTopic,
88
findOrCreateArticleByPromptedTopic, writeArticle,
99
} from "@/lib/agents/researcher/researcher"
10-
import {findGrantsForOrganization, generateAndSaveGrantProposal, generateGrantProposal} from "@/lib/agents/grantAgent";
1110
import {
1211
generateOrganizationFromUrl,
1312
generateOrganizationFromUrlBySearch, getOrCreateOrganizationFromUrl

0 commit comments

Comments
 (0)