Skip to content

Commit

Permalink
Added Conditional component
Browse files Browse the repository at this point in the history
  • Loading branch information
rishit-singh committed Dec 28, 2023
1 parent e18192c commit 14aa4c5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions frontend/src/app/Conditional.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ReactNode } from "react";

interface ConditionalProps
{
Condition: boolean;

children: ReactNode;
}

export default function Conditional({Condition, children} : ConditionalProps): JSX.Element
{
if (Condition)
return (<>children</>);

return <></>;
}
1 change: 1 addition & 0 deletions frontend/src/app/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ export default function HomePage({} : HomePageProps)
);
}


5 changes: 2 additions & 3 deletions frontend/src/app/about/AboutPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { loadProfilesAsync } from "../thunks/ProfileThunks";
import { AppDispatch } from "../stores/store";
import { UnknownAction } from "@reduxjs/toolkit";
import { SetCurrentPage } from "../slices/pageSlice";
import Conditional from "../Conditional";
interface AboutPageProps
{}

Expand Down Expand Up @@ -59,9 +60,7 @@ export default function AboutPage({} : AboutPageProps)
</div>
<div className={"profileContainer"}>
<div className={"flex flex-col ml-5 mr-5 gap-3 items-center"}>
{
((): JSX.Element => { return (loading) ? <div>Loading</div> : <></>; })()
}
<Conditional Condition={loading}>Loading</Conditional>
<ExecProfiles/>
</div>
</div>
Expand Down

0 comments on commit 14aa4c5

Please sign in to comment.