Skip to content

Commit

Permalink
message for no projects
Browse files Browse the repository at this point in the history
  • Loading branch information
harshit-jain52 committed Nov 16, 2024
1 parent ef02609 commit 1bb353c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ VITE_GH_OAUTH_CLIENT_ID=
VITE_REGISTRATIONS_OPEN=true
VITE_MID_EVALS_ENDED=false
VITE_END_EVALS_ENDED=false
VITE_REPORT_SUBMISSION_OPEN=false
VITE_REPORT_SUBMISSION_OPEN=false
VITE_PROJECTS_STARTED=false
2 changes: 1 addition & 1 deletion src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Navbar = () => {
const location = useLocation();
const [LINKS, setLINKS] = useState([
{ name: "Home", link: ROUTER_PATHS.HOME, isActive: false },
// { name: "Projects", link: ROUTER_PATHS.PROJECTS_LIST, isActive: false },
{ name: "Projects", link: ROUTER_PATHS.PROJECTS_LIST, isActive: false },
{ name: "FAQs", link: ROUTER_PATHS.FAQ, isActive: false },
]);
const [isOpen, setIsOpen] = useState(false);
Expand Down
68 changes: 37 additions & 31 deletions src/pages/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Fuse from "fuse.js";
import SpinnerLoader from "../components/SpinnerLoader";
import { IconContext } from "react-icons";
import "../styles/Projects.css";
import { PROJECTS_STARTED } from "../util/constants";

function Projects() {
const [projects, setProjects] = useState<
Expand Down Expand Up @@ -49,39 +50,44 @@ function Projects() {
return (
<div className="projects-container">
<h1 className="projects-title">Projects</h1>
<div className="search-container">
<div className="search-bar">
<input
className="search-input"
type="text"
placeholder="Search for projects by name or topic"
onChange={onQueryChangeHandler}
value={query}
/>
{query !== "" && (
<button onClick={() => setQuery("")} className="search-cancel">
<IconContext.Provider value={{ size: "1.6rem" }}>
<MdCancel />
</IconContext.Provider>
</button>
{PROJECTS_STARTED ? (
<>
<div className="search-container">
<div className="search-bar">
<input
className="search-input"
type="text"
placeholder="Search for projects by name or topic"
onChange={onQueryChangeHandler}
value={query}
/>
{query !== "" && (
<button onClick={() => setQuery("")} className="search-cancel">
<IconContext.Provider value={{ size: "1.6rem" }}>
<MdCancel />
</IconContext.Provider>
</button>
)}
</div>
</div>
{error !== null ? (
<p className="error-message">{error}</p>
) : projects.length > 0 ? (
<div className="projects-grid">
{searchResults.map((project, i) => (
<ProjectCard
key={i}
project={project}
setQuery={(query) => setQuery(query)}
/>
))}
</div>
) : (
<SpinnerLoader />
)}
</div>
</div>

{error !== null ? (
<p className="error-message">{error}</p>
) : projects.length > 0 ? (
<div className="projects-grid">
{searchResults.map((project, i) => (
<ProjectCard
key={i}
project={project}
setQuery={(query) => setQuery(query)}
/>
))}
</div>
</>
) : (
<SpinnerLoader />
<h2>Stay Tuned!</h2>
)}
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const MID_EVALS_ENDED = import.meta.env.VITE_MID_EVALS_ENDED == "true";
export const END_EVALS_ENDED = import.meta.env.VITE_END_EVALS_ENDED == "true";
export const REPORT_SUBMISSION_OPEN =
import.meta.env.VITE_REPORT_SUBMISSION_OPEN == "true";
export const PROJECTS_STARTED = import.meta.env.VITE_PROJECTS_STARTED == "true";

export enum ROUTER_PATHS {
HOME = "/",
Expand Down

0 comments on commit 1bb353c

Please sign in to comment.