import { useState, useEffect } from 'react'; import { Dialog, DialogContent, DialogDescription, DialogTitle } from '../ui/dialog'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card'; import { Button } from '../ui/button'; import { Badge } from '../ui/badge'; import { Separator } from '../ui/separator'; import { Receipt, Package, ArrowRight, ArrowLeft, Clock, CheckCircle, Target, Sparkles, Check, AlertCircle } from 'lucide-react'; import { motion, AnimatePresence } from 'framer-motion'; import { TokenManager } from '../../utils/tokenManager'; interface TemplateSelectionModalProps { open: boolean; onClose: () => void; onSelectTemplate: (templateId: string) => void; } const AVAILABLE_TEMPLATES = [ { id: 'claim-management', name: 'Claim Management', description: 'End-to-end dealer claim processing workflow with automatic IO generation and budget blocking', category: 'Dealer Operations', icon: Receipt, color: 'from-blue-500 to-indigo-600', estimatedTime: '5-7 days', steps: 7, features: [ 'Automatic IO confirmation', 'Budget blocking', 'Document verification', 'E-invoice generation', 'Credit note issuance' ], disabled: false }, { id: 'vendor-payment', name: 'Vendor Payment', description: 'Streamlined vendor payment approval with PO validation and financial controls', category: 'Finance', icon: Package, color: 'from-green-500 to-emerald-600', estimatedTime: '3-5 days', steps: 5, features: [ 'PO matching', 'Invoice verification', 'Multi-level approvals', 'Payment scheduling' ], disabled: true, comingSoon: true } ]; export function TemplateSelectionModal({ open, onClose, onSelectTemplate }: TemplateSelectionModalProps) { const [selectedTemplate, setSelectedTemplate] = useState(null); const [isDealer, setIsDealer] = useState(false); // Check if user is a Dealer useEffect(() => { const userData = TokenManager.getUserData(); setIsDealer(userData?.jobTitle === 'Dealer'); }, []); const handleSelect = (templateId: string) => { // Don't allow selection if user is a dealer if (isDealer) { return; } // Don't allow selection if template is disabled const template = AVAILABLE_TEMPLATES.find(t => t.id === templateId); if (template?.disabled) { return; } setSelectedTemplate(templateId); }; const handleContinue = () => { if (selectedTemplate) { onSelectTemplate(selectedTemplate); onClose(); } }; return ( {/* Accessibility - Hidden Title and Description */} Select a Template Choose from pre-configured templates with predefined workflows and approval chains for faster processing. {/* Back arrow button - Top left */} {/* Full Screen Content Container */}
{/* Header Section */}

Choose Your Template

Select from pre-configured templates with predefined workflows and approval chains for faster processing.

{/* Template Cards Grid */}
{AVAILABLE_TEMPLATES.map((template, index) => { const Icon = template.icon; const isSelected = selectedTemplate === template.id; const isDisabled = isDealer || template.disabled; return ( handleSelect(template.id)} >
{isSelected && (
)}
{template.name} {template.description} {isDealer && (

Not accessible for Dealers

)} {template.comingSoon && !isDealer && (

Coming Soon

)}
{template.category}
{template.estimatedTime}
{template.steps} steps

Key Features:

{template.features.slice(0, 3).map((feature, idx) => (
{feature}
))} {template.features.length > 3 && (

+{template.features.length - 3} more features

)}
); })}
{/* Action Buttons */} {/* Selected template indicator */} {selectedTemplate && (

Selected: {AVAILABLE_TEMPLATES.find(t => t.id === selectedTemplate)?.name}

)}
); }