Skip to content

Commit

Permalink
refactor(mui-error-component): add params resource variable
Browse files Browse the repository at this point in the history
  • Loading branch information
biskuvit committed Jun 13, 2022
1 parent 28a038c commit e72ab12
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/mui/src/components/pages/error/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@ export const ErrorComponent: React.FC = () => {

useEffect(() => {
const action = params.action ?? "list";
const resourceName = params.resource;
setErrorMessage(
translate(
"pages.error.info",
{
action,
resource: params.resource,
resource: resourceName,
},
`You may have forgotten to add the "${action}" component to "${params.resource}" resource.`,
`You may have forgotten to add the "${action}" component to "${resourceName}" resource.`,
),
);
if (params.resource) {
const resourceFromRoute = resource(params.resource);
if (resourceName) {
const resourceFromRoute = resource(resourceName);
if (
action &&
actionTypes.includes(action) &&
Expand All @@ -44,9 +45,9 @@ export const ErrorComponent: React.FC = () => {
"pages.error.info",
{
action,
resource: params.resource,
resource: resourceName,
},
`You may have forgotten to add the "${action}" component to "${params.resource}" resource.`,
`You may have forgotten to add the "${action}" component to "${resourceName}" resource.`,
),
);
}
Expand Down

0 comments on commit e72ab12

Please sign in to comment.