utopia-ui/src/Components/Auth/RequestPasswordPage.tsx
Anton Tranelis 9e6bcf1846
fix(source): update tailwind and daisyui (#196)
* removed daisy from config

* removed tw-elements artefact

* removed comments from tailwind config

* removed safelist

* migrated to tailwind4 and daisyui5

* deleted tailwind.config.js which is not eeded anymore

* 3.0.79

* version number

* fixed broken layouts

* more fixing

* more layout fixing

* tested theming

* small fixes

* adapt snapshots to changes

* package.json: add unit test update script

* more ui refactoring & theme controller

* ui improvements

* package-lock.json

* fix linting

* fixed tabs

* fix linting

* fixed typing

---------

Co-authored-by: mahula <lenzmath@posteo.de>
2025-04-25 16:03:42 +02:00

64 lines
1.7 KiB
TypeScript

import { useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { toast } from 'react-toastify'
import { MapOverlayPage } from '#components/Templates/MapOverlayPage'
import { useAuth } from './useAuth'
/**
* @category Auth
*/
export function RequestPasswordPage({ resetUrl }: { resetUrl: string }) {
const [email, setEmail] = useState<string>('')
const { requestPasswordReset, loading } = useAuth()
const navigate = useNavigate()
const onReset = async () => {
await toast.promise(requestPasswordReset(email, resetUrl), {
success: {
render() {
navigate('/')
return 'Check your mailbox'
},
// other options
icon: '📬',
},
error: {
render({ data }) {
return `${data as string}`
},
},
pending: 'sending email ...',
})
}
return (
<MapOverlayPage backdrop className='tw:max-w-xs tw:h-fit'>
<h2 className='tw:text-2xl tw:font-semibold tw:mb-2 tw:text-center'>Reset Password</h2>
<input
type='email'
placeholder='E-Mail'
value={email}
onChange={(e) => setEmail(e.target.value)}
className='tw:input tw:input-bordered tw:w-full tw:max-w-xs'
/>
<div className='tw:card-actions tw:mt-4'>
<button
className={
loading
? 'tw:btn tw:btn-disabled tw:btn-block tw:btn-primary'
: 'tw:btn tw:btn-primary tw:btn-block'
}
// eslint-disable-next-line @typescript-eslint/no-misused-promises
onClick={() => onReset()}
>
{loading ? <span className='tw:loading tw:loading-spinner'></span> : 'Send'}
</button>
</div>
</MapOverlayPage>
)
}