2022-03-02 08:15:29 +01:00
|
|
|
import {
|
|
|
|
Modal,
|
|
|
|
ModalOverlay,
|
|
|
|
ModalContent,
|
|
|
|
ModalHeader,
|
|
|
|
ModalCloseButton,
|
|
|
|
ModalBody,
|
|
|
|
Stack,
|
|
|
|
Text,
|
|
|
|
Image,
|
|
|
|
Button,
|
|
|
|
ModalFooter,
|
|
|
|
Flex,
|
|
|
|
} from '@chakra-ui/react'
|
2023-03-15 11:51:30 +01:00
|
|
|
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
2022-11-02 19:45:46 +01:00
|
|
|
import Link from 'next/link'
|
2022-03-02 08:15:29 +01:00
|
|
|
import React from 'react'
|
2022-11-15 09:35:48 +01:00
|
|
|
import { AlertInfo } from '@/components/AlertInfo'
|
|
|
|
import { GoogleLogo } from '@/components/GoogleLogo'
|
2023-03-15 11:51:30 +01:00
|
|
|
import { getGoogleSheetsConsentScreenUrlQuery } from '../queries/getGoogleSheetsConsentScreenUrlQuery'
|
2022-03-02 08:15:29 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
isOpen: boolean
|
2022-06-11 07:27:38 +02:00
|
|
|
blockId: string
|
2022-03-02 08:15:29 +01:00
|
|
|
onClose: () => void
|
|
|
|
}
|
|
|
|
|
2022-06-11 07:27:38 +02:00
|
|
|
export const GoogleSheetConnectModal = ({
|
|
|
|
blockId,
|
|
|
|
isOpen,
|
|
|
|
onClose,
|
|
|
|
}: Props) => {
|
2022-05-13 15:22:44 -07:00
|
|
|
const { workspace } = useWorkspace()
|
2022-03-02 08:15:29 +01:00
|
|
|
return (
|
|
|
|
<Modal isOpen={isOpen} onClose={onClose} size="lg">
|
|
|
|
<ModalOverlay />
|
|
|
|
<ModalContent>
|
|
|
|
<ModalHeader>Connect Spreadsheets</ModalHeader>
|
|
|
|
<ModalCloseButton />
|
|
|
|
<ModalBody as={Stack} spacing="6">
|
2022-11-15 09:35:48 +01:00
|
|
|
<AlertInfo>
|
2022-03-02 08:15:29 +01:00
|
|
|
Typebot needs access to Google Drive in order to list all your
|
|
|
|
spreadsheets. It also needs access to your spreadsheets in order to
|
|
|
|
fetch or inject data in it.
|
2022-11-15 09:35:48 +01:00
|
|
|
</AlertInfo>
|
2022-03-02 08:15:29 +01:00
|
|
|
<Text>
|
|
|
|
Make sure to check all the permissions so that the integration works
|
|
|
|
as expected:
|
|
|
|
</Text>
|
|
|
|
<Image
|
|
|
|
src="/images/google-spreadsheets-scopes.jpeg"
|
|
|
|
alt="Google Spreadsheets checkboxes"
|
|
|
|
/>
|
|
|
|
<Flex>
|
|
|
|
<Button
|
2022-11-02 19:45:46 +01:00
|
|
|
as={Link}
|
2022-03-02 08:15:29 +01:00
|
|
|
leftIcon={<GoogleLogo />}
|
|
|
|
data-testid="google"
|
|
|
|
isLoading={['loading', 'authenticated'].includes(status)}
|
|
|
|
variant="outline"
|
2022-11-15 09:35:48 +01:00
|
|
|
href={getGoogleSheetsConsentScreenUrlQuery(
|
2022-03-02 08:15:29 +01:00
|
|
|
window.location.href,
|
2022-06-11 07:27:38 +02:00
|
|
|
blockId,
|
2022-05-13 15:22:44 -07:00
|
|
|
workspace?.id
|
2022-03-02 08:15:29 +01:00
|
|
|
)}
|
|
|
|
mx="auto"
|
|
|
|
>
|
|
|
|
Continue with Google
|
|
|
|
</Button>
|
|
|
|
</Flex>
|
|
|
|
</ModalBody>
|
|
|
|
|
|
|
|
<ModalFooter />
|
|
|
|
</ModalContent>
|
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
}
|