···11import { useState, useEffect, useCallback } from 'react';
22import { ApiClient } from '@/api-client/ApiClient';
33import type { UrlMetadata } from '@/components/UrlMetadataDisplay';
44-import type { UrlCardView } from '@/api-client/types';
44+import type {
55+ GetUrlStatusForMyLibraryResponse,
66+ UrlCardView,
77+} from '@/api-client/types';
5869interface UseUrlMetadataProps {
710 apiClient: ApiClient;
···1518 autoFetch = true,
1619}: UseUrlMetadataProps) {
1720 const [metadata, setMetadata] = useState<UrlMetadata | null>(null);
1818- const [existingCard, setExistingCard] = useState<UrlCardView | null>(null);
2121+ const [existingCardCollections, setExistingCardCollections] = useState<
2222+ GetUrlStatusForMyLibraryResponse['collections'] | null
2323+ >(null);
1924 const [loading, setLoading] = useState(false);
2025 const [error, setError] = useState<string | null>(null);
2126···33383439 setLoading(true);
3540 setError(null);
3636- setExistingCard(null);
4141+ setExistingCardCollections(null);
37423843 try {
3944 const response = await apiClient.getUrlMetadata(targetUrl);
4045 setMetadata(response.metadata);
41464242- // If there's an existing card, fetch its details including collections
4343- if (response.existingCardId) {
4747+ const existingCard = await apiClient.getUrlStatusForMyLibrary({
4848+ url: targetUrl,
4949+ });
5050+5151+ // If there's an existing card, fetch its collections
5252+ if (existingCard.cardId) {
4453 try {
4545- const cardResponse = await apiClient.getUrlCardView(
4646- response.existingCardId,
4747- );
4848- setExistingCard(cardResponse);
5454+ setExistingCardCollections(existingCard.collections);
4955 } catch (cardErr: any) {
5056 console.error('Failed to fetch existing card details:', cardErr);
5157 // Don't set error here as the metadata fetch was successful
···5561 console.error('Failed to fetch URL metadata:', err);
5662 setError('Failed to load page information');
5763 setMetadata(null);
5858- setExistingCard(null);
6464+ setExistingCardCollections(null);
5965 } finally {
6066 setLoading(false);
6167 }
···78847985 return {
8086 metadata,
8181- existingCard,
8787+ existingCardCollections,
8288 loading,
8389 error,
8490 fetchMetadata,
+1
src/webapp/next-env.d.ts
···11/// <reference types="next" />
22/// <reference types="next/image-types/global" />
33+/// <reference path="./.next/types/routes.d.ts" />
3445// NOTE: This file should not be edited
56// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.