Spaces:
Running
Running
| ```javascript | |
| import React from 'react'; | |
| import { Link } from 'react-router-dom'; | |
| import Sidebar from '../components/Sidebar'; | |
| const Apps = () => { | |
| const apps = [ | |
| { | |
| id: 1, | |
| name: "Payment Gateway", | |
| type: "Web App", | |
| color: "purple", | |
| description: "Secure payment processing solution with multiple currency support.", | |
| updated: "2 days ago", | |
| image: "1" | |
| }, | |
| { | |
| id: 2, | |
| name: "USSD Banking", | |
| type: "USSD", | |
| color: "blue", | |
| description: "Mobile banking service accessible via USSD without internet.", | |
| updated: "1 week ago", | |
| image: "2" | |
| }, | |
| { | |
| id: 3, | |
| name: "Weather API", | |
| type: "API", | |
| color: "green", | |
| description: "Real-time weather data and forecasts API service.", | |
| updated: "3 days ago", | |
| image: "3" | |
| }, | |
| { | |
| id: 4, | |
| name: "Inventory System", | |
| type: "Web App", | |
| color: "yellow", | |
| description: "Comprehensive inventory management system with reporting.", | |
| updated: "yesterday", | |
| image: "4" | |
| }, | |
| { | |
| id: 5, | |
| name: "USSD Voting", | |
| type: "USSD", | |
| color: "red", | |
| description: "Mobile voting system accessible via USSD for elections.", | |
| updated: "2 weeks ago", | |
| image: "5" | |
| }, | |
| { | |
| id: 6, | |
| name: "SMS Gateway API", | |
| type: "API", | |
| color: "indigo", | |
| description: "Bulk SMS sending and receiving API with analytics.", | |
| updated: "5 days ago", | |
| image: "6" | |
| } | |
| ]; | |
| return ( | |
| <div className="flex h-screen overflow-hidden bg-gray-50"> | |
| <Sidebar active="apps" /> | |
| <div className="flex-1 overflow-auto"> | |
| <Header title="All Apps" /> | |
| <main className="p-6"> | |
| <div className="mb-6 bg-white rounded-lg shadow p-4"> | |
| <div className="flex flex-col md:flex-row md:items-center md:justify-between"> | |
| <div className="relative w-full md:w-64 mb-4 md:mb-0"> | |
| <input type="text" placeholder="Search apps..." | |
| className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500" /> | |
| <i data-feather="search" className="absolute left-3 top-2.5 text-gray-400"></i> | |
| </div> | |
| <div className="flex space-x-2"> | |
| <select className="border border-gray-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-purple-500"> | |
| <option>All Categories</option> | |
| <option>Web Apps</option> | |
| <option>USSD</option> | |
| <option>APIs</option> | |
| </select> | |
| <select className="border border-gray-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-purple-500"> | |
| <option>Sort by</option> | |
| <option>Recently Added</option> | |
| <option>Most Popular</option> | |
| <option>A-Z</option> | |
| </select> | |
| <Link to="/new-app" className="bg-purple-600 text-white px-4 py-2 rounded-lg hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-purple-500 flex items-center"> | |
| <i data-feather="plus" className="w-4 h-4 mr-1"></i> | |
| New App | |
| </Link> | |
| </div> | |
| </div> | |
| </div> | |
| <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6"> | |
| {apps.map(app => ( | |
| <AppCard key={app.id} app={app} /> | |
| ))} | |
| </div> | |
| <Pagination /> | |
| </main> | |
| </div> | |
| </div> | |
| ); | |
| }; | |
| const Header = ({ title }) => ( | |
| <header className="bg-white shadow-sm"> | |
| <div className="flex justify-between items-center px-6 py-4"> | |
| <h1 className="text-2xl font-semibold text-gray-800">{title}</h1> | |
| <div className="flex items-center space-x-4"> | |
| <button className="p-2 rounded-full bg-gray-100 text-gray-600 hover:bg-gray-200"> | |
| <i data-feather="bell"></i> | |
| </button> | |
| <button className="p-2 rounded-full bg-gray-100 text-gray-600 hover:bg-gray-200"> | |
| <i data-feather="help-circle"></i> | |
| </button> | |
| </div> | |
| </div> | |
| </header> | |
| ); | |
| const AppCard = ({ app }) => ( | |
| <div className="app-card bg-white rounded-lg shadow overflow-hidden transition-all duration-200"> | |
| <div className={`h-40 bg-${app.color}-100 flex items-center justify-center`}> | |
| <img | |
| src={`http://static.photos/technology/640x360/${app.image}`} | |
| alt="App screenshot" | |
| className="h-full w-full object-cover" | |
| /> | |
| </div> | |
| <div className="p-5"> | |
| <div className="flex justify-between items-start"> | |
| <div> | |
| <h3 className="text-lg font-semibold text-gray-800">{app.name}</h3> | |
| <span className={`inline-block px-2 py-1 text-xs font-semibold rounded-full bg-${app.color}-100 text-${app.color}-800 mt-1`}> | |
| {app.type} | |
| </span> | |
| </div> | |
| <div className="flex space-x-2"> | |
| <button className="p-2 text-gray-500 hover:text-purple-600 hover:bg-purple-50 rounded-full"> | |
| <i data-feather="edit-2" className="w-4 h-4"></i> | |
| </button> | |
| <button className="p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 rounded-full"> | |
| <i data-feather="trash-2" className="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| </div> | |
| <p className="mt-3 text-gray-600 text-sm">{app.description}</p> | |
| <div className="mt-4 flex justify-between items-center"> | |
| <span className="text-xs text-gray-500">Updated {app.updated}</span> | |
| <a | |
| href={app.type === 'USSD' ? `tel:*123#` : `https://${app.name.toLowerCase()}.example.com`} | |
| target="_blank" | |
| rel="noopener noreferrer" | |
| className={`text-sm font-medium text-${app.color}-600 hover:text-${app.color}-500 flex items-center`} | |
| > | |
| {app.type === 'USSD' ? 'Dial' : app.type === 'API' ? 'Docs' : 'Open'} | |
| <i data-feather={app.type === 'USSD' ? 'phone' : app.type === 'API' ? 'file-text' : 'external-link'} className="w-4 h-4 ml-1"></i> | |
| </a> | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| const Pagination = () => ( | |
| <div className="mt-8 flex justify-center"> | |
| <nav className="inline-flex rounded-md shadow"> | |
| <a href="#" className="px-3 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"> | |
| Previous | |
| </a> | |
| <a href="#" className="px-3 py-2 border-t border-b border-gray-300 bg-white text-sm font-medium text-purple-600 hover:bg-purple-50"> | |
| 1 | |
| </a> | |
| <a href="#" className="px-3 py-2 border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"> | |
| 2 | |
| </a> | |
| <a href="#" className="px-3 py-2 border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"> | |
| 3 | |
| </a> | |
| <a href="#" className="px-3 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50"> | |
| Next | |
| </a> | |
| </nav> | |
| </div> | |
| ); | |
| export default Apps; | |
| ``` |