Skip to content

Commit dd4fc4a

Browse files
authored
Merge pull request #210 from ctfguide-tech/dev
Dev
2 parents a519cc3 + 5cea8f0 commit dd4fc4a

File tree

3 files changed

+100
-2
lines changed

3 files changed

+100
-2
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@
8787
"tailwind-merge": "^2.3.0",
8888
"tailwindcss": "^3.2.1",
8989
"tailwindcss-animate": "^1.0.7",
90-
"xterm": "^5.3.0"
90+
"xterm": "^5.3.0",
91+
"node-fetch": "^2.6.7"
9192
},
9293
"devDependencies": {
9394
"eslint": "8.26.0",

src/components/practice/community.jsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Listbox, Transition } from '@headlessui/react';
55
import { CheckIcon, ChevronUpDownIcon } from '@heroicons/react/24/solid';
66
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
77
import { faFolderOpen } from '@fortawesome/free-solid-svg-icons';
8+
89
function getCategoryIcon(category) {
910
switch (category.toLowerCase()) {
1011
case 'forensics':
@@ -79,7 +80,6 @@ function CategorySelect({ category, setCategory, isDifficulty }) {
7980
<ChevronUpDownIcon className="h-5 w-5 text-gray-400" aria-hidden="true" />
8081
</span>
8182
</Listbox.Button>
82-
8383
<Transition
8484
show={open}
8585
as={Fragment}
@@ -137,6 +137,32 @@ export function Community({ challenges }) {
137137
const [filter, setFilter] = useState('');
138138
const [solvedFilter, setSolvedFilter] = useState('all');
139139

140+
useEffect(() => {
141+
if (typeof window !== 'undefined') {
142+
setDifficulty(localStorage.getItem('difficulty') || 'all');
143+
setCategory(localStorage.getItem('category') || 'all');
144+
setSolvedFilter(localStorage.getItem('solvedFilter') || 'all');
145+
}
146+
}, []);
147+
148+
useEffect(() => {
149+
if (typeof window !== 'undefined') {
150+
localStorage.setItem('difficulty', difficulty);
151+
}
152+
}, [difficulty]);
153+
154+
useEffect(() => {
155+
if (typeof window !== 'undefined') {
156+
localStorage.setItem('category', category);
157+
}
158+
}, [category]);
159+
160+
useEffect(() => {
161+
if (typeof window !== 'undefined') {
162+
localStorage.setItem('solvedFilter', solvedFilter);
163+
}
164+
}, [solvedFilter]);
165+
140166
useEffect(() => {
141167
const filteredChallenges = challenges
142168
.filter((challenge) => {

src/pages/create.jsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,77 @@ export default function Create() {
567567
</div>
568568

569569

570+
<hr className='mt-4 border-neutral-700'></hr>
571+
<div className=" mt-4 pb-4 ">
572+
<div className="flex items-center">
573+
<h1 className="flex-1 text-2xl font-medium text-white">
574+
<div className="flex">
575+
Your Learn Modules
576+
<div className='ml-auto'>
577+
<button onClick={() => { setIsCreating(true) }} className='bg-blue-700 text-sm shadow-sm hover:bg-blue-700/90 px-2 py-1 text-white rounded-sm mr-3'>New Draft Module</button>
578+
579+
</div>
580+
581+
582+
583+
</div>
584+
585+
586+
587+
<div className="mt-4 flow-root">
588+
<div className="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
589+
<div className="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8">
590+
<table className="min-w-full divide-y divide-neutral-800 border border-neutral-800">
591+
<thead>
592+
<tr>
593+
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text--white">
594+
Module Name
595+
</th>
596+
597+
598+
<th scope="col" className="px-3 py-3.5 text-left text-sm font-semibold text--white">
599+
Last Updated
600+
</th>
601+
<th scope="col" className="relative py-3.5 pl-3 pr-4 sm:pr-3">
602+
<span className="sr-only">Edit</span>
603+
</th>
604+
</tr>
605+
</thead>
606+
<tbody className="bg-neutral-800">
607+
{writeups.map((writeup) => (
608+
<tr key={writeup.title} className="even:bg-neutral-900">
609+
610+
<td className="whitespace-nowrap px-3 py-4 text-sm text-white">
611+
{writeup.draft &&
612+
<span className='text-yellow-400 bg-yellow-900 px-2 rounded-full mr-2'>draft</span>
613+
}
614+
615+
{!writeup.draft &&
616+
<span className='text-green-400 bg-green-900 px-2 rounded-full mr-2'>published</span>
617+
}
618+
619+
{writeup.title} </td>
620+
621+
<td className="whitespace-nowrap px-3 py-4 text-sm text-white">{new Date(writeup.updatedAt).toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })}</td>
622+
623+
<td className="relative whitespace-nowrap py-4 pl-3 pr-4 text-right text-sm font-medium sm:pr-3">
624+
<button className='bg-neutral-700 text-sm shadow-sm hover:bg-neutral-700/90 px-2 py-1 text-white rounded-sm mr-3'>Open in Studio</button>
625+
</td>
626+
</tr>
627+
)) || <Skeleton containerClassName='tbody' className='mb-4' baseColor='#999' count={2} />
628+
}
629+
</tbody>
630+
</table>
631+
</div>
632+
633+
</div>
634+
</div>
635+
</h1>
636+
637+
638+
</div>
639+
</div>
640+
570641

571642
</div>
572643
</div>

0 commit comments

Comments
 (0)