feat: init new auth

This commit is contained in:
swve 2024-05-25 14:56:28 +02:00
parent f838a8512c
commit 1708b36818
34 changed files with 1853 additions and 3613 deletions

View file

@ -1,7 +1,8 @@
'use client';
import { updateProfile } from '@services/settings/profile'
import React, { useEffect } from 'react'
import { Formik, Form, Field } from 'formik'
import { useSession } from '@components/Contexts/SessionContext'
import { useSession } from 'next-auth/react'
import {
ArrowBigUpDash,
Check,
@ -23,7 +24,7 @@ function UserEditGeneral() {
const file = event.target.files[0]
setLocalAvatar(file)
setIsLoading(true)
const res = await updateUserAvatar(session.user.user_uuid, file)
const res = await updateUserAvatar(session.data.user_uuid, file)
// wait for 1 second to show loading animation
await new Promise((r) => setTimeout(r, 1500))
if (res.success === false) {
@ -35,24 +36,24 @@ function UserEditGeneral() {
}
}
useEffect(() => {}, [session, session.user])
useEffect(() => {}, [session, session.data])
return (
<div className="ml-10 mr-10 mx-auto bg-white rounded-xl shadow-sm px-6 py-5">
{session.user && (
{session.data.user && (
<Formik
enableReinitialize
initialValues={{
username: session.user.username,
first_name: session.user.first_name,
last_name: session.user.last_name,
email: session.user.email,
bio: session.user.bio,
username: session.data.user.username,
first_name: session.data.user.first_name,
last_name: session.data.user.last_name,
email: session.data.user.email,
bio: session.data.user.bio,
}}
onSubmit={(values, { setSubmitting }) => {
setTimeout(() => {
setSubmitting(false)
updateProfile(values, session.user.id)
updateProfile(values, session.data.user.id)
}, 400)
}}
>