feat(marketplace): enable ProductSearch page for pharmacy owners and employees
- Add ProductSearch route at /search with access for owner, seller, employee roles - Add 'Comprar Medicamentos' button to SellerDashboard header - Add 'Comprar Medicamentos' button and card to EmployeeDashboard - Remove redirect that was blocking access to the product search page
This commit is contained in:
parent
14eb6c61c8
commit
77d23dac7e
3 changed files with 45 additions and 14 deletions
|
|
@ -9,6 +9,7 @@ import { SellerDashboardPage } from './pages/SellerDashboard'
|
|||
import { EmployeeDashboardPage } from './pages/EmployeeDashboard'
|
||||
import { DeliveryDashboardPage } from './pages/DeliveryDashboard'
|
||||
import { MyProfilePage } from './pages/MyProfile'
|
||||
import ProductSearch from './pages/ProductSearch'
|
||||
import { ProtectedRoute } from './components/ProtectedRoute'
|
||||
import { DashboardLayout } from './layouts/DashboardLayout'
|
||||
import {
|
||||
|
|
@ -143,7 +144,15 @@ function App() {
|
|||
</ProtectedRoute>
|
||||
}
|
||||
/>
|
||||
<Route path="/search" element={<Navigate to="/dashboard" replace />} />
|
||||
{/* Product Search - Buy from other pharmacies */}
|
||||
<Route
|
||||
path="/search"
|
||||
element={
|
||||
<ProtectedRoute allowedRoles={['owner', 'seller', 'employee']}>
|
||||
<ProductSearch />
|
||||
</ProtectedRoute>
|
||||
}
|
||||
/>
|
||||
<Route path="*" element={<Navigate to="/login" replace />} />
|
||||
</Routes>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { useAuth } from '../context/AuthContext'
|
||||
import { Link } from 'react-router-dom'
|
||||
|
||||
export function EmployeeDashboardPage() {
|
||||
const { user, logout } = useAuth()
|
||||
|
|
@ -11,6 +12,13 @@ export function EmployeeDashboardPage() {
|
|||
<h1 className="text-2xl font-bold text-gray-900">Painel do Colaborador</h1>
|
||||
<p className="text-gray-600">Bem-vindo, {user?.name}</p>
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
<Link
|
||||
to="/search"
|
||||
className="rounded bg-green-600 px-4 py-2 font-bold text-white hover:bg-green-700"
|
||||
>
|
||||
🛒 Comprar Medicamentos
|
||||
</Link>
|
||||
<button
|
||||
onClick={logout}
|
||||
className="rounded bg-red-600 px-4 py-2 font-bold text-white hover:bg-red-700"
|
||||
|
|
@ -18,8 +26,13 @@ export function EmployeeDashboardPage() {
|
|||
Sair
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-8 grid gap-6 md:grid-cols-2">
|
||||
<div className="mt-8 grid gap-6 md:grid-cols-3">
|
||||
<Link to="/search" className="rounded-lg bg-white p-6 shadow hover:shadow-lg transition-shadow">
|
||||
<h3 className="text-lg font-bold text-green-600">🛒 Comprar Medicamentos</h3>
|
||||
<p className="mt-2 text-gray-600">Encontrar medicamentos próximos à venda.</p>
|
||||
</Link>
|
||||
<div className="rounded-lg bg-white p-6 shadow">
|
||||
<h3 className="text-lg font-bold">Pedidos</h3>
|
||||
<p className="mt-2 text-gray-600">Gerenciar pedidos recebidos.</p>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Shell } from '../layouts/Shell'
|
||||
import { apiClient } from '../services/apiClient'
|
||||
import { formatCents } from '../utils/format'
|
||||
|
|
@ -59,6 +60,13 @@ export function SellerDashboardPage() {
|
|||
<h1 className="text-xl font-semibold text-medicalBlue">Dashboard do Vendedor</h1>
|
||||
<p className="text-sm text-gray-600">Métricas e indicadores de performance</p>
|
||||
</div>
|
||||
<div className="flex gap-3">
|
||||
<Link
|
||||
to="/search"
|
||||
className="rounded bg-green-600 px-4 py-2 text-sm font-semibold text-white hover:bg-green-700"
|
||||
>
|
||||
🛒 Comprar Medicamentos
|
||||
</Link>
|
||||
<button
|
||||
onClick={loadDashboard}
|
||||
className="rounded bg-medicalBlue px-4 py-2 text-sm font-semibold text-white"
|
||||
|
|
@ -66,6 +74,7 @@ export function SellerDashboardPage() {
|
|||
Atualizar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{loading && (
|
||||
<div className="flex justify-center py-8">
|
||||
|
|
|
|||
Loading…
Reference in a new issue