@@ -10,6 +10,7 @@ import { useEffect, useState } from "react";
10
10
import { User } from "@/types/user" ;
11
11
import { z } from "zod" ;
12
12
import { zodResolver } from "@hookform/resolvers/zod" ;
13
+ import Swal from "sweetalert2" ;
13
14
14
15
const formSchema = z . object ( {
15
16
username : z . string ( )
@@ -43,23 +44,36 @@ const ProfilePage = () => {
43
44
form . reset ( data ) ;
44
45
} ) . catch ( ( error ) => {
45
46
console . error ( "Profile Fetch Failed:" , error ) ;
46
- // or swal
47
+ Swal . fire ( {
48
+ icon : "error" ,
49
+ title : "Profile Fetch Failed" ,
50
+ text : "Please try again later" ,
51
+ } ) ;
47
52
} ) ;
48
53
} , [ token , form ] ) ;
49
54
50
55
const onSubmit = ( data : z . infer < typeof formSchema > ) => {
51
56
setGetProfile ( token , data ) . then ( ( data ) => {
52
57
setUser ( data ) ;
53
58
form . reset ( data ) ;
59
+ Swal . fire ( {
60
+ icon : "success" ,
61
+ title : "Profile Updated" ,
62
+ text : "Your profile has been updated successfully" ,
63
+ } ) ;
54
64
} ) . catch ( ( error ) => {
55
65
console . error ( "Profile Update Failed:" , error ) ;
56
- // or swal
66
+ Swal . fire ( {
67
+ icon : "error" ,
68
+ title : "Profile Update Failed" ,
69
+ text : "Please try again later" ,
70
+ } )
57
71
} ) ;
58
72
} ;
59
73
60
74
return (
61
75
< div className = "mx-auto max-w-xl my-10 p-4" >
62
- < h1 className = "text-white font-extrabold text-h1" > Welcome, { user ?. username } </ h1 >
76
+ < h1 className = "text-white font-extrabold text-h1" > Welcome, { user ?. username } ! </ h1 >
63
77
64
78
< Form { ...form } >
65
79
< form className = "my-10 grid gap-4" onSubmit = { form . handleSubmit ( onSubmit ) } >
0 commit comments