11import { Dialog , Transition } from "@headlessui/react" ;
22import { XMarkIcon } from "@heroicons/react/24/outline" ;
3+ import { notifications } from "@mantine/notifications" ;
4+ import { getCookie } from "cookies-next" ;
35import React , { Fragment , useState } from "react" ;
46
5- export default function ResetPassword ( { user } ) {
7+ export default function ResetPassword ( ) {
68 const [ open , setOpen ] = useState ( false ) ;
79 const [ password , setPassword ] = useState ( "" ) ;
810 const [ check , setCheck ] = useState ( "" ) ;
911
1012 const postData = async ( ) => {
11- if ( check === password && password . length > 0 ) {
13+ if ( check === password && password . length > 3 ) {
1214 await fetch (
1315 `${ process . env . NEXT_PUBLIC_API_URL } /api/v1/auth/reset-password` ,
1416 {
1517 method : "POST" ,
1618 headers : {
1719 "Content-Type" : "application/json" ,
18- Authorization : "Bearer " + token ,
20+ Authorization : "Bearer " + getCookie ( "session" ) ,
1921 } ,
2022 body : JSON . stringify ( {
2123 password,
@@ -24,7 +26,7 @@ export default function ResetPassword({ user }) {
2426 )
2527 . then ( ( res ) => res . json ( ) )
2628 . then ( ( res ) => {
27- if ( res . failed === false ) {
29+ if ( res . success ) {
2830 notifications . show ( {
2931 title : "Success" ,
3032 message : `Password updated :)` ,
@@ -34,7 +36,7 @@ export default function ResetPassword({ user }) {
3436 } else {
3537 notifications . show ( {
3638 title : "Error" ,
37- message : `Error: ${ res . message } ` ,
39+ message : `Error: failed to update password ` ,
3840 color : "red" ,
3941 autoClose : 5000 ,
4042 } ) ;
0 commit comments