Skip to content

Commit

Permalink
Fix navigation to support base path
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgxvii committed Oct 2, 2024
1 parent 20e62f6 commit 4e25bf8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
3 changes: 0 additions & 3 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const GlobalStyle = createGlobalStyle((props: ThemeProps) =>
function MyApp({ Component, pageProps }: AppProps) {
return (
<div data-testid="app-react">
<Head>
<base href="/kratos-ui/" />
</Head>
<ThemeProvider theme={theme}>
<GlobalStyle />
<Component {...pageProps} />
Expand Down
21 changes: 11 additions & 10 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Home: NextPage = () => {
const [hasSession, setHasSession] = useState<boolean>(false)
const router = useRouter()
const onLogout = LogoutLink()
const handleNavigation = (href: string) => () => router.push(href)

useEffect(() => {
ory
Expand Down Expand Up @@ -60,62 +61,62 @@ const Home: NextPage = () => {
<div className="row">
<DocsButton
testid="study"
href="/study?projectId=STAGING_PROJECT"
disabled={hasSession}
title={"Study"}
onClick={handleNavigation("/study?projectId=STAGING_PROJECT")}
/>
<DocsButton
testid="eligibility"
href="/eligibility"
disabled={hasSession}
title={"Eligibility"}
onClick={handleNavigation("/eligibility")}
/>
<DocsButton
testid="login"
href="/login"
disabled={hasSession}
title={"Login"}
onClick={handleNavigation("/login")}
/>
<DocsButton
testid="sign-up"
href="/registration"
disabled={hasSession}
title={"Sign Up"}
onClick={handleNavigation("/registration")}
/>
<DocsButton
testid="recover-account"
href="/recovery"
disabled={hasSession}
title="Recover Account"
onClick={handleNavigation("/recovery")}
/>
<DocsButton
testid="verify-account"
href="/verification"
title="Verify Account"
onClick={handleNavigation("/verification")}
/>
<DocsButton
testid="consent"
href="/study-consent"
title="Study Consent"
disabled={!hasSession}
onClick={handleNavigation("/study-consent")}
/>
<DocsButton
testid="apps"
href="/apps"
title="Apps"
disabled={!hasSession}
onClick={handleNavigation("/apps")}
/>
<DocsButton
testid="profile"
href="/profile"
title="Profile"
disabled={!hasSession}
onClick={handleNavigation("/profile")}
/>
<DocsButton
testid="account-settings"
href="/settings"
disabled={!hasSession}
title={"Account Settings"}
onClick={handleNavigation("/settings")}
/>
<DocsButton
testid="logout"
Expand Down
5 changes: 1 addition & 4 deletions pkg/styled/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
import cn from "classnames"
import styled from "styled-components"

const BASE_URL = process.env.BASE_PATH || ""

export const MarginCard = styled(Card)`
margin-top: 70px;
margin-bottom: 18px;
Expand Down Expand Up @@ -109,15 +107,14 @@ export const DocsButton = ({
disabled,
unresponsive,
}: DocsButtonProps) => {
const url = BASE_URL + href
return (
<div className={cn("col-xs-4", { "col-md-12": !unresponsive })}>
<div className="box">
<TextLeftButton
onClick={onClick}
disabled={disabled}
data-testid={testid}
href={url}
href={href}
>
{title}
</TextLeftButton>
Expand Down

0 comments on commit 4e25bf8

Please sign in to comment.