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
8 changes: 4 additions & 4 deletions app/components/LLMChatInline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export default function AIChatInline({ initialInput }: { initialInput?: string }

const requirePremium = (): boolean => {
if (!hasPremiumAccess && !hasValidPromoAccess()) {
if (!isAuthenticated) { openAuthModal(); return false; }
router.push('/subscribe');
return false;
}
Expand Down Expand Up @@ -692,9 +691,10 @@ Write questions from the user's perspective — as if the user is asking you. No
};

const handleResearch = async () => {
const query = inputValue.trim();
if (!query || isLoading) return;
if (isLoading) return;
if (!requirePremium()) return;
const query = inputValue.trim();
if (!query) return;

setInputValue('');
setIsLoading(true);
Expand Down Expand Up @@ -1236,7 +1236,7 @@ Write questions from the user's perspective — as if the user is asking you. No
<button
className="chat-research-button"
onClick={handleResearch}
disabled={isLoading || !inputValue.trim()}
disabled={isLoading || (hasPremiumAccess && !inputValue.trim())}
title="Searches 10 targeted keyword angles across your genetic data, then synthesizes findings into a comprehensive answer."
>
{isLoading ? 'Thinking...' : 'Research'}
Expand Down
69 changes: 69 additions & 0 deletions app/components/StudyNavButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"use client";

import { useState, useEffect } from "react";
import { useRouter } from "next/navigation";
import Link from "next/link";
import { useResults } from "./ResultsContext";

export default function StudyNavButtons() {
const router = useRouter();
const { savedResults } = useResults();
const [totalStudies, setTotalStudies] = useState<number | null>(null);
const [navigating, setNavigating] = useState(false);

useEffect(() => {
if (savedResults.length > 0) return;
fetch("/api/studies?limit=1")
.then(r => r.json())
.then(data => { if (data.total) setTotalStudies(data.total); })
.catch(() => {});
}, [savedResults.length]);

const handleNextRandom = () => {
setNavigating(true);
if (savedResults.length > 0) {
const result = savedResults[Math.floor(Math.random() * savedResults.length)];
router.push(`/study/${result.studyId}`);
} else if (totalStudies !== null) {
router.push(`/study/${Math.floor(Math.random() * totalStudies) + 1}`);
}
};

const disabled = navigating || (savedResults.length === 0 && totalStudies === null);

return (
<div style={{ display: "flex", gap: "0.75rem", flexWrap: "wrap", alignItems: "center" }}>
<Link href="/browse" style={{
display: "inline-block",
padding: "0.5rem 1rem",
backgroundColor: "#667eea",
color: "white",
textDecoration: "none",
borderRadius: "6px",
fontSize: "0.85rem",
fontWeight: 600,
}}>
← Back to Browse
</Link>
<button
onClick={handleNextRandom}
disabled={disabled}
style={{
fontSize: "0.85rem",
padding: "0.5rem 1rem",
background: "linear-gradient(135deg, #667eea, #764ba2)",
border: "none",
color: "white",
borderRadius: "6px",
cursor: "pointer",
whiteSpace: "nowrap",
fontWeight: 600,
boxShadow: "0 2px 6px rgba(102,126,234,0.4)",
opacity: disabled ? 0.5 : 1,
}}
>
{navigating ? "Loading..." : "Next Random Study →"}
</button>
</div>
);
}
65 changes: 65 additions & 0 deletions app/components/StudyPersonalSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"use client";

import { useResults } from "./ResultsContext";
import StudyPersonalResultBanner from "./StudyPersonalResultBanner";
import StudyInlineAnalysis from "./StudyInlineAnalysis";

type Props = {
studyId: number;
studyAccession: string | null;
snps: string | null;
traitName: string;
studyTitle: string;
riskAllele?: string | null;
orOrBeta?: string | null;
ciText?: string | null;
isAnalyzable: boolean;
nonAnalyzableReason?: string;
pubmedId?: string | null;
mappedGene?: string | null;
reportedTrait?: string | null;
};

export default function StudyPersonalSection({
studyId,
studyAccession,
snps,
traitName,
studyTitle,
riskAllele,
orOrBeta,
ciText,
isAnalyzable,
nonAnalyzableReason,
pubmedId,
mappedGene,
reportedTrait,
}: Props) {
const { hasResult, getResult } = useResults();
const result = getResult(studyId);

return (
<>
<StudyPersonalResultBanner
studyId={studyId}
studyAccession={studyAccession}
snps={snps}
traitName={traitName}
studyTitle={studyTitle}
riskAllele={riskAllele}
orOrBeta={orOrBeta}
ciText={ciText}
isAnalyzable={isAnalyzable}
nonAnalyzableReason={nonAnalyzableReason}
/>
{hasResult(studyId) && result && (
<StudyInlineAnalysis
result={result}
pubmedId={pubmedId}
mappedGene={mappedGene}
reportedTrait={reportedTrait}
/>
)}
</>
);
}
1 change: 0 additions & 1 deletion app/overview-report/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default function OverviewReportPage() {

const requirePremium = () => {
if (!hasPremiumAccess && !hasValidPromoAccess()) {
if (!isAuthenticated) { openAuthModal(); return false; }
router.push('/subscribe');
return false;
}
Expand Down
Loading
Loading