@riocrypto/common-server 1.0.1005 → 1.0.1006
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,7 +4,7 @@ declare class GoogleSheetsAPIClient {
|
|
|
4
4
|
googleAuth: any;
|
|
5
5
|
constructor(env: RioEnv);
|
|
6
6
|
getSheetValues(sheetId: string, range: string): Promise<any[][] | null | undefined>;
|
|
7
|
-
getNextAvailableRow(sheetId: string): Promise<
|
|
7
|
+
getNextAvailableRow(sheetId: string): Promise<number>;
|
|
8
8
|
}
|
|
9
9
|
export declare const googleSheetsAPIClient: GoogleSheetsAPIClient;
|
|
10
10
|
export {};
|
|
@@ -38,7 +38,19 @@ class GoogleSheetsAPIClient {
|
|
|
38
38
|
spreadsheetId: sheetId,
|
|
39
39
|
range: "A:A",
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
const data = response.data.values;
|
|
42
|
+
if (!data || data.length === 0) {
|
|
43
|
+
// If the sheet is completely empty, return the first row (1)
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
// Find the first empty row
|
|
47
|
+
for (let i = 0; i < data.length; i++) {
|
|
48
|
+
if (data[i].length === 0) {
|
|
49
|
+
return i + 1;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// If no empty row found, return the next row after the last row
|
|
53
|
+
return data.length + 1;
|
|
42
54
|
});
|
|
43
55
|
}
|
|
44
56
|
}
|