@q2devel/q2-storybook 1.0.21 → 1.0.22

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.
Files changed (81) hide show
  1. package/dist/components/badge/Badge.js +0 -1
  2. package/dist/components/{Heading1 → head}/Heading1.js +2 -3
  3. package/dist/index.d.ts +2 -12
  4. package/dist/index.js +3 -12
  5. package/package.json +3 -12
  6. package/dist/auth/Auth.types.d.ts +0 -32
  7. package/dist/auth/Auth.types.js +0 -1
  8. package/dist/auth/components/AuthenticatedFactory.d.ts +0 -8
  9. package/dist/auth/components/AuthenticatedFactory.js +0 -21
  10. package/dist/auth/components/AuthenticatedFactory.types.d.ts +0 -4
  11. package/dist/auth/components/AuthenticatedFactory.types.js +0 -1
  12. package/dist/auth/config/Config.d.ts +0 -3
  13. package/dist/auth/config/Config.js +0 -19
  14. package/dist/auth/config/config.types.d.ts +0 -27
  15. package/dist/auth/config/config.types.js +0 -1
  16. package/dist/auth/context/AuthContextFactory.d.ts +0 -4
  17. package/dist/auth/context/AuthContextFactory.js +0 -19
  18. package/dist/auth/hooks/useCurrentUserHookFactory.d.ts +0 -12
  19. package/dist/auth/hooks/useCurrentUserHookFactory.js +0 -18
  20. package/dist/auth/hooks/useCurrentUserUpdateHookFactory.d.ts +0 -9
  21. package/dist/auth/hooks/useCurrentUserUpdateHookFactory.js +0 -73
  22. package/dist/auth/hooks/useCurrentUserUpdatePasswordHookFactory.d.ts +0 -7
  23. package/dist/auth/hooks/useCurrentUserUpdatePasswordHookFactory.js +0 -76
  24. package/dist/auth/hooks/useForgotPasswordHookFactory.d.ts +0 -7
  25. package/dist/auth/hooks/useForgotPasswordHookFactory.js +0 -70
  26. package/dist/auth/hooks/useResetPasswordHookFactory.d.ts +0 -7
  27. package/dist/auth/hooks/useResetPasswordHookFactory.js +0 -74
  28. package/dist/auth/hooks/useSignInHookFactory.d.ts +0 -7
  29. package/dist/auth/hooks/useSignInHookFactory.js +0 -74
  30. package/dist/auth/hooks/useSignOutHookFactory.d.ts +0 -6
  31. package/dist/auth/hooks/useSignOutHookFactory.js +0 -74
  32. package/dist/auth/hooks/useSignUpHookFactory.d.ts +0 -7
  33. package/dist/auth/hooks/useSignUpHookFactory.js +0 -74
  34. package/dist/auth/index.d.ts +0 -53
  35. package/dist/auth/index.js +0 -30
  36. package/dist/auth/provider/AuthContextProviderFactory.d.ts +0 -7
  37. package/dist/auth/provider/AuthContextProviderFactory.js +0 -55
  38. package/dist/auth/service/AuthService.d.ts +0 -15
  39. package/dist/auth/service/AuthService.js +0 -206
  40. package/dist/auth/service/AuthService.types.d.ts +0 -26
  41. package/dist/auth/service/AuthService.types.js +0 -1
  42. package/dist/auth/service/index.d.ts +0 -2
  43. package/dist/auth/service/index.js +0 -3
  44. package/dist/auth/types/index.d.ts +0 -14
  45. package/dist/auth/types/index.js +0 -1
  46. package/dist/auth/utils/Helper.d.ts +0 -1
  47. package/dist/auth/utils/Helper.js +0 -25
  48. package/dist/auth/utils/Storage.d.ts +0 -6
  49. package/dist/auth/utils/Storage.js +0 -57
  50. package/dist/components/banner/Banner.d.ts +0 -48
  51. package/dist/components/banner/Banner.js +0 -137
  52. package/dist/components/basket-dialog/BasketDialog.d.ts +0 -55
  53. package/dist/components/basket-dialog/BasketDialog.js +0 -167
  54. package/dist/components/icon/CloseIcon.d.ts +0 -3
  55. package/dist/components/icon/CloseIcon.js +0 -14
  56. package/dist/components/icon/InfoIcon.d.ts +0 -3
  57. package/dist/components/icon/InfoIcon.js +0 -15
  58. package/dist/components/label/Label.d.ts +0 -12
  59. package/dist/components/label/Label.js +0 -11
  60. package/dist/components/nav-bar/NavBar.d.ts +0 -19
  61. package/dist/components/nav-bar/NavBar.js +0 -36
  62. package/dist/components/product-card/ProductCard.d.ts +0 -61
  63. package/dist/components/product-card/ProductCard.js +0 -148
  64. package/dist/components/select-field/SelectField.d.ts +0 -27
  65. package/dist/components/select-field/SelectField.js +0 -132
  66. package/dist/components/select-field/SelectFieldOption.d.ts +0 -5
  67. package/dist/components/select-field/SelectFieldOption.js +0 -31
  68. package/dist/components/text-field/TextField.d.ts +0 -21
  69. package/dist/components/text-field/TextField.js +0 -87
  70. package/dist/components/text-field/TextField.types.d.ts +0 -22
  71. package/dist/components/text-field/TextField.types.js +0 -1
  72. package/dist/components/tooltip/Tooltip.d.ts +0 -18
  73. package/dist/components/tooltip/Tooltip.js +0 -18
  74. package/dist/global.css +0 -1
  75. package/dist/utils/Helper.d.ts +0 -0
  76. package/dist/utils/Helper.js +0 -1
  77. package/dist/utils/StyleHelper.d.ts +0 -4
  78. package/dist/utils/StyleHelper.js +0 -12
  79. package/dist/utils/StylingHelper.d.ts +0 -4
  80. package/dist/utils/StylingHelper.js +0 -12
  81. /package/dist/components/{Heading1 → head}/Heading1.d.ts +0 -0
