Files
parcer/src/api/interpretation.ts

24 lines
898 B
TypeScript
Raw Normal View History

2024-09-17 22:36:40 +05:30
import { default as axios } from "axios";
2024-09-17 22:39:28 +05:30
// todo: proper typescript types for params
2024-09-17 22:39:05 +05:30
export const handleUploadCredentials = async (credentials: any) => {
2024-09-17 22:36:40 +05:30
try {
2024-09-17 22:36:54 +05:30
await axios.post('http://localhost:8080/integration/upload-credentials', { credentials: JSON.parse(credentials) });
alert('Service Account credentials saved successfully.');
2024-09-17 22:36:40 +05:30
} catch (error) {
2024-09-17 22:36:54 +05:30
console.error('Error uploading credentials:', error);
alert('Failed to upload credentials.');
2024-09-17 22:36:40 +05:30
}
2024-09-17 22:36:54 +05:30
};
2024-09-17 22:36:40 +05:30
2024-09-17 22:39:05 +05:30
export const handleWriteToSheet = async (spreadsheetId: any, range: any) => {
2024-09-17 22:38:32 +05:30
try {
2024-09-17 22:39:05 +05:30
await axios.post('http://localhost:8080/integration/write-to-sheet', { spreadsheetId, range });
alert('Data written to Google Sheet successfully.');
2024-09-17 22:38:32 +05:30
} catch (error) {
2024-09-17 22:39:05 +05:30
console.error('Error writing to Google Sheet:', error);
alert('Failed to write to Google Sheet.');
2024-09-17 22:38:32 +05:30
}
2024-09-17 22:39:05 +05:30
};
2024-09-17 22:36:40 +05:30