From 05529ed91e2af9460ac20e66f3ae0a8c892f6f2c Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 17 Sep 2024 20:10:51 +0530 Subject: [PATCH] feat: gsheet ui --- .../molecules/IntegrationSettings.tsx | 130 ++++++++---------- 1 file changed, 54 insertions(+), 76 deletions(-) diff --git a/src/components/molecules/IntegrationSettings.tsx b/src/components/molecules/IntegrationSettings.tsx index 0c4ce109..7e118e68 100644 --- a/src/components/molecules/IntegrationSettings.tsx +++ b/src/components/molecules/IntegrationSettings.tsx @@ -1,33 +1,35 @@ import React, { useState } from 'react'; import { GenericModal } from "../atoms/GenericModal"; import { MenuItem, TextField, Typography } from "@mui/material"; -import { Dropdown } from "../atoms/DropdownMui"; import Button from "@mui/material/Button"; import { modalStyle } from "./AddWhereCondModal"; -interface IntegrationSettingsProps { +interface GoogleSheetsIntegrationProps { isOpen: boolean; - handleStart: (settings: IntegrationSettings) => void; + handleSubmit: (data: GoogleSheetsSettings) => void; handleClose: () => void; - isTask: boolean; - params?: string[]; } -export interface IntegrationSettings { - maxConcurrency: number; - maxRepeats: number; - debug: boolean; - params?: any; +export interface GoogleSheetsSettings { + credentials: string; + spreadsheetId: string; + range: string; + data: string; } -export const IntegrationSettingsModal = ({ isOpen, handleStart, handleClose, isTask, params }: IntegrationSettingsProps) => { +export const GoogleSheetsIntegrationModal = ({ isOpen, handleSubmit, handleClose }: GoogleSheetsIntegrationProps) => { - const [settings, setSettings] = React.useState({ - maxConcurrency: 1, - maxRepeats: 1, - debug: true, + const [settings, setSettings] = useState({ + credentials: '', + spreadsheetId: '', + range: '', + data: '', }); + const handleChange = (field: keyof GoogleSheetsSettings) => (e: React.ChangeEvent) => { + setSettings({ ...settings, [field]: e.target.value }); + }; + return ( - {isTask - ? - ( - - Recording parameters: - {params?.map((item, index) => { - return setSettings( - { - ...settings, - params: settings.params - ? { - ...settings.params, - [item]: e.target.value, - } - : { - [item]: e.target.value, - }, - })} - /> - })} - ) - : null - } - Interpreter settings: + Google Sheets Integration + setSettings( - { - ...settings, - maxConcurrency: parseInt(e.target.value), - })} - defaultValue={settings.maxConcurrency} + value={settings.credentials} + onChange={handleChange('credentials')} + fullWidth /> + setSettings( - { - ...settings, - maxRepeats: parseInt(e.target.value), - })} - defaultValue={settings.maxRepeats} + value={settings.spreadsheetId} + onChange={handleChange('spreadsheetId')} + fullWidth /> - setSettings( - { - ...settings, - debug: e.target.value === "true", - })} - > - true - false - - + + + + + + ); -} +};