mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Feature/tinder (#179)
* basic framework for match/tinder * working version of swiping * working version of profile editing * introducing backend * working matching system * working profile updating * fix all linting issues * updated events to Enum * working profile generation * documentation updates * general PR feedback * working profile loading, matches show matchedAt * slight modification to event strings * added sql imports
This commit is contained in:
46 files changed
+1932
-49
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Paper } from '@material-ui/core';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { useProfiles } from '../../hooks/useProfiles';
|
||||
import Loader from '../Loader';
|
||||
import PageText from '../PageText';
|
||||
import ActiveProfile from '../ActiveProfile';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
root: {
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
overflow: 'hidden',
|
||||
},
|
||||
});
|
||||
|
||||
// set a minimum load time so the user doesn't see a flash
|
||||
// of the loader and then the matches themselves
|
||||
const MINIMUM_LOAD_TIME = 1250;
|
||||
|
||||
const MatchPage = () => {
|
||||
const classes = useStyles();
|
||||
const { t } = useTranslation();
|
||||
const { profiles, error, activeProfile, setViewed } = useProfiles();
|
||||
const [loaded, setLoaded] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
window.setTimeout(() => {
|
||||
setLoaded(true);
|
||||
}, MINIMUM_LOAD_TIME);
|
||||
}, []);
|
||||
|
||||
const handleSwipe = (id: number, liked: boolean) => {
|
||||
// the user didn't choose (didn't swipe far enough)
|
||||
if (liked === null) return;
|
||||
|
||||
setViewed(id, liked);
|
||||
};
|
||||
|
||||
if (error) return <PageText text={t('APPS_MATCH_PROFILES_ERROR')} />;
|
||||
if (!loaded || !profiles) return <Loader />;
|
||||
if (!activeProfile) return <PageText text={t('APPS_MATCH_NO_PROFILES')} />;
|
||||
|
||||
return (
|
||||
<Paper className={classes.root} square>
|
||||
<ActiveProfile profile={activeProfile} onSwipe={handleSwipe} />
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
|
||||
export default MatchPage;
|
||||
Reference in new issue
Block a user