Download services/orderService.js from phanquocdat123/Chatbot_Robot_Automation: direct link, hf CLI and curl.
- Browser
- Download file 788 Bytes
-
https://huggingface.co/spaces/phanquocdat123/Chatbot_Robot_Automation/resolve/main/services/orderService.js
- Command line
-
hf download hf://spaces/phanquocdat123/Chatbot_Robot_Automation/services/orderService.js
-
curl -L -o orderService.js https://huggingface.co/spaces/phanquocdat123/Chatbot_Robot_Automation/resolve/main/services/orderService.js
788 Bytes
| const { google } = require('googleapis'); | |
| async function saveOrderToSheet(orderData) { | |
| const auth = new google.auth.GoogleAuth({ | |
| keyFile: 'credentials.json', // File key của Google Cloud | |
| scopes: ['https://www.googleapis.com/auth/spreadsheets'], | |
| }); | |
| const sheets = google.sheets({ version: 'v4', auth }); | |
| const values = [[ | |
| new Date().toLocaleString(), | |
| `DH${Date.now()}`, | |
| orderData.phone, | |
| orderData.address, | |
| orderData.items.join(", "), | |
| orderData.totalPrice, | |
| orderData.weight | |
| ]]; | |
| await sheets.spreadsheets.values.append({ | |
| spreadsheetId: process.env.SPREADSHEET_ID, | |
| range: 'khachhang!A:G', | |
| valueInputOption: 'USER_ENTERED', | |
| resource: { values }, | |
| }); | |
| } |