Skip to content

Commit cf0a883

Browse files
ewurchpaulpopus
andauthored
chore(templates): remove redundant condition check (#12130)
<!-- Thank you for the PR! Please go through the checklist below and make sure you've completed all the steps. Please review the [CONTRIBUTING.md](https://github.com/payloadcms/payload/blob/main/CONTRIBUTING.md) document in this repository if you haven't already. The following items will ensure that your PR is handled as smoothly as possible: - PR Title must follow conventional commits format. For example, `feat: my new feature`, `fix(plugin-seo): my fix`. - Minimal description explained as if explained to someone not immediately familiar with the code. - Provide before/after screenshots or code diffs if applicable. - Link any related issues/discussions from GitHub or Discord. - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Fixes # --> This PR fixes a redundant condition check on the Card element from: ```typescript <div className="p-4"> {showCategories && hasCategories && ( <div className="uppercase text-sm mb-4"> {showCategories && hasCategories && ( <div> ... ``` to: ```typescript <div className="p-4"> {showCategories && hasCategories && ( <div className="uppercase text-sm mb-4"> ... ``` Co-authored-by: Paul Popus <paul@payloadcms.com>
1 parent 750d29f commit cf0a883

1 file changed

Lines changed: 18 additions & 22 deletions

File tree

  • templates/website/src/components/Card

templates/website/src/components/Card/index.tsx

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,24 @@ export const Card: React.FC<{
4444
<div className="p-4">
4545
{showCategories && hasCategories && (
4646
<div className="uppercase text-sm mb-4">
47-
{showCategories && hasCategories && (
48-
<div>
49-
{categories?.map((category, index) => {
50-
if (typeof category === 'object') {
51-
const { title: titleFromCategory } = category
52-
53-
const categoryTitle = titleFromCategory || 'Untitled category'
54-
55-
const isLast = index === categories.length - 1
56-
57-
return (
58-
<Fragment key={index}>
59-
{categoryTitle}
60-
{!isLast && <Fragment>, &nbsp;</Fragment>}
61-
</Fragment>
62-
)
63-
}
64-
65-
return null
66-
})}
67-
</div>
68-
)}
47+
{categories?.map((category, index) => {
48+
if (typeof category === 'object') {
49+
const { title: titleFromCategory } = category
50+
51+
const categoryTitle = titleFromCategory || 'Untitled category'
52+
53+
const isLast = index === categories.length - 1
54+
55+
return (
56+
<Fragment key={index}>
57+
{categoryTitle}
58+
{!isLast && <Fragment>, &nbsp;</Fragment>}
59+
</Fragment>
60+
)
61+
}
62+
63+
return null
64+
})}
6965
</div>
7066
)}
7167
{titleToUse && (

0 commit comments

Comments
 (0)