Skip to content

Commit 183194f

Browse files
committed
Improve form submission feedback and navigation
Updated integration and token instance pages to use more accurate navigation routes after actions. Enhanced SN Site and Token Instance forms to provide user feedback on both success and failure of create/update operations by awaiting service results and displaying appropriate toast messages.
1 parent 33fa9d8 commit 183194f

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

turing-react/src/app/console/integration/integration.instance.page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default function IntegrationInstancePage() {
5757
try {
5858
if (await turIntegrationInstanceService.delete(integration)) {
5959
toast.success(`The ${integration.title} Integration Instance was deleted`);
60-
navigate(urlBase);
60+
navigate(`${ROUTES.INTEGRATION_INSTANCE}`);
6161
} else {
6262
toast.error(`The ${integration.title} Integration Instance was not deleted`);
6363
}

turing-react/src/app/console/integration/integration.instance.source.list.page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function IntegrationInstanceSourceListPage() {
3333
title="You don’t seem to have any AEM sources."
3434
description="Create a new AEM source to index from many AEM external data sources."
3535
buttonText="New AEM source"
36-
urlNew={`${ROUTES.INTEGRATION_INSTANCE}/new`} />
36+
urlNew={`${ROUTES.INTEGRATION_INSTANCE}/${id}/source/new`} />
3737
)}
3838
</>
3939
)

turing-react/src/components/sn/sn.site.form.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,24 @@ export const SNSiteForm: React.FC<Props> = ({ value, isNew }) => {
4949
form.reset(value);
5050
}, [value])
5151

52-
function onSubmit(snSite: TurSNSite) {
52+
async function onSubmit(snSite: TurSNSite) {
5353
try {
5454
if (isNew) {
55-
turSNSiteService.create(snSite);
56-
toast.success(`The ${snSite.name} SN Site was saved`);
57-
navigate(urlBase);
55+
const result = await turSNSiteService.create(snSite);
56+
if (result) {
57+
toast.success(`The ${snSite.name} SN Site was saved`);
58+
navigate(urlBase);
59+
} else {
60+
toast.error(`The ${snSite.name} SN Site was not saved`);
61+
}
5862
}
5963
else {
60-
turSNSiteService.update(snSite);
61-
toast.success(`The ${snSite.name} SN Site was updated`);
64+
const result = await turSNSiteService.update(snSite);
65+
if (result) {
66+
toast.success(`The ${snSite.name} SN Site was updated`);
67+
} else {
68+
toast.error(`The ${snSite.name} SN Site was not updated`);
69+
}
6270
}
6371
} catch (error) {
6472
console.error("Form submission error", error);

turing-react/src/components/token/token.instance.form.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,24 @@ export const TokenInstanceForm: React.FC<Props> = ({ value, isNew }) => {
4747
}, [setValue, value]);
4848

4949

50-
function onSubmit(seInstance: TurTokenInstance) {
50+
async function onSubmit(seInstance: TurTokenInstance) {
5151
try {
5252
if (isNew) {
53-
turTokenInstanceService.create(seInstance);
54-
toast.success(`The ${seInstance.title} API Token was saved`);
55-
navigate(ROUTES.TOKEN_INSTANCE);
53+
const result = await turTokenInstanceService.create(seInstance);
54+
if (result) {
55+
toast.success(`The ${seInstance.title} API Token was saved`);
56+
navigate(ROUTES.TOKEN_INSTANCE);
57+
} else {
58+
toast.error(`The ${seInstance.title} API Token was not saved`);
59+
}
5660
}
5761
else {
58-
turTokenInstanceService.update(seInstance);
59-
toast.success(`The ${seInstance.title} API Token was updated`);
62+
const result = await turTokenInstanceService.update(seInstance);
63+
if (result) {
64+
toast.success(`The ${seInstance.title} API Token was updated`);
65+
} else {
66+
toast.error(`The ${seInstance.title} API Token was not updated`);
67+
}
6068
}
6169
} catch (error) {
6270
console.error("Form submission error", error);

0 commit comments

Comments
 (0)