Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 47 additions & 48 deletions src/components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -1,84 +1,83 @@
import Link from 'next/link';
import { Container } from '@/components/Container';
import { NavLink } from '@/components/NavLink';
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_URL;
import Link from 'next/link'
import { Container } from '@/components/Container'
import { NavLink } from '@/components/NavLink'
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_URL

export function Footer() {
export function Footer () {
return (
<footer style={{ backgroundColor: '#161716' }}>
<Container>
<div className="py-16">
<img src= {`${baseUrl}/darkLogo.png`} className="mx-auto w-14 text-center" />
<nav className="mt-4 text-sm" aria-label="quick links">
<div className="-my-1 flex place-content-center gap-x-6">
<NavLink href="../terms-of-service">Terms of Service</NavLink>
<NavLink href="../privacy-policy">Privacy Policy</NavLink>
<NavLink href="https://status.ctfguide.com/">Status</NavLink>
<NavLink href="../careers">Careers</NavLink>
<div className='py-16'>
<img src={`${baseUrl}/darkLogo.png`} className='mx-auto w-14 text-center' />
<nav className='mt-4 text-sm' aria-label='quick links'>
<div className='-my-1 flex place-content-center gap-x-6'>
<NavLink href='../terms-of-service'>Terms of Service</NavLink>
<NavLink href='../privacy-policy'>Privacy Policy</NavLink>
<NavLink href='https://status.ctfguide.com/'>Status</NavLink>
<NavLink href='../careers'>Careers</NavLink>
</div>
</nav>
</div>
<div className="mx-auto flex max-w-4xl flex-col items-center border-t border-slate-400/10 py-10 sm:flex-row-reverse sm:justify-between">
<div className="flex gap-x-6">
<div className='mx-auto flex max-w-4xl flex-col items-center border-t border-slate-400/10 py-10 sm:flex-row-reverse sm:justify-between'>
<div className='flex gap-x-6'>
<Link
href="https://discord.gg/q3hgRBvgkX"
className="group"
aria-label="ctfguideapp on Discord"
href='https://discord.gg/q3hgRBvgkX'
className='group'
aria-label='ctfguideapp on Discord'
>
<svg
aria-hidden="true"
className="h-6 w-6 fill-white group-hover:fill-[#5865F2]"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 640 512"
aria-hidden='true'
className='h-6 w-6 fill-white group-hover:fill-[#5865F2]'
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 640 512'
>
<path d="M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"/>
<path d='M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z' />
</svg>
</Link>
<Link
href="https://www.linkedin.com/company/ctfguide"
className="group"
aria-label="ctfguideapp on Linkedin"
href='https://www.linkedin.com/company/ctfguide'
className='group'
aria-label='ctfguideapp on Linkedin'
>
<svg
aria-hidden="true"
className="h-6 w-6 fill-white group-hover:fill-[#3b82f6]"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 448 512"
<svg
aria-hidden='true'
className='h-6 w-6 fill-white group-hover:fill-[#3b82f6]'
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 448 512'
>
<path d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"/>
<path d='M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z' />
</svg>
</Link>

<Link
href="https://github.com/ctfguide-tech"
className="group"
aria-label="ctfguide-tech on GitHub"
href='https://github.com/ctfguide-tech'
className='group'
aria-label='ctfguide-tech on GitHub'
>
<svg
aria-hidden="true"
className="h-6 w-6 fill-white group-hover:fill-black"
aria-hidden='true'
className='h-6 w-6 fill-white group-hover:fill-black'
>
<path d="M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844a9.59 9.59 0 0 1 2.504.337c1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.02 10.02 0 0 0 22 12.017C22 6.484 17.522 2 12 2Z" />
<path d='M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0 1 12 6.844a9.59 9.59 0 0 1 2.504.337c1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.02 10.02 0 0 0 22 12.017C22 6.484 17.522 2 12 2Z' />
</svg>
</Link>

<Link
href ="https://x.com/ctfguideapp"
aria-label = "ctfguideapp on X"
href='https://x.com/ctfguideapp'
aria-label='ctfguideapp on X'
>
<svg className="h-6 w-6 fill-white hover:fill-black" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="100" ><path fill="white" d="M 5.9199219 6 L 20.582031 27.375 L 6.2304688 44 L 9.4101562 44 L 21.986328 29.421875 L 31.986328 44 L 44 44 L 28.681641 21.669922 L 42.199219 6 L 39.029297 6 L 27.275391 19.617188 L 17.933594 6 L 5.9199219 6 z M 9.7167969 8 L 16.880859 8 L 40.203125 42 L 33.039062 42 L 9.7167969 8 z"/>
</svg>
<svg className='h-6 w-6 fill-white hover:fill-black' aria-hidden='true' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50' width='100'><path fill='white' d='M 5.9199219 6 L 20.582031 27.375 L 6.2304688 44 L 9.4101562 44 L 21.986328 29.421875 L 31.986328 44 L 44 44 L 28.681641 21.669922 L 42.199219 6 L 39.029297 6 L 27.275391 19.617188 L 17.933594 6 L 5.9199219 6 z M 9.7167969 8 L 16.880859 8 L 40.203125 42 L 33.039062 42 L 9.7167969 8 z' />

</svg>


</Link>
</div>
<p className="mt-6 text-sm text-white sm:mt-0">
<p className='mt-6 text-sm text-white sm:mt-0'>
Copyright &copy; {new Date().getFullYear()} CTFGuide. All rights
reserved. <br></br>
reserved. <br />
</p>
</div>
</Container>
</footer>
);
)
}
128 changes: 64 additions & 64 deletions src/components/profile/ChallengeCard.jsx
Original file line number Diff line number Diff line change
@@ -1,102 +1,102 @@
import React, { useEffect, useState } from 'react';
import { CardDecorator } from '../design/CardDecorator';
import Link from 'next/link';
import Skeleton from 'react-loading-skeleton';
import { EyeIcon, HeartIcon, PuzzlePieceIcon, ThumbUpIcon, ThumbDownIcon } from '@heroicons/react/20/solid';
import request from '@/utils/request';
import React, { useEffect, useState } from 'react'
import { CardDecorator } from '../design/CardDecorator'
import Link from 'next/link'
import Skeleton from 'react-loading-skeleton'
import { EyeIcon, HeartIcon, PuzzlePieceIcon, ThumbUpIcon, ThumbDownIcon } from '@heroicons/react/20/solid'
import request from '@/utils/request'

