import React, { useState, useEffect, useRef } from 'react'; import { Printer, FileText, CreditCard, ShieldCheck, User, Phone, MapPin, Mail, Upload, CheckCircle, Clock, AlertCircle, Lock, LogOut, ShoppingBag, Settings, Plus, Trash2, Edit3, QrCode, Download, Volume2, ChevronRight, Eye, FileCheck, Search, RefreshCw, TrendingUp, FileSpreadsheet } from 'lucide-react'; // Main Web Application Component export default function App() { // Navigation & User State const [activeTab, setActiveTab] = useState('services'); // services, orders, profile, admin const [user, setUser] = useState(() => { const saved = localStorage.getItem('narayan_user'); return saved ? JSON.parse(saved) : null; }); // Auth Modals & Form State const [authModal, setAuthModal] = useState({ open: false, mode: 'login' }); // 'login', 'register', 'forgot' const [adminPin, setAdminPin] = useState(''); const [isAdminAuthenticated, setIsAdminAuthenticated] = useState(() => { return localStorage.getItem('narayan_admin_auth') === 'true'; }); // Services Catalog State (Dukandaar can update rates dynamically) const [services, setServices] = useState(() => { const saved = localStorage.getItem('narayan_services'); return saved ? JSON.parse(saved) : [ { id: 'pdf', title: 'PDF Document Print', icon: 'FileText', badge: 'Tiered Pricing', requiresUpload: true, fields: ['pdfFile'] }, { id: 'photo', title: 'Passport Photo Print (6 Pcs)', price: 40, icon: 'Printer', requiresUpload: true, fields: ['photo'] }, { id: 'aadhar', title: 'Aadhar Card Print', price: 50, icon: 'ShieldCheck', requiresUpload: true, fields: ['aadhar'] }, { id: 'voter', title: 'Voter Card Print', price: 50, icon: 'CreditCard', requiresUpload: true, fields: ['voter'] }, { id: 'new_pan', title: 'New PAN Card Apply', price: 200, icon: 'FileCheck', requiresUpload: true, fields: ['aadhar', 'birthCert'] }, { id: 'pan_corr', title: 'PAN Card Correction', price: 300, icon: 'Edit3', requiresUpload: true, fields: ['aadhar', 'birthCert'] }, { id: 'new_gst', title: 'New GST Registration', price: 1500, icon: 'TrendingUp', requiresUpload: true, fields: ['aadhar', 'pan', 'photo', 'electricity'] }, { id: 'itr', title: 'ITR Filing', price: 1200, icon: 'FileSpreadsheet', requiresUpload: true, fields: ['aadhar', 'pan', 'bankStatement'] } ]; }); // Orders State const [orders, setOrders] = useState(() => { const saved = localStorage.getItem('narayan_orders'); return saved ? JSON.parse(saved) : [ { id: 'NC-98421', customerName: 'Rahul Kumar', mobile: '9876543210', address: 'Main Road, Near Hanuman Mandir, Patna', serviceName: 'Aadhar Card Print', amount: 50, status: 'Completed', date: new Date(Date.now() - 86400000).toLocaleString(), paymentStatus: 'Paid (UPI)', files: [{ name: 'Aadhar_Doc.pdf', type: 'aadhar' }] } ]; }); // Selected Service for Ordering const [selectedService, setSelectedService] = useState(null); const [pdfPageCount, setPdfPageCount] = useState(1); const [uploadedFiles, setUploadedFiles] = useState({}); const [activePaymentOrder, setActivePaymentOrder] = useState(null); const [receiptOrder, setReceiptOrder] = useState(null); // Audio simulation for New Order alert in Dukandaar portal const playAlertSound = () => { try { const ctx = new (window.AudioContext || window.webkitAudioContext)(); const osc = ctx.createOscillator(); const gain = ctx.createGain(); osc.type = 'sine'; osc.frequency.setValueAtTime(587.33, ctx.currentTime); // D5 osc.frequency.setValueAtTime(880, ctx.currentTime + 0.15); // A5 gain.gain.setValueAtTime(0.3, ctx.currentTime); osc.connect(gain); gain.connect(ctx.destination); osc.start(); osc.stop(ctx.currentTime + 0.4); } catch (e) { console.log('Audio alert allowed after interaction'); } }; // Save changes to localStorage useEffect(() => { localStorage.setItem('narayan_orders', JSON.stringify(orders)); }, [orders]); useEffect(() => { localStorage.setItem('narayan_services', JSON.stringify(services)); }, [services]); // Handle PDF Price Calculation Tier const calculatePdfPrice = (pages) => { const count = parseInt(pages) || 1; if (count === 1) return 10; if (count >= 10 && count <= 50) return count * 5; if (count > 50) return count * 3; return count * 10; // Default for 2-9 pages }; // Auth Submit Handlers const handleAuthSubmit = (e) => { e.preventDefault(); const formData = new FormData(e.target); const data = Object.fromEntries(formData.entries()); if (authModal.mode === 'register') { const newUser = { name: data.name, address: data.address, mobile: data.mobile, email: data.email, password: data.password }; localStorage.setItem('narayan_user_' + data.mobile, JSON.stringify(newUser)); setUser(newUser); localStorage.setItem('narayan_user', JSON.stringify(newUser)); setAuthModal({ open: false, mode: 'login' }); } else if (authModal.mode === 'login') { const saved = localStorage.getItem('narayan_user_' + data.mobile); if (saved) { const parsed = JSON.parse(saved); if (parsed.password === data.password) { setUser(parsed); localStorage.setItem('narayan_user', JSON.stringify(parsed)); setAuthModal({ open: false, mode: 'login' }); } else { alert('Incorrect Password! Please try again.'); } } else { // Fallback quick simulation login const tempUser = { name: 'Customer', mobile: data.mobile, address: 'Patna, Bihar' }; setUser(tempUser); localStorage.setItem('narayan_user', JSON.stringify(tempUser)); setAuthModal({ open: false, mode: 'login' }); } } else if (authModal.mode === 'forgot') { alert('Password reset link sent to your mobile via SMS simulation.'); setAuthModal({ open: false, mode: 'login' }); } }; const handleLogout = () => { setUser(null); localStorage.removeItem('narayan_user'); setIsAdminAuthenticated(false); localStorage.removeItem('narayan_admin_auth'); }; const handleAdminLogin = (e) => { e.preventDefault(); if (adminPin === '703388') { // Dukandaar PIN setIsAdminAuthenticated(true); localStorage.setItem('narayan_admin_auth', 'true'); setActiveTab('admin'); } else { alert('Invalid Admin PIN! Default PIN is 703388'); } }; // Handle File Input Simulation const handleFileUpload = (fieldName, e) => { const file = e.target.files[0]; if (file) { setUploadedFiles(prev => ({ ...prev, [fieldName]: { name: file.name, size: (file.size / 1024).toFixed(1) + ' KB' } })); } }; // Create Order and Prompt Payment Modal const initiateOrder = (service) => { if (!user) { setAuthModal({ open: true, mode: 'login' }); return; } let calculatedAmount = service.price || 0; if (service.id === 'pdf') { calculatedAmount = calculatePdfPrice(pdfPageCount); } // Check required uploads const required = service.fields || []; const missing = required.filter(f => !uploadedFiles[f]); if (missing.length > 0) { alert(`Please upload all required documents (${missing.join(', ')}) before proceeding to payment.`); return; } const orderId = 'NC-' + Math.floor(10000 + Math.random() * 90000); const newOrder = { id: orderId, customerName: user.name, mobile: user.mobile, address: user.address || 'Self Pick-up / Local Address', serviceName: service.title + (service.id === 'pdf' ? ` (${pdfPageCount} Pages)` : ''), amount: calculatedAmount, status: 'Pending', date: new Date().toLocaleString(), paymentStatus: 'Payment Pending', files: Object.keys(uploadedFiles).map(k => ({ type: k, name: uploadedFiles[k].name })) }; setActivePaymentOrder(newOrder); }; // Confirm Payment & Trigger Store Alert const confirmPayment = () => { if (!activePaymentOrder) return; const finalizedOrder = { ...activePaymentOrder, paymentStatus: 'Paid (UPI)', status: 'Received' }; setOrders(prev => [finalizedOrder, ...prev]); playAlertSound(); setReceiptOrder(finalizedOrder); setActivePaymentOrder(null); setSelectedService(null); setUploadedFiles({}); }; // Dukandaar update order status const updateOrderStatus = (orderId, newStatus) => { setOrders(prev => prev.map(o => o.id === orderId ? { ...o, status: newStatus } : o)); }; return (
{/* HEADER SECTION */}
{/* Shop Title & Contact */}
setActiveTab('services')}>

