@greatapps/common 1.1.98 → 1.1.100
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/account/hooks/useTwoFactorAuthForm.mjs +5 -13
- package/dist/components/account/hooks/useTwoFactorAuthForm.mjs.map +1 -1
- package/dist/components/account/sections/MyProfileSection.mjs +30 -19
- package/dist/components/account/sections/MyProfileSection.mjs.map +1 -1
- package/dist/components/account/sections/PreferencesSection.mjs +11 -10
- package/dist/components/account/sections/PreferencesSection.mjs.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +1 -1
- package/dist/modules/accounts/actions/account-management.action.mjs +36 -168
- package/dist/modules/accounts/actions/account-management.action.mjs.map +1 -1
- package/dist/modules/accounts/actions/find-current-account.action.mjs +3 -2
- package/dist/modules/accounts/actions/find-current-account.action.mjs.map +1 -1
- package/dist/modules/accounts/actions/list-currencies.action.mjs +3 -2
- package/dist/modules/accounts/actions/list-currencies.action.mjs.map +1 -1
- package/dist/modules/accounts/actions/list-timezones.action.mjs +3 -2
- package/dist/modules/accounts/actions/list-timezones.action.mjs.map +1 -1
- package/dist/modules/accounts/hooks/current-account.hook.mjs +2 -1
- package/dist/modules/accounts/hooks/current-account.hook.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useAccountManagement.mjs +8 -5
- package/dist/modules/accounts/hooks/useAccountManagement.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useCurrencies.mjs +2 -1
- package/dist/modules/accounts/hooks/useCurrencies.mjs.map +1 -1
- package/dist/modules/accounts/hooks/useTimezones.mjs +2 -1
- package/dist/modules/accounts/hooks/useTimezones.mjs.map +1 -1
- package/dist/modules/auth/actions/logout.action.mjs +6 -3
- package/dist/modules/auth/actions/logout.action.mjs.map +1 -1
- package/dist/modules/auth/actions/register.action.mjs +6 -3
- package/dist/modules/auth/actions/register.action.mjs.map +1 -1
- package/dist/modules/auth/actions/verify-two-factor.action.mjs +5 -10
- package/dist/modules/auth/actions/verify-two-factor.action.mjs.map +1 -1
- package/dist/modules/auth/hooks/logout.hook.mjs +2 -1
- package/dist/modules/auth/hooks/logout.hook.mjs.map +1 -1
- package/dist/modules/auth/hooks/register.hook.mjs +2 -1
- package/dist/modules/auth/hooks/register.hook.mjs.map +1 -1
- package/dist/modules/auth/hooks/useUserQuery.mjs +2 -2
- package/dist/modules/auth/hooks/useUserQuery.mjs.map +1 -1
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs +3 -2
- package/dist/modules/ia-credits/actions/list-ia-credits.action.mjs.map +1 -1
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs +2 -1
- package/dist/modules/ia-credits/hooks/ia-credits.hook.mjs.map +1 -1
- package/dist/modules/projects/actions/add-project-user.action.mjs +3 -2
- package/dist/modules/projects/actions/add-project-user.action.mjs.map +1 -1
- package/dist/modules/projects/actions/list-available-users.action.mjs +3 -2
- package/dist/modules/projects/actions/list-available-users.action.mjs.map +1 -1
- package/dist/modules/projects/actions/list-project-users.action.mjs +3 -2
- package/dist/modules/projects/actions/list-project-users.action.mjs.map +1 -1
- package/dist/modules/projects/actions/remove-project-user.action.mjs +3 -2
- package/dist/modules/projects/actions/remove-project-user.action.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs +8 -1
- package/dist/modules/projects/hooks/list-available-users.hook.mjs.map +1 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs +8 -1
- package/dist/modules/projects/hooks/list-project-users.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs +3 -2
- package/dist/modules/subscriptions/actions/list-subscriptions.action.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs +5 -1
- package/dist/modules/subscriptions/hooks/find-active-subscription.hook.mjs.map +1 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs +2 -1
- package/dist/modules/subscriptions/hooks/list-subscriptions.hook.mjs.map +1 -1
- package/dist/modules/users/action/find-user-by-id.action.mjs +3 -14
- package/dist/modules/users/action/find-user-by-id.action.mjs.map +1 -1
- package/dist/modules/users/action/list-messages.action.mjs +6 -2
- package/dist/modules/users/action/list-messages.action.mjs.map +1 -1
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs +3 -2
- package/dist/modules/users/action/mark-all-messages-as-read.action.mjs.map +1 -1
- package/dist/modules/users/action/mark-message-as-read.action.mjs +3 -2
- package/dist/modules/users/action/mark-message-as-read.action.mjs.map +1 -1
- package/dist/modules/users/hooks/messages.hook.mjs +11 -9
- package/dist/modules/users/hooks/messages.hook.mjs.map +1 -1
- package/dist/utils/safeServerAction.mjs +10 -16
- package/dist/utils/safeServerAction.mjs.map +1 -1
- package/dist/utils/withAction.mjs +13 -0
- package/dist/utils/withAction.mjs.map +1 -0
- package/package.json +1 -1
- package/src/components/account/hooks/useTwoFactorAuthForm.tsx +101 -114
- package/src/components/account/sections/MyProfileSection.tsx +29 -26
- package/src/components/account/sections/PreferencesSection.tsx +10 -16
- package/src/index.ts +2 -0
- package/src/modules/accounts/actions/account-management.action.ts +90 -261
- package/src/modules/accounts/actions/find-current-account.action.ts +5 -4
- package/src/modules/accounts/actions/list-currencies.action.ts +8 -7
- package/src/modules/accounts/actions/list-timezones.action.ts +8 -7
- package/src/modules/accounts/hooks/current-account.hook.tsx +6 -5
- package/src/modules/accounts/hooks/useAccountManagement.ts +85 -83
- package/src/modules/accounts/hooks/useCurrencies.ts +15 -14
- package/src/modules/accounts/hooks/useTimezones.ts +15 -14
- package/src/modules/auth/actions/logout.action.ts +8 -7
- package/src/modules/auth/actions/register.action.ts +9 -6
- package/src/modules/auth/actions/verify-two-factor.action.ts +8 -21
- package/src/modules/auth/hooks/logout.hook.tsx +2 -1
- package/src/modules/auth/hooks/register.hook.tsx +2 -1
- package/src/modules/auth/hooks/useUserQuery.ts +2 -2
- package/src/modules/ia-credits/actions/list-ia-credits.action.ts +8 -11
- package/src/modules/ia-credits/hooks/ia-credits.hook.ts +2 -1
- package/src/modules/projects/actions/add-project-user.action.ts +9 -8
- package/src/modules/projects/actions/list-available-users.action.ts +9 -8
- package/src/modules/projects/actions/list-project-users.action.ts +9 -8
- package/src/modules/projects/actions/remove-project-user.action.ts +9 -8
- package/src/modules/projects/hooks/list-available-users.hook.ts +33 -26
- package/src/modules/projects/hooks/list-project-users.hook.ts +33 -26
- package/src/modules/subscriptions/actions/list-subscriptions.action.ts +9 -11
- package/src/modules/subscriptions/hooks/find-active-subscription.hook.ts +19 -15
- package/src/modules/subscriptions/hooks/list-subscriptions.hook.ts +17 -15
- package/src/modules/users/action/find-user-by-id.action.ts +8 -25
- package/src/modules/users/action/list-messages.action.ts +12 -10
- package/src/modules/users/action/mark-all-messages-as-read.action.ts +8 -8
- package/src/modules/users/action/mark-message-as-read.action.ts +8 -8
- package/src/modules/users/hooks/messages.hook.ts +60 -58
- package/src/utils/safeServerAction.ts +18 -24
- package/src/utils/withAction.ts +13 -0
|
@@ -1,198 +1,66 @@
|
|
|
1
1
|
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
2
3
|
import { accountService } from "../services/account.service";
|
|
3
|
-
import { ApiError } from "../../../infra/api/types";
|
|
4
4
|
import { twoFactorService } from "../services/two-factor.service";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function listAccountUsersAction(params) {
|
|
6
|
+
return safeServerAction(async () => {
|
|
7
7
|
const { users, total } = await accountService.listAccountUsers(params);
|
|
8
|
-
return {
|
|
9
|
-
}
|
|
10
|
-
if (error instanceof ApiError)
|
|
11
|
-
return { success: false, error: error.message };
|
|
12
|
-
return {
|
|
13
|
-
success: false,
|
|
14
|
-
error: "Erro ao listar usu\xE1rios. Tente novamente."
|
|
15
|
-
};
|
|
16
|
-
}
|
|
8
|
+
return { data: users, total };
|
|
9
|
+
});
|
|
17
10
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const result = await accountService.updateAccountUser(user);
|
|
21
|
-
return { success: true, data: result };
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (error instanceof ApiError)
|
|
24
|
-
return { success: false, error: error.message };
|
|
25
|
-
return {
|
|
26
|
-
success: false,
|
|
27
|
-
error: "Erro ao atualizar usu\xE1rio. Tente novamente."
|
|
28
|
-
};
|
|
29
|
-
}
|
|
11
|
+
function updateUserAction(user) {
|
|
12
|
+
return safeServerAction(() => accountService.updateAccountUser(user));
|
|
30
13
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const result = await accountService.updateAccountUserById(userId, user);
|
|
34
|
-
return { success: true, data: result };
|
|
35
|
-
} catch (error) {
|
|
36
|
-
if (error instanceof ApiError)
|
|
37
|
-
return { success: false, error: error.message };
|
|
38
|
-
return {
|
|
39
|
-
success: false,
|
|
40
|
-
error: "Erro ao atualizar usu\xE1rio. Tente novamente."
|
|
41
|
-
};
|
|
42
|
-
}
|
|
14
|
+
function updateAccountUserByIdAction(userId, user) {
|
|
15
|
+
return safeServerAction(() => accountService.updateAccountUserById(userId, user));
|
|
43
16
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
await accountService.updateAccount(data);
|
|
47
|
-
return { success: true };
|
|
48
|
-
} catch (error) {
|
|
49
|
-
if (error instanceof ApiError)
|
|
50
|
-
return { success: false, error: error.message };
|
|
51
|
-
return {
|
|
52
|
-
success: false,
|
|
53
|
-
error: "Erro ao atualizar conta. Tente novamente."
|
|
54
|
-
};
|
|
55
|
-
}
|
|
17
|
+
function updateAccountAction(data) {
|
|
18
|
+
return safeServerAction(() => accountService.updateAccount(data));
|
|
56
19
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
await accountService.deleteAccountUser(userId);
|
|
60
|
-
return { success: true };
|
|
61
|
-
} catch (error) {
|
|
62
|
-
if (error instanceof ApiError)
|
|
63
|
-
return { success: false, error: error.message };
|
|
64
|
-
return {
|
|
65
|
-
success: false,
|
|
66
|
-
error: "Erro ao remover usu\xE1rio. Tente novamente."
|
|
67
|
-
};
|
|
68
|
-
}
|
|
20
|
+
function deleteAccountUserAction(userId) {
|
|
21
|
+
return safeServerAction(() => accountService.deleteAccountUser(userId));
|
|
69
22
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
await accountService.deleteAccount();
|
|
73
|
-
return { success: true };
|
|
74
|
-
} catch (error) {
|
|
75
|
-
if (error instanceof ApiError)
|
|
76
|
-
return { success: false, error: error.message };
|
|
77
|
-
return { success: false, error: "Erro ao excluir conta. Tente novamente." };
|
|
78
|
-
}
|
|
23
|
+
function deleteAccountAction() {
|
|
24
|
+
return safeServerAction(() => accountService.deleteAccount());
|
|
79
25
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const result = await accountService.createAccountUser(user);
|
|
83
|
-
return { success: true, data: result.data };
|
|
84
|
-
} catch (error) {
|
|
85
|
-
if (error instanceof ApiError)
|
|
86
|
-
return { success: false, error: error.message };
|
|
87
|
-
return { success: false, error: "Erro ao criar usu\xE1rio. Tente novamente." };
|
|
88
|
-
}
|
|
26
|
+
function createAccountUserAction(user) {
|
|
27
|
+
return safeServerAction(() => accountService.createAccountUser(user));
|
|
89
28
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
await accountService.changePassword(data);
|
|
93
|
-
return { success: true };
|
|
94
|
-
} catch (error) {
|
|
95
|
-
if (error instanceof ApiError)
|
|
96
|
-
return { success: false, error: error.message };
|
|
97
|
-
return { success: false, error: "Erro ao alterar senha. Tente novamente." };
|
|
98
|
-
}
|
|
29
|
+
function changePasswordAction(data) {
|
|
30
|
+
return safeServerAction(() => accountService.changePassword(data));
|
|
99
31
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await accountService.requestContactReset("email", newEmail);
|
|
103
|
-
return { success: true };
|
|
104
|
-
} catch (error) {
|
|
105
|
-
if (error instanceof ApiError)
|
|
106
|
-
return { success: false, error: error.message };
|
|
107
|
-
return {
|
|
108
|
-
success: false,
|
|
109
|
-
error: "E-mail j\xE1 existente ou ocorreu um erro. Tente novamente mais tarde."
|
|
110
|
-
};
|
|
111
|
-
}
|
|
32
|
+
function requestEmailChangeAction(newEmail) {
|
|
33
|
+
return safeServerAction(() => accountService.requestContactReset("email", newEmail));
|
|
112
34
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
await accountService.confirmContactReset("email", token, newEmail);
|
|
116
|
-
return { success: true };
|
|
117
|
-
} catch (error) {
|
|
118
|
-
if (error instanceof ApiError)
|
|
119
|
-
return { success: false, error: error.message };
|
|
120
|
-
return {
|
|
121
|
-
success: false,
|
|
122
|
-
error: "C\xF3digo inv\xE1lido ou expirado. Tente novamente."
|
|
123
|
-
};
|
|
124
|
-
}
|
|
35
|
+
function confirmEmailChangeAction(token, newEmail) {
|
|
36
|
+
return safeServerAction(() => accountService.confirmContactReset("email", token, newEmail));
|
|
125
37
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
await accountService.requestContactReset("phone", newPhone);
|
|
129
|
-
return { success: true };
|
|
130
|
-
} catch (error) {
|
|
131
|
-
if (error instanceof ApiError)
|
|
132
|
-
return { success: false, error: error.message };
|
|
133
|
-
return {
|
|
134
|
-
success: false,
|
|
135
|
-
error: "N\xFAmero j\xE1 existente ou ocorreu um erro. Tente novamente mais tarde."
|
|
136
|
-
};
|
|
137
|
-
}
|
|
38
|
+
function requestPhoneChangeAction(newPhone) {
|
|
39
|
+
return safeServerAction(() => accountService.requestContactReset("phone", newPhone));
|
|
138
40
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
await accountService.confirmContactReset("phone", token, newPhone);
|
|
142
|
-
return { success: true };
|
|
143
|
-
} catch (error) {
|
|
144
|
-
if (error instanceof ApiError)
|
|
145
|
-
return { success: false, error: error.message };
|
|
146
|
-
return {
|
|
147
|
-
success: false,
|
|
148
|
-
error: "C\xF3digo inv\xE1lido ou expirado. Tente novamente."
|
|
149
|
-
};
|
|
150
|
-
}
|
|
41
|
+
function confirmPhoneChangeAction(token, newPhone) {
|
|
42
|
+
return safeServerAction(() => accountService.confirmContactReset("phone", token, newPhone));
|
|
151
43
|
}
|
|
152
|
-
|
|
153
|
-
|
|
44
|
+
function generateTwoFactorAction() {
|
|
45
|
+
return safeServerAction(async () => {
|
|
154
46
|
const result = await twoFactorService.generate();
|
|
155
47
|
return {
|
|
156
|
-
success: true,
|
|
157
48
|
qrcode: result.data.qrcode,
|
|
158
49
|
backupCodes: result.data.backup_codes
|
|
159
50
|
};
|
|
160
|
-
}
|
|
161
|
-
if (error instanceof ApiError)
|
|
162
|
-
return { success: false, error: error.message };
|
|
163
|
-
return { success: false, error: "Erro ao gerar QR Code. Tente novamente." };
|
|
164
|
-
}
|
|
51
|
+
});
|
|
165
52
|
}
|
|
166
|
-
|
|
167
|
-
|
|
53
|
+
function confirmTwoFactorAction(code) {
|
|
54
|
+
return safeServerAction(async () => {
|
|
168
55
|
await twoFactorService.confirm(code);
|
|
169
56
|
await accountService.updateAccountUser({ two_factor_authentication: true });
|
|
170
|
-
}
|
|
171
|
-
if (error instanceof ApiError)
|
|
172
|
-
return { success: false, error: error.message };
|
|
173
|
-
return { success: false, error: "C\xF3digo inv\xE1lido. Tente novamente." };
|
|
174
|
-
}
|
|
175
|
-
return { success: true };
|
|
57
|
+
});
|
|
176
58
|
}
|
|
177
|
-
|
|
178
|
-
|
|
59
|
+
function disableTwoFactorAction(code) {
|
|
60
|
+
return safeServerAction(async () => {
|
|
179
61
|
await twoFactorService.verify(code);
|
|
180
|
-
} catch (error) {
|
|
181
|
-
if (error instanceof ApiError)
|
|
182
|
-
return { success: false, error: error.message };
|
|
183
|
-
return { success: false, error: "C\xF3digo inv\xE1lido. Tente novamente." };
|
|
184
|
-
}
|
|
185
|
-
try {
|
|
186
62
|
await twoFactorService.disable();
|
|
187
|
-
|
|
188
|
-
} catch (error) {
|
|
189
|
-
if (error instanceof ApiError)
|
|
190
|
-
return { success: false, error: error.message };
|
|
191
|
-
return {
|
|
192
|
-
success: false,
|
|
193
|
-
error: "Erro ao desabilitar 2FA. Tente novamente."
|
|
194
|
-
};
|
|
195
|
-
}
|
|
63
|
+
});
|
|
196
64
|
}
|
|
197
65
|
export {
|
|
198
66
|
changePasswordAction,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/actions/account-management.action.ts"],"sourcesContent":["\"use server\";\r\n\r\nimport { accountService } from \"../services/account.service\";\r\nimport { ApiError } from \"../../../infra/api/types\";\r\nimport type {\r\n AccountUsersPaginationParams,\r\n AccountUsersActionResult,\r\n ChangePasswordActionResult,\r\n ChangePasswordRequest,\r\n ContactResetResult,\r\n CreateAccountUserRequest,\r\n DeleteAccountActionResult,\r\n DeleteUserActionResult,\r\n TwoFactorActionResult,\r\n TwoFactorGenerateResult,\r\n UpdateAccountActionResult,\r\n UpdateAccountRequest,\r\n UpdateAccountUserRequest,\r\n UpdateUserActionResult,\r\n} from \"../types\";\r\nimport { twoFactorService } from \"../services/two-factor.service\";\r\n\r\nexport async function listAccountUsersAction(\r\n params?: AccountUsersPaginationParams\r\n): Promise<AccountUsersActionResult> {\r\n try {\r\n const { users, total } = await accountService.listAccountUsers(params);\r\n return { success: true, data: users, total };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error: \"Erro ao listar usuários. Tente novamente.\",\r\n };\r\n }\r\n}\r\n\r\nexport async function updateUserAction(\r\n user: UpdateAccountUserRequest\r\n): Promise<UpdateUserActionResult> {\r\n try {\r\n const result = await accountService.updateAccountUser(user);\r\n return { success: true, data: result };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error: \"Erro ao atualizar usuário. Tente novamente.\",\r\n };\r\n }\r\n}\r\n\r\nexport async function updateAccountUserByIdAction(\r\n userId: number,\r\n user: UpdateAccountUserRequest\r\n): Promise<UpdateUserActionResult> {\r\n try {\r\n const result = await accountService.updateAccountUserById(userId, user);\r\n return { success: true, data: result };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error: \"Erro ao atualizar usuário. Tente novamente.\",\r\n };\r\n }\r\n}\r\n\r\nexport async function updateAccountAction(\r\n data: UpdateAccountRequest\r\n): Promise<UpdateAccountActionResult> {\r\n try {\r\n await accountService.updateAccount(data);\r\n return { success: true };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error: \"Erro ao atualizar conta. Tente novamente.\",\r\n };\r\n }\r\n}\r\n\r\nexport async function deleteAccountUserAction(\r\n userId: number\r\n): Promise<DeleteUserActionResult> {\r\n try {\r\n await accountService.deleteAccountUser(userId);\r\n return { success: true };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error: \"Erro ao remover usuário. Tente novamente.\",\r\n };\r\n }\r\n}\r\n\r\nexport async function deleteAccountAction(): Promise<DeleteAccountActionResult> {\r\n try {\r\n await accountService.deleteAccount();\r\n return { success: true };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return { success: false, error: \"Erro ao excluir conta. Tente novamente.\" };\r\n }\r\n}\r\n\r\nexport async function createAccountUserAction(\r\n user: CreateAccountUserRequest\r\n): Promise<AccountUsersActionResult> {\r\n try {\r\n const result = await accountService.createAccountUser(user);\r\n return { success: true, data: result.data };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return { success: false, error: \"Erro ao criar usuário. Tente novamente.\" };\r\n }\r\n}\r\n\r\nexport async function changePasswordAction(\r\n data: ChangePasswordRequest\r\n): Promise<ChangePasswordActionResult> {\r\n try {\r\n await accountService.changePassword(data);\r\n return { success: true };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return { success: false, error: \"Erro ao alterar senha. Tente novamente.\" };\r\n }\r\n}\r\n\r\nexport async function requestEmailChangeAction(\r\n newEmail: string\r\n): Promise<ContactResetResult> {\r\n try {\r\n await accountService.requestContactReset(\"email\", newEmail);\r\n return { success: true };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error:\r\n \"E-mail já existente ou ocorreu um erro. Tente novamente mais tarde.\",\r\n };\r\n }\r\n}\r\n\r\nexport async function confirmEmailChangeAction(\r\n token: string,\r\n newEmail: string\r\n): Promise<ContactResetResult> {\r\n try {\r\n await accountService.confirmContactReset(\"email\", token, newEmail);\r\n return { success: true };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error: \"Código inválido ou expirado. Tente novamente.\",\r\n };\r\n }\r\n}\r\n\r\nexport async function requestPhoneChangeAction(\r\n newPhone: string\r\n): Promise<ContactResetResult> {\r\n try {\r\n await accountService.requestContactReset(\"phone\", newPhone);\r\n return { success: true };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error:\r\n \"Número já existente ou ocorreu um erro. Tente novamente mais tarde.\",\r\n };\r\n }\r\n}\r\n\r\nexport async function confirmPhoneChangeAction(\r\n token: string,\r\n newPhone: string\r\n): Promise<ContactResetResult> {\r\n try {\r\n await accountService.confirmContactReset(\"phone\", token, newPhone);\r\n return { success: true };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error: \"Código inválido ou expirado. Tente novamente.\",\r\n };\r\n }\r\n}\r\n\r\nexport async function generateTwoFactorAction(): Promise<TwoFactorGenerateResult> {\r\n try {\r\n const result = await twoFactorService.generate();\r\n return {\r\n success: true,\r\n qrcode: result.data.qrcode,\r\n backupCodes: result.data.backup_codes,\r\n };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return { success: false, error: \"Erro ao gerar QR Code. Tente novamente.\" };\r\n }\r\n}\r\n\r\nexport async function confirmTwoFactorAction(\r\n code: string\r\n): Promise<TwoFactorActionResult> {\r\n try {\r\n await twoFactorService.confirm(code);\r\n await accountService.updateAccountUser({ two_factor_authentication: true });\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return { success: false, error: \"Código inválido. Tente novamente.\" };\r\n }\r\n\r\n return { success: true };\r\n}\r\n\r\nexport async function disableTwoFactorAction(\r\n code: string\r\n): Promise<TwoFactorActionResult> {\r\n try {\r\n await twoFactorService.verify(code);\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return { success: false, error: \"Código inválido. Tente novamente.\" };\r\n }\r\n\r\n try {\r\n await twoFactorService.disable();\r\n return { success: true };\r\n } catch (error) {\r\n if (error instanceof ApiError)\r\n return { success: false, error: error.message };\r\n return {\r\n success: false,\r\n error: \"Erro ao desabilitar 2FA. Tente novamente.\",\r\n };\r\n }\r\n}\r\n"],"mappings":";AAEA,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AAiBzB,SAAS,wBAAwB;AAEjC,eAAsB,uBACpB,QACmC;AACnC,MAAI;AACF,UAAM,EAAE,OAAO,MAAM,IAAI,MAAM,eAAe,iBAAiB,MAAM;AACrE,WAAO,EAAE,SAAS,MAAM,MAAM,OAAO,MAAM;AAAA,EAC7C,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,eAAsB,iBACpB,MACiC;AACjC,MAAI;AACF,UAAM,SAAS,MAAM,eAAe,kBAAkB,IAAI;AAC1D,WAAO,EAAE,SAAS,MAAM,MAAM,OAAO;AAAA,EACvC,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,eAAsB,4BACpB,QACA,MACiC;AACjC,MAAI;AACF,UAAM,SAAS,MAAM,eAAe,sBAAsB,QAAQ,IAAI;AACtE,WAAO,EAAE,SAAS,MAAM,MAAM,OAAO;AAAA,EACvC,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,eAAsB,oBACpB,MACoC;AACpC,MAAI;AACF,UAAM,eAAe,cAAc,IAAI;AACvC,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,eAAsB,wBACpB,QACiC;AACjC,MAAI;AACF,UAAM,eAAe,kBAAkB,MAAM;AAC7C,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,eAAsB,sBAA0D;AAC9E,MAAI;AACF,UAAM,eAAe,cAAc;AACnC,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO,EAAE,SAAS,OAAO,OAAO,0CAA0C;AAAA,EAC5E;AACF;AAEA,eAAsB,wBACpB,MACmC;AACnC,MAAI;AACF,UAAM,SAAS,MAAM,eAAe,kBAAkB,IAAI;AAC1D,WAAO,EAAE,SAAS,MAAM,MAAM,OAAO,KAAK;AAAA,EAC5C,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO,EAAE,SAAS,OAAO,OAAO,6CAA0C;AAAA,EAC5E;AACF;AAEA,eAAsB,qBACpB,MACqC;AACrC,MAAI;AACF,UAAM,eAAe,eAAe,IAAI;AACxC,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO,EAAE,SAAS,OAAO,OAAO,0CAA0C;AAAA,EAC5E;AACF;AAEA,eAAsB,yBACpB,UAC6B;AAC7B,MAAI;AACF,UAAM,eAAe,oBAAoB,SAAS,QAAQ;AAC1D,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OACE;AAAA,IACJ;AAAA,EACF;AACF;AAEA,eAAsB,yBACpB,OACA,UAC6B;AAC7B,MAAI;AACF,UAAM,eAAe,oBAAoB,SAAS,OAAO,QAAQ;AACjE,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,eAAsB,yBACpB,UAC6B;AAC7B,MAAI;AACF,UAAM,eAAe,oBAAoB,SAAS,QAAQ;AAC1D,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OACE;AAAA,IACJ;AAAA,EACF;AACF;AAEA,eAAsB,yBACpB,OACA,UAC6B;AAC7B,MAAI;AACF,UAAM,eAAe,oBAAoB,SAAS,OAAO,QAAQ;AACjE,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;AAEA,eAAsB,0BAA4D;AAChF,MAAI;AACF,UAAM,SAAS,MAAM,iBAAiB,SAAS;AAC/C,WAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ,OAAO,KAAK;AAAA,MACpB,aAAa,OAAO,KAAK;AAAA,IAC3B;AAAA,EACF,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO,EAAE,SAAS,OAAO,OAAO,0CAA0C;AAAA,EAC5E;AACF;AAEA,eAAsB,uBACpB,MACgC;AAChC,MAAI;AACF,UAAM,iBAAiB,QAAQ,IAAI;AACnC,UAAM,eAAe,kBAAkB,EAAE,2BAA2B,KAAK,CAAC;AAAA,EAC5E,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO,EAAE,SAAS,OAAO,OAAO,0CAAoC;AAAA,EACtE;AAEA,SAAO,EAAE,SAAS,KAAK;AACzB;AAEA,eAAsB,uBACpB,MACgC;AAChC,MAAI;AACF,UAAM,iBAAiB,OAAO,IAAI;AAAA,EACpC,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO,EAAE,SAAS,OAAO,OAAO,0CAAoC;AAAA,EACtE;AAEA,MAAI;AACF,UAAM,iBAAiB,QAAQ;AAC/B,WAAO,EAAE,SAAS,KAAK;AAAA,EACzB,SAAS,OAAO;AACd,QAAI,iBAAiB;AACnB,aAAO,EAAE,SAAS,OAAO,OAAO,MAAM,QAAQ;AAChD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/actions/account-management.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { accountService } from '../services/account.service';\nimport type {\n AccountUsersPaginationParams,\n ChangePasswordRequest,\n CreateAccountUserRequest,\n UpdateAccountRequest,\n UpdateAccountUserRequest,\n} from '../types';\nimport { twoFactorService } from '../services/two-factor.service';\n\nexport function listAccountUsersAction(params?: AccountUsersPaginationParams) {\n return safeServerAction(async () => {\n const { users, total } = await accountService.listAccountUsers(params);\n return { data: users, total };\n });\n}\n\nexport function updateUserAction(user: UpdateAccountUserRequest) {\n return safeServerAction(() => accountService.updateAccountUser(user));\n}\n\nexport function updateAccountUserByIdAction(\n userId: number,\n user: UpdateAccountUserRequest\n) {\n return safeServerAction(() => accountService.updateAccountUserById(userId, user));\n}\n\nexport function updateAccountAction(data: UpdateAccountRequest) {\n return safeServerAction(() => accountService.updateAccount(data));\n}\n\nexport function deleteAccountUserAction(userId: number) {\n return safeServerAction(() => accountService.deleteAccountUser(userId));\n}\n\nexport function deleteAccountAction() {\n return safeServerAction(() => accountService.deleteAccount());\n}\n\nexport function createAccountUserAction(user: CreateAccountUserRequest) {\n return safeServerAction(() => accountService.createAccountUser(user));\n}\n\nexport function changePasswordAction(data: ChangePasswordRequest) {\n return safeServerAction(() => accountService.changePassword(data));\n}\n\nexport function requestEmailChangeAction(newEmail: string) {\n return safeServerAction(() => accountService.requestContactReset('email', newEmail));\n}\n\nexport function confirmEmailChangeAction(token: string, newEmail: string) {\n return safeServerAction(() => accountService.confirmContactReset('email', token, newEmail));\n}\n\nexport function requestPhoneChangeAction(newPhone: string) {\n return safeServerAction(() => accountService.requestContactReset('phone', newPhone));\n}\n\nexport function confirmPhoneChangeAction(token: string, newPhone: string) {\n return safeServerAction(() => accountService.confirmContactReset('phone', token, newPhone));\n}\n\nexport function generateTwoFactorAction() {\n return safeServerAction(async () => {\n const result = await twoFactorService.generate();\n return {\n qrcode: result.data.qrcode,\n backupCodes: result.data.backup_codes,\n };\n });\n}\n\nexport function confirmTwoFactorAction(code: string) {\n return safeServerAction(async () => {\n await twoFactorService.confirm(code);\n await accountService.updateAccountUser({ two_factor_authentication: true });\n });\n}\n\nexport function disableTwoFactorAction(code: string) {\n return safeServerAction(async () => {\n await twoFactorService.verify(code);\n await twoFactorService.disable();\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAQ/B,SAAS,wBAAwB;AAE1B,SAAS,uBAAuB,QAAuC;AAC5E,SAAO,iBAAiB,YAAY;AAClC,UAAM,EAAE,OAAO,MAAM,IAAI,MAAM,eAAe,iBAAiB,MAAM;AACrE,WAAO,EAAE,MAAM,OAAO,MAAM;AAAA,EAC9B,CAAC;AACH;AAEO,SAAS,iBAAiB,MAAgC;AAC/D,SAAO,iBAAiB,MAAM,eAAe,kBAAkB,IAAI,CAAC;AACtE;AAEO,SAAS,4BACd,QACA,MACA;AACA,SAAO,iBAAiB,MAAM,eAAe,sBAAsB,QAAQ,IAAI,CAAC;AAClF;AAEO,SAAS,oBAAoB,MAA4B;AAC9D,SAAO,iBAAiB,MAAM,eAAe,cAAc,IAAI,CAAC;AAClE;AAEO,SAAS,wBAAwB,QAAgB;AACtD,SAAO,iBAAiB,MAAM,eAAe,kBAAkB,MAAM,CAAC;AACxE;AAEO,SAAS,sBAAsB;AACpC,SAAO,iBAAiB,MAAM,eAAe,cAAc,CAAC;AAC9D;AAEO,SAAS,wBAAwB,MAAgC;AACtE,SAAO,iBAAiB,MAAM,eAAe,kBAAkB,IAAI,CAAC;AACtE;AAEO,SAAS,qBAAqB,MAA6B;AAChE,SAAO,iBAAiB,MAAM,eAAe,eAAe,IAAI,CAAC;AACnE;AAEO,SAAS,yBAAyB,UAAkB;AACzD,SAAO,iBAAiB,MAAM,eAAe,oBAAoB,SAAS,QAAQ,CAAC;AACrF;AAEO,SAAS,yBAAyB,OAAe,UAAkB;AACxE,SAAO,iBAAiB,MAAM,eAAe,oBAAoB,SAAS,OAAO,QAAQ,CAAC;AAC5F;AAEO,SAAS,yBAAyB,UAAkB;AACzD,SAAO,iBAAiB,MAAM,eAAe,oBAAoB,SAAS,QAAQ,CAAC;AACrF;AAEO,SAAS,yBAAyB,OAAe,UAAkB;AACxE,SAAO,iBAAiB,MAAM,eAAe,oBAAoB,SAAS,OAAO,QAAQ,CAAC;AAC5F;AAEO,SAAS,0BAA0B;AACxC,SAAO,iBAAiB,YAAY;AAClC,UAAM,SAAS,MAAM,iBAAiB,SAAS;AAC/C,WAAO;AAAA,MACL,QAAQ,OAAO,KAAK;AAAA,MACpB,aAAa,OAAO,KAAK;AAAA,IAC3B;AAAA,EACF,CAAC;AACH;AAEO,SAAS,uBAAuB,MAAc;AACnD,SAAO,iBAAiB,YAAY;AAClC,UAAM,iBAAiB,QAAQ,IAAI;AACnC,UAAM,eAAe,kBAAkB,EAAE,2BAA2B,KAAK,CAAC;AAAA,EAC5E,CAAC;AACH;AAEO,SAAS,uBAAuB,MAAc;AACnD,SAAO,iBAAiB,YAAY;AAClC,UAAM,iBAAiB,OAAO,IAAI;AAClC,UAAM,iBAAiB,QAAQ;AAAA,EACjC,CAAC;AACH;","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
2
3
|
import { accountService } from "../services/account.service";
|
|
3
|
-
|
|
4
|
-
return
|
|
4
|
+
function findCurrentAccount() {
|
|
5
|
+
return safeServerAction(() => accountService.findCurrentAccount());
|
|
5
6
|
}
|
|
6
7
|
export {
|
|
7
8
|
findCurrentAccount
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/actions/find-current-account.action.ts"],"sourcesContent":["'use server';\n\nimport { accountService } from
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/actions/find-current-account.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { accountService } from '../services/account.service';\nimport type { Account } from '../types';\n\nexport function findCurrentAccount() {\n return safeServerAction<Account>(() => accountService.findCurrentAccount());\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,sBAAsB;AAGxB,SAAS,qBAAqB;AACnC,SAAO,iBAA0B,MAAM,eAAe,mBAAmB,CAAC;AAC5E;","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
2
3
|
import { currencyService } from "../services/currency.service";
|
|
3
|
-
|
|
4
|
-
return currencyService.fetchOptions();
|
|
4
|
+
function listCurrenciesAction() {
|
|
5
|
+
return safeServerAction(() => currencyService.fetchOptions());
|
|
5
6
|
}
|
|
6
7
|
export {
|
|
7
8
|
listCurrenciesAction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/actions/list-currencies.action.ts"],"sourcesContent":["'use server';\
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/actions/list-currencies.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { currencyService } from '../services/currency.service';\n\nexport function listCurrenciesAction() {\n return safeServerAction(() => currencyService.fetchOptions());\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEzB,SAAS,uBAAuB;AACrC,SAAO,iBAAiB,MAAM,gBAAgB,aAAa,CAAC;AAC9D;","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
2
3
|
import { timezoneService } from "../services/timezone.service";
|
|
3
|
-
|
|
4
|
-
return timezoneService.fetchOptions();
|
|
4
|
+
function listTimezonesAction() {
|
|
5
|
+
return safeServerAction(() => timezoneService.fetchOptions());
|
|
5
6
|
}
|
|
6
7
|
export {
|
|
7
8
|
listTimezonesAction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/actions/list-timezones.action.ts"],"sourcesContent":["'use server';\
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/actions/list-timezones.action.ts"],"sourcesContent":["'use server';\n\nimport { safeServerAction } from '../../../utils/safeServerAction';\nimport { timezoneService } from '../services/timezone.service';\n\nexport function listTimezonesAction() {\n return safeServerAction(() => timezoneService.fetchOptions());\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAEzB,SAAS,sBAAsB;AACpC,SAAO,iBAAiB,MAAM,gBAAgB,aAAa,CAAC;AAC9D;","names":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { findCurrentAccount } from "../actions/find-current-account.action";
|
|
4
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
5
|
const ACCOUNT_QUERY_KEY = ["account"];
|
|
5
6
|
function useCurrentAccount() {
|
|
6
7
|
return useQuery({
|
|
7
8
|
queryKey: ACCOUNT_QUERY_KEY,
|
|
8
|
-
queryFn: findCurrentAccount,
|
|
9
|
+
queryFn: withAction(findCurrentAccount),
|
|
9
10
|
staleTime: 0,
|
|
10
11
|
gcTime: 10 * 60 * 1e3,
|
|
11
12
|
retry: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/hooks/current-account.hook.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/hooks/current-account.hook.tsx"],"sourcesContent":["'use client';\n\nimport { useQuery, useQueryClient } from '@tanstack/react-query';\nimport { findCurrentAccount } from '../actions/find-current-account.action';\nimport { withAction } from '../../../utils/withAction';\n\nexport const ACCOUNT_QUERY_KEY = ['account'];\n\nexport function useCurrentAccount() {\n return useQuery({\n queryKey: ACCOUNT_QUERY_KEY,\n queryFn: withAction(findCurrentAccount),\n staleTime: 0,\n gcTime: 10 * 60 * 1000,\n retry: false,\n });\n}\n\nexport function useInvalidateAccount() {\n const queryClient = useQueryClient();\n return () => queryClient.invalidateQueries({ queryKey: ACCOUNT_QUERY_KEY });\n}\n"],"mappings":";AAEA,SAAS,UAAU,sBAAsB;AACzC,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAEpB,MAAM,oBAAoB,CAAC,SAAS;AAEpC,SAAS,oBAAoB;AAClC,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS,WAAW,kBAAkB;AAAA,IACtC,WAAW;AAAA,IACX,QAAQ,KAAK,KAAK;AAAA,IAClB,OAAO;AAAA,EACT,CAAC;AACH;AAEO,SAAS,uBAAuB;AACrC,QAAM,cAAc,eAAe;AACnC,SAAO,MAAM,YAAY,kBAAkB,EAAE,UAAU,kBAAkB,CAAC;AAC5E;","names":[]}
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
deleteAccountUserAction,
|
|
10
10
|
deleteAccountAction
|
|
11
11
|
} from "../actions/account-management.action";
|
|
12
|
+
import { withAction } from "../../../utils/withAction";
|
|
12
13
|
const ACCOUNT_USERS_QUERY_KEY = ["account-users"];
|
|
13
14
|
function useUpdateAccount() {
|
|
14
15
|
const queryClient = useQueryClient();
|
|
15
16
|
return useMutation({
|
|
16
|
-
mutationFn: (
|
|
17
|
+
mutationFn: withAction(updateAccountAction),
|
|
17
18
|
onSuccess: () => {
|
|
18
19
|
queryClient.invalidateQueries({ queryKey: ACCOUNT_USERS_QUERY_KEY });
|
|
19
20
|
queryClient.invalidateQueries({ queryKey: ACCOUNT_QUERY_KEY });
|
|
@@ -24,7 +25,7 @@ function useUpdateAccount() {
|
|
|
24
25
|
function useUpdateAccountUser() {
|
|
25
26
|
const queryClient = useQueryClient();
|
|
26
27
|
return useMutation({
|
|
27
|
-
mutationFn: updateUserAction,
|
|
28
|
+
mutationFn: withAction(updateUserAction),
|
|
28
29
|
onSuccess: () => {
|
|
29
30
|
queryClient.invalidateQueries({ queryKey: ACCOUNT_USERS_QUERY_KEY });
|
|
30
31
|
queryClient.invalidateQueries({ queryKey: ACCOUNT_QUERY_KEY });
|
|
@@ -35,7 +36,9 @@ function useUpdateAccountUser() {
|
|
|
35
36
|
function useUpdateAccountUserById() {
|
|
36
37
|
const queryClient = useQueryClient();
|
|
37
38
|
return useMutation({
|
|
38
|
-
mutationFn: (
|
|
39
|
+
mutationFn: withAction(
|
|
40
|
+
({ userId, ...user }) => updateAccountUserByIdAction(userId, user)
|
|
41
|
+
),
|
|
39
42
|
onSuccess: () => {
|
|
40
43
|
queryClient.invalidateQueries({ queryKey: ACCOUNT_USERS_QUERY_KEY });
|
|
41
44
|
}
|
|
@@ -44,7 +47,7 @@ function useUpdateAccountUserById() {
|
|
|
44
47
|
function useDeleteAccountUser(options) {
|
|
45
48
|
const queryClient = useQueryClient();
|
|
46
49
|
return useMutation({
|
|
47
|
-
mutationFn: (
|
|
50
|
+
mutationFn: withAction(deleteAccountUserAction),
|
|
48
51
|
...options,
|
|
49
52
|
onSuccess: (...params) => {
|
|
50
53
|
options?.onSuccess?.(...params);
|
|
@@ -54,7 +57,7 @@ function useDeleteAccountUser(options) {
|
|
|
54
57
|
}
|
|
55
58
|
function useDeleteAccount(options) {
|
|
56
59
|
return useMutation({
|
|
57
|
-
mutationFn: (
|
|
60
|
+
mutationFn: withAction(deleteAccountAction),
|
|
58
61
|
...options
|
|
59
62
|
});
|
|
60
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/hooks/useAccountManagement.ts"],"sourcesContent":["'use client';\
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/hooks/useAccountManagement.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient } from '@tanstack/react-query';\nimport { USER_QUERY_KEY } from '../../auth/hooks/useUserQuery';\nimport { ACCOUNT_QUERY_KEY } from './current-account.hook';\nimport type {\n UpdateAccountRequest,\n UpdateAccountUserRequest,\n DeleteAccountUserResponse,\n DeleteAccountResponse,\n} from '../types';\nimport {\n updateUserAction,\n updateAccountAction,\n updateAccountUserByIdAction,\n deleteAccountUserAction,\n deleteAccountAction,\n} from '../actions/account-management.action';\nimport { withAction } from '../../../utils/withAction';\nimport type { UseMutationOptions } from '@tanstack/react-query';\n\nconst ACCOUNT_USERS_QUERY_KEY = ['account-users'];\n\nexport function useUpdateAccount() {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: withAction(updateAccountAction),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ACCOUNT_USERS_QUERY_KEY });\n queryClient.invalidateQueries({ queryKey: ACCOUNT_QUERY_KEY });\n queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });\n },\n });\n}\n\nexport function useUpdateAccountUser() {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: withAction(updateUserAction),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ACCOUNT_USERS_QUERY_KEY });\n queryClient.invalidateQueries({ queryKey: ACCOUNT_QUERY_KEY });\n queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });\n },\n });\n}\n\nexport function useUpdateAccountUserById() {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: withAction(({ userId, ...user }: UpdateAccountUserRequest & { userId: number }) =>\n updateAccountUserByIdAction(userId, user)\n ),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ACCOUNT_USERS_QUERY_KEY });\n },\n });\n}\n\nexport function useDeleteAccountUser(\n options?: UseMutationOptions<DeleteAccountUserResponse, Error, number>\n) {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: withAction(deleteAccountUserAction),\n ...options,\n onSuccess: (...params) => {\n options?.onSuccess?.(...params);\n queryClient.invalidateQueries({ queryKey: ACCOUNT_USERS_QUERY_KEY });\n },\n });\n}\n\nexport function useDeleteAccount(\n options?: UseMutationOptions<DeleteAccountResponse, Error, void>\n) {\n return useMutation({\n mutationFn: withAction(deleteAccountAction),\n ...options,\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAsB;AAC5C,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAOlC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAG3B,MAAM,0BAA0B,CAAC,eAAe;AAEzC,SAAS,mBAAmB;AACjC,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,mBAAmB;AAAA,IAC1C,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,wBAAwB,CAAC;AACnE,kBAAY,kBAAkB,EAAE,UAAU,kBAAkB,CAAC;AAC7D,kBAAY,kBAAkB,EAAE,UAAU,eAAe,CAAC;AAAA,IAC5D;AAAA,EACF,CAAC;AACH;AAEO,SAAS,uBAAuB;AACrC,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,gBAAgB;AAAA,IACvC,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,wBAAwB,CAAC;AACnE,kBAAY,kBAAkB,EAAE,UAAU,kBAAkB,CAAC;AAC7D,kBAAY,kBAAkB,EAAE,UAAU,eAAe,CAAC;AAAA,IAC5D;AAAA,EACF,CAAC;AACH;AAEO,SAAS,2BAA2B;AACzC,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY;AAAA,MAAW,CAAC,EAAE,QAAQ,GAAG,KAAK,MACxC,4BAA4B,QAAQ,IAAI;AAAA,IAC1C;AAAA,IACA,WAAW,MAAM;AACf,kBAAY,kBAAkB,EAAE,UAAU,wBAAwB,CAAC;AAAA,IACrE;AAAA,EACF,CAAC;AACH;AAEO,SAAS,qBACd,SACA;AACA,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,uBAAuB;AAAA,IAC9C,GAAG;AAAA,IACH,WAAW,IAAI,WAAW;AACxB,eAAS,YAAY,GAAG,MAAM;AAC9B,kBAAY,kBAAkB,EAAE,UAAU,wBAAwB,CAAC;AAAA,IACrE;AAAA,EACF,CAAC;AACH;AAEO,SAAS,iBACd,SACA;AACA,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,mBAAmB;AAAA,IAC1C,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { listCurrenciesAction } from "../actions/list-currencies.action";
|
|
4
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
5
|
const CURRENCIES_QUERY_KEY = ["currencies"];
|
|
5
6
|
function useCurrencies() {
|
|
6
7
|
return useQuery({
|
|
7
8
|
queryKey: CURRENCIES_QUERY_KEY,
|
|
8
|
-
queryFn: listCurrenciesAction,
|
|
9
|
+
queryFn: withAction(listCurrenciesAction),
|
|
9
10
|
staleTime: Infinity
|
|
10
11
|
});
|
|
11
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/hooks/useCurrencies.ts"],"sourcesContent":["'use client';\
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/hooks/useCurrencies.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { listCurrenciesAction } from '../actions/list-currencies.action';\nimport { withAction } from '../../../utils/withAction';\n\nexport const CURRENCIES_QUERY_KEY = ['currencies'];\n\nexport function useCurrencies() {\n return useQuery({\n queryKey: CURRENCIES_QUERY_KEY,\n queryFn: withAction(listCurrenciesAction),\n staleTime: Infinity,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,4BAA4B;AACrC,SAAS,kBAAkB;AAEpB,MAAM,uBAAuB,CAAC,YAAY;AAE1C,SAAS,gBAAgB;AAC9B,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS,WAAW,oBAAoB;AAAA,IACxC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { listTimezonesAction } from "../actions/list-timezones.action";
|
|
4
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
5
|
const TIMEZONES_QUERY_KEY = ["timezones"];
|
|
5
6
|
function useTimezones() {
|
|
6
7
|
return useQuery({
|
|
7
8
|
queryKey: TIMEZONES_QUERY_KEY,
|
|
8
|
-
queryFn: listTimezonesAction,
|
|
9
|
+
queryFn: withAction(listTimezonesAction),
|
|
9
10
|
staleTime: Infinity
|
|
10
11
|
});
|
|
11
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/accounts/hooks/useTimezones.ts"],"sourcesContent":["'use client';\
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/accounts/hooks/useTimezones.ts"],"sourcesContent":["'use client';\n\nimport { useQuery } from '@tanstack/react-query';\nimport { listTimezonesAction } from '../actions/list-timezones.action';\nimport { withAction } from '../../../utils/withAction';\n\nexport const TIMEZONES_QUERY_KEY = ['timezones'];\n\nexport function useTimezones() {\n return useQuery({\n queryKey: TIMEZONES_QUERY_KEY,\n queryFn: withAction(listTimezonesAction),\n staleTime: Infinity,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,2BAA2B;AACpC,SAAS,kBAAkB;AAEpB,MAAM,sBAAsB,CAAC,WAAW;AAExC,SAAS,eAAe;AAC7B,SAAO,SAAS;AAAA,IACd,UAAU;AAAA,IACV,SAAS,WAAW,mBAAmB;AAAA,IACvC,WAAW;AAAA,EACb,CAAC;AACH;","names":[]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
2
3
|
import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
|
|
3
4
|
import { authService } from "../services/auth.service";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function logoutAction() {
|
|
6
|
+
return safeServerAction(async () => {
|
|
7
|
+
const clientInfo = await getClientInfoFromRequest();
|
|
8
|
+
return authService.logout(clientInfo);
|
|
9
|
+
});
|
|
7
10
|
}
|
|
8
11
|
export {
|
|
9
12
|
logoutAction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/actions/logout.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/auth/actions/logout.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { safeServerAction } from '../../../utils/safeServerAction';\r\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\r\nimport { authService } from '../services/auth.service';\r\n\r\nexport function logoutAction() {\r\n return safeServerAction(async () => {\r\n const clientInfo = await getClientInfoFromRequest();\r\n return authService.logout(clientInfo);\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,gCAAgC;AACzC,SAAS,mBAAmB;AAErB,SAAS,eAAe;AAC7B,SAAO,iBAAiB,YAAY;AAClC,UAAM,aAAa,MAAM,yBAAyB;AAClD,WAAO,YAAY,OAAO,UAAU;AAAA,EACtC,CAAC;AACH;","names":[]}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
2
3
|
import { authService } from "../services/auth.service";
|
|
3
4
|
import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
function registerAction(data) {
|
|
6
|
+
return safeServerAction(async () => {
|
|
7
|
+
const clientInfo = await getClientInfoFromRequest();
|
|
8
|
+
return authService.register(data, clientInfo);
|
|
9
|
+
});
|
|
7
10
|
}
|
|
8
11
|
export {
|
|
9
12
|
registerAction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/actions/register.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { RegisterRequest
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/auth/actions/register.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { safeServerAction } from '../../../utils/safeServerAction';\r\nimport { RegisterRequest } from '../schema';\r\nimport { authService } from '../services/auth.service';\r\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\r\n\r\nexport function registerAction(data: RegisterRequest) {\r\n return safeServerAction(async () => {\r\n const clientInfo = await getClientInfoFromRequest();\r\n return authService.register(data, clientInfo);\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,wBAAwB;AAEjC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AAElC,SAAS,eAAe,MAAuB;AACpD,SAAO,iBAAiB,YAAY;AAClC,UAAM,aAAa,MAAM,yBAAyB;AAClD,WAAO,YAAY,SAAS,MAAM,UAAU;AAAA,EAC9C,CAAC;AACH;","names":[]}
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
"use server";
|
|
2
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
2
3
|
import { authService } from "../services/auth.service";
|
|
3
4
|
import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
function verifyTwoFactorAction(cookie, code) {
|
|
6
|
+
return safeServerAction(async () => {
|
|
6
7
|
if (!/^\d{6}$/.test(code)) {
|
|
7
|
-
|
|
8
|
+
throw new Error("Formato inv\xE1lido");
|
|
8
9
|
}
|
|
9
10
|
const clientInfo = await getClientInfoFromRequest();
|
|
10
11
|
await authService.verifyTwoFactor(cookie, code, clientInfo);
|
|
11
|
-
|
|
12
|
-
} catch (error) {
|
|
13
|
-
return {
|
|
14
|
-
status: 0,
|
|
15
|
-
message: error.message || "Ocorreu um erro durante a verifica\xE7\xE3o de dois fatores"
|
|
16
|
-
};
|
|
17
|
-
}
|
|
12
|
+
});
|
|
18
13
|
}
|
|
19
14
|
export {
|
|
20
15
|
verifyTwoFactorAction
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/actions/verify-two-factor.action.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/auth/actions/verify-two-factor.action.ts"],"sourcesContent":["'use server';\r\n\r\nimport { safeServerAction } from '../../../utils/safeServerAction';\r\nimport { authService } from '../services/auth.service';\r\nimport { getClientInfoFromRequest } from '../../../infra/utils/client-info';\r\n\r\nexport function verifyTwoFactorAction(cookie: string, code: string) {\r\n return safeServerAction(async () => {\r\n if (!/^\\d{6}$/.test(code)) {\r\n throw new Error('Formato inválido');\r\n }\r\n const clientInfo = await getClientInfoFromRequest();\r\n await authService.verifyTwoFactor(cookie, code, clientInfo);\r\n });\r\n}\r\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AAElC,SAAS,sBAAsB,QAAgB,MAAc;AAClE,SAAO,iBAAiB,YAAY;AAClC,QAAI,CAAC,UAAU,KAAK,IAAI,GAAG;AACzB,YAAM,IAAI,MAAM,qBAAkB;AAAA,IACpC;AACA,UAAM,aAAa,MAAM,yBAAyB;AAClD,UAAM,YAAY,gBAAgB,QAAQ,MAAM,UAAU;AAAA,EAC5D,CAAC;AACH;","names":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useMutation } from "@tanstack/react-query";
|
|
3
3
|
import { logoutAction } from "../actions/logout.action";
|
|
4
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
5
|
function useLogout() {
|
|
5
6
|
return useMutation({
|
|
6
|
-
mutationFn: logoutAction
|
|
7
|
+
mutationFn: withAction(logoutAction)
|
|
7
8
|
});
|
|
8
9
|
}
|
|
9
10
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/hooks/logout.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { logoutAction } from \"../actions/logout.action\";\n\nexport function useLogout() {\n return useMutation({\n mutationFn: logoutAction,\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/auth/hooks/logout.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { logoutAction } from \"../actions/logout.action\";\nimport { withAction } from \"../../../utils/withAction\";\n\nexport function useLogout() {\n return useMutation({\n mutationFn: withAction(logoutAction),\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,SAAS,YAAY;AAC1B,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,YAAY;AAAA,EACrC,CAAC;AACH;","names":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useMutation } from "@tanstack/react-query";
|
|
3
3
|
import { registerAction } from "../actions/register.action";
|
|
4
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
5
|
function useRegister() {
|
|
5
6
|
return useMutation({
|
|
6
|
-
mutationFn: registerAction
|
|
7
|
+
mutationFn: withAction(registerAction)
|
|
7
8
|
});
|
|
8
9
|
}
|
|
9
10
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/auth/hooks/register.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { registerAction } from \"../actions/register.action\";\n\nexport function useRegister() {\n return useMutation({\n mutationFn: registerAction,\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/auth/hooks/register.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { registerAction } from \"../actions/register.action\";\nimport { withAction } from \"../../../utils/withAction\";\n\nexport function useRegister() {\n return useMutation({\n mutationFn: withAction(registerAction),\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB;AAEpB,SAAS,cAAc;AAC5B,SAAO,YAAY;AAAA,IACjB,YAAY,WAAW,cAAc;AAAA,EACvC,CAAC;AACH;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
-
import {
|
|
3
|
+
import { withAction } from "../../../utils/withAction";
|
|
4
4
|
const USER_QUERY_KEY = ["user"];
|
|
5
5
|
async function fetchUser() {
|
|
6
6
|
const { findUserById: getUserDataAction } = await import("../../users/action/find-user-by-id.action");
|
|
@@ -36,7 +36,7 @@ function useTwoFactorVerify() {
|
|
|
36
36
|
return useMutation({
|
|
37
37
|
mutationFn: async ({ cookie, code }) => {
|
|
38
38
|
const { verifyTwoFactorAction } = await import("../actions/verify-two-factor.action");
|
|
39
|
-
return
|
|
39
|
+
return withAction(() => verifyTwoFactorAction(cookie, code))();
|
|
40
40
|
},
|
|
41
41
|
onSuccess: () => {
|
|
42
42
|
queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY });
|