shelflife-react-hooks 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  export type RequestStateHandlers = {
2
2
  setIsLoading: (value: boolean) => void;
3
3
  setIsError: (value: boolean) => void;
4
- setError: (error: Error | null) => void;
4
+ setError: (error: any | null) => void;
5
5
  };
6
6
 
7
7
  export const runWithRequestState = async <T>(
@@ -15,10 +15,9 @@ export const runWithRequestState = async <T>(
15
15
  try {
16
16
  return await request();
17
17
  } catch (err) {
18
- const error = err instanceof Error ? err : new Error('Unknown error');
19
18
  handlers.setIsError(true);
20
- handlers.setError(error);
21
- throw error;
19
+ handlers.setError(err);
20
+ throw err;
22
21
  } finally {
23
22
  handlers.setIsLoading(false);
24
23
  }
package/src/type/auth.ts CHANGED
@@ -10,7 +10,9 @@ type LoginSuccessResponse = {
10
10
  token: string;
11
11
  }
12
12
 
13
- type LoginErrorResponse = ErrorResponse;
13
+ type LoginErrorResponse = {
14
+ error: string;
15
+ };
14
16
 
15
17
  type LoginResponse = LoginSuccessResponse | LoginErrorResponse;
16
18
 
@@ -27,11 +29,19 @@ type ChangePasswordRequest = {
27
29
  newPasswordRepeat: string;
28
30
  }
29
31
 
30
- type SignupError = FieldErrorMap;
32
+ type SignupError = {
33
+ username?: string;
34
+ email?: string;
35
+ password?: string;
36
+ passwordRepeat?: string;
37
+ error?: string;
38
+ };
31
39
 
32
40
  type SignupResponse = User | SignupError | EmptyResponse;
33
41
 
34
- type LogoutErrorResponse = ErrorResponse;
42
+ type LogoutErrorResponse = {
43
+ error: string;
44
+ };
35
45
 
36
46
  type LogoutResponse = EmptyResponse | LogoutErrorResponse;
37
47