Skip to content

Commit

Permalink
fix(edithomepage): move error msg extraction into component
Browse files Browse the repository at this point in the history
  • Loading branch information
seaerchin committed Sep 6, 2023
1 parent 5e285cf commit 63ebfb1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/layouts/EditHomepage/EditHomepage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ const EditHomepage = ({ match }) => {
setDisplayHighlights(displayHighlights)
}
const heroSection = frontMatter.sections.filter((section) => !!section.hero)
const errorMessages = getErrorsFromHomepageState(homepageState)

const errorToast = useErrorToast()

Expand Down Expand Up @@ -1093,7 +1092,13 @@ const EditHomepage = ({ match }) => {
/>
</HStack>
<Footer>
{errorMessages.some((message) => message.includes("longer")) && (
{/* NOTE: We have to call this method twice because `homepageState` isn't guaranteed to be loaded
if we put the declaration out of the components.
This is because we have a blocking conditional `isLoaded` that gets set only after data is fetched.
*/}
{getErrorsFromHomepageState(homepageState).some((message) =>
message.includes("longer")
) && (
<Text
mr="0.25rem"
textStyle="body-2"
Expand All @@ -1104,7 +1109,7 @@ const EditHomepage = ({ match }) => {
</Text>
)}
<LoadingButton
isDisabled={errorMessages.length > 0}
isDisabled={getErrorsFromHomepageState(homepageState)}
onClick={savePage}
>
Save
Expand Down

0 comments on commit 63ebfb1

Please sign in to comment.