Pages corrections
This commit is contained in:
parent
e55bcb8b78
commit
d78e26914d
@ -141,14 +141,18 @@ export default function CarnetPage() {
|
||||
}, [isSmallScreen, isMediumScreen]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(`[useEffect] selectedFolder changed to: "${selectedFolder}"`);
|
||||
if (selectedFolder === 'Contacts') {
|
||||
// When "Contacts" is selected, show all contacts
|
||||
console.log(`[useEffect] Calling fetchContacts('Contacts')`);
|
||||
fetchContacts('Contacts');
|
||||
} else if (selectedFolder.endsWith('.vcf')) {
|
||||
// When a specific VCF file is selected, show its contacts
|
||||
console.log(`[useEffect] Calling fetchContacts('${selectedFolder}')`);
|
||||
fetchContacts(selectedFolder);
|
||||
} else {
|
||||
// For other folders (Notes, etc.), fetch notes
|
||||
console.log(`[useEffect] Calling fetchNotes() for folder: ${selectedFolder}`);
|
||||
fetchNotes();
|
||||
}
|
||||
}, [selectedFolder, session?.user?.id]);
|
||||
@ -214,11 +218,13 @@ export default function CarnetPage() {
|
||||
};
|
||||
|
||||
const fetchContacts = async (folder: string) => {
|
||||
console.log(`[fetchContacts] Called with folder: ${folder}`);
|
||||
try {
|
||||
setIsLoadingContacts(true);
|
||||
|
||||
// Use lowercase for consistency
|
||||
const folderLowercase = folder.toLowerCase();
|
||||
console.log(`[fetchContacts] Processing folder: ${folderLowercase}`);
|
||||
|
||||
// First, check if we're looking at a specific VCF file
|
||||
if (folder.endsWith('.vcf')) {
|
||||
@ -233,7 +239,9 @@ export default function CarnetPage() {
|
||||
}
|
||||
} else {
|
||||
// If not a VCF file, list all VCF files in the folder
|
||||
console.log(`[fetchContacts] Fetching files from API for folder: ${folderLowercase}`);
|
||||
const response = await fetch(`/api/storage/files?folder=${folderLowercase}`);
|
||||
console.log(`[fetchContacts] API response status: ${response.status}`);
|
||||
if (response.ok) {
|
||||
const files = await response.json();
|
||||
console.log(`[fetchContacts] Found ${files.length} files in contacts folder`, files);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user