fix cards
Some checks failed
Create and publish a Docker image / Deploy image (push) Has been skipped
Create and publish a Docker image / Publish image (push) Failing after 19s

This commit is contained in:
VITALY-VORON
2023-08-25 16:41:45 +03:00
parent 7d7658d38c
commit 88067edac3
13 changed files with 514 additions and 3150 deletions

View File

@ -1,43 +1,24 @@
import React, {useState, useEffect} from 'react';
import './App.css';
import React, {useState} from 'react';
import Start from './components/Start/Start';
import Second from './components/Second/Second';
import Tinder from './components/Tinder/Tinder';
import Map from './components/Map/Map';
import axios from 'axios';
function App() {
const options = {
method: 'GET',
url: 'https://easytravel.zetcraft.ru/v1/GetAllCards'
};
const [buttonValue, setButtonValue] = useState("");
const [fetchData, setFetchData] = useState([]);
const handleButtonValue = (value) => {
setButtonValue(value);
};
useEffect(() => {
axios.request(options).then(function (response) {
console.log(response.data);
fetchData.push(response.data);
console.log(fetchData);
}).catch(function (error) {
console.error(error);
return null;
});
});
let content = null;
switch (buttonValue) {
case '/':
content = <Second getValue={handleButtonValue}/>
break;
case '/tinder':
content = <Tinder getValue={handleButtonValue} cardData={fetchData}/>
content = <Tinder getValue={handleButtonValue}/>
break;
case '/map':
content = <Map/>

View File

@ -1,7 +1,7 @@
const Map = () => {
return (
<div>
<span>Переход готов</span>
</div>
);
}

View File

@ -0,0 +1,122 @@
@import url(https://fonts.googleapis.com/css?family=Pathway+Gothic+One);
@-webkit-keyframes rotate-right {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(360deg);
}
}
@-webkit-keyframes rotate-left {
from {
-webkit-transform: rotate(0deg);
}
to {
-webkit-transform: rotate(-360deg);
}
}
@-webkit-keyframes hover {
0% {
-webkit-transform: translateY(0%);
}
50% {
-webkit-transform: translateY(5%);
}
100% {
-webkit-transform: translateY(0%);
}
}
@-webkit-keyframes pull {
0% {
-webkit-transform: scaleY(1);
}
40% {
-webkit-transform: scaleY(1.01);
}
60% {
-webkit-transform: scaleY(0.99);
}
80% {
-webkit-transform: scaleY(1.01);
}
100% {
-webkit-transform: scaleY(0.99);
}
80% {
-webkit-transform: scaleY(1.01);
}
100% {
-webkit-transform: scaleY(1);
}
}
#airplane2, #airplane1 {
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform-origin: 200px 200px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: rotate-right 60s linear 0s infinite;
}
#countryObjects {
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform-origin: 200px 200px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: rotate-right 240s linear 0s infinite;
}
#floatingGlobe {
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform-origin: 200px 200px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: rotate-left 360s linear 0s infinite;
}
#globe {
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: hover 0s linear 0s infinite;
}
#windmill {
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform-origin: 331px 201px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: rotate-right 2s linear 0s infinite;
}
#cloud1 {
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: hover 3s linear 1s infinite;
}
#cloud2 {
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: hover 3s linear 2s infinite;
}
#cloud3 {
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: hover 3s linear 3s infinite;
}
#circle1 {
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform-origin: 200px 200px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: rotate-right 12s linear 0s infinite;
}
#circle2 {
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform-origin: 200px 200px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: rotate-left 24s linear 0s infinite;
}
#circle3 {
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform-origin: 200px 200px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: rotate-right 12s linear 0s infinite;
}
#circle4 {
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform-origin: 200px 200px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: rotate-left 24s linear 0s infinite;
}
#circle5 {
-webkit-transform: translate3d(0, 0, 0);
-webkit-transform-origin: 200px 200px;
-webkit-transform: translate3d(0, 0, 0);
-webkit-animation: rotate-right 12s linear 0s infinite;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
.tinder-container {
.tinder-container {
margin-top: 30%;
height: 85vh;
width: 100%;
@ -42,7 +42,7 @@
.card {
height: 400px;
width: 90%;
width: 100%;
max-width: 300px;
max-height: 400px;
border-radius: 10px;
@ -54,19 +54,19 @@
align-items: flex-end;
align-content: center;
flex-wrap: wrap;
padding: 16px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
background-color: #fff;
}
.card-content {
border-radius: 10px;
padding: 8px;
/* padding: 8px; */
text-align: center;
width: 300px;
height: 400px;
background-color: rgba(255, 255, 255, 0.8);
}
.infoText {
margin-top: 16px;
}
}

View File

@ -1,100 +1,80 @@
import React, {useEffect, useState} from 'react';
import React, { useEffect, useState } from 'react';
import TinderCard from 'react-tinder-card';
import './Tinder.css';
import axios from 'axios';
const db = [
{
id: 1,
name: 'Richard Hendricks',
},
{
id: 2,
name: 'Erlich Bachman',
},
{
id: 3,
name: 'Monica Hall',
},
{
id: 4,
name: 'Jared Dunn',
},
{
id: 5,
name: 'Dinesh Chugtai',
}
];
const Tinder = (props) => {
const Tinder = (props) => {
const route = props.getValue;
useEffect(() => {
console.log(characters[0])
});
const characters = props.cardData;
const [lastDirection, setLastDirection] = useState();
const [cardId, setCardId] = useState([]);
const [allIds, setAllIds] = useState([]);
const [cardLenth, setCardLenth] = useState(false);
const [cardInfo, setCardInfo] = useState([]);
let uniqueTags = [...characters];
let allTags = [];
useEffect(() => {
const fetchData = () => {
axios.get('https://easytravel.zetcraft.ru/v1/GetAllCards')
.then(response => {
setCardInfo(response.data);
console.log(cardInfo.length);
})
.catch(error => {
console.error('Error fetching data:', error);
});
}
fetchData();
}, []);
const swiped = (direction, id) => {
setLastDirection(direction);
allIds.push(id);
if (direction === 'right') {
console.log(allIds.length);
if (direction === 'right' || direction === 'up') {
cardId.push(id);
};
};
const getId = () => {
// uniqueTags = cardId.filter(function(elem, pos) {
// return cardId.indexOf(elem) === pos;
// });
// allTags = allIds.filter(function(elem, pos){
// return allIds.indexOf(elem) === pos;
// });
// characters.length === allTags.length ? setCardLenth(true) : setCardLenth(false);
// if(cardLenth) {
// route('/map')
// }
console.log(uniqueTags);
}
return (
<div className='tinder-container'>
<div className='tinder-container'>
<h1>Card</h1>
<div className='card-container'>
{characters.map((character) => (
<TinderCard
className='swipe'
key={character.id}
onSwipe={(dir) => {
swiped(dir, character.id);
getId();
// console.log(uniqueTags);
}}
>
<div className='card'>
<div
className='card-content'
// style={{ backgroundImage: url(${character.url}) }}
{cardInfo.map((card) => (
<TinderCard
className='swipe'
key={card.id}
onSwipe={(dir) => {
swiped(dir, card.id);
var unique = [...new Set(cardId)]
var uniqueIds = [...new Set(allIds)];
if(uniqueIds.length === cardInfo.length) {
route('/map');
console.log(unique);
}
}}
>
<h3>{props.character.question}</h3>
</div>
</div>
</TinderCard>
))}
<div className='card'>
<div
className='card-content'
style={{
backgroundImage: `url(${card.imageURL})`,
width: '300px',
height: '400px',
borderRadius: '10px',
backgroundRepeat: 'no-repeat',
backgroundPosition: 'center',
}}
>
<h3>{card.question}</h3>
</div>
</div>
</TinderCard>
))}
</div>
</div>
);
};
export default Tinder;
}
export default Tinder;

View File

@ -1,4 +1,4 @@
* {
margin: 0;
padding: 0;
margin: 0;
padding: 0;
}

View File

@ -7,11 +7,9 @@ import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
serviceWorkerRegistration.unregister();
reportWebVitals();
reportWebVitals();

View File

@ -1,13 +1,13 @@
const reportWebVitals = (onPerfEntry) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@ -11,127 +11,127 @@
// opt-in, read https://cra.link/PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://cra.link/PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://cra.link/PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://cra.link/PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://cra.link/PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
}
};
};
};
})
.catch((error) => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log('No internet connection found. App is running in offline mode.');
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then((registration) => {
registration.unregister();
})
.catch((error) => {
console.error(error.message);
console.error('Error during service worker registration:', error);
});
}
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log('No internet connection found. App is running in offline mode.');
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then((registration) => {
registration.unregister();
})
.catch((error) => {
console.error(error.message);
});
}
}