import { Button } from '@wordpress/components';
import { useCallback } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import IntegrationCard from '../../blocks/contact-form/components/jetpack-integrations-modal/integration-card';
import GoogleSheetsIcon from '../../icons/google-sheets';
import type { IntegrationCardProps, JPFormsBlocksWindow } from './types';
const FORM_RESPONSES_URL =
( window as JPFormsBlocksWindow ).jpFormsBlocks?.defaults?.formsResponsesUrl ||
'/wp-admin/admin.php?page=jetpack-forms';
const GoogleSheetsDashboardCard = ( {
isExpanded,
onToggle,
data,
refreshStatus,
}: IntegrationCardProps ) => {
const isConnected = !! data?.isConnected;
const settingsUrl = data?.settingsUrl;
const cardData = {
...data,
slug: 'google-sheets',
showHeaderToggle: false, // Always off for dashboard
isLoading: ! data,
refreshStatus,
trackEventName: 'jetpack_forms_upsell_googledrive_click',
isActive: !! data?.isConnected,
};
const handleConnectClick = useCallback( () => {
if ( ! settingsUrl ) return;
window.open( settingsUrl, '_blank', 'noopener,noreferrer' );
}, [ settingsUrl ] );
return (
{ __( 'Connect your site to Google Drive to export form responses directly to Google Sheets.', 'jetpack-forms' ) }
{ __( 'Google Sheets is connected. You can export your form responses from the form responses page.', 'jetpack-forms' ) }