/**
* @param {import('react').HTMLAttributes<HTMLDivElement> & { challenge: {id: string, title: string, category: string, difficulty: string, createdAt: string, creator: string, views: number, likes: number} }} props
/**
* @param {import('react').HTMLAttributes<HTMLDivElement> & { challenge: {id: string, title: string, category: string, difficulty: string, createdAt: string, creator: string, views: number, likes: number} }} props
* */
const ChallengeCard = (_props) => {
const { challenge, ...props } = _props;
const [creatorPfp, setCreatorPfp] = useState('');
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_URL;
const { challenge, ...props } = _props
const [creatorPfp, setCreatorPfp] = useState('')
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_URL
// generate code to hit /users endpoint for each challenge creator
const [creator, setCreator] = useState(null);
const [creator, setCreator] = useState(null)
useEffect(() => {
async function fetchCreatorData(username) {
const endPoint = `${process.env.NEXT_PUBLIC_API_URL}/users/${username}`;
const result = await request(endPoint, "GET", null);
setCreator(result);
async function fetchCreatorData (username) {
const endPoint = `${process.env.NEXT_PUBLIC_API_URL}/users/${username}`
const result = await request(endPoint, 'GET', null)
setCreator(result)
if (result.profileImage) {
setCreatorPfp(result.profileImage);
setCreatorPfp(result.profileImage)
} else {
setCreatorPfp(`https://robohash.org/${username}.png?set=set1&size=150x150`);
setCreatorPfp(`https://robohash.org/${username}.png?set=set1&size=150x150`)
}
}
if (challenge && challenge.creator) {
fetchCreatorData(challenge.creator);
fetchCreatorData(challenge.creator)
}
}, [challenge]);
}, [challenge])

const dateFormatted = (date) =>
new Date(date)
.toLocaleDateString('en-US', {
month: '2-digit',
day: '2-digit',
year: 'numeric',
});
year: 'numeric'
})

const colorBG = {
'BEGINNER': 'group-hover:bg-blue-500',
'EASY': 'group-hover:bg-green-500',
'MEDIUM': 'group-hover:bg-orange-500',
'HARD': 'group-hover:bg-red-500',
'INSANE': 'group-hover:bg-purple-500',
};
BEGINNER: 'group-hover:bg-blue-500',
EASY: 'group-hover:bg-green-500',
MEDIUM: 'group-hover:bg-orange-500',
HARD: 'group-hover:bg-red-500',
INSANE: 'group-hover:bg-purple-500'
}
const colorText = {
'BEGINNER': 'bg-blue-500 text-blue-50',
'EASY': 'bg-green-500 text-green-50',
'MEDIUM': 'bg-orange-500 text-orange-50',
'HARD': 'bg-red-500 text-red-50',
'INSANE': 'bg-purple-500 text-purple-50',
};
BEGINNER: 'bg-blue-500 text-blue-50',
EASY: 'bg-green-500 text-green-50',
MEDIUM: 'bg-orange-500 text-orange-50',
HARD: 'bg-red-500 text-red-50',
INSANE: 'bg-purple-500 text-purple-50'
}
const colorBorder = {
'BEGINNER': 'border-blue-500',
'EASY': 'border-green-500',
'MEDIUM': 'border-orange-500',
'HARD': 'border-red-500',
'INSANE': 'border-purple-500',
};
BEGINNER: 'border-blue-500',
EASY: 'border-green-500',
MEDIUM: 'border-orange-500',
HARD: 'border-red-500',
INSANE: 'border-purple-500'
}

