import React, { useState, useEffect } from 'react'; import { initializeApp } from 'firebase/app'; import { getAuth, signInAnonymously, onAuthStateChanged, signInWithCustomToken } from 'firebase/auth'; import { getFirestore, doc, setDoc, collection, onSnapshot, addDoc, serverTimestamp } from 'firebase/firestore'; import { ChevronRight, Upload, CheckCircle2, AlertCircle, FileText, Settings, Truck, CreditCard, Play, ArrowRight, Save, Mail, Phone, Building, MapPin, Loader2, X, FileSearch, FolderOpen } from 'lucide-react'; // --- Firebase Configuration & Initialization --- const firebaseConfig = JSON.parse(__firebase_config); const app = initializeApp(firebaseConfig); const auth = getAuth(app); const db = getFirestore(app); const appId = typeof __app_id !== 'undefined' ? __app_id : 'oleary-welding-ordering'; const App = () => { const [user, setUser] = useState(null); const [step, setStep] = useState(0); // 0: Landing, 1: Interface, 2: AI Analysis, 3: Quote const [isLoading, setIsLoading] = useState(false); const [saveStatus, setSaveStatus] = useState(null); const [formErrors, setFormErrors] = useState({}); const [aiStatus, setAiStatus] = useState('idle'); // idle, uploading, processing, error, success const [formData, setFormData] = useState({ customerType: '', otherCustomerType: '', supplySteel: '', customerDeliver: '', customerPickup: '', recoverDrops: '', companyName: '', companyAddress: '', contactName: '', email: '', phone: '', projectName: '', projectAddress: '', files: [] }); // --- Auth Effect --- useEffect(() => { const initAuth = async () => { try { if (typeof __initial_auth_token !== 'undefined' && __initial_auth_token) { await signInWithCustomToken(auth, __initial_auth_token); } else { await signInAnonymously(auth); } } catch (error) { console.error("Auth error:", error); } }; initAuth(); const unsubscribe = onAuthStateChanged(auth, setUser); return () => unsubscribe(); }, []); const handleInputChange = (e) => { const { name, value } = e.target; setFormData(prev => ({ ...prev, [name]: value })); if (formErrors[name]) { setFormErrors(prev => { const newErrors = { ...prev }; delete newErrors[name]; return newErrors; }); } }; const validateForm = () => { const errors = {}; const required = ['customerType', 'contactName', 'email', 'phone', 'projectName', 'projectAddress']; required.forEach(field => { if (!formData[field]) errors[field] = true; }); if (formData.customerType === 'Other' && !formData.otherCustomerType) { errors.otherCustomerType = true; } setFormErrors(errors); if (Object.keys(errors).length > 0) { const firstErrorField = document.querySelector('.error-border'); if (firstErrorField) { firstErrorField.scrollIntoView({ behavior: 'smooth', block: 'center' }); } return false; } return true; }; // --- Logic: Save Information (Link Folder & Create Docs) --- const handleSaveInformation = async () => { if (!user) return; setIsLoading(true); try { const parentFolderName = formData.companyName || formData.contactName || 'Guest_Customer'; const projectSubFolderName = `${formData.projectName} ${formData.projectAddress}`.trim(); // Document Path: /artifacts/{appId}/public/data/customer_projects/{ID} // We simulate the hierarchy within the metadata to match the OWC requirement const projectRef = doc(db, 'artifacts', appId, 'public', 'data', 'customer_projects', `${parentFolderName}_${formData.projectName}`.replace(/\s+/g, '_')); await setDoc(projectRef, { ...formData, savedAt: serverTimestamp(), userId: user.uid, status: 'Draft', owc_path: `OWC / Customer Projects / ${parentFolderName} / ${projectSubFolderName}`, lastUpdate: 'System folder metadata generated.' }); setSaveStatus('success'); setTimeout(() => setSaveStatus(null), 3000); } catch (error) { console.error("Save error:", error); setSaveStatus('error'); } finally { setIsLoading(false); } }; const handleFinalSubmit = (e) => { e.preventDefault(); if (validateForm()) { setStep(2); } }; // --- Logic: AI Analysis (Link Steel Pricing Gem) --- const simulateAiAnalysis = () => { setAiStatus('uploading'); setTimeout(() => { setAiStatus('processing'); // Simulate "Steel Pricing" Gem calculating pricing and time estimate setTimeout(() => { const success = Math.random() > 0.15; // High success rate for AI read setAiStatus(success ? 'success' : 'error'); }, 3000); }, 1500); }; const handleSendToTeam = async () => { setIsLoading(true); try { // Logic for "Send to O’Leary Welding team for review" // Simulated Email to timo@olearywelding.com const emailLogRef = collection(db, 'artifacts', appId, 'public', 'data', 'system_notifications'); await addDoc(emailLogRef, { to: 'timo@olearywelding.com', subject: `${formData.contactName}, ${formData.projectName} Drawings`, body: `Gemini can not read the files submitted by customer, review here: [Link to OWC Customer Project Folder]`, timestamp: serverTimestamp() }); setTimeout(() => { setIsLoading(false); setAiStatus('team_notified'); }, 1000); } catch (e) { setIsLoading(false); } }; const LandingPage = () => (

