From 38c9fbb245aeb315e90f42c281a17257a5eeb122 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 5 Apr 2023 09:46:31 +0700 Subject: forgot and reset password --- src/pages/forgot-password.jsx | 122 +++++++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 43 deletions(-) (limited to 'src/pages/forgot-password.jsx') diff --git a/src/pages/forgot-password.jsx b/src/pages/forgot-password.jsx index eb5c5185..6211d237 100644 --- a/src/pages/forgot-password.jsx +++ b/src/pages/forgot-password.jsx @@ -2,63 +2,99 @@ import Alert from '@/core/components/elements/Alert/Alert' import SimpleFooter from '@/core/components/elements/Footer/SimpleFooter' import Link from '@/core/components/elements/Link/Link' import BasicLayout from '@/core/components/layouts/BasicLayout' +import DesktopView from '@/core/components/views/DesktopView' import MobileView from '@/core/components/views/MobileView' import IndoteknikLogo from '@/images/logo.png' +import axios from 'axios' import Image from 'next/image' -import { useRouter } from 'next/router' import { useState } from 'react' export default function ForgotPassword() { - const router = useRouter() - const { token } = router.query + return ( + <> + + + + + + +
+
+ +
+
+
+
+ + ) +} + +const FormComponent = () => { const [isLoading, setIsLoading] = useState(false) - const [alert, setAlert] = useState() + const [alert, setAlert] = useState(null) - const [email, setEmail] = useState(router.query?.email || '') + const [email, setEmail] = useState('') - const forgotPasswordRequest = () => {} + const forgotPasswordRequest = async (e) => { + e.preventDefault() + setIsLoading(true) + let submitRequest = await axios.post( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/forgot-password`, + { + email + } + ) + setIsLoading(false) + if (submitRequest.data.success) { + setAlert({ + children: <>Mohon cek email anda untuk reset password akun Indoteknik, + type: 'success' + }) + } else { + setAlert({ + children: ( + <> + Email tersebut belum terdaftar,{' '} + + daftar sekarang + + . + + ), + type: 'info' + }) + } + } return ( - <> - -
- - Logo Indoteknik - - -

- Lupa Kata Sandi Akun Indoteknik -

+
+ + Logo Indoteknik + - {alert && ( - - {alert.children} - - )} +

Lupa Kata Sandi Akun Indoteknik

-
- setEmail(e.target.value)} - placeholder='Masukan alamat email' - autoFocus - /> - -
-
+ {alert && ( + + {alert.children} + + )} - - - +
+ setEmail(e.target.value)} + placeholder='Masukan alamat email' + autoFocus + /> + +
+
) } -- cgit v1.2.3