From 95f58428e099779a84f3cedf15788804d61cc5d8 Mon Sep 17 00:00:00 2001 From: Kabir <44284877+kabir0x23@users.noreply.github.com> Date: Sun, 15 Sep 2024 19:45:12 +0530 Subject: [PATCH] fix: CTF --- src/components/CaptureTheFlag/CTF.jsx | 168 ++++++++++++++------------ 1 file changed, 90 insertions(+), 78 deletions(-) diff --git a/src/components/CaptureTheFlag/CTF.jsx b/src/components/CaptureTheFlag/CTF.jsx index ebf92f6d..3598003f 100644 --- a/src/components/CaptureTheFlag/CTF.jsx +++ b/src/components/CaptureTheFlag/CTF.jsx @@ -1,64 +1,67 @@ -import React, { useEffect, useState } from "react"; +import React from // ,{useEffect, useState} +"react"; import { Wrapper } from "src/components/Dashboard/Profile/ProfileElements"; -import { getAllCTFs } from "src/features/ctf/ctfSlice"; -import { useDispatch, useSelector } from "react-redux"; +// import {getAllCTFs} from "src/features/ctf/ctfSlice"; +// import {useDispatch, useSelector} from "react-redux"; import { CTFContainer, CTFHeader, CTFHeading, Option, SearchContainer, SearchDifficulty, Select } from "./CTFElements"; -import { getUserDetail } from "src/features/userDetail/userDetailSlice"; -import UnderMaintenance from "src/components/Other/UnderMaintenance/UnderMaintenance"; -import apiStatus from "src/features/apiStatus"; +// import {getUserDetail} from "src/features/userDetail/userDetailSlice"; +// import UnderMaintenance from "src/components/Other/UnderMaintenance/UnderMaintenance"; +// import apiStatus from "src/features/apiStatus"; // import CtfChallenges from "./CTFCards/CtfChallenges"; import { RankTrophy } from "src/components/Header/Navbar/NavbarElements"; import { RouteLink } from "src/components/Common/GeneralDashboardSidebar/GeneralDashboardSidebarElements"; -import LoadingSpinner from "src/components/Other/MixComponents/Spinner/LoadingSpinner"; +// import LoadingSpinner from "src/components/Other/MixComponents/Spinner/LoadingSpinner"; import SearchInputBox from "src/components/Common/SearchInputBox"; +// import {Link} from "react-router-dom"; +// import {Heading2} from "src/components/Blogs/ManageBlogs/CreateBlog/CreateBlogElements.jsx"; const CTF = () => { - const { isApiLoading, isApiWorking } = apiStatus(); - const dispatch = useDispatch(); - const { user } = useSelector((state) => state.auth); - const { ctfs, isCtfLoading } = useSelector((state) => state.ctfs); - const { isUserDetailLoading } = useSelector((state) => state.userDetail); - - useEffect(() => { - dispatch(getAllCTFs()); - if (user) { - dispatch(getUserDetail(user?.username)); - } - }, [dispatch]); - - const [searchTerm, setSearchTerm] = useState(""); - const [selectedDifficulty, setSelectedDifficulty] = useState("all"); - const [selectedType, setSelectedType] = useState("all"); - const [setFilteredCTFs] = useState(ctfs); - - useEffect(() => { - const filteredCTFs = Array?.isArray(ctfs) - ? ctfs?.filter((challenge) => { - const nameMatches = challenge?.challengeName?.toLowerCase().includes(searchTerm?.toLowerCase()); - const difficultyMatches = - selectedDifficulty === "all" || challenge?.difficulty === selectedDifficulty; - const typeMatches = selectedType === "all" || challenge?.type === selectedType; - return nameMatches && difficultyMatches && typeMatches; - }) - : []; - setFilteredCTFs(filteredCTFs); - }, [ctfs, searchTerm, selectedDifficulty, selectedType]); - - const handleSearchTermChange = (event) => { - setSearchTerm(event.target.value); - }; - - const handleTypeSelect = (event) => { - setSelectedType(event.target.value); - }; - - const handleDifficultySelect = (event) => { - setSelectedDifficulty(event.target.value); - }; - - if (isApiLoading || isUserDetailLoading || isCtfLoading) return ; - - if (!isApiWorking) return ; + // const {isApiLoading, isApiWorking} = apiStatus(); + // const dispatch = useDispatch(); + // const {user} = useSelector((state) => state.auth); + // const {ctfs, isCtfLoading} = useSelector((state) => state.ctfs); + // const {userDetail, isUserDetailLoading} = useSelector((state) => state.userDetail); + + // useEffect(() => { + // dispatch(getAllCTFs()); + // if (user) { + // dispatch(getUserDetail(user?.username)); + // } + // }, [dispatch]); + + // const [searchTerm, setSearchTerm] = useState(""); + // const [selectedDifficulty, setSelectedDifficulty] = useState("all"); + // const [selectedType, setSelectedType] = useState("all"); + // const [filteredCTFs, setFilteredCTFs] = useState(ctfs); + + // useEffect(() => { + // const filteredCTFs = Array?.isArray(ctfs) + // ? ctfs?.filter((challenge) => { + // const nameMatches = challenge?.challengeName?.toLowerCase().includes(searchTerm?.toLowerCase()); + // const difficultyMatches = + // selectedDifficulty === "all" || challenge?.difficulty === selectedDifficulty; + // const typeMatches = selectedType === "all" || challenge?.type === selectedType; + // return nameMatches && difficultyMatches && typeMatches; + // }) + // : []; + // setFilteredCTFs(filteredCTFs); + // }, [ctfs, searchTerm, selectedDifficulty, selectedType]); + + // const handleSearchTermChange = (event) => { + // setSearchTerm(event.target.value); + // }; + + // const handleTypeSelect = (event) => { + // setSelectedType(event.target.value); + // }; + + // const handleDifficultySelect = (event) => { + // setSelectedDifficulty(event.target.value); + // }; + + // if (isApiLoading || isUserDetailLoading || isCtfLoading) return ; + + // if (!isApiWorking) return ; return ( @@ -66,20 +69,26 @@ const CTF = () => { Capture The Flag - {/* */} - {/* Create */} - {/* */} + + {/* {user && user.role === 'admin' || user.role === 'team' ? ( */} + {/* */} + {/* Create */} + {/* */} + {/* ) : null} */} Type - @@ -89,7 +98,10 @@ const CTF = () => { Difficulty - @@ -99,22 +111,22 @@ const CTF = () => { - {/* */} - {/* */} - {/* */} - {/* Teams */} - {/* */} - {/* */} + + + + Teams + + { Coming Soon - {/* */} + {/* */} );