fix: Header Role Indicator + Disable course creation wording if user isn't connected

This commit is contained in:
swve 2024-03-19 22:34:28 +01:00
parent a124cde229
commit 7398e9e946
9 changed files with 85 additions and 169 deletions

View file

@ -10,6 +10,7 @@ import Link from 'next/link'
import { getAccessTokenFromRefreshTokenCookie } from '@services/auth/auth'
import CollectionThumbnail from '@components/Objects/Thumbnails/CollectionThumbnail'
import NewCollectionButton from '@components/StyledElements/Buttons/NewCollectionButton'
import ContentPlaceHolderIfUserIsNotAdmin from '@components/ContentPlaceHolder'
type MetadataProps = {
params: { orgslug: string; courseid: string }
@ -127,7 +128,9 @@ const CollectionsPage = async (params: any) => {
No collections yet
</h1>
<p className="text-lg text-gray-400">
Create a collection to group courses together
<ContentPlaceHolderIfUserIsNotAdmin
text="Create a collection to add content"
/>
</p>
</div>
<AuthenticatedClientElement

View file

@ -8,6 +8,7 @@ import TypeOfContentTitle from '@components/StyledElements/Titles/TypeOfContentT
import AuthenticatedClientElement from '@components/Security/AuthenticatedClientElement'
import CourseThumbnail from '@components/Objects/Thumbnails/CourseThumbnail'
import NewCourseButton from '@components/StyledElements/Buttons/NewCourseButton'
import useAdminStatus from '@components/Hooks/useAdminStatus'
interface CourseProps {
orgslug: string
@ -21,6 +22,7 @@ function Courses(props: CourseProps) {
const searchParams = useSearchParams()
const isCreatingCourse = searchParams.get('new') ? true : false
const [newCourseModal, setNewCourseModal] = React.useState(isCreatingCourse)
const isUserAdmin = useAdminStatus() as any
async function closeNewCourseModal() {
setNewCourseModal(false)
@ -97,9 +99,11 @@ function Courses(props: CourseProps) {
<h1 className="text-3xl font-bold text-gray-600">
No courses yet
</h1>
<p className="text-lg text-gray-400">
{isUserAdmin ? (<p className="text-lg text-gray-400">
Create a course to add content
</p>
</p>) : (<p className="text-lg text-gray-400">
No courses available yet
</p>)}
</div>
<AuthenticatedClientElement
action="create"

View file

@ -14,6 +14,7 @@ import CollectionThumbnail from '@components/Objects/Thumbnails/CollectionThumbn
import AuthenticatedClientElement from '@components/Security/AuthenticatedClientElement'
import NewCourseButton from '@components/StyledElements/Buttons/NewCourseButton'
import NewCollectionButton from '@components/StyledElements/Buttons/NewCollectionButton'
import ContentPlaceHolderIfUserIsNotAdmin from '@components/ContentPlaceHolder'
type MetadataProps = {
params: { orgslug: string }
@ -139,7 +140,9 @@ const OrgHomePage = async (params: any) => {
No collections yet
</h1>
<p className="text-md text-gray-400">
Create a collection to group courses together
<ContentPlaceHolderIfUserIsNotAdmin
text="Create collections to group courses together"
/>
</p>
</div>
</div>
@ -206,7 +209,7 @@ const OrgHomePage = async (params: any) => {
No courses yet
</h1>
<p className="text-md text-gray-400">
Create a course to add content
<ContentPlaceHolderIfUserIsNotAdmin text='Create courses to add content' />
</p>
</div>
</div>

View file

@ -76,7 +76,7 @@ function DashboardHome() {
<Link
href={'/dash/user-account/settings/general'}
className="flex bg-white shadow-lg p-[15px] items-center rounded-lg items-center mx-auto hover:scale-105 transition-all ease-linear cursor-pointer"
className="flex bg-white shadow-lg p-[15px] items-center rounded-lg mx-auto hover:scale-105 transition-all ease-linear cursor-pointer"
>
<div className="flex flex-row mx-auto space-x-3 items-center">
<Settings className=" text-gray-500" size={20}></Settings>