/**
 * Analytics Setup form.
 *
 * Site Kit by Google, Copyright 2020 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * WordPress dependencies
 */
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

/**
 * Internal dependencies
 */
import AccountSelect from '../common/account-select';
import PropertySelect from '../common/property-select';
import ProfileSelect from '../common/profile-select';
import { STORE_NAME } from '../datastore';

export default function AnalyticsSetupForm() {
	const accounts = useSelect( ( select ) => select( STORE_NAME ).getAccounts() ) || [];
	const hasExistingTag = useSelect( ( select ) => select( STORE_NAME ).hasExistingTag() );

	return (
		<div className="googlesitekit-analytics-setup__form">
			{ ( !! accounts.length && ! hasExistingTag ) && (
				<p>
					{ __( 'Please select the account information below. You can change this view later in your settings.', 'google-site-kit' ) }
				</p>
			) }

			<div className="googlesitekit-setup-module__inputs">
				<AccountSelect />

				<PropertySelect />

				<ProfileSelect />
			</div>
		</div>
	);
}

@@ -785,24 +785,73 @@
 dencies%0A */%0A
+import Button from '../../../components/button';%0A
 import Accou
@@ -1044,16 +1044,79 @@
 astore';
+%0Aimport %7B isValidAccountID, isValidPropertyID %7D from '../util';
 %0A%0Aexport
@@ -1254,109 +1254,571 @@
 nst 
-hasExistingTag = useSelect( ( select ) =%3E select( STORE_NAME ).hasExistingTag() );%0A%0A%09return (%0A%09%09%3Cdiv 
+accountID = useSelect( ( select ) =%3E select( STORE_NAME ).getAccountID() );%0A%09const propertyID = useSelect( ( select ) =%3E select( STORE_NAME ).getAccountID() );%0A%09const hasExistingTag = useSelect( ( select ) =%3E select( STORE_NAME ).hasExistingTag() );%0A%09const isSavingSettings = useSelect( ( select ) =%3E select( STORE_NAME ).isDoingSaveSettings() );%0A%0A%09const isBlockedFromSaving = (%0A%09%09isSavingSettings %7C%7C%0A%09%09! isValidAccountID( accountID ) %7C%7C%0A%09%09! isValidPropertyID( propertyID )%0A%09);%0A%0A%09const submitForm = () =%3E %7B%7D; // TODO: Handle form submission%0A%0A%09return (%0A%09%09%3Cform%0A%09%09%09
 clas
@@ -1860,16 +1860,46 @@
 p__form%22
+%0A%09%09%09onSubmit=%7B submitForm %7D%0A%09%09
 %3E%0A%09%09%09%7B (
@@ -2235,23 +2235,207 @@
 %09%3C/div%3E%0A
-%09%09%3C/div
+%0A%09%09%09%3Cdiv className=%22googlesitekit-setup-module__action%22%3E%0A%09%09%09%09%3CButton disabled=%7B isBlockedFromSaving %7D%3E%0A%09%09%09%09%09%7B __( 'Configure Analytics', 'google-site-kit' ) %7D%0A%09%09%09%09%3C/Button%3E%0A%09%09%09%3C/div%3E%0A%09%09%3C/form
 %3E%0A%09);%0A%7D%0A

Update setup form to be form, add submit button.