mirror of
https://github.com/StepanovPlaton/jelly_belly_wiki.git
synced 2026-04-04 04:40:43 +04:00
09-07
This commit is contained in:
39
src/features/itemCard/itemCard.tsx
Normal file
39
src/features/itemCard/itemCard.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import {
|
||||
BeanType,
|
||||
CombinationType,
|
||||
FactType,
|
||||
ItemService,
|
||||
ItemType,
|
||||
RecipeType,
|
||||
TypesOfItems,
|
||||
} from "@/entities/item";
|
||||
import { BeanCard } from "./beanCard";
|
||||
import React from "react";
|
||||
import { FactCard } from "./factCard";
|
||||
import { RecipeCard } from "./recipeCard";
|
||||
import { CombinationCard } from "./combinationCard";
|
||||
import { MileStoneCard } from "./mileStoneCard";
|
||||
import { MileStoneType } from "@/entities/item/mileStones";
|
||||
|
||||
const ItemTypeToCard = (
|
||||
item: ItemType,
|
||||
ref: React.ForwardedRef<HTMLDivElement>
|
||||
) => {
|
||||
return {
|
||||
[TypesOfItems.bean]: <BeanCard item={item as BeanType} ref={ref} />,
|
||||
[TypesOfItems.fact]: <FactCard item={item as FactType} ref={ref} />,
|
||||
[TypesOfItems.recipe]: <RecipeCard item={item as RecipeType} ref={ref} />,
|
||||
[TypesOfItems.combination]: (
|
||||
<CombinationCard item={item as CombinationType} ref={ref} />
|
||||
),
|
||||
[TypesOfItems.mileStone]: (
|
||||
<MileStoneCard item={item as MileStoneType} ref={ref} />
|
||||
),
|
||||
}[ItemService.GetTypeOfItem(item)];
|
||||
};
|
||||
|
||||
export const ItemCard = React.forwardRef<HTMLDivElement, { item: ItemType }>(
|
||||
({ item }, ref) => {
|
||||
return ItemTypeToCard(item, ref);
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user