mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
chore: misc improvements
This commit is contained in:
parent
46e09f27c2
commit
c8cff9cbb4
4 changed files with 45 additions and 24 deletions
|
|
@ -42,6 +42,7 @@ function ForgotPasswordClient() {
|
||||||
email: ''
|
email: ''
|
||||||
},
|
},
|
||||||
validate,
|
validate,
|
||||||
|
validateOnBlur: true,
|
||||||
onSubmit: async (values) => {
|
onSubmit: async (values) => {
|
||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
let res = await sendResetLink(values.email, org?.id)
|
let res = await sendResetLink(values.email, org?.id)
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,17 @@ const LoginClient = (props: LoginClientProps) => {
|
||||||
password: '',
|
password: '',
|
||||||
},
|
},
|
||||||
validate,
|
validate,
|
||||||
onSubmit: async (values) => {
|
validateOnBlur: true,
|
||||||
|
validateOnChange: true,
|
||||||
|
onSubmit: async (values, {validateForm, setErrors, setSubmitting}) => {
|
||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
|
const errors = await validateForm(values);
|
||||||
|
if (Object.keys(errors).length > 0) {
|
||||||
|
setErrors(errors);
|
||||||
|
setSubmitting(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const res = await signIn('credentials', {
|
const res = await signIn('credentials', {
|
||||||
redirect: false,
|
redirect: false,
|
||||||
email: values.email,
|
email: values.email,
|
||||||
|
|
@ -139,7 +148,7 @@ const LoginClient = (props: LoginClientProps) => {
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
value={formik.values.email}
|
value={formik.values.email}
|
||||||
type="email"
|
type="email"
|
||||||
required
|
|
||||||
/>
|
/>
|
||||||
</Form.Control>
|
</Form.Control>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
@ -155,7 +164,7 @@ const LoginClient = (props: LoginClientProps) => {
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
value={formik.values.password}
|
value={formik.values.password}
|
||||||
type="password"
|
type="password"
|
||||||
required
|
|
||||||
/>
|
/>
|
||||||
</Form.Control>
|
</Form.Control>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
@ -170,7 +179,7 @@ const LoginClient = (props: LoginClientProps) => {
|
||||||
</div>
|
</div>
|
||||||
<div className="flex py-4">
|
<div className="flex py-4">
|
||||||
<Form.Submit asChild>
|
<Form.Submit asChild>
|
||||||
<button className="w-full bg-black text-white font-bold text-center p-2 rounded-md shadow-md hover:cursor-pointer">
|
<button className="w-full bg-black text-white font-bold text-center p-2 rounded-md shadow-md hover:cursor-pointer">
|
||||||
{isSubmitting ? 'Loading...' : 'Login'}
|
{isSubmitting ? 'Loading...' : 'Login'}
|
||||||
</button>
|
</button>
|
||||||
</Form.Submit>
|
</Form.Submit>
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ function DynamicCanvaModal({ submitActivity, chapterId, course }: any) {
|
||||||
</FormMessage>
|
</FormMessage>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Form.Control asChild>
|
<Form.Control asChild>
|
||||||
<Textarea onChange={handleActivityDescriptionChange} required />
|
<Textarea onChange={handleActivityDescriptionChange} />
|
||||||
</Form.Control>
|
</Form.Control>
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { useOrg } from '@components/Contexts/OrgContext'
|
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 { createInviteCode, createInviteCodeWithUserGroup } from '@services/organizations/invites'
|
||||||
import { swrFetcher } from '@services/utils/ts/requests'
|
import { swrFetcher } from '@services/utils/ts/requests'
|
||||||
import { Ticket } from 'lucide-react'
|
import { Ticket } from 'lucide-react'
|
||||||
|
|
@ -7,6 +7,7 @@ import { useLHSession } from '@components/Contexts/LHSessionContext'
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import toast from 'react-hot-toast'
|
import toast from 'react-hot-toast'
|
||||||
import useSWR, { mutate } from 'swr'
|
import useSWR, { mutate } from 'swr'
|
||||||
|
import Link from 'next/link'
|
||||||
|
|
||||||
type OrgInviteCodeGenerateProps = {
|
type OrgInviteCodeGenerateProps = {
|
||||||
setInvitesModal: any
|
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>
|
<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>
|
<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'>
|
<div className='flex items-center space-x-4 pt-3 mx-auto'>
|
||||||
<select
|
{usergroups?.length >= 1 &&
|
||||||
defaultValue={usergroup_id}
|
<div className='flex space-x-4 items-center'>
|
||||||
className='flex p-2 w-fit rounded-md text-sm bg-gray-100'>
|
<select
|
||||||
{usergroups?.map((usergroup: any) => (
|
defaultValue={usergroup_id}
|
||||||
<option key={usergroup.id} value={usergroup.id}>
|
className='flex p-2 w-fit rounded-md text-sm bg-gray-100'>
|
||||||
{usergroup.name}
|
{usergroups?.map((usergroup: any) => (
|
||||||
</option>
|
<option key={usergroup.id} value={usergroup.id}>
|
||||||
))}
|
{usergroup.name}
|
||||||
</select>
|
</option>
|
||||||
<div className=''>
|
))}
|
||||||
<button
|
|
||||||
onClick={createInviteWithUserGroup}
|
</select>
|
||||||
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"
|
|
||||||
>
|
<div className=''>
|
||||||
<Ticket className="w-4 h-4" />
|
<button
|
||||||
<span> Generate </span>
|
onClick={createInviteWithUserGroup}
|
||||||
</button>
|
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"
|
||||||
</div>
|
>
|
||||||
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue