|
1 | 1 | import { resolve } from 'path'; |
2 | 2 | import dotenv from 'dotenv'; |
3 | | -import { google } from 'googleapis'; |
| 3 | +// import { google } from 'googleapis'; // Commented out as Google Sheets is not accessible |
4 | 4 | import { getCssStringFromCommittee, generateCommittee } from './lib.mjs'; |
5 | 5 |
|
6 | 6 | // .env config |
7 | 7 | dotenv.config({ path: '.env.local' }); |
8 | 8 | const SPREADSHEET_ID = process.env.LANDING_SPREADSHEET_ID; |
9 | | -const SERVICE_ACCOUNT = process.env.SERVICE_ACCOUNT ?? ''; |
| 9 | +// const SERVICE_ACCOUNT = process.env.SERVICE_ACCOUNT ?? ''; // Commented out as Google Sheets is not accessible |
10 | 10 |
|
11 | 11 | //Grab main information to be displayed |
12 | 12 | //and write to output.json |
13 | 13 | async function getCommitteeInfo(name) { |
14 | | - const committees = await getGoogleSheetData('committee info!A:J'); |
| 14 | + // const committees = await getGoogleSheetData('committee info!A:J'); // Commented out |
| 15 | + const committees = []; // Placeholder since Google Sheets is not accessible |
15 | 16 | const committee = []; |
16 | 17 | //get committee |
17 | 18 | for (const row of committees) { |
@@ -51,40 +52,42 @@ async function getCommitteeInfo(name) { |
51 | 52 |
|
52 | 53 | // Read data from Google sheets |
53 | 54 | // using sheet range (eg: 'Week 1!A:H) |
54 | | -async function getGoogleSheetData(range) { |
55 | | - const sheets = google.sheets({ version: 'v4' }); |
| 55 | +// async function getGoogleSheetData(range) { // Commented out |
| 56 | +// const sheets = google.sheets({ version: 'v4' }); |
56 | 57 |
|
57 | | - // Get JWT Token to access sheet |
58 | | - const service_account = JSON.parse(SERVICE_ACCOUNT); |
59 | | - const jwtClient = new google.auth.JWT( |
60 | | - service_account.client_email, |
61 | | - '', |
62 | | - service_account.private_key, |
63 | | - ['https://www.googleapis.com/auth/spreadsheets'], |
64 | | - ); |
65 | | - jwtClient.authorize(function (err) { |
66 | | - if (err) { |
67 | | - throw err; |
68 | | - } |
69 | | - }); |
| 58 | +// // Validate SERVICE_ACCOUNT |
| 59 | +// if (!SERVICE_ACCOUNT || SERVICE_ACCOUNT === '{}') { |
| 60 | +// console.error('SERVICE_ACCOUNT environment variable is missing or invalid.'); |
| 61 | +// console.error('Ensure that .env.local contains a valid SERVICE_ACCOUNT JSON string.'); |
| 62 | +// throw new Error('SERVICE_ACCOUNT environment variable is missing or invalid.'); |
| 63 | +// } |
70 | 64 |
|
71 | | - // Get data from Google spreadsheets |
72 | | - const res = await sheets.spreadsheets.values.get({ |
73 | | - auth: jwtClient, |
74 | | - spreadsheetId: SPREADSHEET_ID, |
75 | | - range: range, |
76 | | - }); |
77 | | - const rows = res?.data.values; |
78 | | - if (!rows || rows.length == 0) { |
79 | | - console.log('Error: no data found'); |
80 | | - return []; |
81 | | - } |
| 65 | +// // Get JWT Token to access sheet |
| 66 | +// const service_account = JSON.parse(SERVICE_ACCOUNT); |
| 67 | +// const jwtClient = new google.auth.JWT( |
| 68 | +// service_account.client_email, |
| 69 | +// '', |
| 70 | +// service_account.private_key, |
| 71 | +// ['https://www.googleapis.com/auth/spreadsheets'], |
| 72 | +// ); |
| 73 | +// jwtClient.authorize(function (err) { |
| 74 | +// if (err) { |
| 75 | +// throw err; |
| 76 | +// } |
| 77 | +// }); |
82 | 78 |
|
83 | | - // // Replacing the new lines with <br/> (doesnt work tho) |
84 | | - // const formatRows = rows.map((row) => row.map( (r) => r.replace(/\n/g, '<br/>'))); |
85 | | - // return formatRows; |
| 79 | +// // Get data from Google spreadsheets |
| 80 | +// const res = await sheets.spreadsheets.values.get({ |
| 81 | +// auth: jwtClient, |
| 82 | +// spreadsheetId: SPREADSHEET_ID, |
| 83 | +// range: range, |
| 84 | +// }); |
| 85 | +// const rows = res?.data.values; |
| 86 | +// if (!rows || rows.length == 0) { |
| 87 | +// console.log('Error: no data found'); |
| 88 | +// return []; |
86 | 89 |
|
87 | | - return rows; |
88 | | -} |
| 90 | +// return rows; |
| 91 | +// } |
89 | 92 |
|
90 | 93 | export default getCommitteeInfo; |
0 commit comments