Cards
All checks were successful
Create and publish a Docker image / Publish image (push) Successful in 52s
Create and publish a Docker image / Deploy image (push) Successful in 4s

This commit is contained in:
VITALY-VORON
2023-08-25 09:09:16 +03:00
parent edccd52fbd
commit 0cc7a05e94
5 changed files with 57 additions and 21 deletions

View File

@@ -25,26 +25,43 @@ const db = [
}
];
const Tinder = () => {
const Tinder = (props) => {
const route = props.getValue;
const characters = db;
const [lastDirection, setLastDirection] = useState();
const [cardId, setCardId] = useState([]);
const swiped = (direction, id) => {
setLastDirection(direction);
if (direction === 'right') {
cardId.push(id);
};
};
const [allIds, setAllIds] = useState([]);
const [cardLenth, setCardLenth] = useState(false);
let uniqueTags = [];
let allTags = [];
const swiped = (direction, id) => {
setLastDirection(direction);
allIds.push(id);
if (direction === 'right') {
cardId.push(id);
};
};
const getId = () => {
uniqueTags = cardId.filter(function(elem, pos) {
return cardId.indexOf(elem) === pos;
});
console.log(uniqueTags);
allTags = allIds.filter(function(elem, pos){
return allIds.indexOf(elem) === pos;
});
characters.length === allTags.length ? setCardLenth(true) : setCardLenth(false);
if(cardLenth) {
route('/map')
}
}
return (
@@ -58,7 +75,7 @@ const db = [
onSwipe={(dir) => {
swiped(dir, character.id);
getId();
console.log(uniqueTags);
// console.log(uniqueTags);
}}
>
<div className='card'>
@@ -72,11 +89,6 @@ const db = [
</TinderCard>
))}
</div>
{lastDirection ? (
<h2 className='infoText'>You swiped {lastDirection}</h2>
) : (
null
)}
</div>
);
};