Move reset calls to oki-api

This commit is contained in:
Cédric FAMIBELLE-PRONZOLA
2022-05-20 02:22:13 +04:00
parent afbb90ac17
commit 2085238b52
+2 -7
View File
@@ -1,6 +1,5 @@
import {useState} from 'react' import {useState} from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import axios from 'axios'
import Button from '@mui/material/Button' import Button from '@mui/material/Button'
import TextField from '@mui/material/TextField' import TextField from '@mui/material/TextField'
import Dialog from '@mui/material/Dialog' import Dialog from '@mui/material/Dialog'
@@ -10,9 +9,7 @@ import DialogContentText from '@mui/material/DialogContentText'
import DialogTitle from '@mui/material/DialogTitle' import DialogTitle from '@mui/material/DialogTitle'
import {validateEmail} from '../../lib/utils/emails' import {validateEmail} from '../../lib/utils/emails'
import {jwennUserEpiEmail} from '../../lib/oki-api' import {jwennUserEpiEmail, passwordRequest} from '../../lib/oki-api'
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:1337'
export default function ResetDialog({lyen, title, activation, content, open, setOpen, setLoading, setError, setSuccess}) { export default function ResetDialog({lyen, title, activation, content, open, setOpen, setLoading, setError, setSuccess}) {
const [email, setEmail] = useState('') const [email, setEmail] = useState('')
@@ -20,9 +17,7 @@ export default function ResetDialog({lyen, title, activation, content, open, set
const forgotPasswordRequest = async () => { const forgotPasswordRequest = async () => {
setLoading(true) setLoading(true)
try { try {
await axios.post(`${API_URL}/auth/${lyen}`, { await passwordRequest(lyen, email)
email
})
if (activation) { if (activation) {
const user = await jwennUserEpiEmail(email) const user = await jwennUserEpiEmail(email)