Skip to content

Commit

Permalink
Add log in logic to DC Nav homepage for purposes of testing on QA
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Schroer committed Jan 10, 2024
1 parent 0d77e03 commit 77e8808
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/components/ui/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const SiteLinks = () => {
*/}
{authState.isAuthenticated && (
<li>
<Link to="/sign-out">Sign Out</Link>
<Link to="/log-out">Log Out</Link>
</li>
)}
<li>
Expand Down
56 changes: 45 additions & 11 deletions app/pages/UcsfHomePage/UcsfHomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from "react";
import React, { useEffect } from "react";
import { useHistory } from "react-router-dom";
import type { WebAuth } from "auth0-js";

import { icon as assetIcon } from "assets";
import { Section } from "components/ucsf/Section/Section";
import { Layout } from "components/ucsf/Layout/Layout";
import { useAppContext, AuthService } from "../../utils";

import { UCSF_RESOURCES, ResourceItem } from "./ucsfResourceConstants";

Expand Down Expand Up @@ -50,16 +52,48 @@ const ResourceCard = ({ resource }: { resource: ResourceItem }) => {
);
};

const Page = () => (
<div className={styles.ucsfHomePage}>
<Section title="For Clinicians" />
<Section
addClass={styles.subtitleMargin}
subtitle="What kind of assistance does your patient need?"
/>
<ResourceListComponent resourceList={UCSF_RESOURCES} />
</div>
);
const Page = () => {
const { authClient, setAuthState } = useAppContext();
const history = useHistory();

// const secureApiCall = () => {
// fetch("/api/resources/548", {
// method: "GET",
// headers: {
// Authorization: `Bearer ${authState.accessTokenObject.token}`,
// },
// }).then((resp) => {
// console.log(resp);
// });
// };


useEffect(() => {
// Todo: This effect should be moved to the case worker UI homepage when that page is created
const { hash } = window.location;
if (!hash || !hash.includes("access_token")) return;

AuthService.persistUser(
window.location.hash,
authClient as WebAuth,
setAuthState
);

// Remove the url query params set by Auth0
history.replace(window.location.pathname + window.location.search);
}, [history, setAuthState, authClient]);

return (
<div className={styles.ucsfHomePage}>
<Section title="For Clinicians" />
<Section
addClass={styles.subtitleMargin}
subtitle="What kind of assistance does your patient need?"
/>
<ResourceListComponent resourceList={UCSF_RESOURCES} />
</div>
);
};

export const UcsfHomePage = () => (
<Layout>
Expand Down

0 comments on commit 77e8808

Please sign in to comment.