Services¶
Source: pharmanet-admin/src/services/
All services use @supabase/supabase-js for database operations. The shared supabase.js exports the client and an error-handling wrapper.
Auth Service¶
Source: services/auth.js
| Function | Description |
|---|---|
login(credentials) |
Sign in, validate admin role, return {user, profile} |
logout() |
Sign out |
forgotPassword(email) |
Send reset email |
resetPassword(token, password) |
Update password |
verifyToken() |
Get session, validate admin role |
User Service¶
Source: services/users.js
| Function | Description |
|---|---|
getUsers({page, limit, search, role, is_active}) |
Paginated user list |
getUserById(id) |
Single user |
updateUser(id, data) |
Edit user |
updateUserStatus(id, status) |
Activate/deactivate |
deleteUser(id) |
Delete |
getPendingPharmacies() |
Pending pharmacy registrations |
approvePharmacy(id, data) |
Approve + send notification |
rejectPharmacy(id, reason) |
Reject + send notification |
Product Service¶
Source: services/products.js
| Function | Description |
|---|---|
getProducts(params) |
List with filters |
uploadProductImages(files) |
Upload to Storage |
createProduct(payload) |
Create with images |
updateProduct(id, payload) |
Update with images |
getPendingProducts() |
Awaiting approval |
approveProduct(id) |
Approve + notify seller |
rejectProduct(id, reason) |
Reject + notify seller |
toggleFeatured(id, featured) |
Toggle flag |
deleteProduct(id) |
Delete |
getBrands() / CRUD |
Brand management |
getAttributes() / CRUD |
Variant option management |
Order Service¶
Source: services/orders.js
| Function | Description |
|---|---|
getOrders({page, limit, search, status}) |
List with customer info |
getOrderById(id) |
Full detail |
updateOrderStatus(id, status, trackingData) |
Change status + log + notify |
updatePrescriptionStatus(id, status) |
Verify prescription |
Payment Service¶
Source: services/payments.js
| Function | Description |
|---|---|
getTransactions({page, limit, search, status}) |
Payment list |
getTransactionById(id) |
Single transaction |
getPaymentLogs({page, limit}) |
Payment logs |
updateChapaSettings(settings) |
Save Chapa keys |
Dashboard Service¶
Source: services/dashboard.js
| Function | Description |
|---|---|
getStats() |
System-wide KPI data |
getOverview() |
Recent orders, latest products |
Category Service¶
Source: services/categories.js
| Function | Description |
|---|---|
getCategories() |
All categories sorted |
createCategory(payload) |
Create with image |
updateCategory(id, payload) |
Update with image |
deleteCategory(id) |
Delete |
reorderCategories(order) |
Bulk sort order |
CMS Service¶
Source: services/cms.js
| Function | Description |
|---|---|
getBanners() |
All banners |
createBanner(payload) |
Create with image |
updateBanner(id, payload) |
Update with image |
deleteBanner(id) |
Delete |
reorderBanners(order) |
Bulk sort order |
getPages() |
Static pages |
getPageById(id) / updatePage(id, data) |
Page management |
Promotion Service¶
Source: services/promotions.js
| Function | Description |
|---|---|
getPromotions({status, search, page, limit}) |
Paginated list |
getPromotionById(id) |
Single promotion |
createPromotion(payload) |
Create |
updatePromotion(id, payload) |
Edit |
deletePromotion(id) |
Delete |
activatePromotion(id) |
Activate + broadcast notification |
endPromotion(id) |
End campaign |
getPromotionOffers(promotionId) |
View seller offers |
getActivePromotions() |
Currently active |
Notification Service¶
Source: services/notifications.js
| Function | Description |
|---|---|
getNotifications({limit, unreadOnly}) |
User notifications |
getUnreadCount() |
Unread count |
markAsRead(id) |
Mark single read |
markAllAsRead() |
Mark all read |
createNotification(data) |
Insert notification |
createNotificationForAllCustomers(data) |
Broadcast to all customers |
subscribeToNotifications(userId, callback) |
Realtime subscription |
Report Service¶
Source: services/reports.js
| Function | Description |
|---|---|
getSalesReport({startDate, endDate}) |
Sales analytics |
getProductPerformance({limit, sortBy}) |
Product metrics |
getProductAnalytics(id) |
Single product analytics |
getSellerPerformance() |
Seller rankings |
exportReport(type, params) |
Export to CSV/PDF |
Settings Service¶
Source: services/settings.js
| Function | Description |
|---|---|
getSettings() |
All settings KV |
updateSettings(payload) |
Upsert settings |
Chapa Service¶
Source: services/chapa.js
| Function | Description |
|---|---|
setChapaKeys(publicKey, secretKey) |
Set API keys |
generateTxRef(prefix) |
Generate reference |
verifyPayment(txRef) |
Verify payment |
initializeChapaKeys() |
Load from localStorage |
Featured Products Service¶
Source: services/featuredProducts.js
| Function | Description |
|---|---|
getFeaturedProducts(filters) |
List all |
getFeaturedProductById(id) |
Single |
createFeaturedProduct(payload) |
Create |
deleteFeaturedProduct(id) |
Remove |
activateFeaturedProduct(id, startDate, endDate) |
Activate |
Subscription Service¶
Source: services/pharmacySubscription.js
| Function | Description |
|---|---|
getPharmacySubscriptions(filters) |
List all |
createSubscription(payload) |
Create |
getSubscriptionAnalytics() |
Aggregate metrics |
getActiveSubscription(pharmacyId) |
Active for pharmacy |
activateSubscription(id, startDate, endDate) |
Activate |