From 5d9f0f6d94c9659679971fefa8ae6b4fe91d5b41 Mon Sep 17 00:00:00 2001 From: Firman Ramdhani <33869609+firmanramdhani@users.noreply.github.com> Date: Fri, 29 May 2026 17:36:34 +0700 Subject: [PATCH] refactor: restructure storage and environment modules; remove unused code - Deleted unused PouchDB configuration and types from core storage. - Removed Electron-related hooks and utilities that are no longer needed. - Introduced new local storage management for application keys. - Created a new environment wrapper for landing application. - Added public HTTP client for landing application with minimal configuration. - Implemented new PouchDB entities for items and POS configurations. - Updated main application entry point to reflect new storage structure. --- .../landing/src/{ => core}/environment/env.ts | 0 apps/landing/src/{ => core}/lib/api-client.ts | 0 .../src/{ => core}/locales/en/home.json | 0 .../src/{ => core}/locales/id/home.json | 0 .../data/public.data-services.ts | 13 +- .../src/presentation/I18nLandingSample.tsx | 4 +- apps/landing/src/types/i18next.d.ts | 2 +- .../auth-sync/storage-sync.listener.tsx | 2 +- .../booking/data/booking.data-services.ts | 13 +- .../features/i18n/presentation/I18nSample.tsx | 2 +- .../storage/presentation/StorageSample.tsx | 2 +- apps/web/src/apps/showcase/pouch-sample.tsx | 128 ++++++++-------- apps/web/src/apps/showcase/printer-list.tsx | 16 +- apps/web/src/apps/showcase/showcase-view.tsx | 141 ++++++++++++------ apps/web/src/core/db/types.ts | 47 ------ .../env.ts => core/environment/index.ts} | 0 .../{ => core}/hooks/use-electron-printer.ts | 0 .../{ => core}/hooks/use-electron-updater.ts | 0 .../src/{ => core}/hooks/use-is-electron.ts | 0 apps/web/src/{ => core}/lib/api-client.ts | 0 .../web/src/core/storage/{ => local}/index.ts | 0 .../core/storage/pouch-db/entities/index.ts | 2 + .../pouch-db/entities/item.pouchdb.entity.ts | 27 ++++ .../pos-configuration.pouchdb.entity.ts | 16 ++ .../core/{db => storage/pouch-db}/index.ts | 13 +- apps/web/src/main.tsx | 2 +- 26 files changed, 233 insertions(+), 197 deletions(-) rename apps/landing/src/{ => core}/environment/env.ts (100%) rename apps/landing/src/{ => core}/lib/api-client.ts (100%) rename apps/landing/src/{ => core}/locales/en/home.json (100%) rename apps/landing/src/{ => core}/locales/id/home.json (100%) delete mode 100644 apps/web/src/core/db/types.ts rename apps/web/src/{environment/env.ts => core/environment/index.ts} (100%) rename apps/web/src/{ => core}/hooks/use-electron-printer.ts (100%) rename apps/web/src/{ => core}/hooks/use-electron-updater.ts (100%) rename apps/web/src/{ => core}/hooks/use-is-electron.ts (100%) rename apps/web/src/{ => core}/lib/api-client.ts (100%) rename apps/web/src/core/storage/{ => local}/index.ts (100%) create mode 100644 apps/web/src/core/storage/pouch-db/entities/index.ts create mode 100644 apps/web/src/core/storage/pouch-db/entities/item.pouchdb.entity.ts create mode 100644 apps/web/src/core/storage/pouch-db/entities/pos-configuration.pouchdb.entity.ts rename apps/web/src/core/{db => storage/pouch-db}/index.ts (85%) diff --git a/apps/landing/src/environment/env.ts b/apps/landing/src/core/environment/env.ts similarity index 100% rename from apps/landing/src/environment/env.ts rename to apps/landing/src/core/environment/env.ts diff --git a/apps/landing/src/lib/api-client.ts b/apps/landing/src/core/lib/api-client.ts similarity index 100% rename from apps/landing/src/lib/api-client.ts rename to apps/landing/src/core/lib/api-client.ts diff --git a/apps/landing/src/locales/en/home.json b/apps/landing/src/core/locales/en/home.json similarity index 100% rename from apps/landing/src/locales/en/home.json rename to apps/landing/src/core/locales/en/home.json diff --git a/apps/landing/src/locales/id/home.json b/apps/landing/src/core/locales/id/home.json similarity index 100% rename from apps/landing/src/locales/id/home.json rename to apps/landing/src/core/locales/id/home.json diff --git a/apps/landing/src/features/public-content/data/public.data-services.ts b/apps/landing/src/features/public-content/data/public.data-services.ts index 6217c88..cd2d3bc 100644 --- a/apps/landing/src/features/public-content/data/public.data-services.ts +++ b/apps/landing/src/features/public-content/data/public.data-services.ts @@ -1,6 +1,6 @@ import { CommonRemoteDataServices } from '@repo/core-api/data-services'; import type { BaseEntity } from '@repo/core-api/data-services'; -import { publicClient } from '../../../lib/api-client'; +import { publicClient } from '../../../core/lib/api-client'; // ─── Domain Entity ────────────────────────────────────────────── @@ -31,10 +31,7 @@ export interface PublicContentEntity extends BaseEntity { * const { data: post } = await publicContentServices.getOne('hello-world'); * ``` */ -export const publicContentServices = new CommonRemoteDataServices( - publicClient, - { - apiUrl: '/content', - moduleKey: 'PUBLIC_CONTENT', - }, -); +export const publicContentServices = new CommonRemoteDataServices(publicClient, { + apiUrl: '/content', + moduleKey: 'PUBLIC_CONTENT', +}); diff --git a/apps/landing/src/presentation/I18nLandingSample.tsx b/apps/landing/src/presentation/I18nLandingSample.tsx index 366bbc0..2d5efcb 100644 --- a/apps/landing/src/presentation/I18nLandingSample.tsx +++ b/apps/landing/src/presentation/I18nLandingSample.tsx @@ -2,8 +2,8 @@ import { useEffect, useState } from 'react'; import { useTranslation, changeLanguage, i18n } from '@repo/core-i18n'; // Decentralized locale imports -import homeId from '../locales/id/home.json'; -import homeEn from '../locales/en/home.json'; +import homeId from '../core/locales/id/home.json'; +import homeEn from '../core/locales/en/home.json'; // Bendera penanda statis di level modul (default: false) let isHomeDictLoaded = false; diff --git a/apps/landing/src/types/i18next.d.ts b/apps/landing/src/types/i18next.d.ts index fd7316b..4035df8 100644 --- a/apps/landing/src/types/i18next.d.ts +++ b/apps/landing/src/types/i18next.d.ts @@ -7,7 +7,7 @@ import homeEn from '../locales/en/home.json'; declare module 'react-i18next' { interface CustomTypeOptions { defaultNS: 'common'; - resources: typeof coreResources['en'] & { + resources: (typeof coreResources)['en'] & { home: typeof homeEn; }; } diff --git a/apps/web/src/apps/showcase/events-demo/auth-sync/storage-sync.listener.tsx b/apps/web/src/apps/showcase/events-demo/auth-sync/storage-sync.listener.tsx index 7ed0ca5..7725582 100644 --- a/apps/web/src/apps/showcase/events-demo/auth-sync/storage-sync.listener.tsx +++ b/apps/web/src/apps/showcase/events-demo/auth-sync/storage-sync.listener.tsx @@ -1,6 +1,6 @@ import { useAppEvent } from '@repo/core-events'; import type { ProfileUpdatedPayload } from '@repo/core-events'; -import { secureIndexedDB, AppStorageKey } from '../../../../core/storage'; +import { secureIndexedDB, AppStorageKey } from '../../../../core/storage/local'; // ─── Props ────────────────────────────────────────────────────── diff --git a/apps/web/src/apps/showcase/example/features/booking/data/booking.data-services.ts b/apps/web/src/apps/showcase/example/features/booking/data/booking.data-services.ts index 2473f15..2c2d8a0 100644 --- a/apps/web/src/apps/showcase/example/features/booking/data/booking.data-services.ts +++ b/apps/web/src/apps/showcase/example/features/booking/data/booking.data-services.ts @@ -1,6 +1,6 @@ import { CommonRemoteDataServices } from '@repo/core-api/data-services'; import type { BaseEntity } from '@repo/core-api/data-services'; -import { apiClient } from '../../../../../../lib/api-client'; +import { apiClient } from '../../../../../../core/lib/api-client'; // ─── Domain Entity ────────────────────────────────────────────── @@ -34,10 +34,7 @@ export interface BookingEntity extends BaseEntity { * await bookingServices.confirmProcessTransaction('42'); * ``` */ -export const bookingServices = new CommonRemoteDataServices( - apiClient, - { - apiUrl: '/bookings', - moduleKey: 'BOOKING', - }, -); +export const bookingServices = new CommonRemoteDataServices(apiClient, { + apiUrl: '/bookings', + moduleKey: 'BOOKING', +}); diff --git a/apps/web/src/apps/showcase/example/features/i18n/presentation/I18nSample.tsx b/apps/web/src/apps/showcase/example/features/i18n/presentation/I18nSample.tsx index 992602e..971cac4 100644 --- a/apps/web/src/apps/showcase/example/features/i18n/presentation/I18nSample.tsx +++ b/apps/web/src/apps/showcase/example/features/i18n/presentation/I18nSample.tsx @@ -1,6 +1,6 @@ import { useState, useEffect, useCallback } from 'react'; import { useTranslation, changeLanguage, applyTenantOverrides, i18n } from '@repo/core-i18n'; -import { secureIndexedDB, AppStorageKey } from '../../../../../../core/storage'; +import { secureIndexedDB, AppStorageKey } from '../../../../../../core/storage/local'; // Decentralized locale imports import bookingId from '../locales/id/booking.json'; diff --git a/apps/web/src/apps/showcase/example/features/storage/presentation/StorageSample.tsx b/apps/web/src/apps/showcase/example/features/storage/presentation/StorageSample.tsx index cb2d6b0..58e9d7b 100644 --- a/apps/web/src/apps/showcase/example/features/storage/presentation/StorageSample.tsx +++ b/apps/web/src/apps/showcase/example/features/storage/presentation/StorageSample.tsx @@ -1,5 +1,5 @@ import { useState, useCallback } from 'react'; -import { secureStorage, secureIndexedDB, AppStorageKey } from '../../../../../../core/storage'; +import { secureStorage, secureIndexedDB, AppStorageKey } from '../../../../../../core/storage/local'; // ─── Demo Data ────────────────────────────────────────────────── diff --git a/apps/web/src/apps/showcase/pouch-sample.tsx b/apps/web/src/apps/showcase/pouch-sample.tsx index 08ccfe4..2ab3b51 100644 --- a/apps/web/src/apps/showcase/pouch-sample.tsx +++ b/apps/web/src/apps/showcase/pouch-sample.tsx @@ -1,20 +1,12 @@ import { useEffect, useState, useCallback } from 'react'; -import { - Button, - Card, - Group, - Stack, - Title, - Text, - Table, - Badge, -} from '@repo/ui/components'; -import { itemDB, posConfigDB } from '../../core/db'; -import type { Item, POSConfiguration } from '../../core/db/types'; +import { Button, Card, Group, Stack, Title, Text, Table, Badge } from '@repo/ui/components'; + +import { itemDB, posConfigDB } from '../../core/storage/pouch-db'; +import type { ItemEntity, POSConfigurationEntity } from '../../core/storage/pouch-db/entities'; export default function PouchSample() { - const [configs, setConfigs] = useState([]); - const [items, setItems] = useState([]); + const [configs, setConfigs] = useState([]); + const [items, setItems] = useState([]); // Load initial data const loadData = useCallback(async () => { @@ -24,7 +16,7 @@ export default function PouchSample() { const allItems = await itemDB.find({ selector: {} }); setItems(allItems); - console.log({allConfigs, allItems}) + console.log({ allConfigs, allItems }); } catch (err) { console.error('Failed to load PouchDB data', err); } @@ -150,35 +142,35 @@ export default function PouchSample() { Actions - - {items.length > 0 ? ( - items.map((item) => ( - - {item._id} - {item.name} - - - {item.item_type} - - - ${Number(item.base_price).toFixed(2)} - {item.item_rates?.length || 0} - - + + {items.length > 0 ? ( + items.map((item) => ( + + {item._id} + {item.name} + + + {item.item_type} + + + ${Number(item.base_price).toFixed(2)} + {item.item_rates?.length || 0} + + + + + )) + ) : ( + + + No items found. - )) - ) : ( - - - No items found. - - - )} - - + )} + + @@ -202,34 +194,34 @@ export default function PouchSample() { Actions - - {configs.length > 0 ? ( - configs.map((cfg) => ( - - {cfg._id} - {cfg.pos_name} - {cfg.pos_number} - - - {cfg.items?.length || 0} Items - - - - + + {configs.length > 0 ? ( + configs.map((cfg) => ( + + {cfg._id} + {cfg.pos_name} + {cfg.pos_number} + + + {cfg.items?.length || 0} Items + + + + + + + )) + ) : ( + + + No configurations found. - )) - ) : ( - - - No configurations found. - - - )} - - + )} + + diff --git a/apps/web/src/apps/showcase/printer-list.tsx b/apps/web/src/apps/showcase/printer-list.tsx index 832b663..a03df5a 100644 --- a/apps/web/src/apps/showcase/printer-list.tsx +++ b/apps/web/src/apps/showcase/printer-list.tsx @@ -1,7 +1,7 @@ // 1. Import hooks yang baru saja dibuat Opus import { Button } from '@repo/ui/components'; -import { useElectronPrinter } from '../../hooks/use-electron-printer'; -import { useElectronUpdater } from '../../hooks/use-electron-updater'; +import { useElectronPrinter } from '../../core/hooks/use-electron-printer'; +import { useElectronUpdater } from '../../core/hooks/use-electron-updater'; export default function App() { // 2. Panggil hooks-nya @@ -11,13 +11,15 @@ export default function App() { return (

