From b6ba41e1206139fb0a87bb356f7013c6793a6a98 Mon Sep 17 00:00:00 2001 From: Firman Ramdhani <33869609+firmanramdhani@users.noreply.github.com> Date: Sat, 23 May 2026 06:55:58 +0700 Subject: [PATCH] feat: add showcase example component and integrate booking and storage demos --- apps/web/src/apps/index.tsx | 3 +- .../src/apps/modules/example/example.page.tsx | 18 +----- .../apps/showcase/example/example.page.tsx | 22 +++++++ .../booking/data/booking.data-services.ts | 0 .../booking/presentation/BookingSample.tsx | 0 .../features/i18n/locales/en/booking.json | 0 .../features/i18n/locales/id/booking.json | 0 .../features/i18n/presentation/I18nSample.tsx | 63 ++++++++++++------- .../storage/presentation/StorageSample.tsx | 4 +- apps/web/src/apps/showcase/showcase-view.tsx | 13 +++- 10 files changed, 80 insertions(+), 43 deletions(-) create mode 100644 apps/web/src/apps/showcase/example/example.page.tsx rename apps/web/src/apps/{modules => showcase}/example/features/booking/data/booking.data-services.ts (100%) rename apps/web/src/apps/{modules => showcase}/example/features/booking/presentation/BookingSample.tsx (100%) rename apps/web/src/apps/{modules => showcase}/example/features/i18n/locales/en/booking.json (100%) rename apps/web/src/apps/{modules => showcase}/example/features/i18n/locales/id/booking.json (100%) rename apps/web/src/apps/{modules => showcase}/example/features/i18n/presentation/I18nSample.tsx (87%) rename apps/web/src/apps/{modules => showcase}/example/features/storage/presentation/StorageSample.tsx (98%) diff --git a/apps/web/src/apps/index.tsx b/apps/web/src/apps/index.tsx index 0b35f3d..7ca77b6 100644 --- a/apps/web/src/apps/index.tsx +++ b/apps/web/src/apps/index.tsx @@ -33,8 +33,7 @@ export default function App() { } /> } /> } /> - {/* } /> */} - } /> + } /> } /> diff --git a/apps/web/src/apps/modules/example/example.page.tsx b/apps/web/src/apps/modules/example/example.page.tsx index f77b202..e6c1363 100644 --- a/apps/web/src/apps/modules/example/example.page.tsx +++ b/apps/web/src/apps/modules/example/example.page.tsx @@ -1,19 +1,3 @@ -import BookingSample from "./features/booking/presentation/BookingSample"; -import StorageSample from "./features/storage/presentation/StorageSample"; -import I18nSample from "./features/i18n/presentation/I18nSample"; - export default function ExamplePage() { - return
example -
-

Enterprise Web App

- -
-
-

Enterprise Web App

- -
-
- -
-
; + return
example
; } diff --git a/apps/web/src/apps/showcase/example/example.page.tsx b/apps/web/src/apps/showcase/example/example.page.tsx new file mode 100644 index 0000000..236318f --- /dev/null +++ b/apps/web/src/apps/showcase/example/example.page.tsx @@ -0,0 +1,22 @@ +import BookingSample from './features/booking/presentation/BookingSample'; +import StorageSample from './features/storage/presentation/StorageSample'; +import I18nSample from './features/i18n/presentation/I18nSample'; + +export default function ExamplePage() { + return ( +
+ example +
+

Enterprise Web App

+ +
+
+

Enterprise Web App

+ +
+
+ +
+
+ ); +} diff --git a/apps/web/src/apps/modules/example/features/booking/data/booking.data-services.ts b/apps/web/src/apps/showcase/example/features/booking/data/booking.data-services.ts similarity index 100% rename from apps/web/src/apps/modules/example/features/booking/data/booking.data-services.ts rename to apps/web/src/apps/showcase/example/features/booking/data/booking.data-services.ts diff --git a/apps/web/src/apps/modules/example/features/booking/presentation/BookingSample.tsx b/apps/web/src/apps/showcase/example/features/booking/presentation/BookingSample.tsx similarity index 100% rename from apps/web/src/apps/modules/example/features/booking/presentation/BookingSample.tsx rename to apps/web/src/apps/showcase/example/features/booking/presentation/BookingSample.tsx diff --git a/apps/web/src/apps/modules/example/features/i18n/locales/en/booking.json b/apps/web/src/apps/showcase/example/features/i18n/locales/en/booking.json similarity index 100% rename from apps/web/src/apps/modules/example/features/i18n/locales/en/booking.json rename to apps/web/src/apps/showcase/example/features/i18n/locales/en/booking.json diff --git a/apps/web/src/apps/modules/example/features/i18n/locales/id/booking.json b/apps/web/src/apps/showcase/example/features/i18n/locales/id/booking.json similarity index 100% rename from apps/web/src/apps/modules/example/features/i18n/locales/id/booking.json rename to apps/web/src/apps/showcase/example/features/i18n/locales/id/booking.json diff --git a/apps/web/src/apps/modules/example/features/i18n/presentation/I18nSample.tsx b/apps/web/src/apps/showcase/example/features/i18n/presentation/I18nSample.tsx similarity index 87% rename from apps/web/src/apps/modules/example/features/i18n/presentation/I18nSample.tsx rename to apps/web/src/apps/showcase/example/features/i18n/presentation/I18nSample.tsx index cd68b5e..0cab5e9 100644 --- a/apps/web/src/apps/modules/example/features/i18n/presentation/I18nSample.tsx +++ b/apps/web/src/apps/showcase/example/features/i18n/presentation/I18nSample.tsx @@ -47,6 +47,8 @@ export default function I18nSample() { try { const data = await demoIndexedDB.getItem(MOCK_DB_KEY); setDbPayloadStr(data ? JSON.stringify(data, null, 2) : 'No data in DB'); + setAdminHeaderTitle(data?.overrides?.header?.title || 'Daftar Pengeluaran'); + setAdminModuleName(data?.overrides?.module_name || 'PENGELUARAN'); } catch (e) { setDbPayloadStr('Error reading DB'); } @@ -61,8 +63,8 @@ export default function I18nSample() { namespace: 'booking', overrides: { module_name: adminModuleName, - header: { title: adminHeaderTitle } - } + header: { title: adminHeaderTitle }, + }, }; await demoIndexedDB.setItem(MOCK_DB_KEY, payload); setSyncStatus('✅ Saved tenant config to IndexedDB!'); @@ -83,8 +85,8 @@ export default function I18nSample() { namespace: 'booking', overrides: { module_name: 'PROCUREMENT (B)', - header: { title: 'Procurement List (B)' } - } + header: { title: 'Procurement List (B)' }, + }, }; } throw new Error('Unknown company'); @@ -137,7 +139,6 @@ export default function I18nSample() { // In a real app, you might apply this to the current active language or all languages. applyTenantOverrides(config.namespace, config.overrides, 'id'); applyTenantOverrides(config.namespace, config.overrides, 'en'); - } catch (err) { console.error('Failed to fetch config', err); } finally { @@ -153,7 +154,7 @@ export default function I18nSample() { }; return ( -
+

🌐 Enterprise i18n Demo

Current Active Language: {i18n.language} @@ -173,7 +174,14 @@ export default function I18nSample() { type="text" value={adminModuleName} onChange={(e) => setAdminModuleName(e.target.value)} - style={{ padding: 6, borderRadius: 4, background: '#1e293b', border: '1px solid #475569', color: '#fff', width: 250 }} + style={{ + padding: 6, + borderRadius: 4, + background: '#1e293b', + border: '1px solid #475569', + color: '#fff', + width: 250, + }} />

@@ -237,14 +252,12 @@ export default function I18nSample() {

B. Dynamic Tenant Overrides (End-to-End)

- Simulates a user logging in. It fetches the config directly from IndexedDB (mock database) and applies the deep-merge override. + Simulates a user logging in. It fetches the config directly from IndexedDB (mock database) and applies the + deep-merge override.

-