@@ -1,4 +1,3 @@
1
- 'use client';
2
1
  import React from 'react';
3
2
  var Badge = function (_a) {
4
3
  var children = _a.children, onClick = _a.onClick, _b = _a.color, color = _b === void 0 ? 'bg-blue-100 text-blue-800' : _b, _c = _a.className, className = _c === void 0 ? '' : _c, _d = _a.labelClassName, labelClassName = _d === void 0 ? '' : _d, rightIcon = _a.rightIcon;
@@ -1,15 +1,14 @@
1
1
  import React from "react";
2
- import buildClassesByJoining from "../../utils/StylingHelper";
3
2
  export default function Heading1(_a) {
4
3
  var _b = _a.level, level = _b === void 0 ? 1 : _b, children = _a.children, className = _a.className, id = _a.id;
5
4
  var Tag = "h".concat(level);
6
5
  var baseStyles = {
7
- 1: "text-4xl font-bold mt-12 mb-8 text-gray-900",
6
+ 1: "text-4xl font-bold mt-12 mb-8 text-gray-900 text-red-600",
8
7
  2: "text-3xl font-semibold text-gray-900",
9
8
  3: "text-2xl font-semibold text-gray-900",
10
9
  4: "text-xl font-medium text-gray-900",
11
10
  5: "text-lg font-medium text-gray-900",
12
11
  6: "text-base font-medium text-gray-900",
13
12
  };
14
- return (React.createElement(Tag, { id: id, className: buildClassesByJoining(baseStyles[level], className) }, children));
13
+ return (React.createElement(Tag, { id: id, className: "".concat(baseStyles[level], " ").concat(className || "") }, children));
15
14
  }
package/dist/index.d.ts CHANGED
@@ -1,14 +1,4 @@
1
- export { default as createAuthentication } from './auth';
2
- export * from './auth/config/config.types';
3
- export * from './auth/service/AuthService.types';
4
- export * from './auth/types';
5
- export { default as Badge } from './components/badge/Badge';
6
- export { Banner } from './components/banner/Banner';
7
1
  export { default as Button } from './components/button/Button';
8
- export { NavBar } from './components/nav-bar/NavBar';
9
- export { ProductCard } from './components/product-card/ProductCard';
10
- export { default as SelectField } from './components/select-field/SelectField';
11
- export { default as TextField } from './components/text-field/TextField';
2
+ export { default as Badge } from './components/badge/Badge';
12
3
  export { default as ImageWithText } from './components/text-with-image/ImageWithText';
13
- export { default as Heading1 } from './components/Heading1/Heading1';
14
- export { buildClassesByJoining } from './utils/StylingHelper';
4
+ export { default as Heading1 } from './components/head/Heading1';
package/dist/index.js CHANGED
@@ -1,14 +1,5 @@
1
- export { default as createAuthentication } from './auth';
2
- export * from './auth/config/config.types';
3
- export * from './auth/service/AuthService.types';
4
- export * from './auth/types';
5
- export { default as Badge } from './components/badge/Badge';
6
- export { Banner } from './components/banner/Banner';
1
+ // src/index.ts
7
2
  export { default as Button } from './components/button/Button';
8
- export { NavBar } from './components/nav-bar/NavBar';
9
- export { ProductCard } from './components/product-card/ProductCard';
10
- export { default as SelectField } from './components/select-field/SelectField';
11
- export { default as TextField } from './components/text-field/TextField';
3
+ export { default as Badge } from './components/badge/Badge';
12
4
  export { default as ImageWithText } from './components/text-with-image/ImageWithText';
13
- export { default as Heading1 } from './components/Heading1/Heading1';
14
- export { buildClassesByJoining } from './utils/StylingHelper';
5
+ export { default as Heading1 } from './components/head/Heading1';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@q2devel/q2-storybook",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,8 +17,7 @@
17
17
  "test": "echo \"Error: no test specified\" && exit 1",
18
18
  "storybook": "storybook dev -p 6006",
19
19
  "build-storybook": "storybook build",
20
- "build": "tsc",
21
- "prepublishOnly": "npm run build"
20
+ "build": "tsc"
22
21
  },
