@q2devel/q2-storybook 1.0.21 → 1.0.23
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.
- package/dist/components/badge/Badge.js +0 -1
- package/dist/components/{Heading1 → head}/Heading1.js +2 -3
- package/dist/index.d.ts +2 -12
- package/dist/index.js +3 -12
- package/package.json +3 -12
- package/dist/auth/Auth.types.d.ts +0 -32
- package/dist/auth/Auth.types.js +0 -1
- package/dist/auth/components/AuthenticatedFactory.d.ts +0 -8
- package/dist/auth/components/AuthenticatedFactory.js +0 -21
- package/dist/auth/components/AuthenticatedFactory.types.d.ts +0 -4
- package/dist/auth/components/AuthenticatedFactory.types.js +0 -1
- package/dist/auth/config/Config.d.ts +0 -3
- package/dist/auth/config/Config.js +0 -19
- package/dist/auth/config/config.types.d.ts +0 -27
- package/dist/auth/config/config.types.js +0 -1
- package/dist/auth/context/AuthContextFactory.d.ts +0 -4
- package/dist/auth/context/AuthContextFactory.js +0 -19
- package/dist/auth/hooks/useCurrentUserHookFactory.d.ts +0 -12
- package/dist/auth/hooks/useCurrentUserHookFactory.js +0 -18
- package/dist/auth/hooks/useCurrentUserUpdateHookFactory.d.ts +0 -9
- package/dist/auth/hooks/useCurrentUserUpdateHookFactory.js +0 -73
- package/dist/auth/hooks/useCurrentUserUpdatePasswordHookFactory.d.ts +0 -7
- package/dist/auth/hooks/useCurrentUserUpdatePasswordHookFactory.js +0 -76
- package/dist/auth/hooks/useForgotPasswordHookFactory.d.ts +0 -7
- package/dist/auth/hooks/useForgotPasswordHookFactory.js +0 -70
- package/dist/auth/hooks/useResetPasswordHookFactory.d.ts +0 -7
- package/dist/auth/hooks/useResetPasswordHookFactory.js +0 -74
- package/dist/auth/hooks/useSignInHookFactory.d.ts +0 -7
- package/dist/auth/hooks/useSignInHookFactory.js +0 -74
- package/dist/auth/hooks/useSignOutHookFactory.d.ts +0 -6
- package/dist/auth/hooks/useSignOutHookFactory.js +0 -74
- package/dist/auth/hooks/useSignUpHookFactory.d.ts +0 -7
- package/dist/auth/hooks/useSignUpHookFactory.js +0 -74
- package/dist/auth/index.d.ts +0 -53
- package/dist/auth/index.js +0 -30
- package/dist/auth/provider/AuthContextProviderFactory.d.ts +0 -7
- package/dist/auth/provider/AuthContextProviderFactory.js +0 -55
- package/dist/auth/service/AuthService.d.ts +0 -15
- package/dist/auth/service/AuthService.js +0 -206
- package/dist/auth/service/AuthService.types.d.ts +0 -26
- package/dist/auth/service/AuthService.types.js +0 -1
- package/dist/auth/service/index.d.ts +0 -2
- package/dist/auth/service/index.js +0 -3
- package/dist/auth/types/index.d.ts +0 -14
- package/dist/auth/types/index.js +0 -1
- package/dist/auth/utils/Helper.d.ts +0 -1
- package/dist/auth/utils/Helper.js +0 -25
- package/dist/auth/utils/Storage.d.ts +0 -6
- package/dist/auth/utils/Storage.js +0 -57
- package/dist/components/banner/Banner.d.ts +0 -48
- package/dist/components/banner/Banner.js +0 -137
- package/dist/components/basket-dialog/BasketDialog.d.ts +0 -55
- package/dist/components/basket-dialog/BasketDialog.js +0 -167
- package/dist/components/icon/CloseIcon.d.ts +0 -3
- package/dist/components/icon/CloseIcon.js +0 -14
- package/dist/components/icon/InfoIcon.d.ts +0 -3
- package/dist/components/icon/InfoIcon.js +0 -15
- package/dist/components/label/Label.d.ts +0 -12
- package/dist/components/label/Label.js +0 -11
- package/dist/components/nav-bar/NavBar.d.ts +0 -19
- package/dist/components/nav-bar/NavBar.js +0 -36
- package/dist/components/product-card/ProductCard.d.ts +0 -61
- package/dist/components/product-card/ProductCard.js +0 -148
- package/dist/components/select-field/SelectField.d.ts +0 -27
- package/dist/components/select-field/SelectField.js +0 -132
- package/dist/components/select-field/SelectFieldOption.d.ts +0 -5
- package/dist/components/select-field/SelectFieldOption.js +0 -31
- package/dist/components/text-field/TextField.d.ts +0 -21
- package/dist/components/text-field/TextField.js +0 -87
- package/dist/components/text-field/TextField.types.d.ts +0 -22
- package/dist/components/text-field/TextField.types.js +0 -1
- package/dist/components/tooltip/Tooltip.d.ts +0 -18
- package/dist/components/tooltip/Tooltip.js +0 -18
- package/dist/global.css +0 -1
- package/dist/utils/Helper.d.ts +0 -0
- package/dist/utils/Helper.js +0 -1
- package/dist/utils/StyleHelper.d.ts +0 -4
- package/dist/utils/StyleHelper.js +0 -12
- package/dist/utils/StylingHelper.d.ts +0 -4
- package/dist/utils/StylingHelper.js +0 -12
- /package/dist/components/{Heading1 → head}/Heading1.d.ts +0 -0
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AuthContextType } from '../Auth.types';
|
|
2
|
-
import { DefaultSignInRequestData } from '../service';
|
|
3
|
-
declare const createUseSignInHook: <UserType>(AuthContext: AuthContextType<UserType>) => <SignInRequestData = DefaultSignInRequestData>() => {
|
|
4
|
-
signIn: (data: SignInRequestData, customApiUrl?: string) => Promise<import("..").MakeUserWithAccessToken<UserType> | undefined>;
|
|
5
|
-
isLoading: boolean;
|
|
6
|
-
};
|
|
7
|
-
export default createUseSignInHook;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
// src/auth/hooks/UseSignInHookFactory.tsx
|
|
38
|
-
import { useContext, useCallback } from 'react';
|
|
39
|
-
import { signIn } from '../service/AuthService';
|
|
40
|
-
var createUseSignInHook = function (AuthContext) {
|
|
41
|
-
return function () {
|
|
42
|
-
var _a = useContext(AuthContext), axiosInstance = _a.axiosInstance, config = _a.config, setAccessToken = _a.setAccessToken, setCurrentUser = _a.setCurrentUser, addLoading = _a.addLoading, removeLoading = _a.removeLoading;
|
|
43
|
-
var loading = useContext(AuthContext).loading;
|
|
44
|
-
var isLoading = loading.includes('SIGN_IN');
|
|
45
|
-
var signInCallback = useCallback(function (data, customApiUrl) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
-
var response, e_1;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
_a.trys.push([0, 2, 3, 4]);
|
|
51
|
-
addLoading('SIGN_IN');
|
|
52
|
-
return [4 /*yield*/, signIn(axiosInstance, config, data)];
|
|
53
|
-
case 1:
|
|
54
|
-
response = _a.sent();
|
|
55
|
-
setAccessToken(response.token);
|
|
56
|
-
setCurrentUser(response);
|
|
57
|
-
return [2 /*return*/, response];
|
|
58
|
-
case 2:
|
|
59
|
-
e_1 = _a.sent();
|
|
60
|
-
return [2 /*return*/, undefined];
|
|
61
|
-
case 3:
|
|
62
|
-
removeLoading('SIGN_IN');
|
|
63
|
-
return [7 /*endfinally*/];
|
|
64
|
-
case 4: return [2 /*return*/];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}); }, [axiosInstance, config, setAccessToken, setCurrentUser, addLoading, removeLoading]);
|
|
68
|
-
return {
|
|
69
|
-
signIn: signInCallback,
|
|
70
|
-
isLoading: isLoading,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
export default createUseSignInHook;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
// src/auth/hooks/UseSignOutHookFactory.tsx
|
|
38
|
-
import { useContext, useCallback } from 'react';
|
|
39
|
-
import { signOut } from '../service/AuthService';
|
|
40
|
-
var createUseSignOutHook = function (AuthContext) {
|
|
41
|
-
return function () {
|
|
42
|
-
var _a = useContext(AuthContext), axiosInstance = _a.axiosInstance, config = _a.config, destroyAccessToken = _a.destroyAccessToken, setCurrentUser = _a.setCurrentUser, addLoading = _a.addLoading, removeLoading = _a.removeLoading;
|
|
43
|
-
var loading = useContext(AuthContext).loading;
|
|
44
|
-
var isLoading = loading.includes('SIGN_OUT');
|
|
45
|
-
var signOutCallback = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
-
var response, e_1;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
_a.trys.push([0, 2, 3, 4]);
|
|
51
|
-
addLoading('SIGN_OUT');
|
|
52
|
-
return [4 /*yield*/, signOut(axiosInstance, config)];
|
|
53
|
-
case 1:
|
|
54
|
-
response = _a.sent();
|
|
55
|
-
destroyAccessToken();
|
|
56
|
-
setCurrentUser(undefined);
|
|
57
|
-
return [2 /*return*/, response];
|
|
58
|
-
case 2:
|
|
59
|
-
e_1 = _a.sent();
|
|
60
|
-
return [2 /*return*/, undefined];
|
|
61
|
-
case 3:
|
|
62
|
-
removeLoading('SIGN_OUT');
|
|
63
|
-
return [7 /*endfinally*/];
|
|
64
|
-
case 4: return [2 /*return*/];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}); }, [axiosInstance, config, destroyAccessToken, setCurrentUser, addLoading, removeLoading]);
|
|
68
|
-
return {
|
|
69
|
-
signOut: signOutCallback,
|
|
70
|
-
isLoading: isLoading,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
export default createUseSignOutHook;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { AuthContextType } from '../Auth.types';
|
|
2
|
-
import { DefaultSignUpRequestData } from '../service';
|
|
3
|
-
declare const createUseSignUpHook: <UserType>(AuthContext: AuthContextType<UserType>) => <SignUpRequestData = DefaultSignUpRequestData>() => {
|
|
4
|
-
signUp: (data: SignUpRequestData) => Promise<import("..").MakeUserWithAccessToken<UserType> | undefined>;
|
|
5
|
-
isLoading: boolean;
|
|
6
|
-
};
|
|
7
|
-
export default createUseSignUpHook;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
// src/auth/hooks/UseSignUpHookFactory.tsx
|
|
38
|
-
import { useContext, useCallback } from 'react';
|
|
39
|
-
import { signUp } from '../service/AuthService';
|
|
40
|
-
var createUseSignUpHook = function (AuthContext) {
|
|
41
|
-
return function () {
|
|
42
|
-
var _a = useContext(AuthContext), axiosInstance = _a.axiosInstance, config = _a.config, setAccessToken = _a.setAccessToken, setCurrentUser = _a.setCurrentUser, addLoading = _a.addLoading, removeLoading = _a.removeLoading;
|
|
43
|
-
var loading = useContext(AuthContext).loading;
|
|
44
|
-
var isLoading = loading.includes('SIGN_UP');
|
|
45
|
-
var signUpCallback = useCallback(function (data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
-
var response, e_1;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
_a.trys.push([0, 2, 3, 4]);
|
|
51
|
-
addLoading('SIGN_UP');
|
|
52
|
-
return [4 /*yield*/, signUp(axiosInstance, config, data)];
|
|
53
|
-
case 1:
|
|
54
|
-
response = _a.sent();
|
|
55
|
-
setAccessToken(response.token);
|
|
56
|
-
setCurrentUser(response);
|
|
57
|
-
return [2 /*return*/, response];
|
|
58
|
-
case 2:
|
|
59
|
-
e_1 = _a.sent();
|
|
60
|
-
return [2 /*return*/, undefined];
|
|
61
|
-
case 3:
|
|
62
|
-
removeLoading('SIGN_UP');
|
|
63
|
-
return [7 /*endfinally*/];
|
|
64
|
-
case 4: return [2 /*return*/];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}); }, [axiosInstance, config, setAccessToken, setCurrentUser, addLoading, removeLoading]);
|
|
68
|
-
return {
|
|
69
|
-
signUp: signUpCallback,
|
|
70
|
-
isLoading: isLoading,
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
export default createUseSignUpHook;
|
package/dist/auth/index.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
declare const createAuthentication: <UserType extends unknown>() => {
|
|
2
|
-
AuthContextProvider: {
|
|
3
|
-
({ children, config, axiosInstance, initialAccessToken, initialCurrentUser, }: import("./Auth.types").AuthProviderProps<UserType>): import("react").JSX.Element;
|
|
4
|
-
displayName: string;
|
|
5
|
-
};
|
|
6
|
-
useCurrentUser: () => {
|
|
7
|
-
isLogged: boolean;
|
|
8
|
-
isReady: boolean;
|
|
9
|
-
user: UserType | undefined;
|
|
10
|
-
setUser: (value?: UserType | undefined) => void;
|
|
11
|
-
refetchCurrentUser: () => void;
|
|
12
|
-
setAccessToken: (value?: import("./types").AccessToken) => void;
|
|
13
|
-
isLoading: boolean;
|
|
14
|
-
};
|
|
15
|
-
useCurrentUserUpdate: <UpdateCurrentUserRequestData = import("./service/AuthService.types").DefaultUpdateCurrentUserRequestData>() => {
|
|
16
|
-
updateCurrentUser: (data: UpdateCurrentUserRequestData) => Promise<(UserType & {
|
|
17
|
-
token: import("./types").AccessToken;
|
|
18
|
-
}) | undefined>;
|
|
19
|
-
isLoading: boolean;
|
|
20
|
-
};
|
|
21
|
-
useCurrentUserUpdatePassword: <UpdateCurrentUserPasswordRequestData = import("./service/AuthService.types").DefaultUpdateCurrentUserPasswordRequestData>() => {
|
|
22
|
-
updateCurrentUserPassword: (data: UpdateCurrentUserPasswordRequestData) => Promise<import("./types").MakeUserWithAccessToken<UserType> | undefined>;
|
|
23
|
-
isLoading: boolean;
|
|
24
|
-
};
|
|
25
|
-
useSignIn: <SignInRequestData = import("./service/AuthService.types").DefaultSignInRequestData>() => {
|
|
26
|
-
signIn: (data: SignInRequestData, customApiUrl?: string) => Promise<import("./types").MakeUserWithAccessToken<UserType> | undefined>;
|
|
27
|
-
isLoading: boolean;
|
|
28
|
-
};
|
|
29
|
-
useSignOut: () => {
|
|
30
|
-
signOut: () => Promise<any>;
|
|
31
|
-
isLoading: boolean;
|
|
32
|
-
};
|
|
33
|
-
useSignUp: <SignUpRequestData = import("./service/AuthService.types").DefaultSignUpRequestData>() => {
|
|
34
|
-
signUp: (data: SignUpRequestData) => Promise<import("./types").MakeUserWithAccessToken<UserType> | undefined>;
|
|
35
|
-
isLoading: boolean;
|
|
36
|
-
};
|
|
37
|
-
useForgotPassword: <ForgotPasswordRequestData = import("./service/AuthService.types").DefaultForgotPasswordRequestData>() => {
|
|
38
|
-
forgotPassword: (data: ForgotPasswordRequestData) => Promise<any>;
|
|
39
|
-
isLoading: boolean;
|
|
40
|
-
};
|
|
41
|
-
useResetPassword: <PasswordResetRequestData = import("./service/AuthService.types").DefaultResetPasswordRequestData>() => {
|
|
42
|
-
resetPassword: (data: PasswordResetRequestData) => Promise<import("./types").MakeUserWithAccessToken<UserType> | undefined>;
|
|
43
|
-
isLoading: boolean;
|
|
44
|
-
};
|
|
45
|
-
Authenticated: {
|
|
46
|
-
({ children, middleware }: import("./components/AuthenticatedFactory.types").AuthenticatedProps): import("react").JSX.Element | null;
|
|
47
|
-
displayName: string;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export default createAuthentication;
|
|
51
|
-
export * from './service/AuthService.types';
|
|
52
|
-
export * from './config/config.types';
|
|
53
|
-
export * from './types';
|
package/dist/auth/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import createAuthContext from './context/AuthContextFactory';
|
|
2
|
-
import createAuthContextProvider from './provider/AuthContextProviderFactory';
|
|
3
|
-
import createUseCurrentUserHook from './hooks/useCurrentUserHookFactory';
|
|
4
|
-
import createUseCurrentUserUpdateHook from './hooks/useCurrentUserUpdateHookFactory';
|
|
5
|
-
import createUseCurrentUserUpdatePasswordHook from './hooks/useCurrentUserUpdatePasswordHookFactory';
|
|
6
|
-
import createUseSignInHook from './hooks/useSignInHookFactory';
|
|
7
|
-
import createUseSignOutHook from './hooks/useSignOutHookFactory';
|
|
8
|
-
import createUseSignUpHook from './hooks/useSignUpHookFactory';
|
|
9
|
-
import createUseForgotPasswordHook from './hooks/useForgotPasswordHookFactory';
|
|
10
|
-
import createUseResetPasswordHook from './hooks/useResetPasswordHookFactory';
|
|
11
|
-
import createAuthenticatedComponent from './components/AuthenticatedFactory';
|
|
12
|
-
var createAuthentication = function () {
|
|
13
|
-
var AuthContext = createAuthContext();
|
|
14
|
-
return {
|
|
15
|
-
AuthContextProvider: createAuthContextProvider(AuthContext),
|
|
16
|
-
useCurrentUser: createUseCurrentUserHook(AuthContext),
|
|
17
|
-
useCurrentUserUpdate: createUseCurrentUserUpdateHook(AuthContext),
|
|
18
|
-
useCurrentUserUpdatePassword: createUseCurrentUserUpdatePasswordHook(AuthContext),
|
|
19
|
-
useSignIn: createUseSignInHook(AuthContext),
|
|
20
|
-
useSignOut: createUseSignOutHook(AuthContext),
|
|
21
|
-
useSignUp: createUseSignUpHook(AuthContext),
|
|
22
|
-
useForgotPassword: createUseForgotPasswordHook(AuthContext),
|
|
23
|
-
useResetPassword: createUseResetPasswordHook(AuthContext),
|
|
24
|
-
Authenticated: createAuthenticatedComponent(AuthContext),
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export default createAuthentication;
|
|
28
|
-
export * from './service/AuthService.types';
|
|
29
|
-
export * from './config/config.types';
|
|
30
|
-
export * from './types';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { AuthContextType, AuthProviderProps } from '../Auth.types';
|
|
3
|
-
declare const createAuthContextProvider: <UserType extends unknown>(AuthContext: AuthContextType<UserType>) => {
|
|
4
|
-
({ children, config, axiosInstance, initialAccessToken, initialCurrentUser, }: AuthProviderProps<UserType>): React.JSX.Element;
|
|
5
|
-
displayName: string;
|
|
6
|
-
};
|
|
7
|
-
export default createAuthContextProvider;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
|
-
// src/auth/provider/AuthContextProviderFactory.tsx
|
|
11
|
-
import React, { useEffect, useState, useMemo } from 'react';
|
|
12
|
-
var createAuthContextProvider = function (AuthContext) {
|
|
13
|
-
var Provider = function (_a) {
|
|
14
|
-
var children = _a.children, config = _a.config, axiosInstance = _a.axiosInstance, initialAccessToken = _a.initialAccessToken, initialCurrentUser = _a.initialCurrentUser;
|
|
15
|
-
var _b = useState(initialAccessToken), accessToken = _b[0], setAccessToken = _b[1];
|
|
16
|
-
var _c = useState(initialCurrentUser), currentUser = _c[0], setCurrentUser = _c[1];
|
|
17
|
-
var _d = useState([]), loading = _d[0], setLoading = _d[1];
|
|
18
|
-
var _e = useState(false), isReady = _e[0], setIsReady = _e[1];
|
|
19
|
-
var addLoading = function (value) {
|
|
20
|
-
setLoading(function (prev) { return __spreadArray(__spreadArray([], prev, true), [value], false); });
|
|
21
|
-
};
|
|
22
|
-
var removeLoading = function (value) {
|
|
23
|
-
setLoading(function (prev) { return prev.filter(function (item) { return item !== value; }); });
|
|
24
|
-
};
|
|
25
|
-
var destroyAccessToken = function () {
|
|
26
|
-
setAccessToken(undefined);
|
|
27
|
-
};
|
|
28
|
-
var refetchCurrentUser = function () {
|
|
29
|
-
// Implementace by zde volala getCurrentUser
|
|
30
|
-
};
|
|
31
|
-
var isLogged = useMemo(function () { return !!accessToken && !!currentUser; }, [accessToken, currentUser]);
|
|
32
|
-
var authContextValue = useMemo(function () { return ({
|
|
33
|
-
config: config,
|
|
34
|
-
axiosInstance: axiosInstance,
|
|
35
|
-
accessToken: accessToken,
|
|
36
|
-
currentUser: currentUser,
|
|
37
|
-
loading: loading,
|
|
38
|
-
isLogged: isLogged,
|
|
39
|
-
isReady: isReady,
|
|
40
|
-
setAccessToken: setAccessToken,
|
|
41
|
-
setCurrentUser: setCurrentUser,
|
|
42
|
-
refetchCurrentUser: refetchCurrentUser,
|
|
43
|
-
addLoading: addLoading,
|
|
44
|
-
removeLoading: removeLoading,
|
|
45
|
-
destroyAccessToken: destroyAccessToken,
|
|
46
|
-
}); }, [accessToken, currentUser, loading, isLogged, isReady, axiosInstance]);
|
|
47
|
-
useEffect(function () {
|
|
48
|
-
setIsReady(true);
|
|
49
|
-
}, []);
|
|
50
|
-
return React.createElement(AuthContext.Provider, { value: authContextValue }, children);
|
|
51
|
-
};
|
|
52
|
-
Provider.displayName = 'AuthContextProvider';
|
|
53
|
-
return Provider;
|
|
54
|
-
};
|
|
55
|
-
export default createAuthContextProvider;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { AuthenticationSettings } from '../config/config.types';
|
|
2
|
-
import { AxiosInstance } from 'axios';
|
|
3
|
-
import { DefaultForgotPasswordRequestData, DefaultResetPasswordRequestData, DefaultSignInRequestData, DefaultSignUpRequestData, DefaultUpdateCurrentUserPasswordRequestData, DefaultUpdateCurrentUserRequestData } from './AuthService.types';
|
|
4
|
-
import { MakeUserWithAccessToken } from '../types';
|
|
5
|
-
export declare const signIn: <UserType, SignInRequest = DefaultSignInRequestData>(axios: AxiosInstance, config: AuthenticationSettings, requestData: SignInRequest) => Promise<MakeUserWithAccessToken<UserType>>;
|
|
6
|
-
export declare const signOut: (axios: AxiosInstance, config: AuthenticationSettings) => Promise<any>;
|
|
7
|
-
export declare const signUp: <UserType, SignUpRequest = DefaultSignUpRequestData>(axios: AxiosInstance, config: AuthenticationSettings, requestData: SignUpRequest) => Promise<MakeUserWithAccessToken<UserType>>;
|
|
8
|
-
export declare const forgotPassword: <ForgotPasswordRequest = DefaultForgotPasswordRequestData>(axios: AxiosInstance, config: AuthenticationSettings, requestData: ForgotPasswordRequest) => Promise<any>;
|
|
9
|
-
export declare const resetPassword: <UserType, ResetPasswordRequest = DefaultResetPasswordRequestData>(axios: AxiosInstance, config: AuthenticationSettings, requestData: ResetPasswordRequest) => Promise<MakeUserWithAccessToken<UserType>>;
|
|
10
|
-
export declare const getCurrentUser: <UserType>(axios: AxiosInstance, config: AuthenticationSettings) => Promise<UserType>;
|
|
11
|
-
export declare const updateCurrentUser: <UserType, UpdateCurrentUserRequest = DefaultUpdateCurrentUserRequestData>(axios: AxiosInstance, config: AuthenticationSettings, requestData: UpdateCurrentUserRequest) => Promise<UserType & {
|
|
12
|
-
token: import("../types").AccessToken;
|
|
13
|
-
}>;
|
|
14
|
-
export declare const updateCurrentUserPassword: <UpdateCurrentUserPasswordRequest = DefaultUpdateCurrentUserPasswordRequestData, User = {}>(axios: AxiosInstance, config: AuthenticationSettings, requestData: UpdateCurrentUserPasswordRequest) => Promise<MakeUserWithAccessToken<User>>;
|
|
15
|
-
export declare const updateCurrentUserAvatar: <UserType>(axios: AxiosInstance, config: AuthenticationSettings, requestFile?: File) => Promise<UserType>;
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
export var signIn = function (axios, config, requestData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
-
var requestType, data, response, responseData, token;
|
|
50
|
-
return __generator(this, function (_a) {
|
|
51
|
-
switch (_a.label) {
|
|
52
|
-
case 0:
|
|
53
|
-
requestType = config.signInRouteRequestType || config.defaultRequestType;
|
|
54
|
-
data = requestType === 'json' ? requestData : createFormData(requestData);
|
|
55
|
-
return [4 /*yield*/, axios.post(config.signInRoute, data)];
|
|
56
|
-
case 1:
|
|
57
|
-
response = _a.sent();
|
|
58
|
-
responseData = config.getDataFromRequest(response.data);
|
|
59
|
-
token = config.getTokenFromRequest(response.data);
|
|
60
|
-
return [2 /*return*/, __assign(__assign({}, responseData), { token: token })];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}); };
|
|
64
|
-
export var signOut = function (axios, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
65
|
-
var requestType, data, response;
|
|
66
|
-
return __generator(this, function (_a) {
|
|
67
|
-
switch (_a.label) {
|
|
68
|
-
case 0:
|
|
69
|
-
requestType = config.signOutRouteRequestType || config.defaultRequestType;
|
|
70
|
-
data = requestType === 'json' ? {} : new FormData();
|
|
71
|
-
return [4 /*yield*/, axios.post(config.signOutRoute, data)];
|
|
72
|
-
case 1:
|
|
73
|
-
response = _a.sent();
|
|
74
|
-
return [2 /*return*/, response.data];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}); };
|
|
78
|
-
export var signUp = function (axios, config, requestData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
-
var requestType, data, response, responseData, token;
|
|
80
|
-
return __generator(this, function (_a) {
|
|
81
|
-
switch (_a.label) {
|
|
82
|
-
case 0:
|
|
83
|
-
requestType = config.signUpRouteRequestType || config.defaultRequestType;
|
|
84
|
-
data = requestType === 'json' ? requestData : createFormData(requestData);
|
|
85
|
-
return [4 /*yield*/, axios.post(config.signUpRoute, data)];
|
|
86
|
-
case 1:
|
|
87
|
-
response = _a.sent();
|
|
88
|
-
responseData = config.getDataFromRequest(response.data);
|
|
89
|
-
token = config.getTokenFromRequest(response.data);
|
|
90
|
-
return [2 /*return*/, __assign(__assign({}, responseData), { token: token })];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}); };
|
|
94
|
-
export var forgotPassword = function (axios, config, requestData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
95
|
-
var requestType, data, response;
|
|
96
|
-
return __generator(this, function (_a) {
|
|
97
|
-
switch (_a.label) {
|
|
98
|
-
case 0:
|
|
99
|
-
requestType = config.forgotPasswordRouteRequestDataType || config.defaultRequestType;
|
|
100
|
-
data = requestType === 'json' ? requestData : createFormData(requestData);
|
|
101
|
-
return [4 /*yield*/, axios.post(config.forgotPasswordRoute, data)];
|
|
102
|
-
case 1:
|
|
103
|
-
response = _a.sent();
|
|
104
|
-
return [2 /*return*/, response.data];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}); };
|
|
108
|
-
export var resetPassword = function (axios, config, requestData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
-
var requestType, data, response, responseData, token;
|
|
110
|
-
return __generator(this, function (_a) {
|
|
111
|
-
switch (_a.label) {
|
|
112
|
-
case 0:
|
|
113
|
-
requestType = config.resetPasswordRouteRequestDataType || config.defaultRequestType;
|
|
114
|
-
data = requestType === 'json' ? requestData : createFormData(requestData);
|
|
115
|
-
return [4 /*yield*/, axios.post(config.resetPasswordRoute, data)];
|
|
116
|
-
case 1:
|
|
117
|
-
response = _a.sent();
|
|
118
|
-
responseData = config.getDataFromRequest(response.data);
|
|
119
|
-
token = config.getTokenFromRequest(response.data);
|
|
120
|
-
return [2 /*return*/, __assign(__assign({}, responseData), { token: token })];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}); };
|
|
124
|
-
export var getCurrentUser = function (axios, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
-
var response, responseData;
|
|
126
|
-
return __generator(this, function (_a) {
|
|
127
|
-
switch (_a.label) {
|
|
128
|
-
case 0: return [4 /*yield*/, axios.get(config.currentUserRoute)];
|
|
129
|
-
case 1:
|
|
130
|
-
response = _a.sent();
|
|
131
|
-
responseData = config.getDataFromRequest(response.data);
|
|
132
|
-
return [2 /*return*/, responseData];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}); };
|
|
136
|
-
export var updateCurrentUser = function (axios, config, requestData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
137
|
-
var requestType, data, response, responseData, token;
|
|
138
|
-
return __generator(this, function (_a) {
|
|
139
|
-
switch (_a.label) {
|
|
140
|
-
case 0:
|
|
141
|
-
requestType = config.currentUserUpdateRouteRequestDataType || config.defaultRequestType;
|
|
142
|
-
data = requestType === 'json' ? requestData : createFormData(requestData);
|
|
143
|
-
return [4 /*yield*/, axios.post(config.currentUserUpdateRoute, data)];
|
|
144
|
-
case 1:
|
|
145
|
-
response = _a.sent();
|
|
146
|
-
responseData = config.getDataFromRequest(response.data);
|
|
147
|
-
token = config.getTokenFromRequest(response.data);
|
|
148
|
-
return [2 /*return*/, __assign(__assign({}, responseData), { token: token })];
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}); };
|
|
152
|
-
export var updateCurrentUserPassword = function (axios, config, requestData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
153
|
-
var requestType, data, response, responseData, token;
|
|
154
|
-
return __generator(this, function (_a) {
|
|
155
|
-
switch (_a.label) {
|
|
156
|
-
case 0:
|
|
157
|
-
requestType = config.currentUserChangePasswordRouteRequestDataType || config.defaultRequestType;
|
|
158
|
-
data = requestType === 'json' ? requestData : createFormData(requestData);
|
|
159
|
-
return [4 /*yield*/, axios.post(config.currentUserChangePasswordRoute, data)];
|
|
160
|
-
case 1:
|
|
161
|
-
response = _a.sent();
|
|
162
|
-
responseData = config.getDataFromRequest(response.data);
|
|
163
|
-
token = config.getTokenFromRequest(response.data);
|
|
164
|
-
return [2 /*return*/, __assign(__assign({}, responseData), { token: token })];
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}); };
|
|
168
|
-
export var updateCurrentUserAvatar = function (axios, config, requestFile) { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
-
var formData, response, responseData;
|
|
170
|
-
return __generator(this, function (_a) {
|
|
171
|
-
switch (_a.label) {
|
|
172
|
-
case 0:
|
|
173
|
-
formData = new FormData();
|
|
174
|
-
if (requestFile) {
|
|
175
|
-
formData.append('avatar', requestFile);
|
|
176
|
-
}
|
|
177
|
-
return [4 /*yield*/, axios.post(config.currentUserChangeAvatarRoute, formData, {
|
|
178
|
-
headers: {
|
|
179
|
-
'Content-Type': 'multipart/form-data',
|
|
180
|
-
},
|
|
181
|
-
})];
|
|
182
|
-
case 1:
|
|
183
|
-
response = _a.sent();
|
|
184
|
-
responseData = config.getDataFromRequest(response.data);
|
|
185
|
-
return [2 /*return*/, responseData];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
}); };
|
|
189
|
-
// Pomocná funkce pro převod objektu na FormData
|
|
190
|
-
function createFormData(data) {
|
|
191
|
-
var formData = new FormData();
|
|
192
|
-
for (var key in data) {
|
|
193
|
-
if (data.hasOwnProperty(key)) {
|
|
194
|
-
// Pokud je hodnota null nebo undefined, nepřidávej ji do FormData
|
|
195
|
-
if (data[key] !== null && data[key] !== undefined) {
|
|
196
|
-
if (typeof data[key] === 'object' && !(data[key] instanceof File)) {
|
|
197
|
-
formData.append(key, JSON.stringify(data[key]));
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
formData.append(key, data[key]);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return formData;
|
|
206
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type DefaultSignInRequestData = {
|
|
2
|
-
userId?: number;
|
|
3
|
-
email: string;
|
|
4
|
-
password: string;
|
|
5
|
-
};
|
|
6
|
-
export type DefaultSignUpRequestData = {
|
|
7
|
-
name: string;
|
|
8
|
-
email: string;
|
|
9
|
-
password: string;
|
|
10
|
-
agreement: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type DefaultForgotPasswordRequestData = {
|
|
13
|
-
email: string;
|
|
14
|
-
};
|
|
15
|
-
export type DefaultResetPasswordRequestData = {
|
|
16
|
-
email: string;
|
|
17
|
-
token: string;
|
|
18
|
-
password: string;
|
|
19
|
-
};
|
|
20
|
-
export type DefaultUpdateCurrentUserRequestData = {
|
|
21
|
-
name: string;
|
|
22
|
-
};
|
|
23
|
-
export type DefaultUpdateCurrentUserPasswordRequestData = {
|
|
24
|
-
oldPassword: string;
|
|
25
|
-
password: string;
|
|
26
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|