@fctc/interface-logic 4.4.2 → 4.4.3

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/hooks.js CHANGED
@@ -3296,6 +3296,7 @@ function useActionService() {
3296
3296
  var import_react9 = require("react");
3297
3297
  function useAuthService() {
3298
3298
  const { env } = useEnv();
3299
+ const supabase = useSupabaseOptional();
3299
3300
  const login = (0, import_react9.useCallback)(
3300
3301
  async (body) => {
3301
3302
  const payload = Object.fromEntries(
@@ -3321,6 +3322,22 @@ function useAuthService() {
3321
3322
  },
3322
3323
  [env]
3323
3324
  );
3325
+ const loginSupabase = (0, import_react9.useCallback)(
3326
+ async (body) => {
3327
+ if (!supabase) {
3328
+ return {
3329
+ data: null,
3330
+ error: { message: "Supabase client is not initialized" }
3331
+ };
3332
+ }
3333
+ const { data, error } = await supabase.auth.signInWithPassword({
3334
+ email: body.email,
3335
+ password: body.password
3336
+ });
3337
+ return { data, error };
3338
+ },
3339
+ [supabase]
3340
+ );
3324
3341
  const forgotPassword = (0, import_react9.useCallback)(
3325
3342
  async (email) => {
3326
3343
  const bodyData = {
@@ -3543,6 +3560,7 @@ function useAuthService() {
3543
3560
  );
3544
3561
  return {
3545
3562
  login,
3563
+ loginSupabase,
3546
3564
  forgotPassword,
3547
3565
  forgotPasswordSSO,
3548
3566
  resetPassword,
@@ -6544,9 +6562,16 @@ var use_isvalid_token_default = useIsValidToken;
6544
6562
  // src/hooks/auth/use-login-credential.tsx
6545
6563
  var import_react_query7 = require("@tanstack/react-query");
6546
6564
  var useLoginCredential = () => {
6547
- const { login } = useAuthService();
6565
+ const { login, loginSupabase } = useAuthService();
6566
+ const { env } = useEnv();
6548
6567
  return (0, import_react_query7.useMutation)({
6549
6568
  mutationFn: (data) => {
6569
+ if (env.isSupaMode) {
6570
+ return loginSupabase({
6571
+ email: data.email,
6572
+ password: data.password
6573
+ });
6574
+ }
6550
6575
  return login(data);
6551
6576
  }
6552
6577
  });
package/dist/hooks.mjs CHANGED
@@ -3148,6 +3148,7 @@ function useActionService() {
3148
3148
  import { useCallback as useCallback3 } from "react";
3149
3149
  function useAuthService() {
3150
3150
  const { env } = useEnv();
3151
+ const supabase = useSupabaseOptional();
3151
3152
  const login = useCallback3(
3152
3153
  async (body) => {
3153
3154
  const payload = Object.fromEntries(
@@ -3173,6 +3174,22 @@ function useAuthService() {
3173
3174
  },
3174
3175
  [env]
3175
3176
  );
3177
+ const loginSupabase = useCallback3(
3178
+ async (body) => {
3179
+ if (!supabase) {
3180
+ return {
3181
+ data: null,
3182
+ error: { message: "Supabase client is not initialized" }
3183
+ };
3184
+ }
3185
+ const { data, error } = await supabase.auth.signInWithPassword({
3186
+ email: body.email,
3187
+ password: body.password
3188
+ });
3189
+ return { data, error };
3190
+ },
3191
+ [supabase]
3192
+ );
3176
3193
  const forgotPassword = useCallback3(
3177
3194
  async (email) => {
3178
3195
  const bodyData = {
@@ -3395,6 +3412,7 @@ function useAuthService() {
3395
3412
  );
3396
3413
  return {
3397
3414
  login,
3415
+ loginSupabase,
3398
3416
  forgotPassword,
3399
3417
  forgotPasswordSSO,
3400
3418
  resetPassword,
@@ -6396,9 +6414,16 @@ var use_isvalid_token_default = useIsValidToken;
6396
6414
  // src/hooks/auth/use-login-credential.tsx
6397
6415
  import { useMutation as useMutation5 } from "@tanstack/react-query";
6398
6416
  var useLoginCredential = () => {
6399
- const { login } = useAuthService();
6417
+ const { login, loginSupabase } = useAuthService();
6418
+ const { env } = useEnv();
6400
6419
  return useMutation5({
6401
6420
  mutationFn: (data) => {
6421
+ if (env.isSupaMode) {
6422
+ return loginSupabase({
6423
+ email: data.email,
6424
+ password: data.password
6425
+ });
6426
+ }
6402
6427
  return login(data);
6403
6428
  }
6404
6429
  });