better for github pages

pull/2/head
bvn13 2023-04-30 01:13:31 +03:00
parent 1d9660b133
commit 8c925473cb
4 changed files with 22 additions and 8 deletions

View File

@ -11,6 +11,7 @@ const RootComponent: React.FC = () => {
<Routes>
<Route path="*" element={<NotFoundPage />} />
<Route path={ROUTES.HOMEPAGE_ROUTE} element={<HomePage />} />
<Route path={ROUTES.GITHUB_PAGES_ROUTE} element={<HomePage />} />
</Routes>
</Router>
)

View File

@ -1,7 +1,7 @@
import './Survey.css'
import * as React from "react";
import {useEffect} from "react";
import {SurveyDto} from "./../../api/Api";
import {SurveyDto} from "../../api/Api";
import {Box, Button, Paper, Step, StepContent, StepLabel, Stepper, Typography} from "@mui/material";
import {store} from "../../store/store";
import {setContents, addAnswer} from "../../store/actions/data";

View File

@ -1,6 +1,6 @@
import React from 'react'
import { useNavigate } from 'react-router-dom'
import { ROUTES } from '../resources/routes-constants'
import {useNavigate} from 'react-router-dom'
import {ROUTES} from '../resources/routes-constants'
const NotFoundPage: React.FC = () => {
const navigate = useNavigate()
@ -9,13 +9,25 @@ const NotFoundPage: React.FC = () => {
* Call this function to redirect the user to the homepage.
*/
const redirectToHomePage = () => {
navigate(ROUTES.HOMEPAGE_ROUTE)
const url = new URL(window.location.href)
if (url.host.indexOf('github.io') > 0) {
navigate(ROUTES.GITHUB_PAGES_ROUTE)
} else {
navigate(ROUTES.HOMEPAGE_ROUTE)
}
}
return (
<div style={{ position: 'relative', width: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center', flexDirection: 'column' }}>
<h1 style={{ fontSize: '4em' }}>Oops 404!</h1>
<span style={{ cursor: 'pointer' }} onClick={() => redirectToHomePage()}>
<div style={{
position: 'relative',
width: '100%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'column'
}}>
<h1 style={{fontSize: '4em'}}>Oops 404!</h1>
<span style={{cursor: 'pointer'}} onClick={() => redirectToHomePage()}>
Homepage
</span>
</div>

View File

@ -1,3 +1,4 @@
export const ROUTES = {
HOMEPAGE_ROUTE: '/'
HOMEPAGE_ROUTE: '/',
GITHUB_PAGES_ROUTE: 'tl-esa-tools/'
}