Spaces:
Running
Running
Download index.html from Spriddle/frito-lay-test: direct link, hf CLI and curl.
- Browser
- Download file 39.7 kB
-
https://huggingface.co/spaces/Spriddle/frito-lay-test/resolve/main/index.html
- Command line
-
hf download hf://spaces/Spriddle/frito-lay-test/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Spriddle/frito-lay-test/resolve/main/index.html
39.7 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Frito-Lay Store Management</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .gradient-bg { | |
| background: linear-gradient(135deg, #004B87 0%, #00A3E0 100%); | |
| } | |
| .store-card:hover { | |
| transform: translateY(-5px); | |
| box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1); | |
| } | |
| .time-picker { | |
| -webkit-appearance: none; | |
| -moz-appearance: none; | |
| appearance: none; | |
| } | |
| .day-selector input[type="checkbox"]:checked + label { | |
| background-color: #004B87; | |
| color: white; | |
| } | |
| .slide-in { | |
| animation: slideIn 0.3s ease-out forwards; | |
| } | |
| @keyframes slideIn { | |
| from { transform: translateX(100%); opacity: 0; } | |
| to { transform: translateX(0); opacity: 1; } | |
| } | |
| </style> | |
| </head> | |
| <body class="bg-gray-50 min-h-screen font-sans"> | |
| <!-- Login Screen --> | |
| <div id="loginScreen" class="fixed inset-0 flex items-center justify-center gradient-bg z-50 transition-all duration-300"> | |
| <div class="bg-white p-8 rounded-xl shadow-2xl w-full max-w-md"> | |
| <div class="flex justify-center mb-6"> | |
| <img src="https://www.pepsico.com/images/pepsico-logo.svg" alt="Pepsico Logo" class="h-16"> | |
| </div> | |
| <h2 class="text-2xl font-bold text-center text-gray-800 mb-2">Frito-Lay Store Management</h2> | |
| <p class="text-gray-600 text-center mb-8">Please sign in with your Pepsico ID</p> | |
| <form id="loginForm" class="space-y-4"> | |
| <div> | |
| <label for="pepsicoId" class="block text-sm font-medium text-gray-700 mb-1">Pepsico ID</label> | |
| <input type="text" id="pepsicoId" name="pepsicoId" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| placeholder="Enter your Pepsico ID" required> | |
| </div> | |
| <div> | |
| <label for="password" class="block text-sm font-medium text-gray-700 mb-1">Password</label> | |
| <input type="password" id="password" name="password" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| placeholder="Enter your password" required> | |
| </div> | |
| <button type="submit" class="w-full gradient-bg text-white py-2 px-4 rounded-lg font-medium hover:opacity-90 transition duration-200"> | |
| Sign In | |
| </button> | |
| </form> | |
| <div class="mt-6 text-center text-sm text-gray-600"> | |
| <p>Need help? Contact IT Support at 1-800-PEPSICO</p> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Main App --> | |
| <div id="appContainer" class="hidden"> | |
| <!-- Header --> | |
| <header class="gradient-bg text-white shadow-md"> | |
| <div class="container mx-auto px-4 py-3 flex justify-between items-center"> | |
| <div class="flex items-center space-x-2"> | |
| <img src="https://www.fritolay.com/images/default-source/default-album/frito-lay-logo.png" alt="Frito-Lay Logo" class="h-10"> | |
| <span class="text-xl font-bold">Store Management</span> | |
| </div> | |
| <div class="flex items-center space-x-4"> | |
| <button id="shareBtn" class="bg-white text-blue-800 px-4 py-1 rounded-full text-sm font-medium flex items-center hover:bg-gray-100"> | |
| <i class="fas fa-share-alt mr-2"></i> Share | |
| </button> | |
| <div class="flex items-center space-x-2"> | |
| <div class="w-8 h-8 rounded-full bg-white flex items-center justify-center text-blue-800 font-bold"> | |
| <span id="userInitials">US</span> | |
| </div> | |
| <span id="userIdDisplay" class="font-medium">user@pepsico.com</span> | |
| </div> | |
| </div> | |
| </div> | |
| </header> | |
| <!-- Main Content --> | |
| <main class="container mx-auto px-4 py-6"> | |
| <!-- Store List Header --> | |
| <div class="flex justify-between items-center mb-6"> | |
| <h1 class="text-2xl font-bold text-gray-800">My Stores</h1> | |
| <button id="addStoreBtn" class="gradient-bg text-white px-4 py-2 rounded-lg flex items-center hover:opacity-90"> | |
| <i class="fas fa-plus mr-2"></i> Add Store | |
| </button> | |
| </div> | |
| <!-- Store Cards Grid --> | |
| <div id="storeList" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6"> | |
| <!-- Store cards will be dynamically added here --> | |
| </div> | |
| <!-- Empty State --> | |
| <div id="emptyState" class="text-center py-16"> | |
| <i class="fas fa-store-alt text-4xl text-gray-300 mb-4"></i> | |
| <h3 class="text-xl font-medium text-gray-600 mb-2">No stores added yet</h3> | |
| <p class="text-gray-500 mb-4">Add your first store to get started</p> | |
| <button id="emptyAddStoreBtn" class="gradient-bg text-white px-6 py-2 rounded-lg hover:opacity-90"> | |
| Add Store | |
| </button> | |
| </div> | |
| </main> | |
| <!-- Add Store Modal --> | |
| <div id="addStoreModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto slide-in"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-xl font-bold text-gray-800">Add New Store</h3> | |
| <button id="closeModalBtn" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <form id="storeForm" class="space-y-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label for="storeName" class="block text-sm font-medium text-gray-700 mb-1">Store Name</label> | |
| <input type="text" id="storeName" name="storeName" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| placeholder="e.g. Walmart #1234" required> | |
| </div> | |
| <div> | |
| <label for="storeAddress" class="block text-sm font-medium text-gray-700 mb-1">Address</label> | |
| <input type="text" id="storeAddress" name="storeAddress" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| placeholder="123 Main St, City, State" required> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <label for="storePhone" class="block text-sm font-medium text-gray-700 mb-1">Phone Number</label> | |
| <input type="tel" id="storePhone" name="storePhone" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| placeholder="(555) 123-4567"> | |
| </div> | |
| <div> | |
| <label for="storeManager" class="block text-sm font-medium text-gray-700 mb-1">Store Manager</label> | |
| <input type="text" id="storeManager" name="storeManager" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| placeholder="Manager Name"> | |
| </div> | |
| </div> | |
| <div class="border-t border-gray-200 pt-4"> | |
| <h4 class="text-lg font-medium text-gray-800 mb-3">Delivery Schedule</h4> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4"> | |
| <div> | |
| <label for="openTime" class="block text-sm font-medium text-gray-700 mb-1">Store Opens At</label> | |
| <input type="time" id="openTime" name="openTime" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg time-picker focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| required> | |
| </div> | |
| <div> | |
| <label for="deliveryTime" class="block text-sm font-medium text-gray-700 mb-1">Delivery Window</label> | |
| <input type="time" id="deliveryTime" name="deliveryTime" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg time-picker focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| required> | |
| </div> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-2">Delivery Days</label> | |
| <div class="day-selector flex flex-wrap gap-2"> | |
| <input type="checkbox" id="monday" name="deliveryDays" value="Monday" class="hidden"> | |
| <label for="monday" class="px-3 py-1 border border-gray-300 rounded-full text-sm cursor-pointer hover:bg-gray-100">Mon</label> | |
| <input type="checkbox" id="tuesday" name="deliveryDays" value="Tuesday" class="hidden"> | |
| <label for="tuesday" class="px-3 py-1 border border-gray-300 rounded-full text-sm cursor-pointer hover:bg-gray-100">Tue</label> | |
| <input type="checkbox" id="wednesday" name="deliveryDays" value="Wednesday" class="hidden"> | |
| <label for="wednesday" class="px-3 py-1 border border-gray-300 rounded-full text-sm cursor-pointer hover:bg-gray-100">Wed</label> | |
| <input type="checkbox" id="thursday" name="deliveryDays" value="Thursday" class="hidden"> | |
| <label for="thursday" class="px-3 py-1 border border-gray-300 rounded-full text-sm cursor-pointer hover:bg-gray-100">Thu</label> | |
| <input type="checkbox" id="friday" name="deliveryDays" value="Friday" class="hidden"> | |
| <label for="friday" class="px-3 py-1 border border-gray-300 rounded-full text-sm cursor-pointer hover:bg-gray-100">Fri</label> | |
| <input type="checkbox" id="saturday" name="deliveryDays" value="Saturday" class="hidden"> | |
| <label for="saturday" class="px-3 py-1 border border-gray-300 rounded-full text-sm cursor-pointer hover:bg-gray-100">Sat</label> | |
| <input type="checkbox" id="sunday" name="deliveryDays" value="Sunday" class="hidden"> | |
| <label for="sunday" class="px-3 py-1 border border-gray-300 rounded-full text-sm cursor-pointer hover:bg-gray-100">Sun</label> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="border-t border-gray-200 pt-4"> | |
| <label for="storeNotes" class="block text-sm font-medium text-gray-700 mb-1">Notes</label> | |
| <textarea id="storeNotes" name="storeNotes" rows="3" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| placeholder="Any special instructions or notes about this store..."></textarea> | |
| </div> | |
| <div class="flex justify-end space-x-3 pt-4"> | |
| <button type="button" id="cancelStoreBtn" class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50"> | |
| Cancel | |
| </button> | |
| <button type="submit" class="gradient-bg text-white px-6 py-2 rounded-lg hover:opacity-90"> | |
| Save Store | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Share Modal --> | |
| <div id="shareModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-xl shadow-xl w-full max-w-md slide-in"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-xl font-bold text-gray-800">Share Store Information</h3> | |
| <button id="closeShareModalBtn" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| <div class="space-y-4"> | |
| <div> | |
| <label for="sharePepsicoId" class="block text-sm font-medium text-gray-700 mb-1">Pepsico ID to share with</label> | |
| <input type="text" id="sharePepsicoId" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" | |
| placeholder="Enter Pepsico ID"> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-2">Stores to share</label> | |
| <div id="shareStoreList" class="max-h-60 overflow-y-auto border border-gray-200 rounded-lg p-2 space-y-2"> | |
| <!-- Stores will be added here with checkboxes --> | |
| </div> | |
| </div> | |
| <div class="flex justify-end space-x-3 pt-2"> | |
| <button id="cancelShareBtn" class="px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50"> | |
| Cancel | |
| </button> | |
| <button id="confirmShareBtn" class="gradient-bg text-white px-6 py-2 rounded-lg hover:opacity-90"> | |
| Share | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Store Detail Modal --> | |
| <div id="storeDetailModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden"> | |
| <div class="bg-white rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto slide-in"> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 id="detailStoreName" class="text-xl font-bold text-gray-800">Store Details</h3> | |
| <div class="flex space-x-2"> | |
| <button id="editStoreBtn" class="text-blue-600 hover:text-blue-800"> | |
| <i class="fas fa-edit"></i> | |
| </button> | |
| <button id="deleteStoreBtn" class="text-red-600 hover:text-red-800"> | |
| <i class="fas fa-trash-alt"></i> | |
| </button> | |
| <button id="closeDetailModalBtn" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <div class="space-y-4"> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <p class="text-sm font-medium text-gray-500">Address</p> | |
| <p id="detailStoreAddress" class="text-gray-800">123 Main St, City, State</p> | |
| </div> | |
| <div> | |
| <p class="text-sm font-medium text-gray-500">Phone</p> | |
| <p id="detailStorePhone" class="text-gray-800">(555) 123-4567</p> | |
| </div> | |
| </div> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> | |
| <div> | |
| <p class="text-sm font-medium text-gray-500">Store Manager</p> | |
| <p id="detailStoreManager" class="text-gray-800">John Smith</p> | |
| </div> | |
| <div> | |
| <p class="text-sm font-medium text-gray-500">Added By</p> | |
| <p id="detailAddedBy" class="text-gray-800">user@pepsico.com</p> | |
| </div> | |
| </div> | |
| <div class="border-t border-gray-200 pt-4"> | |
| <h4 class="text-lg font-medium text-gray-800 mb-3">Delivery Schedule</h4> | |
| <div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-4"> | |
| <div> | |
| <p class="text-sm font-medium text-gray-500">Store Opens At</p> | |
| <p id="detailOpenTime" class="text-gray-800">8:00 AM</p> | |
| </div> | |
| <div> | |
| <p class="text-sm font-medium text-gray-500">Delivery Window</p> | |
| <p id="detailDeliveryTime" class="text-gray-800">10:00 AM - 2:00 PM</p> | |
| </div> | |
| </div> | |
| <div> | |
| <p class="text-sm font-medium text-gray-500">Delivery Days</p> | |
| <div id="detailDeliveryDays" class="flex flex-wrap gap-2 mt-1"> | |
| <!-- Days will be added here --> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="border-t border-gray-200 pt-4"> | |
| <p class="text-sm font-medium text-gray-500 mb-1">Notes</p> | |
| <p id="detailStoreNotes" class="text-gray-800 whitespace-pre-line">Special instructions for this store...</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Toast Notification --> | |
| <div id="toast" class="fixed bottom-4 right-4 bg-green-600 text-white px-6 py-3 rounded-lg shadow-lg flex items-center space-x-3 transform translate-y-10 opacity-0 transition-all duration-300 z-50"> | |
| <i class="fas fa-check-circle"></i> | |
| <span id="toastMessage">Action completed successfully</span> | |
| </div> | |
| </div> | |
| <script> | |
| // Sample data storage (in a real app, this would be replaced with API calls) | |
| let stores = []; | |
| let currentUser = null; | |
| let editingStoreId = null; | |
| // DOM Elements | |
| const loginScreen = document.getElementById('loginScreen'); | |
| const appContainer = document.getElementById('appContainer'); | |
| const loginForm = document.getElementById('loginForm'); | |
| const pepsicoIdInput = document.getElementById('pepsicoId'); | |
| const userInitials = document.getElementById('userInitials'); | |
| const userIdDisplay = document.getElementById('userIdDisplay'); | |
| const storeList = document.getElementById('storeList'); | |
| const emptyState = document.getElementById('emptyState'); | |
| const addStoreBtn = document.getElementById('addStoreBtn'); | |
| const emptyAddStoreBtn = document.getElementById('emptyAddStoreBtn'); | |
| const addStoreModal = document.getElementById('addStoreModal'); | |
| const closeModalBtn = document.getElementById('closeModalBtn'); | |
| const storeForm = document.getElementById('storeForm'); | |
| const cancelStoreBtn = document.getElementById('cancelStoreBtn'); | |
| const shareBtn = document.getElementById('shareBtn'); | |
| const shareModal = document.getElementById('shareModal'); | |
| const closeShareModalBtn = document.getElementById('closeShareModalBtn'); | |
| const cancelShareBtn = document.getElementById('cancelShareBtn'); | |
| const confirmShareBtn = document.getElementById('confirmShareBtn'); | |
| const shareStoreList = document.getElementById('shareStoreList'); | |
| const storeDetailModal = document.getElementById('storeDetailModal'); | |
| const closeDetailModalBtn = document.getElementById('closeDetailModalBtn'); | |
| const editStoreBtn = document.getElementById('editStoreBtn'); | |
| const deleteStoreBtn = document.getElementById('deleteStoreBtn'); | |
| const toast = document.getElementById('toast'); | |
| // Event Listeners | |
| loginForm.addEventListener('submit', handleLogin); | |
| addStoreBtn.addEventListener('click', showAddStoreModal); | |
| emptyAddStoreBtn.addEventListener('click', showAddStoreModal); | |
| closeModalBtn.addEventListener('click', hideAddStoreModal); | |
| cancelStoreBtn.addEventListener('click', hideAddStoreModal); | |
| storeForm.addEventListener('submit', saveStore); | |
| shareBtn.addEventListener('click', showShareModal); | |
| closeShareModalBtn.addEventListener('click', hideShareModal); | |
| cancelShareBtn.addEventListener('click', hideShareModal); | |
| confirmShareBtn.addEventListener('click', shareStores); | |
| closeDetailModalBtn.addEventListener('click', hideStoreDetailModal); | |
| editStoreBtn.addEventListener('click', editStore); | |
| deleteStoreBtn.addEventListener('click', deleteStore); | |
| // Initialize the app | |
| function init() { | |
| // Check if user is already logged in (in a real app, this would check localStorage or cookies) | |
| const loggedIn = false; | |
| if (loggedIn) { | |
| // Load user data and stores | |
| } else { | |
| loginScreen.classList.remove('hidden'); | |
| } | |
| } | |
| // Handle login | |
| function handleLogin(e) { | |
| e.preventDefault(); | |
| const pepsicoId = pepsicoIdInput.value.trim(); | |
| const password = document.getElementById('password').value; | |
| // Basic validation | |
| if (!pepsicoId || !password) { | |
| showToast('Please enter both Pepsico ID and password'); | |
| return; | |
| } | |
| // In a real app, this would be an API call to verify credentials | |
| // For demo purposes, we'll just accept any non-empty credentials | |
| currentUser = { | |
| id: pepsicoId, | |
| email: `${pepsicoId}@pepsico.com` | |
| }; | |
| // Update UI | |
| userInitials.textContent = getInitials(currentUser.email); | |
| userIdDisplay.textContent = currentUser.email; | |
| // Transition to main app | |
| loginScreen.classList.add('opacity-0'); | |
| setTimeout(() => { | |
| loginScreen.classList.add('hidden'); | |
| appContainer.classList.remove('hidden'); | |
| loadStores(); | |
| }, 300); | |
| } | |
| // Load stores for current user | |
| function loadStores() { | |
| // In a real app, this would fetch from an API | |
| // For demo, we'll use sample data | |
| stores = [ | |
| { | |
| id: '1', | |
| name: 'Walmart #1234', | |
| address: '123 Main St, Anytown, TX 75001', | |
| phone: '(555) 123-4567', | |
| manager: 'John Smith', | |
| openTime: '08:00', | |
| deliveryTime: '10:00', | |
| deliveryDays: ['Monday', 'Wednesday', 'Friday'], | |
| notes: 'Back door delivery only. Call manager 30 mins before arrival.', | |
| addedBy: currentUser.email | |
| }, | |
| { | |
| id: '2', | |
| name: 'Target #5678', | |
| address: '456 Oak Ave, Somewhere, TX 75002', | |
| phone: '(555) 987-6543', | |
| manager: 'Sarah Johnson', | |
| openTime: '07:30', | |
| deliveryTime: '09:00', | |
| deliveryDays: ['Tuesday', 'Thursday'], | |
| notes: 'Use loading dock on east side.', | |
| addedBy: currentUser.email | |
| } | |
| ]; | |
| renderStores(); | |
| } | |
| // Render stores in the UI | |
| function renderStores() { | |
| if (stores.length === 0) { | |
| emptyState.classList.remove('hidden'); | |
| storeList.classList.add('hidden'); | |
| return; | |
| } | |
| emptyState.classList.add('hidden'); | |
| storeList.classList.remove('hidden'); | |
| storeList.innerHTML = ''; | |
| stores.forEach(store => { | |
| const storeCard = document.createElement('div'); | |
| storeCard.className = 'bg-white rounded-xl shadow-md overflow-hidden store-card transition duration-200'; | |
| storeCard.innerHTML = ` | |
| <div class="p-5"> | |
| <div class="flex justify-between items-start mb-2"> | |
| <h3 class="text-lg font-bold text-gray-800 truncate">${store.name}</h3> | |
| <span class="text-xs px-2 py-1 rounded-full ${store.addedBy === currentUser.email ? 'bg-blue-100 text-blue-800' : 'bg-gray-100 text-gray-800'}"> | |
| ${store.addedBy === currentUser.email ? 'My Store' : 'Shared'} | |
| </span> | |
| </div> | |
| <p class="text-sm text-gray-600 mb-1 truncate"><i class="fas fa-map-marker-alt mr-2 text-blue-500"></i>${store.address}</p> | |
| <p class="text-sm text-gray-600 mb-3 truncate"><i class="fas fa-phone-alt mr-2 text-blue-500"></i>${store.phone}</p> | |
| <div class="flex items-center justify-between text-sm"> | |
| <div> | |
| <p class="text-gray-500">Delivery Days</p> | |
| <div class="flex flex-wrap gap-1 mt-1"> | |
| ${store.deliveryDays.map(day => | |
| `<span class="px-2 py-0.5 bg-gray-100 text-gray-800 rounded-full text-xs">${day.substring(0, 3)}</span>` | |
| ).join('')} | |
| </div> | |
| </div> | |
| <button class="text-blue-600 hover:text-blue-800 font-medium" data-store-id="${store.id}"> | |
| View Details | |
| </button> | |
| </div> | |
| </div> | |
| `; | |
| storeCard.querySelector('button').addEventListener('click', () => showStoreDetails(store.id)); | |
| storeList.appendChild(storeCard); | |
| }); | |
| } | |
| // Show add store modal | |
| function showAddStoreModal() { | |
| // Reset form | |
| storeForm.reset(); | |
| editingStoreId = null; | |
| // Show modal | |
| addStoreModal.classList.remove('hidden'); | |
| document.body.classList.add('overflow-hidden'); | |
| } | |
| // Hide add store modal | |
| function hideAddStoreModal() { | |
| addStoreModal.classList.add('hidden'); | |
| document.body.classList.remove('overflow-hidden'); | |
| } | |
| // Save store (add or update) | |
| function saveStore(e) { | |
| e.preventDefault(); | |
| const formData = new FormData(storeForm); | |
| const deliveryDays = []; | |
| document.querySelectorAll('input[name="deliveryDays"]:checked').forEach(checkbox => { | |
| deliveryDays.push(checkbox.value); | |
| }); | |
| if (deliveryDays.length === 0) { | |
| showToast('Please select at least one delivery day'); | |
| return; | |
| } | |
| const storeData = { | |
| name: formData.get('storeName'), | |
| address: formData.get('storeAddress'), | |
| phone: formData.get('storePhone'), | |
| manager: formData.get('storeManager'), | |
| openTime: formData.get('openTime'), | |
| deliveryTime: formData.get('deliveryTime'), | |
| deliveryDays: deliveryDays, | |
| notes: formData.get('storeNotes'), | |
| addedBy: currentUser.email | |
| }; | |
| if (editingStoreId) { | |
| // Update existing store | |
| const index = stores.findIndex(s => s.id === editingStoreId); | |
| if (index !== -1) { | |
| stores[index] = { ...stores[index], ...storeData }; | |
| showToast('Store updated successfully'); | |
| } | |
| } else { | |
| // Add new store | |
| storeData.id = Date.now().toString(); | |
| stores.push(storeData); | |
| showToast('Store added successfully'); | |
| } | |
| hideAddStoreModal(); | |
| renderStores(); | |
| } | |
| // Show store details | |
| function showStoreDetails(storeId) { | |
| const store = stores.find(s => s.id === storeId); | |
| if (!store) return; | |
| // Populate details | |
| document.getElementById('detailStoreName').textContent = store.name; | |
| document.getElementById('detailStoreAddress').textContent = store.address; | |
| document.getElementById('detailStorePhone').textContent = store.phone; | |
| document.getElementById('detailStoreManager').textContent = store.manager; | |
| document.getElementById('detailAddedBy').textContent = store.addedBy; | |
| document.getElementById('detailOpenTime').textContent = formatTime(store.openTime); | |
| document.getElementById('detailDeliveryTime').textContent = formatTime(store.deliveryTime); | |
| document.getElementById('detailStoreNotes').textContent = store.notes; | |
| // Populate delivery days | |
| const daysContainer = document.getElementById('detailDeliveryDays'); | |
| daysContainer.innerHTML = ''; | |
| store.deliveryDays.forEach(day => { | |
| const dayElement = document.createElement('span'); | |
| dayElement.className = 'px-3 py-1 bg-gray-100 text-gray-800 rounded-full text-sm'; | |
| dayElement.textContent = day; | |
| daysContainer.appendChild(dayElement); | |
| }); | |
| // Store current store ID for edit/delete | |
| editingStoreId = storeId; | |
| // Show modal | |
| storeDetailModal.classList.remove('hidden'); | |
| document.body.classList.add('overflow-hidden'); | |
| } | |
| // Hide store details modal | |
| function hideStoreDetailModal() { | |
| storeDetailModal.classList.add('hidden'); | |
| document.body.classList.remove('overflow-hidden'); | |
| editingStoreId = null; | |
| } | |
| // Edit store | |
| function editStore() { | |
| if (!editingStoreId) return; | |
| const store = stores.find(s => s.id === editingStoreId); | |
| if (!store) return; | |
| // Populate form with store data | |
| document.getElementById('storeName').value = store.name; | |
| document.getElementById('storeAddress').value = store.address; | |
| document.getElementById('storePhone').value = store.phone; | |
| document.getElementById('storeManager').value = store.manager; | |
| document.getElementById('openTime').value = store.openTime; | |
| document.getElementById('deliveryTime').value = store.deliveryTime; | |
| document.getElementById('storeNotes').value = store.notes; | |
| // Check the appropriate delivery days | |
| document.querySelectorAll('input[name="deliveryDays"]').forEach(checkbox => { | |
| checkbox.checked = store.deliveryDays.includes(checkbox.value); | |
| }); | |
| // Switch to add/edit modal | |
| hideStoreDetailModal(); | |
| showAddStoreModal(); | |
| } | |
| // Delete store | |
| function deleteStore() { | |
| if (!editingStoreId) return; | |
| if (confirm('Are you sure you want to delete this store?')) { | |
| stores = stores.filter(s => s.id !== editingStoreId); | |
| showToast('Store deleted successfully'); | |
| hideStoreDetailModal(); | |
| renderStores(); | |
| } | |
| } | |
| // Show share modal | |
| function showShareModal() { | |
| if (stores.length === 0) { | |
| showToast('No stores to share'); | |
| return; | |
| } | |
| // Populate share store list | |
| shareStoreList.innerHTML = ''; | |
| stores.forEach(store => { | |
| if (store.addedBy === currentUser.email) { | |
| const div = document.createElement('div'); | |
| div.className = 'flex items-center space-x-3'; | |
| div.innerHTML = ` | |
| <input type="checkbox" id="share-${store.id}" value="${store.id}" class="rounded text-blue-600 focus:ring-blue-500"> | |
| <label for="share-${store.id}" class="text-sm text-gray-700">${store.name}</label> | |
| `; | |
| shareStoreList.appendChild(div); | |
| } | |
| }); | |
| // Show modal | |
| shareModal.classList.remove('hidden'); | |
| document.body.classList.add('overflow-hidden'); | |
| } | |
| // Hide share modal | |
| function hideShareModal() { | |
| shareModal.classList.add('hidden'); | |
| document.body.classList.remove('overflow-hidden'); | |
| } | |
| // Share stores with another user | |
| function shareStores() { | |
| const shareToId = document.getElementById('sharePepsicoId').value.trim(); | |
| if (!shareToId) { | |
| showToast('Please enter a Pepsico ID to share with'); | |
| return; | |
| } | |
| const selectedStores = []; | |
| document.querySelectorAll('#shareStoreList input[type="checkbox"]:checked').forEach(checkbox => { | |
| selectedStores.push(checkbox.value); | |
| }); | |
| if (selectedStores.length === 0) { | |
| showToast('Please select at least one store to share'); | |
| return; | |
| } | |
| // In a real app, this would send to an API | |
| showToast(`Shared ${selectedStores.length} store(s) with ${shareToId}`); | |
| hideShareModal(); | |
| } | |
| // Show toast notification | |
| function showToast(message) { | |
| const toastMessage = document.getElementById('toastMessage'); | |
| toastMessage.textContent = message; | |
| toast.classList.remove('translate-y-10', 'opacity-0'); | |
| toast.classList.add('translate-y-0', 'opacity-100'); | |
| setTimeout(() => { | |
| toast.classList.remove('translate-y-0', 'opacity-100'); | |
| toast.classList.add('translate-y-10', 'opacity-0'); | |
| }, 3000); | |
| } | |
| // Helper function to format time | |
| function formatTime(timeString) { | |
| if (!timeString) return ''; | |
| const [hours, minutes] = timeString.split(':'); | |
| let hour = parseInt(hours, 10); | |
| const ampm = hour >= 12 ? 'PM' : 'AM'; | |
| hour = hour % 12; | |
| hour = hour ? hour : 12; // the hour '0' should be '12' | |
| return `${hour}:${minutes} ${ampm}`; | |
| } | |
| // Helper function to get initials from email | |
| function getInitials(email) { | |
| if (!email) return 'US'; | |
| const parts = email.split('@'); | |
| if (parts.length === 0) return 'US'; | |
| const namePart = parts[0]; | |
| if (namePart.length === 0) return 'US'; | |
| if (namePart.includes('.')) { | |
| const nameParts = namePart.split('.'); | |
| return nameParts.map(p => p.charAt(0).toUpperCase()).join('').substring(0, 2); | |
| } else { | |
| return namePart.substring(0, 2).toUpperCase(); | |
| } | |
| } | |
| // Initialize the app | |
| init(); | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Spriddle/frito-lay-test" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |