Skip to content

Commit

Permalink
WIP scunt
Browse files Browse the repository at this point in the history
  • Loading branch information
Freeassassin committed Sep 3, 2023
1 parent a8ba3ca commit 43856ee
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 132 deletions.
2 changes: 1 addition & 1 deletion client/src/components/ScuntLinks/ScuntLinks.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef } from 'react';
import React from 'react';
import { Link, useLocation } from 'react-router-dom';
import { pages } from '../../util/pages';
import { ButtonOutlined } from '../button/ButtonOutlined/ButtonOutlined';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,62 @@ import { getScuntTeamObjFromTeamNumber } from '../../../../pages/ScuntJudgeForm/
import { scuntDiscord } from '../../../../util/scunt-constants';
import { scuntTeamsSelector } from '../../../../state/scuntTeams/scuntTeamsSlice';

export const ProfilePageScuntToken = () => {
const { scuntSettings } = useSelector(scuntSettingsSelector);
const { user } = useSelector(userSelector);
const { scuntTeams } = useSelector(scuntTeamsSelector);
const isRegistered = useSelector(registeredSelector);
const { setSnackbar } = useContext(SnackbarContext);
const [showToken, setShowToken] = useState(false);
// export const ProfilePageScuntToken = () => {
// const { scuntSettings } = useSelector(scuntSettingsSelector);
// const { user } = useSelector(userSelector);
// const { scuntTeams } = useSelector(scuntTeamsSelector);
// const isRegistered = useSelector(registeredSelector);
// const { setSnackbar } = useContext(SnackbarContext);
// const [showToken, setShowToken] = useState(false);
// if (!isRegistered || (scuntSettings && !scuntSettings?.revealTeams)) {
// return null;
// }

const code = user?.scuntToken;
if (code === undefined || !isRegistered || (scuntSettings && !scuntSettings?.revealTeams)) {
return null;
}
// if (!user?.attendingScunt && user?.userType !== 'leadur') {
// return (
// <div className="profile-page-scunt-token profile-page-side-section">
// <p>
// <b>Looking for your Scunt login Token?</b>
// </p>
// <p>You have chosen not to participate in Scunt.</p>
// <div style={{ height: '30px' }} />
// </div>
// );
// }
// return (
// <div className="profile-page-scunt-token profile-page-side-section">
// <h2>{getScuntTeamObjFromTeamNumber(user?.scuntTeam, scuntTeams)?.name}</h2>
// <i>
// <h4>Team {user?.scuntTeam ? user?.scuntTeam.toString() : '‽'}</h4>
// </i>
// <h3
// style={{ filter: showToken ? '' : 'blur(10px)' }}
// onClick={() => {
// navigator.clipboard.writeText(code);
// setSnackbar('Copied to clipboard');
// }}
// >
// {code}
// </h3>
// <p>Scunt Login Token</p>
// <p style={{ fontSize: '13px' }}>
// Use this token to login to the{' '}
// <a href={scuntDiscord} target="_blank" rel="noreferrer">
// Scunt Discord
// </a>
// </p>
// <ButtonOutlined
// isSecondary={showToken}
// label={showToken ? 'Hide' : 'Show'}
// onClick={() => {
// setShowToken(!showToken);
// }}
// />
// </div>
// );
// };

if (!user?.attendingScunt && user?.userType !== 'leadur') {
return (
<div className="profile-page-scunt-token profile-page-side-section">
<p>
<b>Looking for your Scunt login Token?</b>
</p>
<p>You have chosen not to participate in Scunt.</p>
<div style={{ height: '30px' }} />
</div>
);
}
return (
<div className="profile-page-scunt-token profile-page-side-section">
<h2>{getScuntTeamObjFromTeamNumber(user?.scuntTeam, scuntTeams)?.name}</h2>
<i>
<h4>Team {user?.scuntTeam ? user?.scuntTeam.toString() : '‽'}</h4>
</i>
<h3
style={{ filter: showToken ? '' : 'blur(10px)' }}
onClick={() => {
navigator.clipboard.writeText(code);
setSnackbar('Copied to clipboard');
}}
>
{code}
</h3>
<p>Scunt Login Token</p>
<p style={{ fontSize: '13px' }}>
Use this token to login to the{' '}
<a href={scuntDiscord} target="_blank" rel="noreferrer">
Scunt Discord
</a>
</p>
<ButtonOutlined
isSecondary={showToken}
label={showToken ? 'Hide' : 'Show'}
onClick={() => {
setShowToken(!showToken);
}}
/>
</div>
);
};

