mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: implement logged in organization joining + improvements
This commit is contained in:
parent
25ac82f4ad
commit
693a28721d
19 changed files with 200 additions and 29 deletions
|
|
@ -1,5 +1,4 @@
|
|||
'use client'
|
||||
import PageLoading from '@components/Objects/Loaders/PageLoading'
|
||||
import { getAPIUrl } from '@services/config/config'
|
||||
import { swrFetcher } from '@services/utils/ts/requests'
|
||||
import React, { createContext, useContext, useEffect, useReducer } from 'react'
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use client'
|
||||
import { getAPIUrl, getUriWithoutOrg } from '@services/config/config'
|
||||
import { swrFetcher } from '@services/utils/ts/requests'
|
||||
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react'
|
||||
import React, { createContext, useContext, useMemo } from 'react'
|
||||
import useSWR from 'swr'
|
||||
import { useLHSession } from '@components/Contexts/LHSessionContext'
|
||||
import ErrorUI from '@components/StyledElements/Error/Error'
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import LearnHouseDashboardLogo from '@public/dashLogo.png'
|
|||
import { BookCopy, Home, LogOut, School, Settings, Users } from 'lucide-react'
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import React, { useEffect } from 'react'
|
||||
import UserAvatar from '../../Objects/UserAvatar'
|
||||
import AdminAuthorization from '@components/Security/AdminAuthorization'
|
||||
|
|
|
|||
|
|
@ -20,10 +20,12 @@ function useAdminStatus() {
|
|||
const isAdminVar = userRoles.some((role: Role) => {
|
||||
return (
|
||||
role.org.id === org.id &&
|
||||
(role.role.id === 1 ||
|
||||
(
|
||||
role.role.id === 1 ||
|
||||
role.role.id === 2 ||
|
||||
role.role.role_uuid === 'role_global_admin' ||
|
||||
role.role.role_uuid === 'role_global_maintainer')
|
||||
role.role.role_uuid === 'role_global_maintainer'
|
||||
)
|
||||
);
|
||||
});
|
||||
setIsAdmin(isAdminVar);
|
||||
|
|
@ -38,3 +40,4 @@ function useAdminStatus() {
|
|||
}
|
||||
|
||||
export default useAdminStatus;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ import UserAvatar from '@components/Objects/UserAvatar'
|
|||
import useAdminStatus from '@components/Hooks/useAdminStatus'
|
||||
import { useLHSession } from '@components/Contexts/LHSessionContext'
|
||||
import { useOrg } from '@components/Contexts/OrgContext'
|
||||
import { getUriWithOrg, getUriWithoutOrg } from '@services/config/config'
|
||||
import { getUriWithoutOrg } from '@services/config/config'
|
||||
|
||||
export const HeaderProfileBox = () => {
|
||||
const session = useLHSession() as any
|
||||
const isUserAdmin = useAdminStatus() as any
|
||||
const isUserAdmin = useAdminStatus()
|
||||
const org = useOrg() as any
|
||||
|
||||
useEffect(() => { }
|
||||
|
|
@ -37,7 +37,7 @@ export const HeaderProfileBox = () => {
|
|||
<div className="flex items-center space-x-2">
|
||||
<div className='flex items-center space-x-2' >
|
||||
<p className='text-sm'>{session.data.user.username}</p>
|
||||
{isUserAdmin && <div className="text-[10px] bg-rose-300 px-2 font-bold rounded-md shadow-inner py-1">ADMIN</div>}
|
||||
{isUserAdmin.isAdmin && <div className="text-[10px] bg-rose-300 px-2 font-bold rounded-md shadow-inner py-1">ADMIN</div>}
|
||||
</div>
|
||||
<div className="py-4">
|
||||
<UserAvatar border="border-4" rounded="rounded-lg" width={30} />
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use client'
|
||||
import { getUriWithoutOrg } from '@services/config/config'
|
||||
import { AlertTriangle, Diamond, Home, PersonStanding, RefreshCcw } from 'lucide-react'
|
||||
import { Diamond, Home, PersonStanding } from 'lucide-react'
|
||||
import Link from 'next/link'
|
||||
import React from 'react'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue