"""Customer Portal - Track orders and receive updates.""" import streamlit as st from datetime import datetime, timedelta import time # Page configuration st.set_page_config( page_title="LogiFlow - Track Your Order", page_icon="πŸ“¦", layout="centered" ) # Custom CSS st.markdown(""" """, unsafe_allow_html=True) def render_tracking_header(): """Render the tracking page header.""" st.markdown("""

πŸ“¦ LogiFlow

AI-Powered Logistics Tracking

""", unsafe_allow_html=True) def render_order_search(): """Render order search form.""" st.markdown("### πŸ” Track Your Order") col1, col2 = st.columns([3, 1]) with col1: order_id = st.text_input( "Enter Order ID", placeholder="ORD-20240605-ABC12345", label_visibility="collapsed" ) with col2: search_btn = st.button("πŸ”Ž Track", use_container_width=True) return order_id, search_btn def render_tracking_timeline(): """Render tracking timeline.""" st.markdown("### πŸ“ Delivery Progress") # Sample tracking data events = [ {"time": "2 hours ago", "status": "Out for Delivery", "location": "Andheri West, Mumbai", "desc": "Your package is out for delivery"}, {"time": "5 hours ago", "status": "Arrived at Hub", "location": "Mumbai West Hub", "desc": "Package arrived at sorting facility"}, {"time": "8 hours ago", "status": "In Transit", "location": "Delhi Sorting Center", "desc": "Package on the way to Mumbai"}, {"time": "12 hours ago", "status": "Picked Up", "location": "Connaught Place, Delhi", "desc": "Package picked up by driver"}, {"time": "1 day ago", "status": "Order Confirmed", "location": "System", "desc": "Order placed and confirmed"}, ] for i, event in enumerate(events): is_completed = i == 0 # Latest is highlighted st.markdown(f"""

{event['time']}

{event['status']}

πŸ“ {event['location']}

{event['desc']}

""", unsafe_allow_html=True) def render_order_details(): """Render order details.""" st.markdown("### πŸ“‹ Order Details") col1, col2 = st.columns(2) with col1: st.markdown("""

πŸ“ Delivery Address

Rajesh Kumar

402, Sunshine Apartments

Andheri West, Mumbai - 400053

πŸ“ž +919876543210

""", unsafe_allow_html=True) with col2: st.markdown("""

πŸ“¦ Package Details

3 items

β€’ Wireless Headphones

β€’ Phone Case

β€’ Screen Protector

Total Weight: 0.8 kg

""", unsafe_allow_html=True) st.markdown("""

⏱️ Estimated Delivery

Today, 4:00 PM - 6:00 PM

On schedule - No delays expected

""", unsafe_allow_html=True) def render_delivery_partner(): """Render delivery partner info.""" st.markdown("### 🚴 Delivery Partner") col1, col2, col3 = st.columns([1, 2, 1]) with col1: st.markdown("""
πŸ‘€
""", unsafe_allow_html=True) with col2: st.markdown("""

Arun Sharma

Delivery Executive

πŸ›΅ Two-wheeler | MH 14 AB 1234

⭐ 4.8 rating (1,234 deliveries)

""", unsafe_allow_html=True) with col3: st.write("") st.write("") if st.button("πŸ“ž Call", use_container_width=True): st.info("Calling Arun Sharma...") if st.button("πŸ’¬ Chat", use_container_width=True): st.info("Opening chat...") def render_ai_assistant(): """Render AI assistant chat.""" st.markdown("### πŸ€– AI Assistant") # Initialize chat history if "messages" not in st.session_state: st.session_state.messages = [ {"role": "assistant", "content": "Hi! I'm your LogiFlow AI assistant. How can I help you today?"} ] # Display chat history for msg in st.session_state.messages: if msg["role"] == "user": st.markdown(f"""
{msg['content']}
""", unsafe_allow_html=True) else: st.markdown(f"""
πŸ€– {msg['content']}
""", unsafe_allow_html=True) # Chat input if prompt := st.chat_input("Ask me anything about your order..."): st.session_state.messages.append({"role": "user", "content": prompt}) # AI response if "where" in prompt.lower() or "track" in prompt.lower(): response = "Your order is currently out for delivery and should arrive by 4:00 PM today. You can see the live location on the map above!" elif "delay" in prompt.lower() or "late" in prompt.lower(): response = "Good news! Your order is on schedule with no delays. The estimated delivery time remains 4:00 PM - 6:00 PM today." elif "cancel" in prompt.lower(): response = "I understand you want to cancel. Unfortunately, your order is already out for delivery, so cancellation is no longer possible. Would you like me to reschedule the delivery instead?" elif "hello" in prompt.lower() or "hi" in prompt.lower(): response = "Hello! I'm here to help you track your order and answer any questions. Your package is doing great and should arrive soon! πŸ“¦" else: response = "I'm here to help! You can ask me about:\n- πŸ“ Current location of your order\n- ⏱️ Estimated delivery time\n- πŸ“‹ Order details\n- 🚚 Delivery partner info\n- ❓ Any other questions!" st.session_state.messages.append({"role": "assistant", "content": response}) st.rerun() def render_map_placeholder(): """Render map placeholder.""" st.markdown("### πŸ—ΊοΈ Live Tracking Map") st.markdown("""
πŸ—ΊοΈ

