From 884947374dd56d77ec67c4df8d0d3b39b0fa8cda Mon Sep 17 00:00:00 2001 From: arc-alex Date: Wed, 13 Dec 2023 18:56:49 +0100 Subject: [PATCH] improve get state check --- .../modals/sheets-modal/SheetsModal.tsx | 80 ++++++++++------- apps/server/src/utils/sheetsAuth.ts | 88 +++++++++++++------ .../src/definitions/core/GoogleSheet.type.ts | 2 + 3 files changed, 110 insertions(+), 60 deletions(-) diff --git a/apps/client/src/features/modals/sheets-modal/SheetsModal.tsx b/apps/client/src/features/modals/sheets-modal/SheetsModal.tsx index 4b53ba59d..00240e197 100644 --- a/apps/client/src/features/modals/sheets-modal/SheetsModal.tsx +++ b/apps/client/src/features/modals/sheets-modal/SheetsModal.tsx @@ -11,6 +11,7 @@ import { ModalFooter, ModalHeader, ModalOverlay, + Select, } from '@chakra-ui/react'; import { IoArrowDownCircleOutline } from '@react-icons/all-files/io5/IoArrowDownCircleOutline'; import { IoArrowUpCircleOutline } from '@react-icons/all-files/io5/IoArrowUpCircleOutline'; @@ -49,12 +50,18 @@ export default function SheetsModal(props: SheetsModalProps) { const [userFields, setUserFields] = useState(null); const [project, setProject] = useState(null); - const [sheetState, setSheetState] = useState({ auth: false, id: false, worksheet: false }); + const [sheetState, setSheetState] = useState({ + secret: false, + auth: false, + id: false, + worksheet: false, + worksheetOptions: [], + }); const queryClient = useQueryClient(); const sheetid = useRef(null); - const worksheet = useRef(null); + const worksheet = useRef(null); const handleClose = () => { setRundown(null); @@ -82,14 +89,21 @@ export default function SheetsModal(props: SheetsModalProps) { useEffect(() => { getSheetSettings().then((data) => { - if (sheetid.current?.value != data.id || worksheet.current?.value != data.worksheet) { + if (data.id == '') { + return; + } + console.log(worksheet.current?.value); + if ( + sheetid.current?.value != data.id || + (worksheet.current?.value != data.worksheet && worksheet.current?.value) + ) { _onChange(); - } - if (sheetid.current) { - sheetid.current.value = data.id; - } - if (worksheet.current) { - worksheet.current.value = data.worksheet; + if (sheetid.current) { + sheetid.current.value = data.id; + } + if (worksheet.current) { + worksheet.current.value = data.worksheet; + } } }); }); @@ -186,14 +200,20 @@ export default function SheetsModal(props: SheetsModalProps) { data-testid='file-input' />
Need to add some help here
+
+ {sheetState.secret ? 'have good secret' : 'no or bad secret'}
- - {sheetState.auth ?
You are authenticated
:
You are not authenticated
} -
+
+
+ + {sheetState.auth ? 'You are authenticated' : 'You are not authenticated'} +
+
+
: } -
- - - - - {sheetState.worksheet ? ( - - ) : ( - - )} - -

-
+
+ + +
+
+