Skip to content

Commit 35d7d5c

Browse files
AmirMohammad CheraghaliAmirMohammad Cheraghali
authored andcommitted
fix: correctly load structure in viewer from notebook card
1 parent fd52a7b commit 35d7d5c

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

src/components/dashboard/StructurePreviewCard.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,27 @@ export const StructurePreviewCard: React.FC<StructurePreviewCardProps> = ({ stru
5353

5454
const rcsbId = structure.name.match(/^[1-9][A-Z0-9]{3}$/i)?.[0]?.toUpperCase();
5555

56-
const handleOpen = (e: React.MouseEvent) => {
56+
const handleOpen = async (e: React.MouseEvent) => {
5757
e.preventDefault();
5858
e.stopPropagation();
59-
navigate(`/view/${structure.id}`);
59+
60+
try {
61+
setLoading(true);
62+
const { getDownloadUrl } = await import('../../lib/structuresService');
63+
const url = await getDownloadUrl(structure.file_path);
64+
65+
sessionStorage.setItem('pendingStructure', JSON.stringify({
66+
url,
67+
name: structure.name,
68+
fileType: structure.file_type.toLowerCase()
69+
}));
70+
71+
navigate('/');
72+
} catch (err) {
73+
console.error('Failed to open structure in viewer:', err);
74+
} finally {
75+
setLoading(false);
76+
}
6077
};
6178

6279
return (

0 commit comments

Comments
 (0)