Live tracking map

Your delivery partner is currently at:

πŸ“ Andheri Metro Station, 2.3 km away

""", unsafe_allow_html=True) def render_quick_actions(): """Render quick action buttons.""" st.markdown("### ⚑ Quick Actions") col1, col2, col3, col4 = st.columns(4) with col1: if st.button("πŸ“ Track Order", use_container_width=True): st.info("Opening tracking view...") with col2: if st.button("πŸ“ž Call Support", use_container_width=True): st.info("Connecting to support...") with col3: if st.button("πŸ”„ Reschedule", use_container_width=True): st.warning("This will open the reschedule form") with col4: if st.button("❓ Help", use_container_width=True): st.info("Opening help center...") def render_delivery_schedule(): """Render delivery schedule.""" st.markdown("### πŸ“… Reschedule Delivery") with st.expander("Change Delivery Time"): st.write("**Select a new delivery slot:**") col1, col2, col3 = st.columns(3) with col1: st.write("**Today**") if st.button("2:00 PM - 4:00 PM", use_container_width=True): st.success("Delivery rescheduled to 2:00 PM - 4:00 PM today") if st.button("6:00 PM - 8:00 PM", use_container_width=True): st.success("Delivery rescheduled to 6:00 PM - 8:00 PM today") with col2: st.write("**Tomorrow**") if st.button("9:00 AM - 12:00 PM", use_container_width=True): st.success("Delivery rescheduled to tomorrow 9:00 AM - 12:00 PM") if st.button("2:00 PM - 6:00 PM", use_container_width=True): st.success("Delivery rescheduled to tomorrow 2:00 PM - 6:00 PM") with col3: st.write("**Custom**") custom_date = st.date_input("Select Date", datetime.now() + timedelta(days=1)) custom_time = st.time_input("Select Time", datetime.now().time()) if st.button("Apply Custom Schedule", use_container_width=True): st.success(f"Delivery rescheduled to {custom_date} at {custom_time}") def render_feedback(): """Render feedback section.""" st.markdown("### ⭐ Rate Your Experience") col1, col2, col3, col4, col5 = st.columns(5) ratings = ["😞", "😐", "πŸ™‚", "😊", "🀩"] selected = st.feedback(options="faces") if selected is not None: st.success(f"Thank you for your {ratings[selected]} feedback!") def render_notifications(): """Render notification preferences.""" st.markdown("### πŸ”” Notification Preferences") col1, col2 = st.columns(2) with col1: st.checkbox("πŸ“± SMS Notifications", value=True) st.checkbox("πŸ“§ Email Updates", value=True) with col2: st.checkbox("πŸ’¬ WhatsApp Updates", value=True) st.checkbox("πŸ”” Push Notifications", value=True) def main(): """Main customer portal function.""" # Tabs tab1, tab2, tab3, tab4 = st.tabs(["πŸ“ Track", "πŸ“‹ Details", "πŸ’¬ Help", "βš™οΈ Settings"]) with tab1: render_tracking_header() order_id, search = render_order_search() if order_id or search: render_map_placeholder() render_tracking_timeline() render_quick_actions() render_delivery_schedule() render_ai_assistant() with tab2: st.header("πŸ“‹ Order Details") render_order_details() render_delivery_partner() with tab3: st.header("πŸ’¬ Help & Support") st.markdown("### Frequently Asked Questions") with st.expander("πŸ“¦ Where is my order?"): st.write("Your order is currently out for delivery. Use the tracking tab above to see real-time location updates.") with st.expander("⏱️ When will my order arrive?"): st.write("Expected delivery is today between 4:00 PM - 6:00 PM. You can track the exact location in real-time.") with st.expander("πŸ”„ Can I reschedule delivery?"): st.write("Yes! You can reschedule your delivery to any available time slot. Go to the Track tab and use the reschedule option.") with st.expander("❌ Can I cancel my order?"): st.write("Cancellation is possible only before the order is dispatched. Once out for delivery, you can reschedule instead.") with st.expander("πŸ“ž How do I contact support?"): st.write("You can call our 24/7 support at 1800-123-4567 or use the in-app chat for instant assistance.") st.markdown("### Contact Us") st.write("πŸ“ž 1800-123-4567 (Toll Free)") st.write("πŸ“§ support@logiflow.ai") st.write("πŸ’¬ Chat with us (Available 24/7)") with tab4: st.header("βš™οΈ Settings") st.markdown("### πŸ“± Communication Preferences") render_notifications() st.markdown("### πŸ” Account") st.write("**Email:** rajesh@example.com") st.write("**Phone:** +919876543210") st.write("**Member since:** January 2024") if st.button("✏️ Edit Profile"): st.info("Profile editing coming soon!") if st.button("πŸšͺ Sign Out"): st.warning("Sign out functionality coming soon!") if __name__ == "__main__": main()