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 { EmployeeDashboardPage } from './pages/EmployeeDashboard'
|
||||||
import { DeliveryDashboardPage } from './pages/DeliveryDashboard'
|
import { DeliveryDashboardPage } from './pages/DeliveryDashboard'
|
||||||
import { MyProfilePage } from './pages/MyProfile'
|
import { MyProfilePage } from './pages/MyProfile'
|
||||||
|
import ProductSearch from './pages/ProductSearch'
|
||||||
import { ProtectedRoute } from './components/ProtectedRoute'
|
import { ProtectedRoute } from './components/ProtectedRoute'
|
||||||
import { DashboardLayout } from './layouts/DashboardLayout'
|
import { DashboardLayout } from './layouts/DashboardLayout'
|
||||||
import {
|
import {
|
||||||
|
|
@ -143,7 +144,15 @@ function App() {
|
||||||
</ProtectedRoute>
|
</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 />} />
|
<Route path="*" element={<Navigate to="/login" replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { useAuth } from '../context/AuthContext'
|
import { useAuth } from '../context/AuthContext'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
|
|
||||||
export function EmployeeDashboardPage() {
|
export function EmployeeDashboardPage() {
|
||||||
const { user, logout } = useAuth()
|
const { user, logout } = useAuth()
|
||||||
|
|
@ -11,15 +12,27 @@ export function EmployeeDashboardPage() {
|
||||||
<h1 className="text-2xl font-bold text-gray-900">Painel do Colaborador</h1>
|
<h1 className="text-2xl font-bold text-gray-900">Painel do Colaborador</h1>
|
||||||
<p className="text-gray-600">Bem-vindo, {user?.name}</p>
|
<p className="text-gray-600">Bem-vindo, {user?.name}</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<div className="flex gap-3">
|
||||||
onClick={logout}
|
<Link
|
||||||
className="rounded bg-red-600 px-4 py-2 font-bold text-white hover:bg-red-700"
|
to="/search"
|
||||||
>
|
className="rounded bg-green-600 px-4 py-2 font-bold text-white hover:bg-green-700"
|
||||||
Sair
|
>
|
||||||
</button>
|
🛒 Comprar Medicamentos
|
||||||
|
</Link>
|
||||||
|
<button
|
||||||
|
onClick={logout}
|
||||||
|
className="rounded bg-red-600 px-4 py-2 font-bold text-white hover:bg-red-700"
|
||||||
|
>
|
||||||
|
Sair
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</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">
|
<div className="rounded-lg bg-white p-6 shadow">
|
||||||
<h3 className="text-lg font-bold">Pedidos</h3>
|
<h3 className="text-lg font-bold">Pedidos</h3>
|
||||||
<p className="mt-2 text-gray-600">Gerenciar pedidos recebidos.</p>
|
<p className="mt-2 text-gray-600">Gerenciar pedidos recebidos.</p>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
|
import { Link } from 'react-router-dom'
|
||||||
import { Shell } from '../layouts/Shell'
|
import { Shell } from '../layouts/Shell'
|
||||||
import { apiClient } from '../services/apiClient'
|
import { apiClient } from '../services/apiClient'
|
||||||
import { formatCents } from '../utils/format'
|
import { formatCents } from '../utils/format'
|
||||||
|
|
@ -59,12 +60,20 @@ export function SellerDashboardPage() {
|
||||||
<h1 className="text-xl font-semibold text-medicalBlue">Dashboard do Vendedor</h1>
|
<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>
|
<p className="text-sm text-gray-600">Métricas e indicadores de performance</p>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<div className="flex gap-3">
|
||||||
onClick={loadDashboard}
|
<Link
|
||||||
className="rounded bg-medicalBlue px-4 py-2 text-sm font-semibold text-white"
|
to="/search"
|
||||||
>
|
className="rounded bg-green-600 px-4 py-2 text-sm font-semibold text-white hover:bg-green-700"
|
||||||
Atualizar
|
>
|
||||||
</button>
|
🛒 Comprar Medicamentos
|
||||||
|
</Link>
|
||||||
|
<button
|
||||||
|
onClick={loadDashboard}
|
||||||
|
className="rounded bg-medicalBlue px-4 py-2 text-sm font-semibold text-white"
|
||||||
|
>
|
||||||
|
Atualizar
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loading && (
|
{loading && (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue