From 196b810a179d0c9f48944f1b94b6b8b424d005e1 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 21 Oct 2024 02:27:45 +0530 Subject: [PATCH 1/6] wip: remove integration --- .../molecules/IntegrationSettings.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/components/molecules/IntegrationSettings.tsx b/src/components/molecules/IntegrationSettings.tsx index b1e87347..b3317a2f 100644 --- a/src/components/molecules/IntegrationSettings.tsx +++ b/src/components/molecules/IntegrationSettings.tsx @@ -77,6 +77,26 @@ export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose }: I } }; + const removeIntegration = async () => { + try { + await axios.post( + `http://localhost:8080/auth/gsheets/remove`, + { robotId: recordingId }, + { withCredentials: true } + ); + + setRecording((prev: any) => ({ + ...prev, + google_sheet_id: null, + google_sheet_name: null, + google_sheet_email: null, + })); + setSettings({ spreadsheetId: '', spreadsheetName: '', data: '' }); + } catch (error: any) { + console.error('Error removing Google Sheets integration:', error.response?.data?.message || error.message); + } + }; + useEffect(() => { // Check if we're on the callback URL const urlParams = new URLSearchParams(window.location.search); From 3782ee2a34794e0e69f2cb5fa355695ec4c17ee3 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 21 Oct 2024 02:29:34 +0530 Subject: [PATCH 2/6] feat: set local state null --- src/components/molecules/IntegrationSettings.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/components/molecules/IntegrationSettings.tsx b/src/components/molecules/IntegrationSettings.tsx index b3317a2f..8ec8cddb 100644 --- a/src/components/molecules/IntegrationSettings.tsx +++ b/src/components/molecules/IntegrationSettings.tsx @@ -85,12 +85,8 @@ export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose }: I { withCredentials: true } ); - setRecording((prev: any) => ({ - ...prev, - google_sheet_id: null, - google_sheet_name: null, - google_sheet_email: null, - })); + setRecording(null); + setSpreadsheets([]); setSettings({ spreadsheetId: '', spreadsheetName: '', data: '' }); } catch (error: any) { console.error('Error removing Google Sheets integration:', error.response?.data?.message || error.message); From 0fe48677d279e0907c6e44647731f4d0a4a2f3df Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 21 Oct 2024 02:33:38 +0530 Subject: [PATCH 3/6] feat: remove gsheet intgration route --- server/src/routes/auth.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/server/src/routes/auth.ts b/server/src/routes/auth.ts index 697a1129..22540456 100644 --- a/server/src/routes/auth.ts +++ b/server/src/routes/auth.ts @@ -354,3 +354,31 @@ router.post('/gsheets/update', requireSignIn, async (req, res) => { res.status(500).json({ message: `Error updating robot: ${error.message}` }); } }); + +router.post('/gsheets/remove', requireSignIn, async (req, res) => { + const { robotId } = req.body; + + if (!robotId) { + return res.status(400).json({ message: 'Robot ID is required' }); + } + + try { + let robot = await Robot.findOne({ where: { 'recording_meta.id': robotId } }); + + if (!robot) { + return res.status(404).json({ message: 'Robot not found' }); + } + + await robot.update({ + google_sheet_id: null, + google_sheet_name: null, + google_sheet_email: null, + google_access_token: null, + google_refresh_token: null + }); + + res.json({ message: 'Google Sheets integration removed successfully' }); + } catch (error: any) { + res.status(500).json({ message: `Error removing Google Sheets integration: ${error.message}` }); + } +}); From 71b6d047d152eea1bd57b1efbb6b3aa6a8bef129 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 21 Oct 2024 02:34:00 +0530 Subject: [PATCH 4/6] chore: lint --- server/src/routes/auth.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/server/src/routes/auth.ts b/server/src/routes/auth.ts index 22540456..16304d09 100644 --- a/server/src/routes/auth.ts +++ b/server/src/routes/auth.ts @@ -302,7 +302,7 @@ router.post('/gsheets/data', requireSignIn, async (req, res) => { router.get('/gsheets/files', requireSignIn, async (req, res) => { try { const robotId = req.query.robotId; - const robot = await Robot.findOne({ where: { 'recording_meta.id': robotId }, raw:true }); + const robot = await Robot.findOne({ where: { 'recording_meta.id': robotId }, raw: true }); if (!robot) { return res.status(400).json({ message: 'Robot not found' }); @@ -357,7 +357,6 @@ router.post('/gsheets/update', requireSignIn, async (req, res) => { router.post('/gsheets/remove', requireSignIn, async (req, res) => { const { robotId } = req.body; - if (!robotId) { return res.status(400).json({ message: 'Robot ID is required' }); } @@ -369,8 +368,8 @@ router.post('/gsheets/remove', requireSignIn, async (req, res) => { return res.status(404).json({ message: 'Robot not found' }); } - await robot.update({ - google_sheet_id: null, + await robot.update({ + google_sheet_id: null, google_sheet_name: null, google_sheet_email: null, google_access_token: null, From d79fa77f3a24245a4f8b40d8b247931aee858992 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 21 Oct 2024 02:39:13 +0530 Subject: [PATCH 5/6] feat: remove integration button --- src/components/molecules/IntegrationSettings.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/molecules/IntegrationSettings.tsx b/src/components/molecules/IntegrationSettings.tsx index 8ec8cddb..91ca251d 100644 --- a/src/components/molecules/IntegrationSettings.tsx +++ b/src/components/molecules/IntegrationSettings.tsx @@ -118,6 +118,7 @@ export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose }: I Google Sheets Integration {recording && recording.google_sheet_id ? ( + <> Google Sheet Integrated Successfully!
@@ -125,6 +126,15 @@ export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose }: I
Sheet ID: {recording.google_sheet_id}
+ + ) : ( <> {!recording?.google_sheet_email ? ( From f4c68744abfc5ee841828617848354feef5220b2 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 21 Oct 2024 02:39:24 +0530 Subject: [PATCH 6/6] chore: lint --- .../molecules/IntegrationSettings.tsx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/components/molecules/IntegrationSettings.tsx b/src/components/molecules/IntegrationSettings.tsx index 91ca251d..898a2042 100644 --- a/src/components/molecules/IntegrationSettings.tsx +++ b/src/components/molecules/IntegrationSettings.tsx @@ -119,21 +119,21 @@ export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose }: I {recording && recording.google_sheet_id ? ( <> - - Google Sheet Integrated Successfully! -
- Sheet Name: {recording.google_sheet_name} -
- Sheet ID: {recording.google_sheet_id} -
- + + Google Sheet Integrated Successfully! +
+ Sheet Name: {recording.google_sheet_name} +
+ Sheet ID: {recording.google_sheet_id} +
+ ) : ( <>