Skip to content

Commit

Permalink
Merge pull request #894 from WildMeOrg/toggleOldEncounter
Browse files Browse the repository at this point in the history
Toggle old report an encounter page
  • Loading branch information
naknomum authored Nov 14, 2024
2 parents 167af97 + 1f2c471 commit 261e612
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 29 deletions.
3 changes: 2 additions & 1 deletion frontend/src/AuthenticatedSwitch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Citation from "./pages/Citation";
import ReportEncounter from "./pages/ReportsAndManagamentPages/ReportEncounter";
import ReportConfirm from "./pages/ReportsAndManagamentPages/ReportConfirm";

export default function AuthenticatedSwitch({ showAlert, setShowAlert }) {
export default function AuthenticatedSwitch({ showAlert, setShowAlert, showclassicsubmit }) {
const { data } = useGetMe();
const username = data?.username;
const avatar =
Expand All @@ -37,6 +37,7 @@ export default function AuthenticatedSwitch({ showAlert, setShowAlert }) {
avatar={avatar}
showAlert={showAlert}
setShowAlert={setShowAlert}
showclassicsubmit={showclassicsubmit}
/>
</div>

Expand Down
5 changes: 5 additions & 0 deletions frontend/src/FrontDesk.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
sessionWarningTime,
sessionCountdownTime,
} from "./constants/sessionWarning";
import useGetSiteSettings from "./models/useGetSiteSettings";

export default function FrontDesk() {
const [isLoggedIn, setIsLoggedIn] = useState(false);
Expand All @@ -25,6 +26,8 @@ export default function FrontDesk() {
Cookies.get("showAlert") === "false" ? false : true,
);
const [loading, setLoading] = useState(true);
const { data } = useGetSiteSettings();
const showclassicsubmit = data?.showClassicSubmit;

const checkLoginStatus = () => {
axios
Expand Down Expand Up @@ -89,6 +92,7 @@ export default function FrontDesk() {
<AuthenticatedSwitch
showAlert={showAlert}
setShowAlert={setShowAlert}
showclassicsubmit={showclassicsubmit}
/>
</AuthContext.Provider>
);
Expand All @@ -105,6 +109,7 @@ export default function FrontDesk() {
<UnauthenticatedSwitch
showAlert={showAlert}
setShowAlert={setShowAlert}
showclassicsubmit={showclassicsubmit}
/>
</AuthContext.Provider>
);
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/UnAuthenticatedSwitch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import Citation from "./pages/Citation";
import ReportEncounter from "./pages/ReportsAndManagamentPages/ReportEncounter";
import ReportConfirm from "./pages/ReportsAndManagamentPages/ReportConfirm";

export default function UnAuthenticatedSwitch({ showAlert, setShowAlert }) {
export default function UnAuthenticatedSwitch({
showAlert,
setShowAlert,
showclassicsubmit,
}) {
const [header, setHeader] = React.useState(true);
const location = useLocation();

Expand All @@ -29,7 +33,7 @@ export default function UnAuthenticatedSwitch({ showAlert, setShowAlert }) {
}}
>
{showAlert && <AlertBanner setShowAlert={setShowAlert} />}
<UnAuthenticatedAppHeader />
<UnAuthenticatedAppHeader showclassicsubmit={showclassicsubmit} />
</div>

<div
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/AuthenticatedAppHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Menu from "./header/Menu";
import FooterVisibilityContext from "../FooterVisibilityContext";
import Logo from "./svg/Logo";

export default function AuthenticatedAppHeader({ username, avatar }) {
export default function AuthenticatedAppHeader({ username, avatar, showclassicsubmit }) {
const { visible } = useContext(FooterVisibilityContext);

const {
Expand Down Expand Up @@ -68,7 +68,7 @@ export default function AuthenticatedAppHeader({ username, avatar }) {
marginLeft: "auto",
}}
>
<Menu username={username} />
<Menu username={username} showclassicsubmit={showclassicsubmit}/>
</Nav>
<NotificationButton
collaborationTitle={collaborationTitle}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/UnAuthenticatedAppHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { FormattedMessage } from "react-intl";
import FooterVisibilityContext from "../FooterVisibilityContext";
import Logo from "./svg/Logo";

export default function AuthenticatedAppHeader() {
export default function AuthenticatedAppHeader({showclassicsubmit}) {
const { visible } = useContext(FooterVisibilityContext);
const [dropdownShows, setDropdownShows] = useState({
dropdown1: false,
Expand Down Expand Up @@ -74,7 +74,7 @@ export default function AuthenticatedAppHeader() {
marginLeft: "auto",
}}
>
{unAuthenticatedMenu.map((item, idx) => (
{unAuthenticatedMenu(showclassicsubmit).map((item, idx) => (
<Nav key={idx} className="me-auto">
<NavDropdown
title={
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/header/Menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DownIcon from "../svg/DownIcon";
import RightIcon from "../svg/RightIcon";
import { authenticatedMenu } from "../../constants/navMenu";

export default function Menu({ username }) {
export default function Menu({ username, showclassicsubmit }) {
const [dropdownColor, setDropdownColor] = useState("transparent");

const [dropdownShows, setDropdownShows] = useState({});
Expand All @@ -21,7 +21,7 @@ export default function Menu({ username }) {

return (
<>
{authenticatedMenu(username).map((item, idx) => (
{authenticatedMenu(username, showclassicsubmit).map((item, idx) => (
<Nav className="me-auto" key={idx}>
<NavDropdown
className="header-dropdown"
Expand Down
48 changes: 28 additions & 20 deletions frontend/src/constants/navMenu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { FormattedMessage } from "react-intl";

const authenticatedMenu = (username) => [
const authenticatedMenu = (username, showclassicsubmit) => [
{
Submit: [
{
Expand All @@ -13,15 +13,19 @@ const authenticatedMenu = (username) => [
),
href: `${process.env.PUBLIC_URL}/report`,
},
{
name: (
<FormattedMessage
id="MENU_LEARN_REPORTENCOUNTER_CLASSIC"
defaultMessage="Report an Encounter(Classic)"
/>
),
href: "/submit.jsp",
},
...(showclassicsubmit
? [
{
name: (
<FormattedMessage
id="MENU_LEARN_REPORTENCOUNTER_CLASSIC"
defaultMessage="Report an Encounter(Classic)"
/>
),
href: "/submit.jsp",
},
]
: []),
{
name: (
<FormattedMessage
Expand Down Expand Up @@ -282,7 +286,7 @@ const authenticatedMenu = (username) => [
},
];

const unAuthenticatedMenu = [
const unAuthenticatedMenu = (showclassicsubmit) => [
{
Submit: [
{
Expand All @@ -294,15 +298,19 @@ const unAuthenticatedMenu = [
),
href: `${process.env.PUBLIC_URL}/report`,
},
{
name: (
<FormattedMessage
id="MENU_LEARN_REPORTENCOUNTER_CLASSIC"
defaultMessage="Report an Encounter(Classic)"
/>
),
href: "/submit.jsp",
},
...(showclassicsubmit
? [
{
name: (
<FormattedMessage
id="MENU_LEARN_REPORTENCOUNTER_CLASSIC"
defaultMessage="Report an Encounter(Classic)"
/>
),
href: "/submit.jsp",
},
]
: []),
],
},
{
Expand Down

0 comments on commit 261e612

Please sign in to comment.