ProfilePageScuntToken.propTypes = {
scuntTeams: PropTypes.array,
scuntTeamObjs: PropTypes.array,
};
// ProfilePageScuntToken.propTypes = {
// scuntTeams: PropTypes.array,
// scuntTeamObjs: PropTypes.array,
// };
29 changes: 18 additions & 11 deletions client/src/pages/Profile/PageProfileFrosh.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { scuntSettingsSelector } from '../../state/scuntSettings/scuntSettingsSl
import { getRemainingTickets } from '../FroshRetreat/FroshRetreat';
import { ProfilePageSchedule } from '../../components/profile/ProfilePageSchedule/ProfilePageSchedule';
import { ProfilePageResources } from '../../components/profile/ProfilePageResources/ProfilePageResources';
import { ProfilePageFroshScuntTeamsSelection } from '../../components/profile/scunt/ProfilePageFroshScuntTeamsSelection/ProfilePageFroshScuntTeamsSelection';
// import { ProfilePageFroshScuntTeamsSelection } from '../../components/profile/scunt/ProfilePageFroshScuntTeamsSelection/ProfilePageFroshScuntTeamsSelection';
import { getScuntTeams } from '../../state/scuntTeams/saga';
import { getScuntSettings } from '../../state/scuntSettings/saga';
import { scuntTeamsSelector } from '../../state/scuntTeams/scuntTeamsSlice';
Expand Down Expand Up @@ -62,7 +62,7 @@ const PageProfileFrosh = () => {
<ProfilePageQRCode />
{/* <ProfilePageScuntToken scuntTeamObjs={scuntTeamObjs} scuntTeams={scuntTeams} /> not doing discord */}
<ProfilePageScuntTeam />
<ProfilePageFroshScuntTeamsSelection />
{/* <ProfilePageFroshScuntTeamsSelection /> */}
<ProfilePageResources froshObject={user?.isRegistered ? user : null} />
</div>
</div>
Expand Down Expand Up @@ -164,8 +164,7 @@ const ProfilePageFroshScuntMessage = () => {
const isRegistered = useSelector(registeredSelector);
const { darkMode } = useContext(DarkModeContext);

const code = user?.scuntToken;
if (code === undefined || !isRegistered || !scuntSettings || !scuntSettings?.revealTeams) {
if (!isRegistered || !scuntSettings || !scuntSettings?.revealTeams) {
return null;
}

Expand All @@ -174,8 +173,8 @@ const ProfilePageFroshScuntMessage = () => {
<div className="frosh-instagram-container">
<img src={ScuntIcon} alt="Scunt" style={{ filter: darkMode ? 'invert(1)' : 'unset' }} />
<div>
<h2>Havenger Scunt!</h2>
<p>Find more information about Scunt by clicking here!</p>
<h2>SkavENGer Hunt!</h2>
<p>Find more information about The Hunt by clicking here!</p>
</div>
</div>
</Link>
Expand Down Expand Up @@ -425,22 +424,30 @@ const ProfilePageQRCode = () => {
);
};

const ProfilePageScuntTeam = () => {
export const ProfilePageScuntTeam = () => {
const isRegistered = useSelector(registeredSelector);
const { scuntSettings } = useSelector(scuntSettingsSelector);
const { scuntTeams } = useSelector(scuntTeamsSelector);
const { user } = useSelector(userSelector);
const [scuntTeam, setScuntTeam] = useState();
const [scuntTeam, setScuntTeam] = useState(null);

const dispatch = useDispatch();

useEffect(() => {
dispatch(getScuntSettings());
dispatch(getScuntTeams());
}, [dispatch]);

if (!isRegistered || !scuntSettings || !scuntSettings?.revealTeams) return null;
useEffect(() => {
if (scuntTeams.length) {
if (scuntTeams?.length) {
const [team] = scuntTeams.filter((team) => {
return team.number === user?.scuntTeam;
return team?.number === user?.scuntTeam;
});
setScuntTeam(team);
}
}, [scuntTeams]);

if (!isRegistered || !scuntSettings || !scuntSettings?.revealTeams) return null;
return (
<div className="profile-page-scunt-team profile-page-side-section">
<h3>Your Scunt Team:</h3>
Expand Down
54 changes: 14 additions & 40 deletions client/src/pages/ScuntHome/ScuntHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ import WaveDarkMode from '../../assets/darkmode/misc/wave.png';
import waveBottom from '../../assets/misc/wave-reverse.png';
import waveBottomDarkMode from '../../assets/darkmode/misc/wave-reverse.png';
import { Confetti } from '../../components/misc/Confetti/Confetti';
import { Link, useLocation } from 'react-router-dom';
import { Link } from 'react-router-dom';
import { ScuntLinks } from '../../components/ScuntLinks/ScuntLinks';
import { DarkModeContext } from '../../util/DarkModeProvider';
import DiscordIcon from '../../assets/social/discord-brands.svg';
// import DiscordIcon from '../../assets/social/discord-brands.svg';
import { aboutScunt, okayToInviteToScunt, scuntDiscord } from '../../util/scunt-constants';
import { useDispatch, useSelector } from 'react-redux';
import { userSelector } from '../../state/user/userSlice';
import { scuntSettingsSelector } from '../../state/scuntSettings/scuntSettingsSlice';
import useAxios from '../../hooks/useAxios';
import { ProfilePageScuntToken } from '../../components/profile/scunt/ProfilePageScuntToken/ProfilePageScuntToken';
// import { ProfilePageScuntToken } from '../../components/profile/scunt/ProfilePageScuntToken/ProfilePageScuntToken';
import { scuntTeamsSelector } from '../../state/scuntTeams/scuntTeamsSlice';
import { getScuntSettings } from '../../state/scuntSettings/saga';
import { getScuntTeams } from '../../state/scuntTeams/saga';
// import { ProfilePageScuntTeam } from '../Profile/PageProfileFrosh';
const { axios } = useAxios();

export const PageScuntHome = () => {
Expand All @@ -39,54 +40,27 @@ export const PageScuntHome = () => {

const AboutScunt = () => {
const { darkMode } = useContext(DarkModeContext);
const [scuntTeamObjs, setScuntTeamObjs] = useState();
const { scuntTeams } = useSelector(scuntTeamsSelector);
// const getScuntTeams = async () => {
// try {
// const response = await axios.get('/scunt-teams');
// const { teamPoints } = response.data;
// if (teamPoints.length <= 0 || !teamPoints) setScuntTeams([]);
// else {
// setScuntTeamObjs(teamPoints);
// setScuntTeams(
// teamPoints.map((team) => {
// return team?.name;
// }),
// );
// }
// } catch (e) {
// console.error(e.toString());
// setScuntTeams(['Error loading teams']);
// }
// };

// useEffect(() => {
// getScuntTeams();
// }, []);

return (
<>
{darkMode ? (
<img src={WaveDarkMode} className="wave-image wave-image-footer" />
) : (
<img src={Wave} className="wave-image wave-image-footer" />
)}
<img src={darkMode ? WaveDarkMode : Wave} className="wave-image wave-image-footer" />
<div className="about-scunt-container">
<div className="about-scunt-content">
<div className="about-scunt-token">
<ProfilePageScuntToken scuntTeamObjs={scuntTeamObjs} scuntTeams={scuntTeams} />
</div>
{/* <div className="about-scunt-token">
<ProfilePageScuntTeam />
</div> */}
<div dangerouslySetInnerHTML={{ __html: aboutScunt }} />
<h4>
Check the <Link to={'/scunt-rules'}>Rules</Link> for more information
</h4>
</div>
</div>
{darkMode ? (
<img className="header-page-wave-bottom" src={waveBottomDarkMode} alt="wave"></img>
) : (
<img className="header-page-wave-bottom" src={waveBottom} alt="wave"></img>
)}
<img
className="header-page-wave-bottom"
src={darkMode ? waveBottomDarkMode : waveBottom}
alt="wave"
></img>

<div style={{ height: '30px' }} />
</>
);
Expand Down
Loading

0 comments on commit 43856ee

Please sign in to comment.