NARAYAN COMPUTER AND CYBER CAFE

📞 Call / WhatsApp: +91 70338 86620 ONLINE 24/7

{/* Navigation Controls */}
{user && ( )} {/* User Profile / Auth Toggle */} {user ? (

{user.name}

{user.mobile}

) : ( )}
{/* HERO / NOTICE BANNER */}

Ghar Baith Kar Document Print & Apply Karein! 🖨️

Upload files, pay instantly via UPI/Scanner, and get printing & online service delivery right at your door or instant shop pickup.

Official Shop Scanner UPI ID: 7033886620@okbizaxis
{/* MAIN CONTENT CONTAINERS */}
{/* TAB 1: CUSTOMER SERVICES VIEW */} {activeTab === 'services' && (

Select Service & Upload Documents

Fast document printing, PAN, GST, and ITR services

{/* SERVICES GRID */}
{/* SPECIAL TIERS PDF PRINT CARD */}
Popular Service

PDF Document Print

Tiered discount pricing based on document page count.

{/* Dynamic Rate Info Chart */}
• 1 Page: ₹10 / Page
• 10 to 50 Pages: ₹5 / Page
• 50 to 500 Pages: ₹3 / Page
{/* PDF Calculator Input */}
setPdfPageCount(Math.max(1, parseInt(e.target.value) || 1))} className="w-full border rounded-lg px-3 py-2 text-sm font-semibold text-slate-800 focus:ring-2 focus:ring-blue-500" />
Calculated Total: ₹{calculatePdfPrice(pdfPageCount)}
{/* File Upload Box */}
handleFileUpload('pdfFile', e)} className="hidden" id="pdf-file-input" />
{/* OTHER DYNAMIC SERVICES CARDS */} {services.filter(s => s.id !== 'pdf').map((service) => (
₹{service.price}

{service.title}

Upload required documents to submit online request.

{/* Required Documents Upload list */}
{service.fields && service.fields.map((field) => (
{field.replace(/([A-Z])/g, ' $1')} File
))}
))}
)} {/* TAB 2: MY ORDERS & STATUS TRACKING */} {activeTab === 'orders' && user && (

My Print & Service Orders

{orders.filter(o => o.mobile === user.mobile).length === 0 ? (

No active or past orders found.

) : (
{orders.filter(o => o.mobile === user.mobile).map((order) => (
{order.id} {order.date}

{order.serviceName}

Delivery Address: {order.address}

₹{order.amount} {order.paymentStatus}
{/* Status Indicator Badge */} {order.status} {/* Download Receipt Button */}
))}
)}
)} {/* TAB 3: DUKANDAAR / ADMIN DASHBOARD */} {activeTab === 'admin' && (
{!isAdminAuthenticated ? ( /* Admin PIN Login Form */

Dukandaar Access Portal

Enter shop owner pin to control customer orders and services

setAdminPin(e.target.value)} className="w-full px-4 py-2.5 border rounded-xl text-center text-lg tracking-widest font-bold focus:ring-2 focus:ring-emerald-500" maxLength={6} />
) : ( /* Authenticated Admin Dashboard */
{/* Top Control Bar */}

DUKANDAAR CONTROL CENTER

Manage orders, update rates, and view customer uploads

{/* ORDERS MANAGEMENT TABLE */}

Incoming Customer Orders ({orders.length})

{orders.map((o) => ( ))}
Order ID & Date Customer Details Service & Amount Uploaded Documents Status Control
{o.id} {o.date} {o.customerName} 📞 {o.mobile} 🏠 {o.address} {o.serviceName} ₹{o.amount} ({o.paymentStatus}) {o.files && o.files.length > 0 ? (
{o.files.map((f, i) => ( {f.name} ))}
) : ( No files )}
{/* SERVICE CATALOG EDITOR (DUKANDAAR DYNAMIC ADD/EDIT) */}

Manage Shop Services & Rates

{services.map((s) => (
{s.title} {s.id === 'pdf' ? 'Tiered Rates (10/5/3)' : `Rate: ₹${s.price}`}
{s.id !== 'pdf' && ( { const newPrice = parseInt(e.target.value) || 0; setServices(prev => prev.map(serv => serv.id === s.id ? { ...serv, price: newPrice } : serv)); }} className="w-20 border rounded px-2 py-1 text-xs text-right font-bold" /> )}
))}
)}
)}
{/* MODAL 1: AUTHENTICATION (LOGIN / REGISTER / FORGOT) */} {authModal.open && (

{authModal.mode === 'login' && 'Customer Login'} {authModal.mode === 'register' && 'New Account Registration'} {authModal.mode === 'forgot' && 'Reset Password'}

{authModal.mode === 'register' && ( <>
)}
{authModal.mode !== 'forgot' && (
)}
{authModal.mode === 'login' ? ( <>

Don't have an account?

) : (

Already have an account?

)}
)} {/* MODAL 2: DYNAMIC UPI PAYMENT GATEWAY & SCANNER */} {activePaymentOrder && (
{/* Header */}

UPI / SCANNER PAYMENT GATEWAY

NARAYAN COMPUTER AND CYBER CAFE

Total Payable Amount ₹{activePaymentOrder.amount}

{activePaymentOrder.serviceName}

{/* DYNAMIC QR CODE DISPLAY */}
Dynamic UPI QR Scanner

Scan & Pay using GPay, PhonePe, Paytm

UPI ID: 7033886620@okbizaxis

📌 Payment Alert Note: After paying via Google Pay or PhonePe scanner, click below to confirm. The store owner will automatically receive an order alert.
)} {/* MODAL 3: DIGITAL BILL RECEIPT */} {receiptOrder && (

NARAYAN COMPUTER

Cyber Cafe & Online Digital Services

Mobile: +91 70338 86620

Bill Order ID: {receiptOrder.id}
Date & Time: {receiptOrder.date}
Customer Name: {receiptOrder.customerName}
Mobile Number: {receiptOrder.mobile}
Service Chosen: {receiptOrder.serviceName}
Total Amount Paid: ₹{receiptOrder.amount}
Payment Status: {receiptOrder.paymentStatus}
)} {/* FOOTER */}
); }