fix: Ancora fix sul BASE_URL

pull/1/head
Antonio De Lucreziis 2 years ago
parent c3b014b50a
commit bd01bc9085

@ -12,7 +12,7 @@ import { ProfilePage } from './pages/Profile'
const Redirect = ({ to }: { to: string }) => { const Redirect = ({ to }: { to: string }) => {
useEffect(() => { useEffect(() => {
route(to, true) route(prependBaseUrl(to), true)
}, []) }, [])
return ( return (

@ -2,7 +2,7 @@ import { route } from 'preact-router'
import { useState } from 'preact/hooks' import { useState } from 'preact/hooks'
import { isAdministrator, isStudent, Solution as SolutionModel, SolutionId } from '../../shared/model' import { isAdministrator, isStudent, Solution as SolutionModel, SolutionId } from '../../shared/model'
import { sortByStringKey } from '../../shared/utils' import { sortByStringKey } from '../../shared/utils'
import { server } from '../api' import { prependBaseUrl, server } from '../api'
import { Header } from '../components/Header' import { Header } from '../components/Header'
import { MarkdownEditor } from '../components/MarkdownEditor' import { MarkdownEditor } from '../components/MarkdownEditor'
import { Select } from '../components/Select' import { Select } from '../components/Select'
@ -16,7 +16,7 @@ const CreateProblem = ({}) => {
content: source, content: source,
}) })
route(`/problem/${id}`) route(prependBaseUrl(`/problem/${id}`))
} }
return ( return (
@ -32,9 +32,9 @@ type SortOrder = 'latest' | 'oldest'
export const AdminPage = ({}) => { export const AdminPage = ({}) => {
const [user] = useCurrentUser(user => { const [user] = useCurrentUser(user => {
if (!user) { if (!user) {
route('/login', true) route(prependBaseUrl('/login'), true)
} else if (isStudent(user.role)) { } else if (isStudent(user.role)) {
route('/', true) route(prependBaseUrl('/'), true)
} }
}) })

@ -1,6 +1,7 @@
import { route } from 'preact-router' import { route } from 'preact-router'
import { useState } from 'preact/hooks' import { useState } from 'preact/hooks'
import { prependBaseUrl } from '../api.js'
import { Header } from '../components/Header.jsx' import { Header } from '../components/Header.jsx'
export const LoginPage = () => { export const LoginPage = () => {
@ -18,7 +19,7 @@ export const LoginPage = () => {
}), }),
}) })
route('/') route(prependBaseUrl('/'))
} }
return ( return (

@ -1,7 +1,7 @@
import { route } from 'preact-router' import { route } from 'preact-router'
import { useState } from 'preact/hooks' import { useState } from 'preact/hooks'
import { isAdministrator, Solution as SolutionModel, User } from '../../shared/model' import { isAdministrator, Solution as SolutionModel, User } from '../../shared/model'
import { server } from '../api' import { prependBaseUrl, server } from '../api'
import { Header } from '../components/Header' import { Header } from '../components/Header'
import { Select } from '../components/Select' import { Select } from '../components/Select'
import { Solution } from '../components/Solution' import { Solution } from '../components/Solution'
@ -22,13 +22,13 @@ const SolutionList = ({ user }: { user: User }) => {
export const ProfilePage = ({}) => { export const ProfilePage = ({}) => {
const [user, logout] = useCurrentUser(user => { const [user, logout] = useCurrentUser(user => {
if (!user) { if (!user) {
route('/login', true) route(prependBaseUrl('/login'), true)
} }
}) })
const handleLogout = () => { const handleLogout = () => {
logout() logout()
route('/') route(prependBaseUrl('/'))
} }
return ( return (

Loading…
Cancel
Save