mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: login and signup orgslug missing bug
This commit is contained in:
parent
2e618d9c5a
commit
f4794ebaf2
5 changed files with 15 additions and 14 deletions
|
|
@ -3,7 +3,7 @@ import learnhouseIcon from 'public/learnhouse_bigicon_1.png'
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
import { getOrgLogoMediaDirectory } from '@services/media/media'
|
import { getOrgLogoMediaDirectory } from '@services/media/media'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { getUriWithOrg } from '@services/config/config'
|
import { getUriWithOrg, getUriWithoutOrg } from '@services/config/config'
|
||||||
import { useLHSession } from '@components/Contexts/LHSessionContext'
|
import { useLHSession } from '@components/Contexts/LHSessionContext'
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { MailWarning, Ticket, UserPlus } from 'lucide-react'
|
import { MailWarning, Ticket, UserPlus } from 'lucide-react'
|
||||||
|
|
@ -191,7 +191,7 @@ const NoTokenScreen = (props: any) => {
|
||||||
"Invite code is valid, you'll be redirected to the signup page in a few seconds"
|
"Invite code is valid, you'll be redirected to the signup page in a few seconds"
|
||||||
)
|
)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
router.push(`/signup?inviteCode=${inviteCode}&orgslug=${org.slug}`)
|
router.push(getUriWithoutOrg(`/signup?inviteCode=${inviteCode}&orgslug=${org.slug}`))
|
||||||
}, 2000)
|
}, 2000)
|
||||||
} else {
|
} else {
|
||||||
toast.error('Invite code is invalid')
|
toast.error('Invite code is invalid')
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { useOrg } from '@components/Contexts/OrgContext'
|
import { useOrg } from '@components/Contexts/OrgContext'
|
||||||
import PageLoading from '@components/Objects/Loaders/PageLoading'
|
import PageLoading from '@components/Objects/Loaders/PageLoading'
|
||||||
import ConfirmationModal from '@components/Objects/StyledElements/ConfirmationModal/ConfirmationModal'
|
import ConfirmationModal from '@components/Objects/StyledElements/ConfirmationModal/ConfirmationModal'
|
||||||
import { getAPIUrl, getUriWithOrg } from '@services/config/config'
|
import { getAPIUrl, getUriWithOrg, getUriWithoutOrg } from '@services/config/config'
|
||||||
import { swrFetcher } from '@services/utils/ts/requests'
|
import { swrFetcher } from '@services/utils/ts/requests'
|
||||||
import { Globe, Ticket, UserSquare, Users, X } from 'lucide-react'
|
import { Globe, Ticket, UserSquare, Users, X } from 'lucide-react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
|
@ -173,14 +173,12 @@ function OrgAccess() {
|
||||||
<Link
|
<Link
|
||||||
className="outline bg-gray-50 text-gray-600 px-2 py-1 rounded-md outline-gray-300 outline-dashed outline-1"
|
className="outline bg-gray-50 text-gray-600 px-2 py-1 rounded-md outline-gray-300 outline-dashed outline-1"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href={getUriWithOrg(
|
href={getUriWithoutOrg(
|
||||||
org?.slug,
|
`/signup?inviteCode=${invite.invite_code}&orgslug=${org.slug}`
|
||||||
`/signup?inviteCode=${invite.invite_code}`
|
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{getUriWithOrg(
|
{getUriWithoutOrg(
|
||||||
org?.slug,
|
`/signup?inviteCode=${invite.invite_code}&orgslug=${org.slug}`
|
||||||
`/signup?inviteCode=${invite.invite_code}`
|
|
||||||
)}
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { revalidateTags } from '@services/utils/ts/requests'
|
||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
import { useLHSession } from '@components/Contexts/LHSessionContext'
|
import { useLHSession } from '@components/Contexts/LHSessionContext'
|
||||||
import { useMediaQuery } from 'usehooks-ts'
|
import { useMediaQuery } from 'usehooks-ts'
|
||||||
import { getUriWithOrg } from '@services/config/config'
|
import { getUriWithOrg, getUriWithoutOrg } from '@services/config/config'
|
||||||
import { getProductsByCourse } from '@services/payments/products'
|
import { getProductsByCourse } from '@services/payments/products'
|
||||||
import { LogIn, LogOut, ShoppingCart, AlertCircle } from 'lucide-react'
|
import { LogIn, LogOut, ShoppingCart, AlertCircle } from 'lucide-react'
|
||||||
import Modal from '@components/Objects/StyledElements/Modal/Modal'
|
import Modal from '@components/Objects/StyledElements/Modal/Modal'
|
||||||
|
|
@ -126,7 +126,7 @@ const Actions = ({ courseuuid, orgslug, course }: CourseActionsProps) => {
|
||||||
|
|
||||||
const handleCourseAction = async () => {
|
const handleCourseAction = async () => {
|
||||||
if (!session.data?.user) {
|
if (!session.data?.user) {
|
||||||
router.push(getUriWithOrg(orgslug, '/signup?orgslug=' + orgslug))
|
router.push(getUriWithoutOrg(`/signup?orgslug=${orgslug}`))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const action = isStarted ? removeCourse : startCourse
|
const action = isStarted ? removeCourse : startCourse
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import { useLHSession } from '@components/Contexts/LHSessionContext';
|
||||||
import useAdminStatus from '@components/Hooks/useAdminStatus';
|
import useAdminStatus from '@components/Hooks/useAdminStatus';
|
||||||
import { usePathname, useRouter } from 'next/navigation';
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
import PageLoading from '@components/Objects/Loaders/PageLoading';
|
import PageLoading from '@components/Objects/Loaders/PageLoading';
|
||||||
|
import { getUriWithoutOrg } from '@services/config/config';
|
||||||
|
import { useOrg } from '@components/Contexts/OrgContext';
|
||||||
|
|
||||||
type AuthorizationProps = {
|
type AuthorizationProps = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
|
|
@ -22,6 +24,7 @@ const ADMIN_PATHS = [
|
||||||
|
|
||||||
const AdminAuthorization: React.FC<AuthorizationProps> = ({ children, authorizationMode }) => {
|
const AdminAuthorization: React.FC<AuthorizationProps> = ({ children, authorizationMode }) => {
|
||||||
const session = useLHSession() as any;
|
const session = useLHSession() as any;
|
||||||
|
const org = useOrg() as any;
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { isAdmin, loading } = useAdminStatus() as any
|
const { isAdmin, loading } = useAdminStatus() as any
|
||||||
|
|
@ -51,7 +54,7 @@ const AdminAuthorization: React.FC<AuthorizationProps> = ({ children, authorizat
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isUserAuthenticated) {
|
if (!isUserAuthenticated) {
|
||||||
router.push('/login');
|
router.push(getUriWithoutOrg('/login?orgslug=' + org.slug));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,10 @@ export const HeaderProfileBox = () => {
|
||||||
<ul className="flex space-x-3 items-center">
|
<ul className="flex space-x-3 items-center">
|
||||||
<li>
|
<li>
|
||||||
<Link
|
<Link
|
||||||
href={{ pathname: getUriWithoutOrg('/login'), query: org ? { orgslug: org.slug } : null }} >Login</Link>
|
href={{ pathname: getUriWithoutOrg('/login?orgslug=' + org.slug), query: org ? { orgslug: org.slug } : null }} >Login</Link>
|
||||||
</li>
|
</li>
|
||||||
<li className="bg-black rounded-lg shadow-md p-2 px-3 text-white">
|
<li className="bg-black rounded-lg shadow-md p-2 px-3 text-white">
|
||||||
<Link href={{ pathname: getUriWithoutOrg('/signup'), query: org ? { orgslug: org.slug } : null }}>Sign up</Link>
|
<Link href={{ pathname: getUriWithoutOrg('/signup?orgslug=' + org.slug), query: org ? { orgslug: org.slug } : null }}>Sign up</Link>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</UnidentifiedArea>
|
</UnidentifiedArea>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue