From 668bc1d829abf7259ffed73808e65014321d5a85 Mon Sep 17 00:00:00 2001 From: kansihksingh23 Date: Thu, 23 Apr 2026 06:38:12 +0000 Subject: [PATCH 1/2] fix: add local demo file support when VITE_API_URL is not set --- .../4f187905-c47e-4ebd-a095-ba254e8bfd80.json | 36 +++++++++++++++++++ public/examples/metadata.json | 21 +++++++++++ src/lib/api/fetchDemoData.ts | 18 +++++++--- src/lib/api/fetchDemoListData.ts | 14 ++++++-- src/pages/demo/demo-page.tsx | 2 +- 5 files changed, 84 insertions(+), 7 deletions(-) create mode 100644 public/examples/4f187905-c47e-4ebd-a095-ba254e8bfd80.json create mode 100644 public/examples/metadata.json diff --git a/public/examples/4f187905-c47e-4ebd-a095-ba254e8bfd80.json b/public/examples/4f187905-c47e-4ebd-a095-ba254e8bfd80.json new file mode 100644 index 0000000..b2ed855 --- /dev/null +++ b/public/examples/4f187905-c47e-4ebd-a095-ba254e8bfd80.json @@ -0,0 +1,36 @@ +{ + "demoName": "Batch Payments flow from PHEE - Mifos X", + "demoDescription": "End-to-end batch payment flow from Payment Hub EE to Mifos X", + "tags": [ + "MifosX", + "Phee" + ], + "steps": { + "1": { + "title": "Login to Ops Web", + "url": "http://ops.mifos.gazelle.test", + "details": "Login with default credentials to access the Payment Hub EE Operations Web" + }, + "2": { + "title": "Upload Batch CSV", + "url": "http://ops.mifos.gazelle.test", + "details": "Upload the pre-generated bulk payment CSV file for the batch transaction" + }, + "3": { + "title": "Approve the Batch", + "url": "http://ops.mifos.gazelle.test", + "details": "Review and approve the batch payment request" + }, + "4": { + "title": "Monitor Batch Status", + "url": "http://ops.mifos.gazelle.test", + "details": "Monitor the batch processing status until completion" + }, + "5": { + "title": "Verify Payments in MifosX", + "url": "http://mifos.mifos.gazelle.test", + "details": "Login to MifosX and verify the payments have been received" + } + }, + "demoId": "4f187905-c47e-4ebd-a095-ba254e8bfd80" +} \ No newline at end of file diff --git a/public/examples/metadata.json b/public/examples/metadata.json new file mode 100644 index 0000000..c614acb --- /dev/null +++ b/public/examples/metadata.json @@ -0,0 +1,21 @@ +{ + "demos": [ + { + "demoId": "4f187905-c47e-4ebd-a095-ba254e8bfd80", + "name": "Batch Payments flow from PHEE - Mifos X", + "file_name": "batch_payments_flow_from_phee__mifos_x.json", + "description": "End-to-end batch payment flow from Payment Hub EE to Mifos X", + "version": 1, + "steps_count": 5, + "created_at": "2026-04-20T09:42:33Z", + "updated_at": "2026-04-22T11:03:55Z", + "created_by": "kanishk05", + "last_modified_by": "kanishk05", + "deleted": false, + "tags": [ + "MifosX", + "Phee" + ] + } + ] +} diff --git a/src/lib/api/fetchDemoData.ts b/src/lib/api/fetchDemoData.ts index b52b180..882513c 100644 --- a/src/lib/api/fetchDemoData.ts +++ b/src/lib/api/fetchDemoData.ts @@ -1,9 +1,19 @@ import axios from 'axios'; export const fetchDemoData = async (demotitle: string) => { - const response = await axios.get(`${import.meta.env.VITE_API_URL}/demoData`, { - params: { demotitle }, + if (import.meta.env.VITE_API_URL) { + const response = await axios.get( + `${import.meta.env.VITE_API_URL}/demoData`, + { params: { demotitle } } + ); + return response.data; + } + + // Fallback to local examples when VITE_API_URL is not set + // demotitle is the demoId from the URL path + const response = await fetch(`/examples/${demotitle}.json`, { + headers: { 'Accept': 'application/json' } }); - console.log(response); - return response.data; + const data = await response.json(); + return data; }; diff --git a/src/lib/api/fetchDemoListData.ts b/src/lib/api/fetchDemoListData.ts index c4a3465..09b08c4 100644 --- a/src/lib/api/fetchDemoListData.ts +++ b/src/lib/api/fetchDemoListData.ts @@ -1,6 +1,16 @@ import axios from 'axios'; export const fetchDemoListData = async () => { - const response = await axios.get(`${import.meta.env.VITE_API_URL}/demoList`); - return response.data.demos; + if (import.meta.env.VITE_API_URL) { + const response = await axios.get( + `${import.meta.env.VITE_API_URL}/demoList` + ); + return response.data.demos; + } + + // Fallback to local examples when VITE_API_URL is not set + const response = await axios.get('/examples/metadata.json'); + return response.data.demos.filter( + (demo: { deleted: boolean }) => !demo.deleted + ); }; diff --git a/src/pages/demo/demo-page.tsx b/src/pages/demo/demo-page.tsx index 63264c6..a95e661 100644 --- a/src/pages/demo/demo-page.tsx +++ b/src/pages/demo/demo-page.tsx @@ -41,7 +41,7 @@ export const DemoPage = () => { useEffect(() => { setIsLoading(true); - const demoTitle = location.pathname.split('/')[3]; + const demoTitle = location.pathname.split('/')[2]; fetchDemoData(demoTitle) .then(demodatajson => { const steps = Object.entries(demodatajson.steps) From ba38a296f2d3abfa666068e0b196846e69bc4ab9 Mon Sep 17 00:00:00 2001 From: kansihksingh23 Date: Thu, 23 Apr 2026 08:39:16 +0000 Subject: [PATCH 2/2] fix: format files with prettier --- public/examples/4f187905-c47e-4ebd-a095-ba254e8bfd80.json | 7 ++----- public/examples/metadata.json | 5 +---- src/lib/api/fetchDemoData.ts | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/public/examples/4f187905-c47e-4ebd-a095-ba254e8bfd80.json b/public/examples/4f187905-c47e-4ebd-a095-ba254e8bfd80.json index b2ed855..27d61b7 100644 --- a/public/examples/4f187905-c47e-4ebd-a095-ba254e8bfd80.json +++ b/public/examples/4f187905-c47e-4ebd-a095-ba254e8bfd80.json @@ -1,10 +1,7 @@ { "demoName": "Batch Payments flow from PHEE - Mifos X", "demoDescription": "End-to-end batch payment flow from Payment Hub EE to Mifos X", - "tags": [ - "MifosX", - "Phee" - ], + "tags": ["MifosX", "Phee"], "steps": { "1": { "title": "Login to Ops Web", @@ -33,4 +30,4 @@ } }, "demoId": "4f187905-c47e-4ebd-a095-ba254e8bfd80" -} \ No newline at end of file +} diff --git a/public/examples/metadata.json b/public/examples/metadata.json index c614acb..a13253e 100644 --- a/public/examples/metadata.json +++ b/public/examples/metadata.json @@ -12,10 +12,7 @@ "created_by": "kanishk05", "last_modified_by": "kanishk05", "deleted": false, - "tags": [ - "MifosX", - "Phee" - ] + "tags": ["MifosX", "Phee"] } ] } diff --git a/src/lib/api/fetchDemoData.ts b/src/lib/api/fetchDemoData.ts index 882513c..5f3fa76 100644 --- a/src/lib/api/fetchDemoData.ts +++ b/src/lib/api/fetchDemoData.ts @@ -12,7 +12,7 @@ export const fetchDemoData = async (demotitle: string) => { // Fallback to local examples when VITE_API_URL is not set // demotitle is the demoId from the URL path const response = await fetch(`/examples/${demotitle}.json`, { - headers: { 'Accept': 'application/json' } + headers: { Accept: 'application/json' }, }); const data = await response.json(); return data;