refactor(ekonomi): consolidate Pasar Desa into UMKM module

- Remove "Pasar Desa" as a separate entity; products are now strictly linked to UMKM.
- Delete redundant Pasar Desa API endpoints and state management.
- Update Admin UI: remove "Pasar Desa" menu and unified product management under UMKM.
- Update Public UI: replace "Pasar Desa" with "UMKM" in navbar and unified hub at /darmasaba/ekonomi/umkm.
- Implement mandatory umkmId in PasarDesa model and update seeders accordingly.
- Fix UI bugs, missing imports, and invalid API filters for mandatory umkmId.
- Increment version to 0.1.18.
This commit is contained in:
2026-04-21 17:52:08 +08:00
parent e286cb4f2b
commit 1a48c15c87
45 changed files with 341 additions and 3409 deletions

View File

@@ -0,0 +1,24 @@
# Plan: Refactor UMKM and Pasar Desa (Consolidation)
## Objective
Consolidate "Pasar Desa" into the UMKM module. Pasar Desa is no longer a separate entity; it is now strictly a collection of products belonging to UMKM entities.
## Steps:
1. **Cleanup API**: Remove `PasarDesa` and `KategoriProduk` (from `pasar-desa` folder) imports from `src/app/api/[[...slugs]]/_lib/ekonomi/index.ts`.
2. **Admin UI**:
- Remove "Pasar Desa" menu from `src/app/admin/_com/list_PageAdmin.tsx`.
- Ensure "UMKM" menu handles all product management.
3. **Public UI**:
- Remove "Pasar Desa" from `src/con/navbar-list-menu.ts`.
- Refactor `src/app/darmasaba/(pages)/ekonomi/pasar-desa/page.tsx` to remove the "Produk Pasar Desa" tab.
- Rename the page or adjust its purpose to be the unified UMKM/Product hub.
4. **Prisma Schema**:
- Ensure `umkmId` is mandatory in `PasarDesa` model (already seems to be).
- (Optional) Rename `PasarDesa` to `ProdukUmkm` if requested, but user said it's optional. For now, keep it as `PasarDesa` to minimize breaking changes.
5. **Build & Verify**: Run `bun run build` and check for any broken references.
## Verification:
- No "Pasar Desa" menu in Admin.
- No "Pasar Desa" menu in Public Navbar.
- Public page `/darmasaba/ekonomi/pasar-desa` (or new path) shows UMKM products only.
- Successful build.

View File

@@ -0,0 +1,8 @@
# Task: Refactor UMKM and Pasar Desa (Consolidation)
- [ ] Cleanup API imports in `src/app/api/[[...slugs]]/_lib/ekonomi/index.ts` <!-- id: 0 -->
- [ ] Remove "Pasar Desa" menu in `src/app/admin/_com/list_PageAdmin.tsx` <!-- id: 1 -->
- [ ] Remove "Pasar Desa" from public navbar in `src/con/navbar-list-menu.ts` <!-- id: 2 -->
- [ ] Refactor public page `src/app/darmasaba/(pages)/ekonomi/pasar-desa/page.tsx` <!-- id: 3 -->
- [ ] Run build and fix errors <!-- id: 4 -->
- [ ] Update version and commit <!-- id: 5 -->

View File

@@ -0,0 +1,34 @@
# Summary: Refactor UMKM and Pasar Desa (Consolidation)
## Objective
Successfully consolidated "Pasar Desa" into the UMKM module. Pasar Desa is now strictly a part of the UMKM ecosystem, where every product must belong to an UMKM entity.
## Changes Made:
1. **Backend & API**:
- Removed redundant `pasar-desa` API endpoints from `src/app/api/[[...slugs]]/_lib/ekonomi/index.ts`.
- Removed invalid `not: null` filters for `umkmId` in UMKM dashboard and product findMany APIs (since `umkmId` is now mandatory).
- Updated `umkmState` to include `findUnique` for products.
2. **Admin UI**:
- Removed "Pasar Desa" menu items from `src/app/admin/_com/list_PageAdmin.tsx` for all roles.
- Cleaned up unused state management for `pasar-desa`.
3. **Public UI**:
- Replaced "Pasar Desa" with "UMKM" in the public navbar (`src/con/navbar-list-menu.ts`).
- Unified the public hub at `/darmasaba/ekonomi/umkm`.
- Refactored the hub page to remove the "Produk Pasar Desa" tab and rename other tabs to "Katalog Produk" and "Direktori Bisnis".
- Updated product detail routing to `/darmasaba/ekonomi/umkm/produk/[id]`.
- Updated UMKM profile routing to `/darmasaba/ekonomi/umkm/[id]`.
4. **Database & Seeding**:
- Created a new UMKM seeder (`prisma/_seeder_list/ekonomi/seed_umkm.ts`).
- Updated `seedPasarDesa` to link products to UMKM entities, satisfying the mandatory `umkmId` constraint.
- Integrated `seedUmkm` into the main `seed.ts`.
5. **Code Cleanup**:
- Fixed missing imports (e.g., `IconUser`).
- Removed unused imports across several files.
- Fixed copy-pasted toast messages in unrelated modules.
## Verification**:
- Build successful (`bun run build`).
- No "Pasar Desa" menu in Admin.
- "UMKM" menu in Public Navbar points to unified hub.
- Unified hub shows products linked to UMKM.
- Product detail pages correctly show seller information.