CE-936 - Update to receive warnings within the response QRecord and display them (this fixes inserts that warn)

This commit is contained in:
2024-03-19 11:13:58 -05:00
parent 6c524c4eca
commit 84e627467f
2 changed files with 22 additions and 4 deletions

View File

@ -6,7 +6,7 @@
"@auth0/auth0-react": "1.10.2", "@auth0/auth0-react": "1.10.2",
"@emotion/react": "11.7.1", "@emotion/react": "11.7.1",
"@emotion/styled": "11.6.0", "@emotion/styled": "11.6.0",
"@kingsrook/qqq-frontend-core": "1.0.89", "@kingsrook/qqq-frontend-core": "1.0.90",
"@mui/icons-material": "5.4.1", "@mui/icons-material": "5.4.1",
"@mui/material": "5.11.1", "@mui/material": "5.11.1",
"@mui/styles": "5.11.1", "@mui/styles": "5.11.1",

View File

@ -759,7 +759,9 @@ function EntityForm(props: Props): JSX.Element
if (props.id !== null && !props.isCopy) if (props.id !== null && !props.isCopy)
{ {
// todo - audit that it's a dupe ///////////////////////
// perform an update //
///////////////////////
await qController await qController
.update(tableName, props.id, valuesToPost) .update(tableName, props.id, valuesToPost)
.then((record) => .then((record) =>
@ -770,8 +772,14 @@ function EntityForm(props: Props): JSX.Element
} }
else else
{ {
let warningMessage = null;
if(record.warnings && record.warnings.length && record.warnings.length > 0)
{
warningMessage = record.warnings[0];
}
const path = location.pathname.replace(/\/edit$/, ""); const path = location.pathname.replace(/\/edit$/, "");
navigate(path, {state: {updateSuccess: true}}); navigate(path, {state: {updateSuccess: true, warning: warningMessage}});
} }
}) })
.catch((error) => .catch((error) =>
@ -793,6 +801,10 @@ function EntityForm(props: Props): JSX.Element
} }
else else
{ {
/////////////////////////////////
// perform an insert //
// todo - audit if it's a dupe //
/////////////////////////////////
await qController await qController
.create(tableName, valuesToPost) .create(tableName, valuesToPost)
.then((record) => .then((record) =>
@ -803,10 +815,16 @@ function EntityForm(props: Props): JSX.Element
} }
else else
{ {
let warningMessage = null;
if(record.warnings && record.warnings.length && record.warnings.length > 0)
{
warningMessage = record.warnings[0];
}
const path = props.isCopy ? const path = props.isCopy ?
location.pathname.replace(new RegExp(`/${props.id}/copy$`), "/" + record.values.get(tableMetaData.primaryKeyField)) location.pathname.replace(new RegExp(`/${props.id}/copy$`), "/" + record.values.get(tableMetaData.primaryKeyField))
: location.pathname.replace(/create$/, record.values.get(tableMetaData.primaryKeyField)); : location.pathname.replace(/create$/, record.values.get(tableMetaData.primaryKeyField));
navigate(path, {state: {createSuccess: true}}); navigate(path, {state: {createSuccess: true, warning: warningMessage}});
} }
}) })
.catch((error) => .catch((error) =>