@@ -4,7 +4,7 @@ import { AuthStatus, UploadProfilePictureResponse } from "@/types/user";
4
4
import Cookie from "js-cookie" ;
5
5
import Swal from "sweetalert2" ;
6
6
7
- const toast = Swal . mixin ( {
7
+ export const ToastComponent = Swal . mixin ( {
8
8
toast : true ,
9
9
position : "top-end" ,
10
10
showConfirmButton : false ,
@@ -88,7 +88,7 @@ export const verifyToken = async (token: string) => {
88
88
} ;
89
89
90
90
export const login = async ( email : string , password : string ) => {
91
- toast . fire ( {
91
+ ToastComponent . fire ( {
92
92
icon : "info" ,
93
93
title : "Logging in..." ,
94
94
} ) ;
@@ -105,7 +105,7 @@ export const login = async (email: string, password: string) => {
105
105
const data = await response . json ( ) ;
106
106
107
107
if ( response . status !== 200 ) {
108
- toast . fire ( {
108
+ ToastComponent . fire ( {
109
109
icon : "error" ,
110
110
title : data . message ,
111
111
} ) ;
@@ -134,7 +134,7 @@ export const register = async (
134
134
password : string ,
135
135
username : string
136
136
) => {
137
- toast . fire ( {
137
+ ToastComponent . fire ( {
138
138
icon : "info" ,
139
139
title : "Registering..." ,
140
140
} ) ;
@@ -152,7 +152,7 @@ export const register = async (
152
152
const data = await response . json ( ) ;
153
153
154
154
if ( response . status !== 201 ) {
155
- toast . fire ( {
155
+ ToastComponent . fire ( {
156
156
icon : "error" ,
157
157
title : data . message ,
158
158
} ) ;
@@ -175,7 +175,7 @@ export const getUser = async (userId = "") => {
175
175
const data = await response . json ( ) ;
176
176
177
177
if ( response . status !== 200 ) {
178
- toast . fire ( {
178
+ ToastComponent . fire ( {
179
179
icon : "error" ,
180
180
title : data . message ,
181
181
} ) ;
@@ -208,14 +208,14 @@ export const updateUser = async (userData: {
208
208
console . log ( data ) ;
209
209
210
210
if ( response . status !== 200 ) {
211
- toast . fire ( {
211
+ ToastComponent . fire ( {
212
212
icon : "error" ,
213
213
title : data . message ,
214
214
} ) ;
215
215
return false ;
216
216
}
217
217
218
- toast . fire ( {
218
+ ToastComponent . fire ( {
219
219
icon : "success" ,
220
220
title : "Profile updated successfully" ,
221
221
} ) ;
@@ -241,7 +241,7 @@ export const getFileUrl = async (
241
241
const data : UploadProfilePictureResponse = await res . json ( ) ;
242
242
243
243
if ( res . status !== 200 ) {
244
- toast . fire ( {
244
+ ToastComponent . fire ( {
245
245
icon : "error" ,
246
246
title : res . statusText ,
247
247
} ) ;
@@ -251,7 +251,7 @@ export const getFileUrl = async (
251
251
} ;
252
252
253
253
export const requestPasswordReset = async ( email : string ) => {
254
- toast . fire ( {
254
+ ToastComponent . fire ( {
255
255
icon : "info" ,
256
256
title : "Requesting password reset..." ,
257
257
} ) ;
@@ -269,14 +269,14 @@ export const requestPasswordReset = async (email: string) => {
269
269
console . log ( data ) ;
270
270
271
271
if ( response . status !== 200 ) {
272
- toast . fire ( {
272
+ ToastComponent . fire ( {
273
273
icon : "error" ,
274
274
title : data . message ,
275
275
} ) ;
276
276
return false ;
277
277
}
278
278
279
- toast . fire ( {
279
+ ToastComponent . fire ( {
280
280
icon : "success" ,
281
281
title : "Password reset requested. Please check your email." ,
282
282
} ) ;
@@ -298,7 +298,7 @@ export const checkPasswordResetCode = async (code: string) => {
298
298
const data = await response . json ( ) ;
299
299
300
300
if ( response . status !== 200 ) {
301
- toast . fire ( {
301
+ ToastComponent . fire ( {
302
302
icon : "error" ,
303
303
title : data . message ,
304
304
} ) ;
@@ -322,7 +322,7 @@ export const resetPasswordWithCode = async (code: string, password: string) => {
322
322
const data = await response . json ( ) ;
323
323
324
324
if ( response . status !== 200 ) {
325
- toast . fire ( {
325
+ ToastComponent . fire ( {
326
326
icon : "error" ,
327
327
title : data . message ,
328
328
} ) ;
0 commit comments