23
22
  "keywords": [],
24
23
  "author": "Q2",
@@ -34,7 +33,6 @@
34
33
  "@storybook/react": "^8.6.12",
35
34
  "@storybook/react-vite": "^8.6.12",
36
35
  "@storybook/test": "^8.6.12",
37
- "@types/classnames": "^2.3.0",
38
36
  "@types/node": "^22.14.1",
39
37
  "@types/react": "^19.1.2",
40
38
  "@types/react-dom": "^19.1.2",
@@ -51,14 +49,7 @@
51
49
  "react-dom": "^19.0.0"
52
50
  },
53
51
  "dependencies": {
54
- "@headlessui/react": "^2.2.2",
55
- "@heroicons/react": "^2.2.0",
56
52
  "@tailwindcss/postcss": "^4.1.4",
57
- "@tanstack/react-query": "^5.76.1",
58
- "axios": "^1.9.0",
59
- "classnames": "^2.5.1",
60
- "html-react-parser": "^5.2.3",
61
- "react-select": "^5.10.1",
62
- "tailwind-merge": "^3.2.0"
53
+ "html-react-parser": "^5.2.3"
63
54
  }
64
55
  }
@@ -1,32 +0,0 @@
1
- import { AxiosInstance } from 'axios';
2
- import { Context, PropsWithChildren } from 'react';
3
- import { AccessToken, DeepNonRequired } from './types';
4
- import { AuthenticationSettings } from './config/config.types';
5
- export type AuthContextType<UserType> = Context<AuthContextState<UserType>>;
6
- export type LoadingType = 'SIGN_IN' | 'SIGN_UP' | 'SIGN_OUT' | 'FORGOT_PASSWORD' | 'RESET_PASSWORD' | 'CURRENT_USER' | 'UPDATE_CURRENT_USER' | 'UPDATE_CURRENT_USER_PASSWORD';
7
- export type TokenStorage = {
8
- get: () => AccessToken | undefined;
9
- set: (accessToken?: AccessToken) => void;
10
- };
11
- export type AuthContextState<UserType> = {
12
- config: AuthenticationSettings;
13
- axiosInstance: AxiosInstance;
14
- tokenStorage?: TokenStorage;
15
- accessToken?: AccessToken;
16
- currentUser?: UserType;
17
- loading: LoadingType[];
18
- isLogged: boolean;
19
- isReady: boolean;
20
- setAccessToken: (value?: AccessToken) => void;
21
- setCurrentUser: (value?: UserType) => void;
22
- refetchCurrentUser: () => void;
23
- addLoading: (value: LoadingType) => void;
24
- removeLoading: (value: LoadingType) => void;
25
- destroyAccessToken: () => void;
26
- };
27
- export type AuthProviderProps<UserType = unknown> = PropsWithChildren<{
28
- config?: DeepNonRequired<AuthenticationSettings>;
29
- axiosInstance: AxiosInstance;
30
- initialAccessToken?: AccessToken;
31
- initialCurrentUser?: UserType;
32
- }>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
- import { AuthContextType } from '../Auth.types';
3
- import { AuthenticatedProps } from './AuthenticatedFactory.types';
4
- declare const createAuthenticatedComponent: <UserType extends unknown>(AuthContext: AuthContextType<UserType>) => {
5
- ({ children, middleware }: AuthenticatedProps): React.JSX.Element | null;
6
- displayName: string;
7
- };
8
- export default createAuthenticatedComponent;
@@ -1,21 +0,0 @@
1
- // src/auth/components/AuthenticatedFactory.tsx
2
- import React, { useContext } from 'react';
3
- var createAuthenticatedComponent = function (AuthContext) {
4
- var Authenticated = function (_a) {
5
- var children = _a.children, middleware = _a.middleware;
6
- var _b = useContext(AuthContext), isLogged = _b.isLogged, isReady = _b.isReady;
7
- if (!isReady) {
8
- return null;
9
- }
10
- if (middleware === 'only-logged' && !isLogged) {
11
- return null;
12
- }
13
- if (middleware === 'only-guest' && isLogged) {
14
- return null;
15
- }
16
- return React.createElement(React.Fragment, null, children);
17
- };
18
- Authenticated.displayName = 'Authenticated';
19
- return Authenticated;
20
- };
21
- export default createAuthenticatedComponent;
@@ -1,4 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- export type AuthenticatedProps = PropsWithChildren<{
3
- middleware?: 'only-logged' | 'only-guest';
4
- }>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import { AuthenticationSettings } from './config.types';
2
- declare const config: AuthenticationSettings;
3
- export default config;
@@ -1,19 +0,0 @@
1
- // Defaultní konfigurace
2
- var config = {
3
- tokenStorageType: 'localStorage',
4
- tokenStorageKey: 'auth-token',
5
- logoutWhenFailedLoadUser: true,
6
- getDataFromRequest: function (data) { return data.data; },
7
- getTokenFromRequest: function (data) { return data.token; },
8
- signInRoute: '/api/auth/login',
9
- defaultRequestType: 'json',
10
- signOutRoute: '/api/auth/logout',
11
- signUpRoute: '/api/auth/register',
12
- currentUserRoute: '/api/auth/user',
13
- currentUserUpdateRoute: '/api/auth/user',
14
- currentUserChangePasswordRoute: '/api/auth/user/password',
15
- currentUserChangeAvatarRoute: '/api/auth/user/avatar',
16
- forgotPasswordRoute: '/api/auth/forgot-password',
17
- resetPasswordRoute: '/api/auth/reset-password',
18
- };
19
- export default config;
@@ -1,27 +0,0 @@
1
- import { AccessToken, TokenStorageProvider } from '../types';
2
- export type TokenStorageType = 'localStorage' | 'cookie' | 'memory';
3
- export type RequestDataType = 'json' | 'form-data';
4
- export type AuthenticationSettings = {
5
- tokenStorageType: TokenStorageType | TokenStorageProvider;
6
- tokenStorageKey: string;
7
- logoutWhenFailedLoadUser: boolean;
8
- getDataFromRequest: (data: any) => unknown;
9
- getTokenFromRequest: (data: any) => AccessToken;
10
- signInRoute: string;
11
- defaultRequestType: RequestDataType;
12
- signInRouteRequestType?: RequestDataType;
13
- signOutRoute: string;
14
- signOutRouteRequestType?: RequestDataType;
15
- signUpRoute: string;
16
- signUpRouteRequestType?: RequestDataType;
17
- currentUserRoute: string;
18
- currentUserUpdateRoute: string;
19
- currentUserUpdateRouteRequestDataType?: RequestDataType;
20
- currentUserChangePasswordRoute: string;
21
- currentUserChangePasswordRouteRequestDataType?: RequestDataType;
22
- currentUserChangeAvatarRoute: string;
23
- forgotPasswordRoute: string;
24
- forgotPasswordRouteRequestDataType?: RequestDataType;
25
- resetPasswordRoute: string;
26
- resetPasswordRouteRequestDataType?: RequestDataType;
27
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import { AuthContextState } from '../Auth.types';
3
- declare const createAuthContext: <UserType>() => React.Context<AuthContextState<UserType>>;
4
- export default createAuthContext;
@@ -1,19 +0,0 @@
1
- // src/auth/context/AuthContextFactory.tsx
2
- import { createContext } from 'react';
3
- var createAuthContext = function () {
4
- var defaultState = {
5
- config: {},
6
- axiosInstance: {},
7
- loading: [],
8
- isLogged: false,
9
- isReady: false,
10
- setAccessToken: function () { },
11
- setCurrentUser: function () { },
12
- refetchCurrentUser: function () { },
13
- addLoading: function () { },
14
- removeLoading: function () { },
15
- destroyAccessToken: function () { },
16
- };
17
- return createContext(defaultState);
18
- };
19
- export default createAuthContext;
@@ -1,12 +0,0 @@
1
- import { AuthContextType } from '../Auth.types';
2
- import { AccessToken } from '../types';
3
- declare const createUseCurrentUserHook: <UserType>(AuthContext: AuthContextType<UserType>) => () => {
4
- isLogged: boolean;
5
- isReady: boolean;
6
- user: UserType | undefined;
7
- setUser: (value?: UserType | undefined) => void;
8
- refetchCurrentUser: () => void;
9
- setAccessToken: (value?: AccessToken) => void;
10
- isLoading: boolean;
11
- };
12
- export default createUseCurrentUserHook;
@@ -1,18 +0,0 @@
1
- // src/auth/hooks/UseCurrentUserHookFactory.tsx
2
- import { useContext } from 'react';
3
- var createUseCurrentUserHook = function (AuthContext) {
4
- return function () {
5
- var _a = useContext(AuthContext), currentUser = _a.currentUser, setCurrentUser = _a.setCurrentUser, refetchCurrentUser = _a.refetchCurrentUser, setAccessToken = _a.setAccessToken, loading = _a.loading, isLogged = _a.isLogged, isReady = _a.isReady;
6
- var isLoading = loading.includes('CURRENT_USER');
7
- return {
8
- isLogged: isLogged,
9
- isReady: isReady,
10
- user: currentUser,
11
- setUser: setCurrentUser,
12
- refetchCurrentUser: refetchCurrentUser,
13
- setAccessToken: setAccessToken,
14
- isLoading: isLoading,
15
- };
16
- };
17
- };
18
- export default createUseCurrentUserHook;
@@ -1,9 +0,0 @@
1
- import { AuthContextType } from '../Auth.types';
2
- import { DefaultUpdateCurrentUserRequestData } from '../service';
3
- declare const createUseCurrentUserUpdateHook: <UserType>(AuthContext: AuthContextType<UserType>) => <UpdateCurrentUserRequestData = DefaultUpdateCurrentUserRequestData>() => {
4
- updateCurrentUser: (data: UpdateCurrentUserRequestData) => Promise<(UserType & {
5
- token: import("..").AccessToken;
6
- }) | undefined>;
7
- isLoading: boolean;
8
- };
9
- export default createUseCurrentUserUpdateHook;
@@ -1,73 +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/UseCurrentUserUpdateHookFactory.tsx
38
- import { useContext, useCallback } from 'react';
39
- import { updateCurrentUser } from '../service/AuthService';
40
- var createUseCurrentUserUpdateHook = function (AuthContext) {
41
- return function () {
42
- var _a = useContext(AuthContext), axiosInstance = _a.axiosInstance, config = _a.config, addLoading = _a.addLoading, removeLoading = _a.removeLoading, setCurrentUser = _a.setCurrentUser;
43
- var loading = useContext(AuthContext).loading;
44
- var isLoading = loading.includes('UPDATE_CURRENT_USER');
45
- var updateCallback = 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('UPDATE_CURRENT_USER');
52
- return [4 /*yield*/, updateCurrentUser(axiosInstance, config, data)];
53
- case 1:
54
- response = _a.sent();
55
- setCurrentUser(response);
56
- return [2 /*return*/, response];
57
- case 2:
58
- e_1 = _a.sent();
59
- return [2 /*return*/, undefined];
60
- case 3:
61
- removeLoading('UPDATE_CURRENT_USER');
62
- return [7 /*endfinally*/];
63
- case 4: return [2 /*return*/];
64
- }
65
- });
66
- }); }, [axiosInstance, config, addLoading, removeLoading, setCurrentUser]);
67
- return {
68
- updateCurrentUser: updateCallback,
69
- isLoading: isLoading,
70
- };
71
- };
72
- };
73
- export default createUseCurrentUserUpdateHook;
@@ -1,7 +0,0 @@
1
- import { AuthContextType } from '../Auth.types';
2
- import { DefaultUpdateCurrentUserPasswordRequestData } from '../service';
3
- declare const createUseCurrentUserUpdatePasswordHook: <UserType>(AuthContext: AuthContextType<UserType>) => <UpdateCurrentUserPasswordRequestData = DefaultUpdateCurrentUserPasswordRequestData>() => {
4
- updateCurrentUserPassword: (data: UpdateCurrentUserPasswordRequestData) => Promise<import("..").MakeUserWithAccessToken<UserType> | undefined>;
5
- isLoading: boolean;
6
- };
7
- export default createUseCurrentUserUpdatePasswordHook;
@@ -1,76 +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/UseCurrentUserUpdatePasswordHookFactory.tsx
38
- import { useContext, useCallback } from 'react';
39
- import { updateCurrentUserPassword } from '../service/AuthService';
40
- var createUseCurrentUserUpdatePasswordHook = function (AuthContext) {
41
- return function () {
42
- var _a = useContext(AuthContext), axiosInstance = _a.axiosInstance, config = _a.config, addLoading = _a.addLoading, removeLoading = _a.removeLoading, setAccessToken = _a.setAccessToken, setCurrentUser = _a.setCurrentUser;
43
- var loading = useContext(AuthContext).loading;
44
- var isLoading = loading.includes('UPDATE_CURRENT_USER_PASSWORD');
45
- var updatePasswordCallback = 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('UPDATE_CURRENT_USER_PASSWORD');
52
- return [4 /*yield*/, updateCurrentUserPassword(axiosInstance, config, data)];
53
- case 1:
54
- response = _a.sent();
55
- if (response.token) {
56
- setAccessToken(response.token);
57
- }
58
- setCurrentUser(response);
59
- return [2 /*return*/, response];
60
- case 2:
61
- e_1 = _a.sent();
62
- return [2 /*return*/, undefined];
63
- case 3:
64
- removeLoading('UPDATE_CURRENT_USER_PASSWORD');
65
- return [7 /*endfinally*/];
66
- case 4: return [2 /*return*/];
67
- }
68
- });
69
- }); }, [axiosInstance, config, addLoading, removeLoading, setAccessToken, setCurrentUser]);
70
- return {
71
- updateCurrentUserPassword: updatePasswordCallback,
72
- isLoading: isLoading,
73
- };
74
- };
75
- };
76
- export default createUseCurrentUserUpdatePasswordHook;
@@ -1,7 +0,0 @@
1
- import { AuthContextType } from '../Auth.types';
2
- import { DefaultForgotPasswordRequestData } from '../service';
3
- declare const createUseForgotPasswordHook: <UserType>(AuthContext: AuthContextType<UserType>) => <ForgotPasswordRequestData = DefaultForgotPasswordRequestData>() => {
4
- forgotPassword: (data: ForgotPasswordRequestData) => Promise<any>;
5
- isLoading: boolean;
6
- };
7
- export default createUseForgotPasswordHook;
@@ -1,70 +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/UseForgotPasswordHookFactory.tsx
38
- import { useContext, useCallback } from 'react';
39
- import { forgotPassword } from '../service/AuthService';
40
- var createUseForgotPasswordHook = function (AuthContext) {
41
- return function () {
42
- var _a = useContext(AuthContext), axiosInstance = _a.axiosInstance, config = _a.config, addLoading = _a.addLoading, removeLoading = _a.removeLoading;
43
- var loading = useContext(AuthContext).loading;
44
- var isLoading = loading.includes('FORGOT_PASSWORD');
45
- var forgotPasswordCallback = useCallback(function (data) { return __awaiter(void 0, void 0, void 0, function () {
46
- var 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('FORGOT_PASSWORD');
52
- return [4 /*yield*/, forgotPassword(axiosInstance, config, data)];
53
- case 1: return [2 /*return*/, _a.sent()];
54
- case 2:
55
- e_1 = _a.sent();
56
- return [2 /*return*/, undefined];
57
- case 3:
58
- removeLoading('FORGOT_PASSWORD');
59
- return [7 /*endfinally*/];
60
- case 4: return [2 /*return*/];
61
- }
62
- });
63
- }); }, [axiosInstance, config, addLoading, removeLoading]);
64
- return {
65
- forgotPassword: forgotPasswordCallback,
66
- isLoading: isLoading,
67
- };
68
- };
69
- };
70
- export default createUseForgotPasswordHook;
@@ -1,7 +0,0 @@
1
- import { AuthContextType } from '../Auth.types';
2
- import { DefaultResetPasswordRequestData } from '../service';
3
- declare const createUseResetPasswordHook: <UserType>(AuthContext: AuthContextType<UserType>) => <PasswordResetRequestData = DefaultResetPasswordRequestData>() => {
4
- resetPassword: (data: PasswordResetRequestData) => Promise<import("..").MakeUserWithAccessToken<UserType> | undefined>;
5
- isLoading: boolean;
6
- };
7
- export default createUseResetPasswordHook;
@@ -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/UseResetPasswordHookFactory.tsx
38
- import { useContext, useCallback } from 'react';
39
- import { resetPassword } from '../service/AuthService';
40
- var createUseResetPasswordHook = 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('RESET_PASSWORD');
45
- var resetPasswordCallback = 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('RESET_PASSWORD');
52
- return [4 /*yield*/, resetPassword(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('RESET_PASSWORD');
63
- return [7 /*endfinally*/];
64
- case 4: return [2 /*return*/];
65
- }
66
- });
67
- }); }, [axiosInstance, config, setAccessToken, setCurrentUser, addLoading, removeLoading]);
68
- return {
69
- resetPassword: resetPasswordCallback,
70
- isLoading: isLoading,
71
- };
72
- };
73
- };
74
- export default createUseResetPasswordHook;