๐ PREXITION
Aplikasi: Premix Intelligent Formulation (PREXITION)
Perusahaan: PT Global Vita Nutritech Indonesia
Tipe Project: Frontend React Web Application
Versi: 3.9.3
Tim Product Terkait: Debby Tantika Ardi
Tanggal Dokumentasi: Januari 2026
๐ Daftar Isiโ
- Overview Project
- Tech Stack & Dependencies
- Struktur Folder Project
- Setup & Running Project
- Environment Variables
- Architecture & Pattern
- Key Components & Features
- API Integration
- State Management
- Routing & Navigation
- Authentication & Authorization
- Build & Deployment
- Development Guidelines
- Common Issues & Troubleshooting
- Dokumentasi & Resources
๐ Akses Aplikasiโ
Berikut adalah alamat akses cepat untuk environment aplikasi:
| Environment | URL Akses | Deskripsi |
|---|---|---|
| ๐ Production | https://prexition.gvn.co.id | Environment utama pengguna |
| ๐งช Development | https://prexitiondev.gvn.co.id | Testing & staging area |
| โ๏ธ Hangfire | https://prexitionapi.gvn.co.id/hangfire | Dashboard Background Jobs |
Overview Projectโ
Deskripsiโ
PREXITION adalah aplikasi web frontend yang dibangun dengan React + TypeScript untuk mengelola Premix Intelligent Formulation. Aplikasi ini menangani:
- ๐ Dashboard & Reporting
- ๐ญ Master Data Management (Items, Formula, Nutrition, dll)
- ๐ผ Transaksi Bisnis (Product Costing, Scale Up Formula, dll)
- ๐ง Sistem Konfigurasi & Parameter
- ๐ฅ User Management & Role-Based Access Control
Target Usersโ
- Product Formulation Specialists
- Supply Chain Managers
- System Administrators
- Finance/Cost Management Teams
Lifecycle Statusโ
- Status: Production (v3.9.3)
- Browser Support: Modern browsers (Chrome, Firefox, Safari, Edge)
- Responsive: Mobile-friendly dengan PWA support
Tech Stack & Dependenciesโ
Framework & Languageโ
โโโ React 18.2.0 โ UI Library
โโโ TypeScript 5.2.2 โ Type-safe JavaScript
โโโ Vite 7.2.2 โ Build tool & Dev server
โโโ React Router 7.9.6 โ Client-side routing
UI & Stylingโ
โโโ Material-UI (MUI) 7.3.5 โ Component library
โโโ Styled Components 6.1.17 โ CSS-in-JS styling
โโโ Emotion 11.14.0 โ CSS-in-JS framework
โโโ Bootstrap 5.3.2 โ Utility classes
โโโ SASS 1.94.0 โ CSS preprocessing
โโโ Iconify 4.1.1 โ Icon library
State Management & Dataโ
โโโ MobX 6.12.0 โ Reactive state management
โโโ MobX-React-Lite 4.0.5 โ React bindings untuk MobX
โโโ MobX-Cookie 4.0.5 โ Cookie integration
โโโ LocalForage 1.10.0 โ Local storage management
Form & Validationโ
โโโ Formik 2.4.5 โ Form state management
โโโ Yup 1.3.3 โ Schema validation
โโโ React Number Format โ Number formatting
API & HTTPโ
โโโ Axios 1.6.7 โ HTTP client
โโโ Crypto-JS 4.2.0 โ Encryption utilities
Utility Librariesโ
โโโ React-PDF 10.2.0 โ PDF rendering
โโโ Date-FNS 3.3.1 โ Date utilities
โโโ Moment 2.30.1 โ Date manipulation
โโโ i18next 23.8.2 โ Internationalization
โโโ UUID 9.0.1 โ ID generation
โโโ SweetAlert2 11.6.13 โ Alert dialogs
โโโ React-Toastify 10.0.4 โ Toast notifications
PWA & Performanceโ
โโโ vite-plugin-pwa 1.1.0 โ Progressive Web App
โโโ NProgress 0.2.0 โ Progress bar
Struktur Folder Projectโ
prexitionfrontend/
โ
โโโ ๐ Konfigurasi Project
โ โโโ package.json โ Dependencies & scripts
โ โโโ tsconfig.json โ TypeScript config
โ โโโ tsconfig.node.json โ Node TS config
โ โโโ vite.config.ts โ Vite configuration
โ โโโ index.html โ Entry HTML
โ โโโ Dockerfile โ Docker config
โ โโโ Jenkinsfile โ CI/CD pipeline
โ โโโ README.md โ Basic readme
โ
โโโ ๐ public/ โ Static assets
โ โโโ pdf.worker.mjs โ PDF worker
โ โโโ Fonts/ โ Custom fonts
โ โโโ icons/ โ App icons (Android, iOS, Windows)
โ โโโ images/ โ Static images
โ โโโ avatars/ โ User avatars
โ โโโ captcha/ โ Captcha images
โ โโโ customizer/ โ Theme customizer
โ โโโ pages/ โ Page backgrounds
โ โโโ screenshots/ โ Screenshots
โ
โโโ ๐ src/ โ SOURCE CODE
โ
โโโ ๐ main.tsx โ React entry point
โโโ ๐ env.d.ts โ Environment type definitions
โโโ ๐ vite-env.d.ts โ Vite type definitions
โ
โโโ ๐ app/ โ Application core
โ โ
โ โโโ ๐ api/
โ โ โโโ agent.ts โ API client & requests
โ โ
โ โโโ ๐ common/ โ Shared utilities
โ โ โโโ Constant.ts โ App constants
โ โ โโโ config/
โ โ โ โโโ pdfConfig.ts โ PDF configuration
โ โ โโโ helpers/ โ Utility functions
โ โ โ โโโ BatchName.ts โ Format Batching Name
โ โ โ โโโ Crypto.ts โ Encryption/decryption
โ โ โ โโโ Currency.ts โ Currency formatting
โ โ โ โโโ ErrorHandler.ts โ Form BE Error Handler
โ โ โ โโโ UomConversion.ts โ UOM Conversion
โ โ โโโ Lov/ โ List of Values
โ โ โโโ types.ts
โ โ
โ โโโ ๐ components/ โ Reusable components
โ โ โโโ Captcha/ โ Captcha component
โ โ โโโ dashboard/ โ Dashboard components
โ โ โโโ Form/ โ Form-related components
โ โ โโโ Master/ โ Master data components
โ โ โ โโโ Formula/
โ โ โโโ PDFTemplate/ โ PDF templates
โ โ โโโ shared/ โ Shared components
โ โ โโโ Transaction/ โ Transaction components
โ โ
โ โโโ ๐ core/ โ Core functionality
โ โ โโโ components/ โ Layout components
โ โ โโโ configs/ โ App configurations
โ โ โโโ context/ โ React Context providers
โ โ โโโ hooks/ โ Custom React hooks
โ โ โโโ layouts/ โ Layout wrappers
โ โ โโโ theme/ โ MUI theme configuration
โ โ โโโ utils/ โ Core utilities
โ โ
โ โโโ ๐ hooks/ โ Custom hooks
โ โ
โ โโโ ๐ layout/ โ Main layouts
โ โ โโโ App.tsx โ Root layout
โ โ โโโ BlankLayout.tsx โ Blank/Minimal layout
โ โ โโโ UserLayout.tsx โ User dashboard layout
โ โ โโโ UserThemeOptions.ts
โ โ โโโ components/ โ Layout sub-components
โ โ
โ โโโ ๐ models/ โ TypeScript types/interfaces
โ โ โโโ clsGlobalAPIModel.ts
โ โ โโโ DatatableModel.ts
โ โ โโโ ErrorModel.ts
โ โ โโโ GeneralModel.ts
โ โ โโโ menuModel.ts
โ โ โโโ ParameterModel.ts
โ โ โโโ ProgramModel.ts
โ โ โโโ roleModel.ts
โ โ โโโ systemAPIModel.ts
โ โ โโโ userModel.ts
โ โ โโโ ValidityRuleModel.ts
โ โ โโโ Dashboard/
โ โ โโโ master/ โ Master data models
โ โ โโโ Oracle/ โ Oracle-specific models
โ โ โโโ Transaction/ โ Transaction models
โ โ
โ โโโ ๐ router/ โ Route definitions
โ โ โโโ AuthRoute.tsx โ Protected routes
โ โ โโโ Routes.tsx โ Route configuration
โ โ
โ โโโ ๐ stores/ โ MobX stores (State Management)
โ โ โโโ authStore.ts โ Authentication state
โ โ โโโ CommonStore.ts โ Shared state
โ โ โโโ DashboardStore.ts
โ โ โโโ GeneralStore.ts
โ โ โโโ LovStore.ts โ List of Values store
โ โ โโโ store.ts โ Root store
โ โ โโโ ValidityRuleStore.ts
โ โ โโโ master/ โ Master data stores
โ โ โโโ oracle/ โ Oracle stores
โ โ โโโ system/ โ System stores
โ โ โโโ transaction/ โ Transaction stores
โ
โโโ ๐ assets/ โ Asset files (images, icons)
โ
โโโ ๐ features/ โ Feature pages
โ โโโ Home.tsx โ Home page
โ โโโ ๐ authentication/ โ Login & role selection
โ โ โโโ ChoseRole.tsx
โ โ โโโ login.tsx
โ โโโ ๐ errors/ โ Error pages
โ โโโ ๐ master/ โ Master data features
โ โ โโโ Approval/
โ โ โโโ Customer/
โ โ โโโ Distributor/
โ โ โโโ Formula/
โ โ โโโ Items/
โ โ โโโ MaterialPrice/
โ โ โโโ Nutrition/
โ โ โโโ NutritionItem/
โ โ โโโ NutritionType/
โ โ โโโ OtherVarCost/
โ โ โโโ ParameterConversion/
โ โ โโโ ProductionType/
โ โโโ ๐ misc/ โ Miscellaneous pages
โ โ โโโ 404.tsx
โ โ โโโ BadGatewayPage.tsx
โ โ โโโ NotAuthorizedPage.tsx
โ โโโ ๐ system/ โ System configuration
โ โ โโโ systemConfig.tsx
โ โ โโโ Parameter/
โ โโโ ๐ transaction/ โ Transaction features
โ โโโ inquiry/
โ โโโ ProductCosting/
โ โโโ ProductDataSheet/
โ โโโ ScaleUpFormula/
โ โโโ Spec/
โ
โโโ ๐ styles/ โ Global styles
โ โโโ fonts.css โ Font definitions
โ โโโ globals.css โ Global CSS
โ
โโโ ๐ dev-dist/ โ Build output (generated)
โโโ Service Worker files
Setup & Running Projectโ
Prerequisitesโ
- Node.js: v16+ (recommended v18 LTS)
- yarn v1.22+
- Git: untuk version control
Installationโ
# Clone repository
git clone <repository-url>
cd prexitionfrontend
# Install dependencies
yarn install
# Jalankan Development Server
yarn dev
# Build untuk Production
yarn build
# Preview hasil Build secara lokal
yarn preview
# Server akan running di: http://localhost:3002
Available Scriptsโ
| Command | Deskripsi |
|---|---|
yarn dev | Jalankan dev server (port 3002) |
yarn dev:production | Dev mode dengan NODE_ENV=production |
yarn build | Build untuk production |
yarn lint | ESLint checking |
yarn preview | Preview production build |
Environment Variablesโ
File Konfigurasiโ
Buat file .env di root project dengan variabel berikut:
# ===== API & WSO Configuration =====
VITE_USERNAME=<username-untuk-wso>
VITE_PASSWORD=<password-untuk-wso>
VITE_WSO_URL=https://prexition-wso.example.com
VITE_API_URL=https://prexitionapidev.gvn.co.id
VITE_SECRET=<secret-key-untuk-encryption>
# ===== Parameter IDs (untuk LOV) =====
VITE_ID_ITEM_TEMPLATE=<id>
VITE_ID_TYPE=<id>
VITE_ID_STATUS=<id>
VITE_ID_UOM=<id>
VITE_ID_LIST_STATUS=<id>
VITE_ID_CONTEXT=<id>
VITE_ID_ORGANIZATIO=<id>
VITE_ID_COSTTYPE=<id>
VITE_ID_LOVSHPNONSHP=<id>
VITE_ID_LOVFLUSHING=<id>
### Cara Mengakses di Code
```typescript
// Import dari vite
const apiUrl = import.meta.env.VITE_API_URL;
const secret = import.meta.env.VITE_SECRET;
Architecture & Patternโ
Architecture Overviewโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ React Components (UI) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ State Management (MobX Stores) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ API Integration (Axios) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Backend API (RESTAPI) with .NET Core โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Design Patternsโ
1. Component Patternโ
- Functional Components: Semua component menggunakan React Hooks
- Custom Hooks: Diletakkan di
src/app/hooks/dansrc/app/core/hooks/ - Reusable Components: Umum digunakan components di
src/app/components/shared/
2. State Management (MobX)โ
// Contoh MobX Store
class AuthStore {
@observable isLoggedIn = false;
@action
async login(username: string, password: string) {
// Login logic
}
@computed
get isAuthenticated() {
return this.isLoggedIn;
}
}
// Usage di component
import { useLocalObservable } from 'mobx-react-lite';
3. Folder Structure per Featureโ
Setiap feature (master, transaction, dll) memiliki struktur:
Feature/
โโโ components/ โ Components spesifik feature
โโโ store.ts โ State management
โโโ models/ โ TypeScript types
โโโ api.ts โ API calls
โโโ index.tsx โ Main page/component
4. API Integration Patternโ
// src/app/api/agent.ts
export const api = {
// Master Data
master: {
getItems: () => axiosInstance.get('/api/items'),
createItem: (data) => axiosInstance.post('/api/items', data),
},
// Transactions
transaction: {
getProductCosting: (id) => axiosInstance.get(`/api/costing/${id}`),
},
};
Key Components & Featuresโ
Dashboardโ
- File:
src/features/Home.tsx,src/app/components/dashboard/ - Deskripsi: Main dashboard dengan statistik dan overview
- Components: GridStatistic, Charts, KPI cards
Master Data Managementโ
Modules untuk mengelola master data:
| Module | Folder | Fungsi |
|---|---|---|
| Items | master/Items/ | CRUD item/produk |
| Formula | master/Formula/ | Manajemen formula produk |
| Nutrition | master/Nutrition/ | Data nutrisi |
| Customer | master/Customer/ | Data pelanggan |
| Distributor | master/Distributor/ | Data distributor |
| MaterialPrice | master/MaterialPrice/ | Harga material |
| Approval | master/Approval/ | Workflow approval |
Transaction Modulesโ
Modules untuk transaksi bisnis:
| Module | Folder | Fungsi |
|---|---|---|
| Product Costing | transaction/ProductCosting/ | Perhitungan cost produk |
| Scale Up Formula | transaction/ScaleUpFormula/ | Scale up resep formula |
| Product Data Sheet | transaction/ProductDataSheet/ | Data sheet produk |
| Specification | transaction/Spec/ | Spesifikasi produk |
| Inquiry | transaction/inquiry/ | Pencarian data |
Form Componentsโ
- Location:
src/app/components/Form/ - Menggunakan: Formik + Yup validation
- Pattern: Controlled components dengan validation real-time
PDF Featuresโ
- Library: @react-pdf/renderer, react-pdf
- Config:
src/app/common/config/pdfConfig.ts - Templates:
src/app/components/PDFTemplate/
API Integrationโ
API Client Setupโ
File: src/app/api/agent.ts
// Axios instance dengan interceptors
const axiosInstance = axios.create({
baseURL: import.meta.env.VITE_API_URL,
timeout: 30000,
});
// Request interceptor (add auth token, encryption, etc)
axiosInstance.interceptors.request.use(config => {
// Add headers, tokens
return config;
});
// Response interceptor (handle errors)
axiosInstance.interceptors.response.use(
response => response,
error => {
// Handle errors globally
return Promise.reject(error);
}
);
Proxy Configurationโ
File: vite.config.ts
server: {
proxy: {
"/api": {
target: "https://prexitionapidev.gvn.co.id",
changeOrigin: true,
},
"/gateway": "https://apim.kalbenutritionals.com:8243",
}
}
Error Handlingโ
- Helper:
src/app/common/helpers/ErrorHandler.ts - Toast Notifications:
react-toastify - Alert Dialogs:
sweetalert2
State Managementโ
MobX Stores Architectureโ
Root Store: src/app/stores/store.ts
export class RootStore {
authStore: AuthStore;
commonStore: CommonStore;
dashboardStore: DashboardStore;
masterStore: MasterStore;
transactionStore: TransactionStore;
constructor() {
// Initialize stores
}
}
Store Usage di Componentsโ
// 1. Create store instance
const rootStore = new RootStore();
// 2. Use di component
const MyComponent = observer(() => {
const { authStore } = rootStore;
return <div>{authStore.userName}</div>;
});
// 3. Actions untuk update state
authStore.setUserData(userData);
Store Filesโ
stores/
โโโ store.ts โ Root store
โโโ authStore.ts โ Authentication state
โโโ CommonStore.ts โ Common/shared state
โโโ DashboardStore.ts โ Dashboard data
โโโ GeneralStore.ts โ General app state
โโโ LovStore.ts โ List of Values
โโโ ValidityRuleStore.ts โ Validation rules
โโโ master/ โ Master data stores
โโโ oracle/ โ Oracle integration
โโโ system/ โ System configuration
โโโ transaction/ โ Transaction stores
Routing & Navigationโ
Route Configurationโ
File: src/app/router/Routes.tsx
const routes = [
{
path: '/',
element: <UserLayout />,
children: [
{ path: 'dashboard', element: <Home /> },
{ path: 'master/items', element: <Items /> },
{ path: 'master/formula', element: <Formula /> },
// ... more routes
]
},
{
path: '/login',
element: <BlankLayout />,
children: [
{ path: '', element: <LoginPage /> },
]
},
// ... catch all
];
Protected Routesโ
File: src/app/router/AuthRoute.tsx
// Component yang melindungi akses berdasarkan authentication
<AuthRoute>
<ProtectedPage />
</AuthRoute>
Navigationโ
// Menggunakan React Router
import { useNavigate } from 'react-router-dom';
const navigate = useNavigate();
navigate('/dashboard');
Authentication & Authorizationโ
Authentication Flowโ
Login Page
โ
Validate Credentials (WSO)
โ
Get JWT Token
โ
Store Token (Cookie/LocalStorage)
โ
Fetch User Data & Roles
โ
Select Role (ChoseRole page)
โ
Redirect to Dashboard
Authentication Storeโ
File: src/app/stores/authStore.ts
class AuthStore {
@observable
isLoggedIn = false;
@observable
currentUser: User | null = null;
@action
async login(username: string, password: string) {
// Call WSO API
// Store token
}
@action
logout() {
// Clear token & user data
}
}
Permission Checkingโ
// User roles dan permissions disimpan di authStore
// Permission check dilakukan di component atau route level
if (userRole === 'ADMIN') {
// Show admin features
}
Build & Deploymentโ
Development Buildโ
yarn build
Output: dist/ folder dengan production-ready files
Build Optimizationโ
- Tree-shaking: TypeScript & Vite sudah enable
- Code Splitting: React Router lazy loading
- Asset Optimization: Vite automatic optimization
Docker Deploymentโ
File: Dockerfile
FROM node:18-alpine AS builder
# Build stage
FROM nginx:alpine AS runtime
# Runtime dengan nginx
Build & Run:
docker build -t prexition:latest .
docker run -p 3002:80 prexition:latest
CI/CD Pipelineโ
File: Jenkinsfile
Pipeline steps:
- Clone repository
- Install dependencies
- Build application
- Run tests & linting
- Deploy to staging/production
Environment-specific Configโ
# Development
yarn dev
# Production
yarn dev:production
yarn build
Development Guidelinesโ
Coding Standardsโ
TypeScriptโ
// โ
DO: Type everything
interface UserProps {
id: string;
name: string;
email: string;
}
const User: React.FC<UserProps> = ({ id, name, email }) => {
return <div>{name}</div>;
};
// โ DON'T: Any types
const User = ({ id, name }: any) => {
return <div>{name}</div>;
};
Component Structureโ
// 1. Imports
import React, { useState } from 'react';
import { observer } from 'mobx-react-lite';
// 2. Types/Interfaces
interface Props {
title: string;
onSubmit: (data: any) => void;
}
// 3. Component
const MyComponent = observer(({ title, onSubmit }: Props) => {
// Hooks
const [count, setCount] = useState(0);
// Event handlers
const handleClick = () => {
setCount(count + 1);
};
// Render
return <div onClick={handleClick}>{title}: {count}</div>;
});
export default MyComponent;
Form Components (Formik + Yup)โ
import * as Yup from 'yup';
import { Formik, Form, Field } from 'formik';
const validationSchema = Yup.object({
email: Yup.string().email('Invalid email').required('Required'),
password: Yup.string().min(6).required('Required'),
});
const MyForm = () => (
<Formik
initialValues={{ email: '', password: '' }}
validationSchema={validationSchema}
onSubmit={(values) => {
// Submit logic
}}
>
{({ errors, touched }) => (
<Form>
<Field name="email" type="email" />
{errors.email && touched.email && <span>{errors.email}</span>}
{/* More fields */}
</Form>
)}
</Formik>
);
Naming Conventionsโ
| Type | Convention | Example |
|---|---|---|
| Components | PascalCase | UserList.tsx, FormDialog.tsx |
| Functions | camelCase | fetchUserData(), handleClick() |
| Variables | camelCase | userData, isLoading |
| Constants | UPPER_SNAKE_CASE | API_TIMEOUT, MAX_RETRIES |
| Interfaces | PascalCase with I | IUser, IApiResponse |
| Files | kebab-case or PascalCase | user-list.ts, UserList.tsx |
File Organization per Featureโ
Feature/
โโโ index.tsx โ Main component/page
โโโ Feature.tsx โ Main logic
โโโ Feature.styles.ts โ Styled components
โโโ Feature.types.ts โ TypeScript interfaces
โโโ Feature.constants.ts โ Constants
โโโ Feature.utils.ts โ Utility functions
โโโ components/ โ Sub-components
โ โโโ SubComponent.tsx
โโโ hooks/ โ Custom hooks
โ โโโ useFeature.ts
โโโ store.ts โ MobX store
Error Handling Best Practicesโ
try {
const response = await api.fetchData();
handleSuccess(response);
} catch (error) {
const errorMessage = error instanceof AxiosError
? error.response?.data?.message
: error.message;
toast.error(errorMessage);
console.error('Error details:', error);
}
Comments & Documentationโ
/**
* Formats currency value to IDR format
* @param value - Numeric value to format
* @param decimals - Number of decimal places (default: 2)
* @returns Formatted currency string
* @example
* formatCurrency(1000000) // "Rp1.000.000,00"
*/
export const formatCurrency = (
value: number,
decimals: number = 2
): string => {
// Implementation
};
๐ Menambahkan LOV Baru (Step-by-Step)โ
Ikuti langkah-langkah berikut untuk mengintegrasikan dataset LOV baru ke dalam sistem:
-
Definisikan API Request Buka
src/app/api/agent.tsdan buat fungsi request baru di dalam kategori yang sesuai (misal: Oracle atau Master).// src/app/api/agent.ts
const Oracle = {
// ... request lainnya
codeshp: (params: URLSearchParams) => requests.get('/oracle/codeshp', params),
}; -
Update LovOfName Type Tambahkan identifier unik untuk LOV baru Anda pada file tipe global agar dikenal oleh sistem TypeScript.
// src/app/common/lov/types.ts
export type LovOfName = "codeshp" | "item" | "akasia" | "specApproved"; -
Konfigurasi LovStore (Fetch Logic) Buka LovStore.ts, cari fungsi fetch, dan tambahkan case baru di dalam blok switch untuk mengarahkan nama LOV ke API request yang telah dibuat di langkah 1.
// src/app/stores/LovStore.ts
switch(nameoflov) {
case "codeshp":
response = await agent.Oracle.codeshp(param) as DatatableResponse<T[]>;
break;
// Tambahkan case lainnya di sini
} -
Registrasi Store di Root Store Daftarkan instance LovStore baru di
store.tsdengan menyertakan interface model data yang sesuai agar mendapatkan dukungan type-safety.// src/app/stores/store.ts
export class RootStore {
// ... store lainnya
lovStoreAkasia: new LovStore<AkasiaModel>(),
LOVScaleUpAFGU: new LovStore<ScaleUpFormulaLovDTO>(),
LOVSpecApproved: new LovStore<SpecApprovedModel>(),
} -
Update Shared Component LOV Langkah terakhir adalah mendaftarkan store baru tersebut ke dalam komponen UI agar bisa digunakan di form. Edit file di
src/app/components/shared/Lov/index.tsx.a. Ambil store dari context:
const { lovStoreAkasia, LOVSpecApproved } = useStore();b. Mapping Nama ke Store: Tambahkan mapping pada
const currentStoredi dalam useMemo agar komponen tahu store mana yang harus digunakan berdasarkan propertiname.const currentStore = useMemo(() => {
const storeMap: Record<LovOfName, LovStore<any>> = {
item: lovStoreItems,
akasia: lovStoreAkasia,
codeshp: lovStoreCodeShp,
specApproved: LOVSpecApproved, // Mapping identifier ke instance store
};
return storeMap[props.name];
}, [props.name, ...]); -
Contoh Implementasi di UI (Page/Feature) Setelah mendaftarkan LOV di store, gunakan komponen
<Lov />pada file fitur Anda. Komponen ini sudah terintegrasi dengan Material-UI (MUI) DataGrid dan mendukung pencarian otomatis. Contoh Penggunaan:<Lov
// Identifier unik untuk row data (biasanya GUID dari database)
rowId={(row) => row.txtGUID}
// State untuk mengontrol buka/tutup modal
open={state.aliasModal}
// Handler untuk menutup modal
setShow={() => setState(prev => ({ ...prev, aliasModal : false }))}
// Nama LOV yang sudah didaftarkan di LovOfName & LovStore
lovName="codeshp"
// Callback saat user memilih item dari tabel
setSelect={(item: any) => {
setFieldValue('txtItemCodeAlias', item.ItemCode);
}}
// Definisi kolom DataGrid yang akan ditampilkan di dalam modal
columns={[
{
field: 'ItemCode',
headerName: 'Item Code',
minWidth: 140,
},
{
field: 'Description',
headerName: 'Description',
minWidth: 350,
},
{
field: 'ItemType',
headerName: 'Type',
minWidth: 160,
},
]}
/>Prop Tipe Deskripsi lovName LovOfName Key identifier yang menghubungkan komponen dengan instance store & API terkait. rowId function Fungsi untuk menentukan primary key dari data (penting untuk seleksi row DataGrid). open boolean State boolean untuk visibilitas modal (biasanya dipicu dari klik button/input). setSelect function Logic yang dijalankan setelah user memilih data (misal: setFieldValue pada Formik). columns array Konfigurasi kolom MUI DataGrid (header, field, width).
Common Issues & Troubleshootingโ
Issue 1: Dev Server tidak bisa diaksesโ
Masalah: http://localhost:3002 tidak bisa dibuka
Solusi:
1. Pastikan port 3002 tidak digunakan program lain
2. Ubah port di vite.config.ts jika port sudah digunakan
3. Gunakan --host flag: yarn dev -- --host
Issue 2: API Proxy tidak bekerjaโ
Masalah: API calls return 404 atau CORS error
Solusi:
1. Verifikasi proxy config di vite.config.ts
2. Pastikan target URL benar dan accessible
3. Check environment variables di .env
4. Lihat browser console untuk error details
Issue 3: MobX store tidak terupdateโ
Masalah: Component tidak re-render saat store berubah
Solusi:
1. Pastikan component wrapped dengan observer()
2. Gunakan @observable untuk state
3. Gunakan @action untuk mutations
4. Verifikasi import path dan store initialization
Issue 4: Build fails dengan TypeScript errorsโ
Masalah: npm run build gagal dengan TS errors
Solusi:
1. Run: npm run lint untuk melihat error details
2. Fix type definitions di model files
3. Pastikan semua imports benar
4. Check tsconfig.json settings
Issue 5: Environment variables tidak terbacaโ
Masalah: import.meta.env.VITE_* return undefined
Solusi:
1. Nama variabel harus diawali VITE_
2. Pastikan .env file ada di root folder
3. Restart dev server setelah update .env
4. Check: console.log(import.meta.env) untuk debugging
Issue 6: PWA tidak bisa installโ
Masalah: Service worker registration fails
Solusi:
1. Verifikasi vite-plugin-pwa config
2. Build project: npm run build
3. Check console.log untuk registration errors
4. PWA hanya bekerja di HTTPS (production)
Issue 7: MobX State tidak Re-renderโ
Masalah: Component lupa dibungkus dengan observer.
Solusi:
import { observer } from 'mobx-react-lite';
const MyComponent = observer(() => {
// logic...
});
Debugging Tipsโ
1. Browser DevToolsโ
- F12 atau Ctrl+Shift+I untuk buka DevTools
- Tab Console untuk JS errors
- Tab Network untuk API calls
- Tab Application > Storage untuk cookies/localStorage
- Tab Sources untuk set breakpoints
2. React DevToolsโ
- Install React DevTools extension
- Inspect components dalam component tree
- View props dan state
- Profile component performance
3. MobX DevToolsโ
- Install MobX DevTools extension
- Monitor store changes
- Time-travel debugging
4. Loggingโ
// Console logging
console.log('Debug:', variable);
console.error('Error:', error);
console.table(data); // Pretty print array/object
// Debugger breakpoint
debugger; // Will pause execution
Dokumentasi & Resourcesโ
Internal Documentationโ
- [README.md] - Dokumentasi awal
- Swagger API: https://prexitionapidev.gvn.co.id/swagger/index.html
External Resourcesโ
React Ecosystemโ
State Managementโ
UI Frameworkโ
Form & Validationโ
Tools & Buildโ
Utility Librariesโ
PWA & Service Workerโ
Migration & Upgrade Guideโ
Updating Dependenciesโ
# Check outdated packages
npm outdated
# Update specific package
npm update package-name@latest
# Update all packages
npm update
# Security audit
npm audit fix
Support & Contactโ
Tim Developmentโ
- Frontend Lead: Dana Mulyana
- BackEnd Lead: Ilham Paqi Andriyansah
Issue Trackingโ
- GitHub
- Dokumentasikan issue dengan clear steps to reproduce
Knowledge Baseโ
- Discussion channel (Teams)
Change Logโ
| Versi | Tanggal | Changes |
|---|---|---|
| 3.0.0 | 2025 | Current version |
| 2.x.x | - | Previous versions |
Dokumen ini dibuat untuk memudahkan handover dan memastikan kontinuitas development.
Untuk update atau pertanyaan, silakan contact tim development.
Last Updated: Desember 2025 Dokumentasi Project PREXITION - PT Global Vita Nutritech Indonesia