Skip to content

Commit

Permalink
refactor(index): simplify error handling in EditHomepage, EditableHom…
Browse files Browse the repository at this point in the history
…epage, 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 <OtherError /> component when an error occurs. This improves code readability and reduces redundancy.
  • Loading branch information
ktun95 committed Feb 28, 2024
1 parent 65b82a0 commit c39445a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 1 addition & 3 deletions apps/stock-center/src/pages/index/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ const EditHomepage = () => {
),
)
.with({ loading: true }, () => <LoadingDisplay rows={4} />)
.with({ error: P.select(P.not(undefined)) }, (error) => (
<OtherError />
))
.with({ error: P.not(undefined) }, () => <OtherError />)
.otherwise(() => (
<> This message should not appear. </>
))}
Expand Down
4 changes: 1 addition & 3 deletions apps/stock-center/src/pages/index/editable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ const EditableHomepage = () => {
(content) => <EditableView data={content} />,
)
.with({ loading: true }, () => <LoadingDisplay rows={4} />)
.with({ error: P.select(P.not(undefined)) }, (error) => (
<OtherError />
))
.with({ error: P.not(undefined) }, () => <OtherError />)
.otherwise(() => (
<> This message should not appear. </>
))}
Expand Down
4 changes: 1 addition & 3 deletions apps/stock-center/src/pages/index/show.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ const ShowHomepage = () => {
(content) => <ContentView data={content} />,
)
.with({ loading: true }, () => <LoadingDisplay rows={4} />)
.with({ error: P.select(P.not(undefined)) }, (error) => (
<OtherError />
))
.with({ error: P.not(undefined) }, () => <OtherError />)
.otherwise(() => (
<> This message should not appear. </>
))}
Expand Down

0 comments on commit c39445a

Please sign in to comment.