return (
challenge && (
<Link {...props} className={`group w-full border-l-4 ${colorBorder[challenge.difficulty]} bg-[#212121] px-5 py-6 hover:bg-[#2c2c2c] ${props.className ?? ''}`} href={`${baseUrl}/challenges/${challenge.id}`} >
<div className="flex justify-between">
<h1 className="truncate text-2xl font-bold text-white pr-1">{challenge.title}</h1>
<Link {...props} className={`group w-full border-l-4 ${colorBorder[challenge.difficulty]} bg-[#212121] px-5 py-6 hover:bg-[#2c2c2c] ${props.className ?? ''}`} href={`${baseUrl}/challenges/${challenge.id}`}>
<div className='flex justify-between'>
<h1 className='truncate text-2xl font-bold text-white pr-1'>{challenge.title}</h1>

<div className="flex items-center text-gray-4000">
<span className='text-green-300'><i className="fas fa-arrow-up text-green-300"></i> {challenge.upvotes !== undefined ? challenge.upvotes : <Skeleton width={20} />}</span>
<span className='ml-2 text-red-300'><i className="fas fa-arrow-down text-red-200"></i> {challenge.downvotes !== undefined ? challenge.downvotes : <Skeleton width={20} />}</span>
<div className='flex items-center text-gray-4000'>
<span className='text-green-300'><i className='fas fa-arrow-up text-green-300' /> {challenge.upvotes !== undefined ? challenge.upvotes : <Skeleton width={20} />}</span>
<span className='ml-2 text-red-300'><i className='fas fa-arrow-down text-red-200' /> {challenge.downvotes !== undefined ? challenge.downvotes : <Skeleton width={20} />}</span>
</div>
</div>
<div className="mt-2 flex items-center text-gray-400">
<div className='mt-2 flex items-center text-gray-400'>
<img
className="h-5 w-5 mr-2 rounded-full"
className='h-5 w-5 mr-2 rounded-full'
src={creatorPfp || 'default-profile-image-url'}
alt="Profile Picture"
alt='Profile Picture'
/>
<span>@{challenge.creator}</span>
{creator && creator.role === 'ADMIN' && (
<span className="text-red-500 text-xs ml-1"><i className="fas fa-code fa-fw"></i></span>
<span className='text-red-500 text-xs ml-1'><i className='fas fa-code fa-fw' /></span>
)}
{creator && creator.role === 'PRO' && (
<span className="text-yellow-500 text-xs ml-1"><i className="fas fa-crown fa-fw"></i></span>
)}
<span className='text-yellow-500 text-xs ml-1'><i className='fas fa-crown fa-fw' /></span>

)}
</div>

<div className="mt-4 flex items-center">
<PuzzlePieceIcon className="h-5 w-5 mr-2 text-white" />
<span className="text-white">{challenge.category}</span>
<div className='mt-4 flex items-center'>
<PuzzlePieceIcon className='h-5 w-5 mr-2 text-white' />
<span className='text-white'>{challenge.category}</span>
<span className={`ml-4 px-2 rounded-sm text-sm font-bold capitalize ${colorText[challenge.difficulty || 0]}`}>{challenge.difficulty?.toLowerCase() || <Skeleton />}</span>

<div className=" ml-auto flex text-gray-400">
<EyeIcon className="h-5 w-5 mr-2" />
<span>{challenge.views !== undefined ? challenge.views : <Skeleton width={20} />}</span>
</div>
<div className=' ml-auto flex text-gray-400'>
<EyeIcon className='h-5 w-5 mr-2' />
<span>{challenge.views !== undefined ? challenge.views : <Skeleton width={20} />}</span>

</div>
</div>
</Link>
) || (
Expand All @@ -107,7 +107,7 @@ const ChallengeCard = (_props) => {
<Skeleton baseColor='#262626' highlightColor='#3a3a3a' />
</div>
)
);
};
)
}

export default ChallengeCard;
export default ChallengeCard