/** * Copyright (c) 2020-present, Goldman Sachs * * 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 * * http://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. */ import { observer } from 'mobx-react-lite'; import { useState } from 'react'; import { CloseIcon, ErrorWarnIcon, RefreshIcon, SendIcon, SimpleCalendarIcon, } from '@finos/legend-art'; import { useLegendMarketplaceBaseStore } from '../../application/providers/LegendMarketplaceFrameworkProvider.js'; import { LEGEND_MARKETPLACE_APP_EVENT } from '../../__lib__/LegendMarketplaceAppEvent.js'; interface DemoFormData { name: string; division: string; reason: string; } export const DemoModal = observer(() => { const legendMarketplaceBaseStore = useLegendMarketplaceBaseStore(); const showDemoForm = legendMarketplaceBaseStore.showDemoModal; const [isSubmitting, setIsSubmitting] = useState(false); const [submitError, setSubmitError] = useState(null); const [formErrors, setFormErrors] = useState>({}); const [formData, setFormData] = useState({ name: '', division: '', reason: '', }); const closeDemoForm = () => { legendMarketplaceBaseStore.setDemoModal(false); setFormData({ name: '', division: '', reason: '' }); setFormErrors({}); setSubmitError(null); }; const handleInputChange = (field: keyof DemoFormData, value: string) => { setFormData((prev) => ({ ...prev, [field]: value })); if (formErrors[field]) { setFormErrors((prev) => ({ ...prev, [field]: undefined })); } // Clear submit error when user starts typing if (submitError) { setSubmitError(null); } }; const validateForm = (): boolean => { const errors: Partial = {}; if (!formData.name.trim()) { errors.name = 'Name is required'; } if (!formData.division.trim()) { errors.division = 'Division/Team name is required'; } if (!formData.reason.trim()) { errors.reason = 'Please provide a reason/use case'; } else if (formData.reason.trim().length < 10) { errors.reason = 'Please provide more details (minimum 10 characters)'; } setFormErrors(errors); return Object.keys(errors).length === 0; }; const handleSubmitDemo = (e: React.FormEvent) => { e.preventDefault(); if (!validateForm()) { return; } setIsSubmitting(true); setSubmitError(null); legendMarketplaceBaseStore.applicationStore.telemetryService.logEvent( LEGEND_MARKETPLACE_APP_EVENT.SCHEDULE_DEMO, { name: formData.name, division: formData.division, }, ); }; if (!showDemoForm) { return null; } return (

Schedule a Demo

Get a personalized demonstration of our vendor data management platform

{/* Show API error if exists */} {submitError && (
{submitError}
)}
handleInputChange('name', e.target.value)} /> {formErrors.name && ( {formErrors.name} )}
handleInputChange('division', e.target.value)} /> {formErrors.division && ( {formErrors.division} )}