Skip to content

Commit

Permalink
Merge pull request #18 from JollyGrin/feat/add-unique-ids
Browse files Browse the repository at this point in the history
Feat/add unique ids
  • Loading branch information
JollyGrin authored Sep 14, 2024
2 parents 2da8b7b + f8f2d37 commit 40a31fb
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
"react": "^18",
"react-dom": "^18",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.3.0"
"react-icons": "^5.3.0",
"uuid": "^10.0.0"
},
"devDependencies": {
"@pandacss/dev": "^0.45.2",
"@shadow-panda/preset": "^0.7.1",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/uuid": "^10.0.0",
"eslint": "^8",
"eslint-config-next": "14.2.8",
"typescript": "^5"
Expand Down
17 changes: 17 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/components/molecules/LoadDeck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { useState } from "react";
import { Box, Flex } from "styled-system/jsx";
import { button, input } from "styled-system/recipes";

import { v4 as uuid } from "uuid";

export const LoadDeck = (props: GameStateActions) => {
const [deckId, setDeckId] = useState<string>("");
const { data: deck } = useCuriosaDeck(deckId);
Expand All @@ -27,7 +29,7 @@ export const LoadDeck = (props: GameStateActions) => {
})).map(
(rest, index) =>
({
id: rest.identifier + index + Date.now(),
id: rest.identifier + index + uuid(),
img: rest.identifier,
type: "site",
}) as GameCard,
Expand All @@ -40,9 +42,9 @@ export const LoadDeck = (props: GameStateActions) => {
...spell,
quantity: undefined, // Remove the quantity field
})).map(
(rest, i) =>
(rest) =>
({
id: rest.identifier + i + Date.now(),
id: rest.identifier + uuid(),
img: rest.identifier,
type: "minion",
}) as GameCard,
Expand All @@ -53,7 +55,7 @@ export const LoadDeck = (props: GameStateActions) => {
newGrid[GRIDS.HAND] = deck?.avatar?.map(
(avatar) =>
({
id: avatar.identifier,
id: avatar.identifier + "-avatar-" + uuid(),
img: avatar.identifier,
type: "avatar",
}) as GameCard,
Expand Down
2 changes: 2 additions & 0 deletions src/components/organisms/GameBoard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const SortItemWrapper = ({
e.preventDefault();
setPreview(true);
}}
data-testid={"sortable-item-wrapper-" + card.id}
style={{
height: heightCalc() + 7 + "px",
transform: isTapped ? "rotate(5deg)" : "",
Expand All @@ -142,6 +143,7 @@ const SortItemWrapper = ({
>
<SortableItem
key={`card-${gridIndex}-${cardIndex}`}
data-testid={"sortable-item-" + card.id}
id={card.id}
gridIndex={gridIndex}
index={cardIndex}
Expand Down

0 comments on commit 40a31fb

Please sign in to comment.