From c39445af1a9dd80cf7c94e17715babc8a681b8cc Mon Sep 17 00:00:00 2001 From: Kevin Tun Date: Wed, 28 Feb 2024 15:33:42 -0600 Subject: [PATCH] refactor(index): simplify error handling in EditHomepage, EditableHomepage, and ShowHomepage components The error handling in the EditHomepage, EditableHomepage, and ShowHomepage components has been simplified by removing unnecessary code. The error handling now uses a single line of code to render the component when an error occurs. This improves code readability and reduces redundancy. --- apps/stock-center/src/pages/index/edit.tsx | 4 +--- apps/stock-center/src/pages/index/editable.tsx | 4 +--- apps/stock-center/src/pages/index/show.tsx | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/apps/stock-center/src/pages/index/edit.tsx b/apps/stock-center/src/pages/index/edit.tsx index 5437067b16..f6b78915b9 100644 --- a/apps/stock-center/src/pages/index/edit.tsx +++ b/apps/stock-center/src/pages/index/edit.tsx @@ -41,9 +41,7 @@ const EditHomepage = () => { ), ) .with({ loading: true }, () => ) - .with({ error: P.select(P.not(undefined)) }, (error) => ( - - )) + .with({ error: P.not(undefined) }, () => ) .otherwise(() => ( <> This message should not appear. ))} diff --git a/apps/stock-center/src/pages/index/editable.tsx b/apps/stock-center/src/pages/index/editable.tsx index c9fa17e44b..7fcdbe344d 100644 --- a/apps/stock-center/src/pages/index/editable.tsx +++ b/apps/stock-center/src/pages/index/editable.tsx @@ -33,9 +33,7 @@ const EditableHomepage = () => { (content) => , ) .with({ loading: true }, () => ) - .with({ error: P.select(P.not(undefined)) }, (error) => ( - - )) + .with({ error: P.not(undefined) }, () => ) .otherwise(() => ( <> This message should not appear. ))} diff --git a/apps/stock-center/src/pages/index/show.tsx b/apps/stock-center/src/pages/index/show.tsx index ecbbff94fe..db37d47a2f 100644 --- a/apps/stock-center/src/pages/index/show.tsx +++ b/apps/stock-center/src/pages/index/show.tsx @@ -34,9 +34,7 @@ const ShowHomepage = () => { (content) => , ) .with({ loading: true }, () => ) - .with({ error: P.select(P.not(undefined)) }, (error) => ( - - )) + .with({ error: P.not(undefined) }, () => ) .otherwise(() => ( <> This message should not appear. ))}