chore: misc improvements

This commit is contained in:
swve 2024-06-15 15:19:11 +01:00
parent 46e09f27c2
commit c8cff9cbb4
4 changed files with 45 additions and 24 deletions

View file

@ -59,7 +59,7 @@ function DynamicCanvaModal({ submitActivity, chapterId, course }: any) {
</FormMessage>
</Flex>
<Form.Control asChild>
<Textarea onChange={handleActivityDescriptionChange} required />
<Textarea onChange={handleActivityDescriptionChange} />
</Form.Control>
</FormField>

View file

@ -1,5 +1,5 @@
import { useOrg } from '@components/Contexts/OrgContext'
import { getAPIUrl } from '@services/config/config'
import { getAPIUrl, getUriWithOrg } from '@services/config/config'
import { createInviteCode, createInviteCodeWithUserGroup } from '@services/organizations/invites'
import { swrFetcher } from '@services/utils/ts/requests'
import { Ticket } from 'lucide-react'
@ -7,6 +7,7 @@ import { useLHSession } from '@components/Contexts/LHSessionContext'
import React, { useEffect } from 'react'
import toast from 'react-hot-toast'
import useSWR, { mutate } from 'swr'
import Link from 'next/link'
type OrgInviteCodeGenerateProps = {
setInvitesModal: any
@ -56,24 +57,34 @@ function OrgInviteCodeGenerate(props: OrgInviteCodeGenerateProps) {
<h1 className='mx-auto pt-4 text-gray-600 font-medium'>Invite Code linked to a UserGroup</h1>
<h2 className='mx-auto text-xs text-gray-600 font-medium'>On Signup, Users will be automatically linked to a UserGroup of your choice</h2>
<div className='flex items-center space-x-4 pt-3 mx-auto'>
<select
defaultValue={usergroup_id}
className='flex p-2 w-fit rounded-md text-sm bg-gray-100'>
{usergroups?.map((usergroup: any) => (
<option key={usergroup.id} value={usergroup.id}>
{usergroup.name}
</option>
))}
</select>
<div className=''>
<button
onClick={createInviteWithUserGroup}
className="flex space-x-2 w-fit hover:cursor-pointer p-1 px-3 bg-green-700 rounded-md font-bold items-center text-sm text-green-100"
>
<Ticket className="w-4 h-4" />
<span> Generate </span>
</button>
</div>
{usergroups?.length >= 1 &&
<div className='flex space-x-4 items-center'>
<select
defaultValue={usergroup_id}
className='flex p-2 w-fit rounded-md text-sm bg-gray-100'>
{usergroups?.map((usergroup: any) => (
<option key={usergroup.id} value={usergroup.id}>
{usergroup.name}
</option>
))}
</select>
<div className=''>
<button
onClick={createInviteWithUserGroup}
className="flex space-x-2 w-fit hover:cursor-pointer p-1 px-3 bg-green-700 rounded-md font-bold items-center text-sm text-green-100"
>
<Ticket className="w-4 h-4" />
<span> Generate </span>
</button>
</div>
</div>}
{usergroups?.length == 0 &&
<div className='flex space-x-3 items-center text-xs pt-3'>
<span className='px-3 text-yellow-700 font-bold rounded-full py-1 mx-3'>No UserGroups available </span>
<Link className='px-3 text-blue-700 font-bold rounded-full py-1 bg-blue-100 mx-1' target='_blank' href={getUriWithOrg(org.slug, '/dash/users/settings/usergroups')}>Create a UserGroup </Link>
</div>}
</div>
</div>
</div>