mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: use new session and auth provider for the frontend
This commit is contained in:
parent
d939dc16eb
commit
6aa849b305
27 changed files with 283 additions and 235 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use client';
|
||||
import { useOrg } from '@components/Contexts/OrgContext';
|
||||
import { useAuth } from '@components/Security/AuthContext';
|
||||
import { useSession } from '@components/Contexts/SessionContext';
|
||||
import ToolTip from '@components/StyledElements/Tooltip/Tooltip'
|
||||
import LearnHouseDashboardLogo from '@public/dashLogo.png';
|
||||
import Avvvatars from 'avvvatars-react';
|
||||
|
|
@ -11,11 +11,11 @@ import React, { use, useEffect } from 'react'
|
|||
|
||||
function LeftMenu() {
|
||||
const org = useOrg() as any;
|
||||
const auth = useAuth() as any;
|
||||
const session = useSession() as any;
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
|
||||
function waitForEverythingToLoad() {
|
||||
if (org && auth) {
|
||||
if (org && session) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -59,15 +59,15 @@ function LeftMenu() {
|
|||
</ToolTip>
|
||||
</div>
|
||||
<div className='flex flex-col mx-auto pb-7 space-y-2'>
|
||||
<ToolTip content={auth.user.username + "'s Settings"} slateBlack sideOffset={8} side='right' >
|
||||
<ToolTip content={session.user.username + "'s Settings"} slateBlack sideOffset={8} side='right' >
|
||||
<Link href={'/dash/user/settings/general'} className='py-3'>
|
||||
<Settings className='mx-auto text-neutral-400 cursor-pointer' size={18} />
|
||||
</Link>
|
||||
</ToolTip>
|
||||
<div className="flex items-center flex-col space-y-4">
|
||||
<ToolTip content={auth.user.username} slateBlack sideOffset={8} side='right' >
|
||||
<ToolTip content={session.user.username} slateBlack sideOffset={8} side='right' >
|
||||
<div className="mx-auto shadow-lg">
|
||||
<Avvvatars radius={3} border borderColor='white' borderSize={3} size={35} value={auth.user.user_uuid} style="shape" />
|
||||
<Avvvatars radius={3} border borderColor='white' borderSize={3} size={35} value={session.user.user_uuid} style="shape" />
|
||||
</div>
|
||||
</ToolTip>
|
||||
<ToolTip content={'Learnhouse Version'} slateBlack sideOffset={8} side='right' >
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
import { useAuth } from '@components/Security/AuthContext';
|
||||
import { updateProfile } from '@services/settings/profile';
|
||||
import React, { useEffect } from 'react'
|
||||
import { Formik, Form, Field, ErrorMessage } from 'formik';
|
||||
import { useSession } from '@components/Contexts/SessionContext';
|
||||
|
||||
function UserEditGeneral() {
|
||||
const auth = useAuth() as any;
|
||||
const session = useSession() as any;
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
}
|
||||
, [auth, auth.user])
|
||||
, [session, session.user])
|
||||
|
||||
return (
|
||||
<div className='ml-10 mr-10 mx-auto bg-white rounded-xl shadow-sm px-6 py-5'>
|
||||
{auth.user && (
|
||||
{session.user && (
|
||||
<Formik
|
||||
enableReinitialize
|
||||
initialValues={{
|
||||
username: auth.user.username,
|
||||
first_name: auth.user.first_name,
|
||||
last_name: auth.user.last_name,
|
||||
email: auth.user.email,
|
||||
bio: auth.user.bio,
|
||||
username: session.user.username,
|
||||
first_name: session.user.first_name,
|
||||
last_name: session.user.last_name,
|
||||
email: session.user.email,
|
||||
bio: session.user.bio,
|
||||
}}
|
||||
onSubmit={(values, { setSubmitting }) => {
|
||||
setTimeout(() => {
|
||||
|
||||
setSubmitting(false);
|
||||
updateProfile(values,auth.user.id)
|
||||
updateProfile(values,session.user.id)
|
||||
}, 400);
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
import { useAuth } from '@components/Security/AuthContext';
|
||||
import { useSession } from '@components/Contexts/SessionContext';
|
||||
import { updatePassword } from '@services/settings/password';
|
||||
import { Formik, Form, Field, ErrorMessage } from 'formik';
|
||||
import React, { useEffect } from 'react'
|
||||
|
||||
function UserEditPassword() {
|
||||
const auth = useAuth() as any;
|
||||
const session = useSession() as any;
|
||||
|
||||
const updatePasswordUI = async (values: any) => {
|
||||
let user_id = auth.userInfo.user_object.user_id;
|
||||
let user_id = session.user.user_id;
|
||||
await updatePassword(user_id, values)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
}
|
||||
, [auth])
|
||||
, [session])
|
||||
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue