@greatapps/common 1.1.632 → 1.1.633

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 (49) hide show
  1. package/dist/components/account/sections/SecuritySection.mjs +2 -38
  2. package/dist/components/account/sections/SecuritySection.mjs.map +1 -1
  3. package/dist/components/navigation/SubscriptionBanner.mjs +1 -0
  4. package/dist/components/navigation/SubscriptionBanner.mjs.map +1 -1
  5. package/dist/index.mjs +0 -6
  6. package/dist/index.mjs.map +1 -1
  7. package/dist/modules/auth/services/auth.service.mjs +0 -165
  8. package/dist/modules/auth/services/auth.service.mjs.map +1 -1
  9. package/dist/modules/auth/utils/assert-management-subscription.mjs +3 -1
  10. package/dist/modules/auth/utils/assert-management-subscription.mjs.map +1 -1
  11. package/dist/modules/auth/utils/assert-paid-subscription.mjs +3 -1
  12. package/dist/modules/auth/utils/assert-paid-subscription.mjs.map +1 -1
  13. package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs +2 -1
  14. package/dist/modules/subscriptions/hooks/use-cancelled-subscription-guard.mjs.map +1 -1
  15. package/dist/modules/users/schema.mjs.map +1 -1
  16. package/dist/providers/auth.provider.mjs +3 -63
  17. package/dist/providers/auth.provider.mjs.map +1 -1
  18. package/dist/server.mjs +0 -6
  19. package/dist/server.mjs.map +1 -1
  20. package/package.json +1 -1
  21. package/src/components/account/sections/SecuritySection.tsx +3 -50
  22. package/src/components/navigation/SubscriptionBanner.tsx +2 -0
  23. package/src/index.ts +0 -3
  24. package/src/modules/auth/schema.ts +0 -74
  25. package/src/modules/auth/services/auth.service.ts +0 -207
  26. package/src/modules/auth/utils/assert-management-subscription.ts +6 -1
  27. package/src/modules/auth/utils/assert-paid-subscription.ts +6 -1
  28. package/src/modules/subscriptions/hooks/use-cancelled-subscription-guard.ts +4 -1
  29. package/src/modules/users/schema.ts +0 -2
  30. package/src/providers/auth.provider.tsx +1 -86
  31. package/src/server.ts +0 -3
  32. package/dist/modules/auth/actions/social-google-login.action.mjs +0 -14
  33. package/dist/modules/auth/actions/social-google-login.action.mjs.map +0 -1
  34. package/dist/modules/auth/actions/social-google-onboarding.action.mjs +0 -14
  35. package/dist/modules/auth/actions/social-google-onboarding.action.mjs.map +0 -1
  36. package/dist/modules/auth/actions/unlink-google.action.mjs +0 -10
  37. package/dist/modules/auth/actions/unlink-google.action.mjs.map +0 -1
  38. package/dist/modules/auth/hooks/social-google-login.hook.mjs +0 -13
  39. package/dist/modules/auth/hooks/social-google-login.hook.mjs.map +0 -1
  40. package/dist/modules/auth/hooks/social-google-onboarding.hook.mjs +0 -13
  41. package/dist/modules/auth/hooks/social-google-onboarding.hook.mjs.map +0 -1
  42. package/dist/modules/auth/hooks/unlink-google.hook.mjs +0 -13
  43. package/dist/modules/auth/hooks/unlink-google.hook.mjs.map +0 -1
  44. package/src/modules/auth/actions/social-google-login.action.ts +0 -12
  45. package/src/modules/auth/actions/social-google-onboarding.action.ts +0 -13
  46. package/src/modules/auth/actions/unlink-google.action.ts +0 -8
  47. package/src/modules/auth/hooks/social-google-login.hook.tsx +0 -13
  48. package/src/modules/auth/hooks/social-google-onboarding.hook.tsx +0 -13
  49. package/src/modules/auth/hooks/unlink-google.hook.tsx +0 -13
@@ -26,16 +26,9 @@ import {
26
26
  SearchPlansApiResponse,
27
27
  SessionKeepRequest,
28
28
  SessionKeepResponse,
29
- SocialGoogleApiResponse,
30
- SocialGoogleResponse,
31
- SocialOnboardingApiResponse,
32
- SocialOnboardingRequest,
33
- SocialOnboardingResponse,
34
29
  TwoFactorApiResponse,
35
30
  TwoFactorRequest,
36
31
  TwoFactorResponse,
37
- UnlinkGoogleApiResponse,
38
- UnlinkGoogleResponse,
39
32
  VerifyEmailRequest,
40
33
  VerifyEmailResponse,
41
34
  } from "../schema";
@@ -158,206 +151,6 @@ class AuthService {
158
151
 
159
152
  return { status: 1 };
160
153
  }
161
-
162
- async socialLoginGoogle(
163
- idToken: string,
164
- clientInfo: ClientInfo,
165
- ): Promise<SocialGoogleResponse> {
166
- const response = await api.apps.post<SocialGoogleApiResponse>(
167
- "/auth/social/google",
168
- {
169
- id_token: idToken,
170
- location: clientInfo.location,
171
- ip: clientInfo.ip,
172
- timezone: clientInfo.timezone,
173
- agent: clientInfo.agent,
174
- verification: true,
175
- },
176
- );
177
-
178
- if (response.status === 0) {
179
- if (response.code === "link_requires_password") {
180
- return {
181
- result: "link_requires_password",
182
- message:
183
- response.message ||
184
- "Uma conta com esse e-mail já existe. Faça login com e-mail e senha para vincular sua conta Google.",
185
- };
186
- }
187
- throw new ApiError(
188
- response.message || "Falha no login com Google",
189
- response.code || "GOOGLE_LOGIN_FAILED",
190
- 401,
191
- );
192
- }
193
-
194
- if (response.needs_onboarding) {
195
- if (!response.onboarding_token || !response.partial?.email) {
196
- throw new ApiError(
197
- "Resposta de onboarding inválida",
198
- "INVALID_RESPONSE",
199
- 500,
200
- );
201
- }
202
- return {
203
- result: "needs_onboarding",
204
- onboardingToken: response.onboarding_token,
205
- partial: response.partial,
206
- };
207
- }
208
-
209
- if (!response.cookie) {
210
- throw new ApiError(
211
- "Resposta de autenticação inválida",
212
- "INVALID_RESPONSE",
213
- 500,
214
- );
215
- }
216
-
217
- if (response.two_factor_required) {
218
- return {
219
- result: "two_factor_required",
220
- cookie: response.cookie,
221
- twoFactorMode: response.two_factor_required,
222
- };
223
- }
224
-
225
- await this.setAuthCookie(response.cookie);
226
-
227
- const [{ userService }, { accountService }] = await Promise.all([
228
- import("../../users/services/user.service"),
229
- import("../../accounts/services/account.service"),
230
- ]);
231
- const [user, account] = await Promise.all([
232
- userService.findById(),
233
- accountService.findCurrentAccount(),
234
- ]);
235
-
236
- return {
237
- result: "success",
238
- user,
239
- account,
240
- accessToken: response.cookie,
241
- expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1000).toISOString(),
242
- };
243
- }
244
-
245
- async completeGoogleOnboarding(
246
- data: SocialOnboardingRequest,
247
- clientInfo: ClientInfo,
248
- ): Promise<SocialOnboardingResponse> {
249
- const today = new Date();
250
- const trialEndDate = new Date(today);
251
- const trialDays = Math.min(Math.max(data.trialDays ?? 7, 1), 90);
252
- trialEndDate.setDate(today.getDate() + trialDays);
253
-
254
- const idPlan = await this.resolvePlanId(data.idPlan);
255
-
256
- const payload = {
257
- onboarding_token: data.onboardingToken,
258
- name: data.user.name,
259
- bussiness_type: 0,
260
- language: "pt-br",
261
- timezone: "America/Sao_Paulo",
262
- currency: "BRL",
263
- location: clientInfo.location,
264
- ip: clientInfo.ip,
265
- agent: clientInfo.agent,
266
- id_affiliate: data.affiliateId || 0,
267
- origin: data.origin,
268
- user: {
269
- id_api: "",
270
- name: data.user.name || "",
271
- last_name: data.user.last_name || "",
272
- rg: data.user.rg || "",
273
- cpf: data.user.cpf || "",
274
- gender: data.user.gender ?? 1,
275
- ddi: data.user.ddi || "55",
276
- phone: data.user.phone || "",
277
- profile: "owner",
278
- language: "pt-br",
279
- },
280
- subscription:
281
- idPlan === -1
282
- ? {
283
- type: "free",
284
- id_coupon: data.couponId || 0,
285
- id_plan: 5,
286
- id_product: 1,
287
- }
288
- : {
289
- type: "trial",
290
- id_coupon: data.couponId || 0,
291
- id_plan: idPlan,
292
- date_due: trialEndDate.toISOString().split("T")[0],
293
- trial_days: trialDays,
294
- id_product: 1,
295
- },
296
- };
297
-
298
- const response = await api.apps.post<SocialOnboardingApiResponse>(
299
- "/auth/social/onboarding",
300
- payload,
301
- );
302
-
303
- if (response.status === 0) {
304
- throw new ApiError(
305
- response.message || "Erro ao finalizar cadastro com Google",
306
- "ONBOARDING_FAILED",
307
- 400,
308
- );
309
- }
310
-
311
- if (!response.data?.length || !response.cookie) {
312
- throw new ApiError(
313
- "Resposta de cadastro inválida",
314
- "INVALID_RESPONSE",
315
- 500,
316
- );
317
- }
318
-
319
- await this.setAuthCookie(response.cookie);
320
-
321
- const [{ userService }, { accountService }] = await Promise.all([
322
- import("../../users/services/user.service"),
323
- import("../../accounts/services/account.service"),
324
- ]);
325
- const [user, account] = await Promise.all([
326
- userService.findById(),
327
- accountService.findCurrentAccount(),
328
- ]);
329
-
330
- return {
331
- user,
332
- account,
333
- accessToken: response.cookie,
334
- expiresAt: new Date(Date.now() + COOKIE_MAX_AGE * 1000).toISOString(),
335
- };
336
- }
337
-
338
- async unlinkGoogle(): Promise<UnlinkGoogleResponse> {
339
- const { id_account, id_user } = await import(
340
- "../utils/get-user-context"
341
- ).then((m) => m.getUserContext());
342
-
343
- const response = await api.apps.delete<UnlinkGoogleApiResponse>(
344
- `/accounts/${id_account}/users/${id_user}/social/google`,
345
- );
346
-
347
- if (response.status === 0) {
348
- throw new ApiError(
349
- response.message || "Erro ao desvincular conta Google",
350
- "UNLINK_FAILED",
351
- 400,
352
- );
353
- }
354
-
355
- return {
356
- success: true,
357
- message: response.message,
358
- };
359
- }
360
-
361
154
  async register(
362
155
  data: RegisterRequest,
363
156
  clientInfo: ClientInfo,
@@ -25,7 +25,12 @@ export async function assertManagementSubscription() {
25
25
  );
26
26
  }
27
27
 
28
- if (hasSubscriptionExpired(subscription?.date_due)) {
28
+ const isWhitelabelType = subscription?.type === 'whitelabel';
29
+ const isExpired = isWhitelabelType
30
+ ? !!subscription?.date_cancellation && new Date() >= new Date(subscription.date_cancellation)
31
+ : hasSubscriptionExpired(subscription?.date_due);
32
+
33
+ if (isExpired) {
29
34
  throw new ApiError(
30
35
  "Sua assinatura está vencida. Assine um novo plano para continuar.",
31
36
  "SUBSCRIPTION_EXPIRED",
@@ -25,7 +25,12 @@ export async function assertPaidSubscription() {
25
25
  );
26
26
  }
27
27
 
28
- if (hasSubscriptionExpired(subscription.date_due)) {
28
+ const isWhitelabelType = subscription.type === 'whitelabel';
29
+ const isExpired = isWhitelabelType
30
+ ? !!subscription.date_cancellation && new Date() >= new Date(subscription.date_cancellation)
31
+ : hasSubscriptionExpired(subscription.date_due);
32
+
33
+ if (isExpired) {
29
34
  throw new ApiError(
30
35
  "Sua assinatura está vencida. Assine um novo plano para continuar.",
31
36
  "SUBSCRIPTION_EXPIRED",
@@ -15,7 +15,10 @@ export function useCancelledSubscriptionGuard() {
15
15
  } = useActiveSubscription();
16
16
 
17
17
  const isViewer = user?.profile === UserProfile.viewer;
18
- const isCancelledSubscription = hasSubscriptionExpired(subscription?.date_due);
18
+ const isWhitelabelType = subscription?.type === 'whitelabel';
19
+ const isCancelledSubscription = isWhitelabelType
20
+ ? !!subscription?.date_cancellation && new Date() >= new Date(subscription.date_cancellation)
21
+ : hasSubscriptionExpired(subscription?.date_due);
19
22
  const shouldBlockManagementAction = !isViewer && isCancelledSubscription;
20
23
 
21
24
  const guardAction = useCallback(
@@ -24,8 +24,6 @@ export interface User {
24
24
 
25
25
  // Autenticação e segurança
26
26
  two_factor_authentication: boolean;
27
- google_sub?: string | null;
28
- google_linked_at?: string | null;
29
27
 
30
28
  // Perfil e permissões
31
29
  profile: UserProfile;
@@ -16,27 +16,16 @@ import {
16
16
  import { useLogin } from "../modules/auth/hooks/login.hook";
17
17
  import { useRegister } from "../modules/auth/hooks/register.hook";
18
18
  import { useLogout } from "../modules/auth/hooks/logout.hook";
19
- import { useSocialGoogleLogin } from "../modules/auth/hooks/social-google-login.hook";
20
- import { useSocialGoogleOnboarding } from "../modules/auth/hooks/social-google-onboarding.hook";
21
19
  import {
22
20
  AuthState,
23
21
  LoginRequest,
24
22
  RegisterRequest,
25
- SocialGooglePartial,
26
- SocialOnboardingRequest,
27
23
  } from "../modules/auth/schema";
28
24
 
29
25
  export type LoginResult =
30
26
  | { result: "success" }
31
27
  | { result: "two_factor_required"; cookie: string; twoFactorMode: "verify" | "setup" }
32
28
  | { result: "error"; message: string };
33
-
34
- export type GoogleLoginResult =
35
- | { result: "success" }
36
- | { result: "two_factor_required"; cookie: string; twoFactorMode: "verify" | "setup" }
37
- | { result: "needs_onboarding"; onboardingToken: string; partial: SocialGooglePartial }
38
- | { result: "link_requires_password"; message: string }
39
- | { result: "error"; message: string };
40
29
  import {
41
30
  useCurrentAccount,
42
31
  ACCOUNT_QUERY_KEY,
@@ -48,8 +37,6 @@ interface AuthContextProps extends AuthState {
48
37
  login: (credentials: LoginRequest) => Promise<LoginResult>;
49
38
  register: (data: RegisterRequest) => Promise<void>;
50
39
  logout: () => Promise<void>;
51
- loginWithGoogle: (idToken: string) => Promise<GoogleLoginResult>;
52
- completeGoogleOnboarding: (data: SocialOnboardingRequest) => Promise<void>;
53
40
  }
54
41
 
55
42
  export const AuthContext = createContext<AuthContextProps | undefined>(
@@ -74,18 +61,12 @@ export function AuthProvider({ children }: AuthProviderProps) {
74
61
  const { mutateAsync: registerMutate, isPending: isRegistering } =
75
62
  useRegister();
76
63
  const { mutateAsync: logoutMutate, isPending: isLoggingOut } = useLogout();
77
- const { mutateAsync: googleLoginMutate, isPending: isGoogleLogging } =
78
- useSocialGoogleLogin();
79
- const { mutateAsync: googleOnboardingMutate, isPending: isGoogleOnboarding } =
80
- useSocialGoogleOnboarding();
81
64
 
82
65
  const isAuthenticated = !!user;
83
66
  const isLoading =
84
67
  isLogging ||
85
68
  isRegistering ||
86
69
  isLoggingOut ||
87
- isGoogleLogging ||
88
- isGoogleOnboarding ||
89
70
  isQueryLoading ||
90
71
  isAccountLoading ||
91
72
  isSessionLoading;
@@ -128,60 +109,6 @@ export function AuthProvider({ children }: AuthProviderProps) {
128
109
  [queryClient, setUserData, accountKey],
129
110
  );
130
111
 
131
- const loginWithGoogle = useCallback(
132
- async (idToken: string): Promise<GoogleLoginResult> => {
133
- try {
134
- const data = await googleLoginMutate(idToken);
135
-
136
- if (data.result === "two_factor_required") {
137
- return {
138
- result: "two_factor_required",
139
- cookie: data.cookie,
140
- twoFactorMode: data.twoFactorMode,
141
- };
142
- }
143
-
144
- if (data.result === "needs_onboarding") {
145
- return {
146
- result: "needs_onboarding",
147
- onboardingToken: data.onboardingToken,
148
- partial: data.partial,
149
- };
150
- }
151
-
152
- if (data.result === "link_requires_password") {
153
- return { result: "link_requires_password", message: data.message };
154
- }
155
-
156
- queryClient.clear();
157
- setUserData(data.user);
158
- queryClient.setQueryData(accountKey, data.account);
159
-
160
- return { result: "success" };
161
- } catch (error) {
162
- const message =
163
- error instanceof Error
164
- ? error.message
165
- : "Ocorreu um erro ao fazer login com Google. Tente novamente.";
166
- return { result: "error", message };
167
- }
168
- },
169
- [googleLoginMutate, queryClient, setUserData, accountKey],
170
- );
171
-
172
- const completeGoogleOnboarding = useCallback(
173
- async (data: SocialOnboardingRequest): Promise<void> => {
174
- await googleOnboardingMutate(data, {
175
- onSuccess: (data) => {
176
- queryClient.clear();
177
- setUserData(data.user);
178
- queryClient.setQueryData(accountKey, data.account);
179
- },
180
- });
181
- },
182
- [googleOnboardingMutate, queryClient, setUserData, accountKey],
183
- );
184
-
185
112
  const resolveLogoutRedirect = useCallback(() => {
186
113
  try {
187
114
  const currentOrigin = window.location.origin;
@@ -217,20 +144,8 @@ export function AuthProvider({ children }: AuthProviderProps) {
217
144
  login,
218
145
  register,
219
146
  logout,
220
- loginWithGoogle,
221
- completeGoogleOnboarding,
222
147
  }),
223
- [
224
- user,
225
- account,
226
- isAuthenticated,
227
- isLoading,
228
- login,
229
- register,
230
- logout,
231
- loginWithGoogle,
232
- completeGoogleOnboarding,
233
- ],
148
+ [user, account, isAuthenticated, isLoading, login, register, logout],
234
149
  );
235
150
 
236
151
  return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
package/src/server.ts CHANGED
@@ -20,9 +20,6 @@ export { iaCreditsService } from './modules/ia-credits/services/ia-credits.servi
20
20
  // Actions
21
21
  export { findWhitelabel } from './modules/whitelabel/actions/find-whitelabel.action';
22
22
  export { validateSessionAction } from './modules/auth/actions/validate-session.action';
23
- export { socialGoogleLoginAction } from './modules/auth/actions/social-google-login.action';
24
- export { socialGoogleOnboardingAction } from './modules/auth/actions/social-google-onboarding.action';
25
- export { unlinkGoogleAction } from './modules/auth/actions/unlink-google.action';
26
23
  export { findUserById } from './modules/users/action/find-user-by-id.action';
27
24
  export { findCurrentAccount } from './modules/accounts/actions/find-current-account.action';
28
25
  export { getAccountTokenAction } from './modules/accounts/actions/get-account-token.action';
@@ -1,14 +0,0 @@
1
- "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
3
- import { authService } from "../services/auth.service";
4
- import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
5
- async function socialGoogleLoginAction(idToken) {
6
- return safeServerAction(async () => {
7
- const clientInfo = await getClientInfoFromRequest();
8
- return authService.socialLoginGoogle(idToken, clientInfo);
9
- });
10
- }
11
- export {
12
- socialGoogleLoginAction
13
- };
14
- //# sourceMappingURL=social-google-login.action.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/modules/auth/actions/social-google-login.action.ts"],"sourcesContent":["\"use server\";\n\nimport { safeServerAction } from \"../../../utils/safeServerAction\";\nimport { authService } from \"../services/auth.service\";\nimport { getClientInfoFromRequest } from \"../../../infra/utils/client-info\";\n\nexport async function socialGoogleLoginAction(idToken: string) {\n return safeServerAction(async () => {\n const clientInfo = await getClientInfoFromRequest();\n return authService.socialLoginGoogle(idToken, clientInfo);\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AAEzC,eAAsB,wBAAwB,SAAiB;AAC7D,SAAO,iBAAiB,YAAY;AAClC,UAAM,aAAa,MAAM,yBAAyB;AAClD,WAAO,YAAY,kBAAkB,SAAS,UAAU;AAAA,EAC1D,CAAC;AACH;","names":[]}
@@ -1,14 +0,0 @@
1
- "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
3
- import { authService } from "../services/auth.service";
4
- import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
5
- async function socialGoogleOnboardingAction(data) {
6
- return safeServerAction(async () => {
7
- const clientInfo = await getClientInfoFromRequest();
8
- return authService.completeGoogleOnboarding(data, clientInfo);
9
- });
10
- }
11
- export {
12
- socialGoogleOnboardingAction
13
- };
14
- //# sourceMappingURL=social-google-onboarding.action.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/modules/auth/actions/social-google-onboarding.action.ts"],"sourcesContent":["\"use server\";\n\nimport { safeServerAction } from \"../../../utils/safeServerAction\";\nimport { authService } from \"../services/auth.service\";\nimport { SocialOnboardingRequest } from \"../schema\";\nimport { getClientInfoFromRequest } from \"../../../infra/utils/client-info\";\n\nexport async function socialGoogleOnboardingAction(data: SocialOnboardingRequest) {\n return safeServerAction(async () => {\n const clientInfo = await getClientInfoFromRequest();\n return authService.completeGoogleOnboarding(data, clientInfo);\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAE5B,SAAS,gCAAgC;AAEzC,eAAsB,6BAA6B,MAA+B;AAChF,SAAO,iBAAiB,YAAY;AAClC,UAAM,aAAa,MAAM,yBAAyB;AAClD,WAAO,YAAY,yBAAyB,MAAM,UAAU;AAAA,EAC9D,CAAC;AACH;","names":[]}
@@ -1,10 +0,0 @@
1
- "use server";
2
- import { safeServerAction } from "../../../utils/safeServerAction";
3
- import { authService } from "../services/auth.service";
4
- async function unlinkGoogleAction() {
5
- return safeServerAction(() => authService.unlinkGoogle());
6
- }
7
- export {
8
- unlinkGoogleAction
9
- };
10
- //# sourceMappingURL=unlink-google.action.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/modules/auth/actions/unlink-google.action.ts"],"sourcesContent":["\"use server\";\n\nimport { safeServerAction } from \"../../../utils/safeServerAction\";\nimport { authService } from \"../services/auth.service\";\n\nexport async function unlinkGoogleAction() {\n return safeServerAction(() => authService.unlinkGoogle());\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAE5B,eAAsB,qBAAqB;AACzC,SAAO,iBAAiB,MAAM,YAAY,aAAa,CAAC;AAC1D;","names":[]}
@@ -1,13 +0,0 @@
1
- "use client";
2
- import { useMutation } from "@tanstack/react-query";
3
- import { socialGoogleLoginAction } from "../actions/social-google-login.action";
4
- import { withAction } from "../../../utils/withAction";
5
- function useSocialGoogleLogin() {
6
- return useMutation({
7
- mutationFn: (idToken) => withAction(socialGoogleLoginAction)(idToken)
8
- });
9
- }
10
- export {
11
- useSocialGoogleLogin
12
- };
13
- //# sourceMappingURL=social-google-login.hook.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/modules/auth/hooks/social-google-login.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { socialGoogleLoginAction } from \"../actions/social-google-login.action\";\nimport { SocialGoogleResponse } from \"../schema\";\nimport { withAction } from \"../../../utils/withAction\";\n\nexport function useSocialGoogleLogin() {\n return useMutation({\n mutationFn: (idToken: string) =>\n withAction(socialGoogleLoginAction)(idToken) as Promise<SocialGoogleResponse>,\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,+BAA+B;AAExC,SAAS,kBAAkB;AAEpB,SAAS,uBAAuB;AACrC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,YACX,WAAW,uBAAuB,EAAE,OAAO;AAAA,EAC/C,CAAC;AACH;","names":[]}
@@ -1,13 +0,0 @@
1
- "use client";
2
- import { useMutation } from "@tanstack/react-query";
3
- import { socialGoogleOnboardingAction } from "../actions/social-google-onboarding.action";
4
- import { withAction } from "../../../utils/withAction";
5
- function useSocialGoogleOnboarding() {
6
- return useMutation({
7
- mutationFn: (data) => withAction(socialGoogleOnboardingAction)(data)
8
- });
9
- }
10
- export {
11
- useSocialGoogleOnboarding
12
- };
13
- //# sourceMappingURL=social-google-onboarding.hook.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/modules/auth/hooks/social-google-onboarding.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { socialGoogleOnboardingAction } from \"../actions/social-google-onboarding.action\";\nimport { SocialOnboardingRequest, SocialOnboardingResponse } from \"../schema\";\nimport { withAction } from \"../../../utils/withAction\";\n\nexport function useSocialGoogleOnboarding() {\n return useMutation({\n mutationFn: (data: SocialOnboardingRequest) =>\n withAction(socialGoogleOnboardingAction)(data) as Promise<SocialOnboardingResponse>,\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,oCAAoC;AAE7C,SAAS,kBAAkB;AAEpB,SAAS,4BAA4B;AAC1C,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,SACX,WAAW,4BAA4B,EAAE,IAAI;AAAA,EACjD,CAAC;AACH;","names":[]}
@@ -1,13 +0,0 @@
1
- "use client";
2
- import { useMutation } from "@tanstack/react-query";
3
- import { unlinkGoogleAction } from "../actions/unlink-google.action";
4
- import { withAction } from "../../../utils/withAction";
5
- function useUnlinkGoogle() {
6
- return useMutation({
7
- mutationFn: () => withAction(unlinkGoogleAction)()
8
- });
9
- }
10
- export {
11
- useUnlinkGoogle
12
- };
13
- //# sourceMappingURL=unlink-google.hook.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/modules/auth/hooks/unlink-google.hook.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMutation } from \"@tanstack/react-query\";\nimport { unlinkGoogleAction } from \"../actions/unlink-google.action\";\nimport { UnlinkGoogleResponse } from \"../schema\";\nimport { withAction } from \"../../../utils/withAction\";\n\nexport function useUnlinkGoogle() {\n return useMutation({\n mutationFn: () =>\n withAction(unlinkGoogleAction)() as Promise<UnlinkGoogleResponse>,\n });\n}\n"],"mappings":";AAEA,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAEpB,SAAS,kBAAkB;AAChC,SAAO,YAAY;AAAA,IACjB,YAAY,MACV,WAAW,kBAAkB,EAAE;AAAA,EACnC,CAAC;AACH;","names":[]}
@@ -1,12 +0,0 @@
1
- "use server";
2
-
3
- import { safeServerAction } from "../../../utils/safeServerAction";
4
- import { authService } from "../services/auth.service";
5
- import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
6
-
7
- export async function socialGoogleLoginAction(idToken: string) {
8
- return safeServerAction(async () => {
9
- const clientInfo = await getClientInfoFromRequest();
10
- return authService.socialLoginGoogle(idToken, clientInfo);
11
- });
12
- }
@@ -1,13 +0,0 @@
1
- "use server";
2
-
3
- import { safeServerAction } from "../../../utils/safeServerAction";
4
- import { authService } from "../services/auth.service";
5
- import { SocialOnboardingRequest } from "../schema";
6
- import { getClientInfoFromRequest } from "../../../infra/utils/client-info";
7
-
8
- export async function socialGoogleOnboardingAction(data: SocialOnboardingRequest) {
9
- return safeServerAction(async () => {
10
- const clientInfo = await getClientInfoFromRequest();
11
- return authService.completeGoogleOnboarding(data, clientInfo);
12
- });
13
- }
@@ -1,8 +0,0 @@
1
- "use server";
2
-
3
- import { safeServerAction } from "../../../utils/safeServerAction";
4
- import { authService } from "../services/auth.service";
5
-
6
- export async function unlinkGoogleAction() {
7
- return safeServerAction(() => authService.unlinkGoogle());
8
- }
@@ -1,13 +0,0 @@
1
- "use client";
2
-
3
- import { useMutation } from "@tanstack/react-query";
4
- import { socialGoogleLoginAction } from "../actions/social-google-login.action";
5
- import { SocialGoogleResponse } from "../schema";
6
- import { withAction } from "../../../utils/withAction";
7
-
8
- export function useSocialGoogleLogin() {
9
- return useMutation({
10
- mutationFn: (idToken: string) =>
11
- withAction(socialGoogleLoginAction)(idToken) as Promise<SocialGoogleResponse>,
12
- });
13
- }
@@ -1,13 +0,0 @@
1
- "use client";
2
-
3
- import { useMutation } from "@tanstack/react-query";
4
- import { socialGoogleOnboardingAction } from "../actions/social-google-onboarding.action";
5
- import { SocialOnboardingRequest, SocialOnboardingResponse } from "../schema";
6
- import { withAction } from "../../../utils/withAction";
7
-
8
- export function useSocialGoogleOnboarding() {
9
- return useMutation({
10
- mutationFn: (data: SocialOnboardingRequest) =>
11
- withAction(socialGoogleOnboardingAction)(data) as Promise<SocialOnboardingResponse>,
12
- });
13
- }
@@ -1,13 +0,0 @@
1
- "use client";
2
-
3
- import { useMutation } from "@tanstack/react-query";
4
- import { unlinkGoogleAction } from "../actions/unlink-google.action";
5
- import { UnlinkGoogleResponse } from "../schema";
6
- import { withAction } from "../../../utils/withAction";
7
-
8
- export function useUnlinkGoogle() {
9
- return useMutation({
10
- mutationFn: () =>
11
- withAction(unlinkGoogleAction)() as Promise<UnlinkGoogleResponse>,
12
- });
13
- }