O'LEARY WELDING

The Industry's First AI-Powered Digital Marketplace for Structural Steel Fabrication.

System Overview

Interactive Tutorial

How OWC Ordering Works

); const CustomerInterface = () => (

1. Order Configuration

Please provide project details and logistics requirements.

Digital Interface

v2.4.1 LIVE

Customer Profile

{formData.customerType === 'Other' && (
)}
{(formData.customerType === 'Supplier' || formData.customerType === 'Fabricator') && (
{['yes', 'no'].map(opt => ( ))}
{formData.supplySteel === 'yes' && (
{['yes', 'no'].map(opt => ( ))}
)}
{['yes', 'no'].map(opt => ( ))}
{formData.customerPickup === 'yes' && (
{['yes', 'no'].map(opt => ( ))}
)}
)}

Contact Information

Project Information

); const DrawingAnalysis = () => (

2. Customer Drawings

Upload part drawings for Gemini AI analysis and Steel Pricing generation.

{aiStatus === 'idle' && (

DRAG & DROP DRAWINGS

Accepting PDF, DXF, NC1, and DWG. AI instantly calculates weight, pricing, and fabrication lead times.

)} {(aiStatus === 'uploading' || aiStatus === 'processing') && (

{aiStatus === 'uploading' ? 'SECURE UPLOADING...' : 'QUERYING PRICING GEM...'}

"Analyzing part geometry for precise weight and labor hour estimates."

)} {aiStatus === 'success' && (

ANALYSIS COMPLETE

File Status

Sub-folder "Drawings" created. Files stored successfully in OWC project directory.

)} {aiStatus === 'error' && (

FILE PARSING ERROR

"The files can not be read by our agent, select an option for next step"

or
)} {aiStatus === 'team_notified' && (

TEAM NOTIFIED

Email dispatched to timo@olearywelding.com.

Subject: {formData.contactName}, {formData.projectName} Drawings
)}
); const QuoteSummary = () => (
Official Project Quote

{formData.projectName}

Order Reference: OWC-{Math.floor(Math.random() * 90000) + 10000}

Estimated Delivery Window

July 22, 2024

Financial Breakdown

  • Structural Material {formData.supplySteel === 'yes' ? '(Owner Provided)' : ''} {formData.supplySteel === 'yes' ? '$0.00' : '$6,120.50'}
  • OWC Precision Fabrication $3,440.00
  • Logistics & Freight {formData.customerPickup === 'yes' ? '(Customer Pick-Up)' : ''} {formData.customerPickup === 'yes' ? '$0.00' : '$550.00'}
  • Order Total $10,110.50

Payment Link

"Confirm your order details. Upon clicking 'Pay Now', you will be redirected to our secure QuickBooks Online portal. Production scheduled immediately upon receipt."

End-to-End SSL OWC Security Hub Intuit Verified
); return (
{/* Navigation Header */}
{step === 0 && } {step === 1 && } {step === 2 && } {step === 3 && }

O'LEARY WELDING CO.

"Building America's skyline since 1998, one precision weld at a time. Merging traditional craft with cutting-edge Gemini AI."

Corporate Reach

Facility

Industrial Fabrication HQ
4400 Steelhouse Plaza
Indianapolis, IN 46201

© 2024 O'LEARY WELDING COMPANY. ALL RIGHTS RESERVED.

Privacy Terms of Sale Powered by OWC Steel Pricing Engine
); }; export default App;