🧪 Test Integrasi Electron

- -

Status Auto-Update: {status}

- + +

+ Status Auto-Update: {status} +

+ - +

🖨️ Daftar Printer di Komputer Ini:

    {printers.length === 0 ? ( @@ -32,4 +34,4 @@ export default function App() {
); -} \ No newline at end of file +} diff --git a/apps/web/src/apps/showcase/showcase-view.tsx b/apps/web/src/apps/showcase/showcase-view.tsx index eda7047..ca8f145 100644 --- a/apps/web/src/apps/showcase/showcase-view.tsx +++ b/apps/web/src/apps/showcase/showcase-view.tsx @@ -15,7 +15,6 @@ import { NumberInput, Textarea, Switch, - Radio, Table, Badge, Divider, @@ -48,13 +47,20 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set const getSubtitle = () => { switch (activeTab) { - case 'rbac': return 'Role-Based Access Control and Permissions'; - case 'storage': return 'Offline-First PouchDB Synchronization'; - case 'auth': return 'Authentication & Security Layers'; - case 'ui-components': return 'Theme, Typography, Forms & Data Grids'; - case 'events': return 'Global Event Bus Synchronization'; - case 'hardware': return 'Hardware Integration & Printers'; - default: return 'Architecture Showcase'; + case 'rbac': + return 'Role-Based Access Control and Permissions'; + case 'storage': + return 'Offline-First PouchDB Synchronization'; + case 'auth': + return 'Authentication & Security Layers'; + case 'ui-components': + return 'Theme, Typography, Forms & Data Grids'; + case 'events': + return 'Global Event Bus Synchronization'; + case 'hardware': + return 'Hardware Integration & Printers'; + default: + return 'Architecture Showcase'; } }; @@ -70,11 +76,11 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set className="h-screen" styles={{ root: { display: 'flex', height: '100vh', overflow: 'hidden' }, - list: { - minWidth: 260, - padding: '1rem', - borderRight: '1px solid var(--mantine-color-default-border)', - backgroundColor: 'var(--mantine-color-default-element-bg)' + list: { + minWidth: 260, + padding: '1rem', + borderRight: '1px solid var(--mantine-color-default-border)', + backgroundColor: 'var(--mantine-color-default-element-bg)', }, panel: { flex: 1, display: 'flex', flexDirection: 'column', height: '100vh', overflow: 'hidden' }, tab: { justifyContent: 'flex-start' }, // Ensure the entire tab content aligns left @@ -83,8 +89,12 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set > - Eigen ERP - Architecture Showcase + + Eigen ERP + + + Architecture Showcase + }> @@ -109,22 +119,24 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set {/* Header */} - Architecture Showcase - {getSubtitle()} + + {getSubtitle()} + @@ -132,25 +144,32 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set {/* Scrollable Content Area */} - {/* --- UI COMPONENTS TAB --- */} {activeTab === 'ui-components' && ( {/* Control Panel */} - Theme Controls + + Theme Controls + setDensity((val as DensityType) || 'standard')} - data={[{ value: 'compact', label: 'Compact (ERP Mode)' }, { value: 'standard', label: 'Standard (UI Mode)' }]} + data={[ + { value: 'compact', label: 'Compact (ERP Mode)' }, + { value: 'standard', label: 'Standard (UI Mode)' }, + ]} /> @@ -159,22 +178,40 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set
- Typography & Badges - This is dimmed small text indicating a subtitle. + + Typography & Badges + + + This is dimmed small text indicating a subtitle. + Brand Badge - Success Status - Error State + + Success Status + + + Error State +
- Buttons + + Buttons + - - - - + + + +
@@ -182,7 +219,9 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set {/* Forms */} - Form Elements + + Form Elements + @@ -202,7 +241,9 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set {/* Data Grid */} - Data Grid + + Data Grid + @@ -218,7 +259,12 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set {row.id} {row.customer} - + {row.status} @@ -242,7 +288,9 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set {activeTab === 'rbac' && ( - RBAC Engine + + RBAC Engine + RBAC Demo Component Coming Soon... @@ -252,7 +300,9 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set {activeTab === 'auth' && ( - Auth & Security + + Auth & Security + Auth Demo Component Coming Soon... @@ -262,7 +312,9 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set {activeTab === 'events' && ( - Nested Showcase Example + + Nested Showcase Example + This is an example of a nested showcase component. @@ -280,7 +332,6 @@ export default function ShowcaseView({ colorScheme, setColorScheme, density, set )} - diff --git a/apps/web/src/core/db/types.ts b/apps/web/src/core/db/types.ts deleted file mode 100644 index 4551cf9..0000000 --- a/apps/web/src/core/db/types.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Enterprise ERP Data Domain Models - * These types reflect the actual schema of the underlying CouchDB instances. - */ - -export interface ItemRate { - season_period?: string | null; - price: string | number; -} - -export interface ItemCategory { - _id?: string; - name?: string; - [key: string]: any; -} - -/** - * Represents a sellable product or service. - */ -export interface Item { - _id: string; - _rev?: string; - name: string; - base_price: string | number; - item_type: string; - usage_type?: string; - item_category?: ItemCategory[] | ItemCategory | string; - item_rates?: ItemRate[]; - - // Allow for other ERP-specific fields - [key: string]: any; -} - -/** - * Represents the configuration and assigned data for a specific Point of Sale terminal. - */ -export interface POSConfiguration { - _id: string; - _rev?: string; - pos_number: string; - pos_name: string; - items: Item[]; - payment_methods?: any[]; - - // Allow for other ERP-specific fields - [key: string]: any; -} diff --git a/apps/web/src/environment/env.ts b/apps/web/src/core/environment/index.ts similarity index 100% rename from apps/web/src/environment/env.ts rename to apps/web/src/core/environment/index.ts diff --git a/apps/web/src/hooks/use-electron-printer.ts b/apps/web/src/core/hooks/use-electron-printer.ts similarity index 100% rename from apps/web/src/hooks/use-electron-printer.ts rename to apps/web/src/core/hooks/use-electron-printer.ts diff --git a/apps/web/src/hooks/use-electron-updater.ts b/apps/web/src/core/hooks/use-electron-updater.ts similarity index 100% rename from apps/web/src/hooks/use-electron-updater.ts rename to apps/web/src/core/hooks/use-electron-updater.ts diff --git a/apps/web/src/hooks/use-is-electron.ts b/apps/web/src/core/hooks/use-is-electron.ts similarity index 100% rename from apps/web/src/hooks/use-is-electron.ts rename to apps/web/src/core/hooks/use-is-electron.ts diff --git a/apps/web/src/lib/api-client.ts b/apps/web/src/core/lib/api-client.ts similarity index 100% rename from apps/web/src/lib/api-client.ts rename to apps/web/src/core/lib/api-client.ts diff --git a/apps/web/src/core/storage/index.ts b/apps/web/src/core/storage/local/index.ts similarity index 100% rename from apps/web/src/core/storage/index.ts rename to apps/web/src/core/storage/local/index.ts diff --git a/apps/web/src/core/storage/pouch-db/entities/index.ts b/apps/web/src/core/storage/pouch-db/entities/index.ts new file mode 100644 index 0000000..4baf085 --- /dev/null +++ b/apps/web/src/core/storage/pouch-db/entities/index.ts @@ -0,0 +1,2 @@ +export * from './item.pouchdb.entity'; +export * from './pos-configuration.pouchdb.entity'; diff --git a/apps/web/src/core/storage/pouch-db/entities/item.pouchdb.entity.ts b/apps/web/src/core/storage/pouch-db/entities/item.pouchdb.entity.ts new file mode 100644 index 0000000..feefa14 --- /dev/null +++ b/apps/web/src/core/storage/pouch-db/entities/item.pouchdb.entity.ts @@ -0,0 +1,27 @@ +interface ItemRateEntity { + season_period?: string | null; + price: string | number; +} + +interface ItemCategoryEntity { + _id?: string; + name?: string; + [key: string]: any; +} + +/** + * Represents a sellable product or service. + */ +export interface ItemEntity { + _id: string; + _rev?: string; + name: string; + base_price: string | number; + item_type: string; + usage_type?: string; + item_category?: ItemCategoryEntity[] | ItemCategoryEntity | string; + item_rates?: ItemRateEntity[]; + + // Allow for other ERP-specific fields + [key: string]: any; +} diff --git a/apps/web/src/core/storage/pouch-db/entities/pos-configuration.pouchdb.entity.ts b/apps/web/src/core/storage/pouch-db/entities/pos-configuration.pouchdb.entity.ts new file mode 100644 index 0000000..3bed0c3 --- /dev/null +++ b/apps/web/src/core/storage/pouch-db/entities/pos-configuration.pouchdb.entity.ts @@ -0,0 +1,16 @@ +import { ItemEntity } from './item.pouchdb.entity'; + +/** + * Represents the configuration and assigned data for a specific Point of Sale terminal. + */ +export interface POSConfigurationEntity { + _id: string; + _rev?: string; + pos_number: string; + pos_name: string; + items: ItemEntity[]; + payment_methods?: any[]; + + // Allow for other ERP-specific fields + [key: string]: any; +} diff --git a/apps/web/src/core/db/index.ts b/apps/web/src/core/storage/pouch-db/index.ts similarity index 85% rename from apps/web/src/core/db/index.ts rename to apps/web/src/core/storage/pouch-db/index.ts index 27cc06a..42c7fdf 100644 --- a/apps/web/src/core/db/index.ts +++ b/apps/web/src/core/storage/pouch-db/index.ts @@ -5,9 +5,10 @@ * which databases to create and where they sync to. The core engine * (`PouchDatabaseManager`) has zero knowledge of business domains. */ +import { ENV } from '../../environment'; import { PouchDatabaseManager } from '@repo/core-storage'; -import { ENV } from '../../environment/env'; -import type { Item, POSConfiguration } from './types'; + +import { ItemEntity, POSConfigurationEntity } from './entities'; // ─── Manager Singleton ────────────────────────────────────────── @@ -24,9 +25,7 @@ function buildRemoteUrl(dbName: string): string | undefined { } // 1. Tambahkan http:// secara otomatis jika DevOps hanya mengisi IP Address di .env - const safeBaseUrl = COUCHDB_BASE_URL.startsWith('http') - ? COUCHDB_BASE_URL - : `http://${COUCHDB_BASE_URL}`; + const safeBaseUrl = COUCHDB_BASE_URL.startsWith('http') ? COUCHDB_BASE_URL : `http://${COUCHDB_BASE_URL}`; try { // 2. Gunakan URL parser yang aman dari karakter aneh pada password @@ -45,13 +44,13 @@ function buildRemoteUrl(dbName: string): string | undefined { // ─── Register Application Databases ───────────────────────────── /** POS Configuration database — stores device settings, theme, etc. */ -export const posConfigDB = dbManager.register({ +export const posConfigDB = dbManager.register({ localName: 'pos_configuration', remoteUrl: buildRemoteUrl('pos_configuration'), }); /** Items database — products available for sale in POS. */ -export const itemDB = dbManager.register({ +export const itemDB = dbManager.register({ localName: 'item', remoteUrl: buildRemoteUrl('item'), }); diff --git a/apps/web/src/main.tsx b/apps/web/src/main.tsx index 300ce25..4c9c1a6 100644 --- a/apps/web/src/main.tsx +++ b/apps/web/src/main.tsx @@ -16,7 +16,7 @@ import './main.css'; import { lazy, StrictMode } from 'react'; import { createRoot } from 'react-dom/client'; import { setupI18n } from '@repo/core-i18n'; -import { secureStorage, AppStorageKey } from './core/storage'; +import { secureStorage, AppStorageKey } from './core/storage/local'; const App = lazy(() => import('./apps'));