Skip to content

Commit

Permalink
fix: カテゴリが存在しない時に新規追加カードが表示されない問題
Browse files Browse the repository at this point in the history
  • Loading branch information
Kogepan229 committed Jan 16, 2024
1 parent f70b641 commit 75412ea
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/app/list/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,22 @@ export default function list(): React.ReactElement {
const [Waiting, StartWaiting] = useWaiting();

function CardList(): React.ReactElement[] {
const card_new_category = (
<div key={'newcategory'} className={css.card} onClick={() => SetIsModalOpen(true)}>
<div className={css.create_icon}>
<AddIcon />
</div>
<p id={css.create_new}>新規作成</p>
</div>
)

Check failure on line 51 in src/app/list/page.tsx

View workflow job for this annotation

GitHub Actions / check (20)

Missing semicolon

if (!list || list.length === 0) {
return [];
return [card_new_category];
}

let cards: React.ReactElement[] = [];

Check failure on line 57 in src/app/list/page.tsx

View workflow job for this annotation

GitHub Actions / check (20)

'cards' is never reassigned. Use 'const' instead
let searchResult: AllCategoryDataType[] = [];
cards = [];

// 検索欄になにか記入されていたら、検索
if (search_str !== '') {
list.forEach(e => {
Expand Down Expand Up @@ -94,14 +104,8 @@ export default function list(): React.ReactElement {
}

// カテゴリ作成ページへ飛ぶカードを追加
cards.unshift(
<div key={'newcategory'} className={css.card} onClick={() => SetIsModalOpen(true)}>
<div className={css.create_icon}>
<AddIcon />
</div>
<p id={css.create_new}>新規作成</p>
</div>,
);
cards.unshift(card_new_category);

return cards;
}

Expand Down

0 comments on commit 75412ea

Please sign in to comment.