// import React, { useState, useEffect } from 'react'; // //import gapi from 'gapi'; // // // import { Document, Page } from 'react-pdf'; // // const CLIENT_ID = '926212607479-d3m8hm8f8esp3rf1639prskn445sa01v.apps.googleusercontent.com'; // // const API_KEY = 'AIzaSyBUtqjxvCLv2GVcVFEPVym7vRtVW-qP4Jw'; // // const DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"]; // // const SCOPES = 'https://www.googleapis.com/auth/drive.readonly'; const GoogleDriveFolderPreview = ({ folderId }) => { // const folderUrl = `https://drive.google.com/drive/folders/${folderId}`; // const [files, setFiles] = useState([]); // useEffect(() => // fetch(folderUrl) // .then(res => res.text()) // .then(text => { // const parser = new DOMParser(); // const htmlDocument = parser.parseFromString(text, 'text/html'); // const fileElements = htmlDocument.querySelectorAll('.Q5txwe'); // const files = Array.from(fileElements).map(fileElement => { // const fileUrl = fileElement.getAttribute('href'); // const fileName = fileElement.querySelector('.Q5txwe').textContent; // return { fileUrl, fileName }; // }); // setFiles(files); // }) // , [folderUrl]); // return ( //
// {files.map(file => ( //
// //
// ))} //
// ); // // useEffect(() => { // // // Initialize the Google API client library // // gapi.load('client:auth2', () => { // // gapi.client.init({ // // apiKey: API_KEY, // // clientId: CLIENT_ID, // // discoveryDocs: DISCOVERY_DOCS, // // scope: SCOPES // // }).then(() => { // // // Listen for sign-in state changes and handle the signed-in state // // gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus); // // updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get()); // // }); // // }); // // const updateSigninStatus = (isSignedIn) => { // // if (isSignedIn) { // // fetchFiles(); // // } else { // // gapi.auth2.getAuthInstance().signIn(); // // } // // }; // // const fetchFiles = async () => { // // const response = await gapi.client.drive.files.list({ // // q: `'${folderId}' in parents and mimeType = 'application/pdf'`, // // fields: 'files(id, name, webContentLink)' // // }); // // setFiles(response.result.files); // // }; // // }, [folderId]); // // const PdfDocument = ({ file }) => { // // return ( // // // // // // {/* Render other pages as needed */} // // // // ); // // }; // // return ( // //
// // {files.map(file => ( // //
// // // //
// // ))} // //
// // ); }; export default GoogleDriveFolderPreview;