@constructive-io/sheets 0.3.0
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/LICENSE +21 -0
- package/README.md +188 -0
- package/dist/advanced.cjs +5477 -0
- package/dist/advanced.cjs.map +1 -0
- package/dist/advanced.d.cts +83 -0
- package/dist/advanced.d.ts +83 -0
- package/dist/advanced.js +34 -0
- package/dist/advanced.js.map +1 -0
- package/dist/auth.cjs +1396 -0
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.cts +60 -0
- package/dist/auth.d.ts +60 -0
- package/dist/auth.js +19 -0
- package/dist/auth.js.map +1 -0
- package/dist/chunk-4PGPVMZB.js +670 -0
- package/dist/chunk-4PGPVMZB.js.map +1 -0
- package/dist/chunk-FNVHSOQQ.js +1314 -0
- package/dist/chunk-FNVHSOQQ.js.map +1 -0
- package/dist/chunk-GGECS2BP.js +17 -0
- package/dist/chunk-GGECS2BP.js.map +1 -0
- package/dist/chunk-GLVZSPV2.js +43 -0
- package/dist/chunk-GLVZSPV2.js.map +1 -0
- package/dist/chunk-H4JJTMP5.js +160 -0
- package/dist/chunk-H4JJTMP5.js.map +1 -0
- package/dist/chunk-ODUBS2NL.js +100 -0
- package/dist/chunk-ODUBS2NL.js.map +1 -0
- package/dist/chunk-PZL2BCWF.js +168 -0
- package/dist/chunk-PZL2BCWF.js.map +1 -0
- package/dist/chunk-TU7ATZ4X.js +4494 -0
- package/dist/chunk-TU7ATZ4X.js.map +1 -0
- package/dist/chunk-X7DHTSOX.js +21 -0
- package/dist/chunk-X7DHTSOX.js.map +1 -0
- package/dist/chunk-YDQQA46V.js +13 -0
- package/dist/chunk-YDQQA46V.js.map +1 -0
- package/dist/date-editor-CXKKGNL6.js +361 -0
- package/dist/date-editor-CXKKGNL6.js.map +1 -0
- package/dist/editor-props-M6Dh0P9f.d.cts +245 -0
- package/dist/editor-props-M6Dh0P9f.d.ts +245 -0
- package/dist/index.cjs +15861 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1650 -0
- package/dist/index.d.ts +1650 -0
- package/dist/index.js +8470 -0
- package/dist/index.js.map +1 -0
- package/dist/map-picker-VTKDS6CM.js +290 -0
- package/dist/map-picker-VTKDS6CM.js.map +1 -0
- package/dist/sheets-context-CojEFlaY.d.cts +214 -0
- package/dist/sheets-context-Da55TTR9.d.ts +214 -0
- package/dist/testing.cjs +1113 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +45 -0
- package/dist/testing.d.ts +45 -0
- package/dist/testing.js +269 -0
- package/dist/testing.js.map +1 -0
- package/package.json +144 -0
|
@@ -0,0 +1,1314 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
setStoredToken
|
|
4
|
+
} from "./chunk-GLVZSPV2.js";
|
|
5
|
+
import {
|
|
6
|
+
useSheetsContext,
|
|
7
|
+
useSheetsStore,
|
|
8
|
+
useSheetsStoreApi
|
|
9
|
+
} from "./chunk-4PGPVMZB.js";
|
|
10
|
+
import {
|
|
11
|
+
cn
|
|
12
|
+
} from "./chunk-YDQQA46V.js";
|
|
13
|
+
|
|
14
|
+
// src/auth/hooks/use-login.ts
|
|
15
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
16
|
+
|
|
17
|
+
// src/auth/utils/auth-errors.ts
|
|
18
|
+
var ERROR_CODES = {
|
|
19
|
+
// Auth errors - login
|
|
20
|
+
INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
|
|
21
|
+
// Generic - prevents user enumeration
|
|
22
|
+
INCORRECT_PASSWORD: "INCORRECT_PASSWORD",
|
|
23
|
+
ACCOUNT_LOCKED_EXCEED_ATTEMPTS: "ACCOUNT_LOCKED_EXCEED_ATTEMPTS",
|
|
24
|
+
ACCOUNT_DISABLED: "ACCOUNT_DISABLED",
|
|
25
|
+
// Password validation errors
|
|
26
|
+
PASSWORD_INSECURE: "PASSWORD_INSECURE",
|
|
27
|
+
PASSWORD_LEN: "PASSWORD_LEN",
|
|
28
|
+
// Registration errors
|
|
29
|
+
ACCOUNT_EXISTS: "ACCOUNT_EXISTS",
|
|
30
|
+
// Invitation errors
|
|
31
|
+
INVITE_NOT_FOUND: "INVITE_NOT_FOUND",
|
|
32
|
+
INVITE_LIMIT: "INVITE_LIMIT",
|
|
33
|
+
INVITE_EMAIL_NOT_FOUND: "INVITE_EMAIL_NOT_FOUND"
|
|
34
|
+
};
|
|
35
|
+
var ERROR_MESSAGES = {
|
|
36
|
+
[ERROR_CODES.INVALID_CREDENTIALS]: "Invalid email or password.",
|
|
37
|
+
[ERROR_CODES.INCORRECT_PASSWORD]: "The password you entered is incorrect. Please try again.",
|
|
38
|
+
[ERROR_CODES.ACCOUNT_LOCKED_EXCEED_ATTEMPTS]: "Your account has been temporarily locked due to too many failed login attempts. Please try again later or reset your password.",
|
|
39
|
+
[ERROR_CODES.ACCOUNT_DISABLED]: "Your account has been disabled. Please contact support for assistance.",
|
|
40
|
+
[ERROR_CODES.PASSWORD_INSECURE]: "This password is not secure enough. Please choose a stronger password.",
|
|
41
|
+
[ERROR_CODES.PASSWORD_LEN]: "Password must be between 8 and 63 characters long.",
|
|
42
|
+
[ERROR_CODES.ACCOUNT_EXISTS]: "An account with this email already exists. Please sign in or use a different email.",
|
|
43
|
+
[ERROR_CODES.INVITE_NOT_FOUND]: "The invitation code is invalid or has expired. Please check the code or request a new invitation.",
|
|
44
|
+
[ERROR_CODES.INVITE_LIMIT]: "This invitation has reached its usage limit. Please request a new invitation.",
|
|
45
|
+
[ERROR_CODES.INVITE_EMAIL_NOT_FOUND]: "This email is not associated with the invitation. Please use the email address the invitation was sent to."
|
|
46
|
+
};
|
|
47
|
+
var DEFAULT_ERROR_MESSAGE = "Something went wrong. Please try again.";
|
|
48
|
+
var AuthError = class _AuthError extends Error {
|
|
49
|
+
code;
|
|
50
|
+
userMessage;
|
|
51
|
+
constructor(code, customMessage) {
|
|
52
|
+
const userMessage = customMessage ?? ERROR_MESSAGES[code];
|
|
53
|
+
super(userMessage);
|
|
54
|
+
this.name = "AuthError";
|
|
55
|
+
this.code = code;
|
|
56
|
+
this.userMessage = userMessage;
|
|
57
|
+
if (Error.captureStackTrace) {
|
|
58
|
+
Error.captureStackTrace(this, _AuthError);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if an error is an AuthError with a specific code.
|
|
63
|
+
*/
|
|
64
|
+
static isCode(error, code) {
|
|
65
|
+
return error instanceof _AuthError && error.code === code;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
function createInvalidCredentialsError() {
|
|
69
|
+
return new AuthError("INVALID_CREDENTIALS");
|
|
70
|
+
}
|
|
71
|
+
function isGraphQLErrorLike(value) {
|
|
72
|
+
if (!value || typeof value !== "object") return false;
|
|
73
|
+
return "message" in value || "extensions" in value;
|
|
74
|
+
}
|
|
75
|
+
function isValidationError(value) {
|
|
76
|
+
if (!value || typeof value !== "object") return false;
|
|
77
|
+
const err = value;
|
|
78
|
+
return err.name === "ZodError" && Array.isArray(err.issues) && err.issues.length > 0 && typeof err.issues[0]?.message === "string";
|
|
79
|
+
}
|
|
80
|
+
function extractErrorCode(error, knownCodes) {
|
|
81
|
+
if (error instanceof AuthError) {
|
|
82
|
+
return error.code;
|
|
83
|
+
}
|
|
84
|
+
if (error && typeof error === "object" && "errors" in error) {
|
|
85
|
+
const gqlErrors = error.errors;
|
|
86
|
+
if (Array.isArray(gqlErrors) && gqlErrors.length > 0) {
|
|
87
|
+
const firstError = gqlErrors[0];
|
|
88
|
+
if (firstError.extensions?.code) return String(firstError.extensions.code);
|
|
89
|
+
if (firstError.message) {
|
|
90
|
+
const codeMatch2 = firstError.message.match(/\(\s*[Cc]ode:\s*([A-Z_]+)\s*\)/);
|
|
91
|
+
if (codeMatch2) return codeMatch2[1];
|
|
92
|
+
for (const code of knownCodes) {
|
|
93
|
+
if (firstError.message.includes(code)) return code;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (isGraphQLErrorLike(error) && error.extensions?.code) {
|
|
99
|
+
return String(error.extensions.code);
|
|
100
|
+
}
|
|
101
|
+
if (error && typeof error === "object" && "code" in error) {
|
|
102
|
+
const code = error.code;
|
|
103
|
+
if (typeof code === "string") return code;
|
|
104
|
+
}
|
|
105
|
+
let message = null;
|
|
106
|
+
if (error instanceof Error) {
|
|
107
|
+
message = error.message;
|
|
108
|
+
} else if (isGraphQLErrorLike(error) && error.message) {
|
|
109
|
+
message = error.message;
|
|
110
|
+
} else if (typeof error === "string") {
|
|
111
|
+
message = error;
|
|
112
|
+
}
|
|
113
|
+
if (!message) return null;
|
|
114
|
+
const codeMatch = message.match(/\(\s*[Cc]ode:\s*([A-Z_]+)\s*\)/);
|
|
115
|
+
if (codeMatch) {
|
|
116
|
+
return codeMatch[1];
|
|
117
|
+
}
|
|
118
|
+
for (const code of knownCodes) {
|
|
119
|
+
if (message.includes(code)) {
|
|
120
|
+
return code;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
function isTechnicalMessage(message) {
|
|
126
|
+
const lower = message.toLowerCase();
|
|
127
|
+
return lower.includes("graphql") || lower.includes("fetch") || lower.includes("network") || lower.includes("econnrefused") || lower.includes("undefined") || lower.includes("null") || lower.includes("timeout") || lower.includes("connection") || lower.includes("socket") || lower.includes("enotfound") || lower.includes("abort");
|
|
128
|
+
}
|
|
129
|
+
function parseGraphQLError(error, options = {}) {
|
|
130
|
+
if (error instanceof AuthError) {
|
|
131
|
+
return {
|
|
132
|
+
code: error.code,
|
|
133
|
+
message: error.userMessage,
|
|
134
|
+
isKnownError: true,
|
|
135
|
+
originalError: error
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (isValidationError(error)) {
|
|
139
|
+
const firstIssue = error.issues[0];
|
|
140
|
+
const message2 = firstIssue?.message || "Validation failed. Please check your input.";
|
|
141
|
+
return {
|
|
142
|
+
code: "VALIDATION_ERROR",
|
|
143
|
+
message: message2,
|
|
144
|
+
isKnownError: true,
|
|
145
|
+
originalError: error
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const { defaultMessage = DEFAULT_ERROR_MESSAGE, customMessages = {} } = options;
|
|
149
|
+
const allMessages = { ...ERROR_MESSAGES, ...customMessages };
|
|
150
|
+
const allKnownCodes = Object.keys(allMessages);
|
|
151
|
+
const code = extractErrorCode(error, allKnownCodes);
|
|
152
|
+
const isKnown = code !== null && code in allMessages;
|
|
153
|
+
let message;
|
|
154
|
+
if (isKnown && code) {
|
|
155
|
+
message = allMessages[code];
|
|
156
|
+
} else {
|
|
157
|
+
if (error instanceof Error && error.message && !isTechnicalMessage(error.message)) {
|
|
158
|
+
message = error.message;
|
|
159
|
+
} else if (error instanceof Error && isTechnicalMessage(error.message) && "errors" in error && Array.isArray(error.errors)) {
|
|
160
|
+
const innerMsg = error.errors[0]?.message;
|
|
161
|
+
message = innerMsg && !isTechnicalMessage(innerMsg) ? innerMsg : defaultMessage;
|
|
162
|
+
} else {
|
|
163
|
+
message = defaultMessage;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
code: isKnown ? code : null,
|
|
168
|
+
message,
|
|
169
|
+
isKnownError: isKnown,
|
|
170
|
+
originalError: error
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// src/auth/auth-execute.ts
|
|
175
|
+
async function executeAuthMutation(config, query, variables) {
|
|
176
|
+
const url = config.authEndpoint || config.endpoint;
|
|
177
|
+
if (!url) {
|
|
178
|
+
throw new Error("No auth endpoint configured.");
|
|
179
|
+
}
|
|
180
|
+
const headers = {
|
|
181
|
+
"Content-Type": "application/json",
|
|
182
|
+
Accept: "application/graphql-response+json"
|
|
183
|
+
};
|
|
184
|
+
let response;
|
|
185
|
+
try {
|
|
186
|
+
response = await fetch(url, {
|
|
187
|
+
method: "POST",
|
|
188
|
+
headers,
|
|
189
|
+
body: JSON.stringify({
|
|
190
|
+
query,
|
|
191
|
+
...variables !== void 0 && { variables }
|
|
192
|
+
})
|
|
193
|
+
});
|
|
194
|
+
} catch (error) {
|
|
195
|
+
throw new Error(
|
|
196
|
+
`Network error: ${error instanceof Error ? error.message : "Failed to connect to auth endpoint"}`
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
if (!response.ok) {
|
|
200
|
+
const { status, statusText } = response;
|
|
201
|
+
try {
|
|
202
|
+
const body = await response.json();
|
|
203
|
+
if (body.errors?.length) {
|
|
204
|
+
const firstError = body.errors[0];
|
|
205
|
+
const err = new Error(firstError.message || `Auth request failed: ${status}`);
|
|
206
|
+
err.code = firstError.extensions?.code;
|
|
207
|
+
err.errors = body.errors;
|
|
208
|
+
throw err;
|
|
209
|
+
}
|
|
210
|
+
} catch (e) {
|
|
211
|
+
if (e instanceof Error && e.errors) throw e;
|
|
212
|
+
}
|
|
213
|
+
throw new Error(`Auth request failed: ${status} ${statusText}`);
|
|
214
|
+
}
|
|
215
|
+
const result = await response.json();
|
|
216
|
+
if (result.errors?.length) {
|
|
217
|
+
const firstError = result.errors[0];
|
|
218
|
+
const err = new Error(firstError.message || "Auth mutation failed");
|
|
219
|
+
err.code = firstError.extensions?.code;
|
|
220
|
+
err.errors = result.errors;
|
|
221
|
+
throw err;
|
|
222
|
+
}
|
|
223
|
+
return result.data;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/auth/auth-types.ts
|
|
227
|
+
function toAuthToken(record) {
|
|
228
|
+
if (!record?.accessToken || !record?.accessTokenExpiresAt) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
accessToken: record.accessToken,
|
|
233
|
+
expiresAt: record.accessTokenExpiresAt
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// src/auth/hooks/use-login.ts
|
|
238
|
+
var SIGN_IN_MUTATION = (
|
|
239
|
+
/* GraphQL */
|
|
240
|
+
`
|
|
241
|
+
mutation SignIn($input: SignInInput!) {
|
|
242
|
+
signIn(input: $input) {
|
|
243
|
+
result {
|
|
244
|
+
id
|
|
245
|
+
userId
|
|
246
|
+
accessToken
|
|
247
|
+
accessTokenExpiresAt
|
|
248
|
+
isVerified
|
|
249
|
+
totpEnabled
|
|
250
|
+
}
|
|
251
|
+
clientMutationId
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
`
|
|
255
|
+
);
|
|
256
|
+
function useSheetsLogin() {
|
|
257
|
+
const queryClient = useQueryClient();
|
|
258
|
+
const { config } = useSheetsContext();
|
|
259
|
+
const storeApi = useSheetsStoreApi();
|
|
260
|
+
return useMutation({
|
|
261
|
+
mutationKey: ["sheets", "auth", "signIn"],
|
|
262
|
+
mutationFn: async (credentials) => {
|
|
263
|
+
const result = await executeAuthMutation(
|
|
264
|
+
config,
|
|
265
|
+
SIGN_IN_MUTATION,
|
|
266
|
+
{
|
|
267
|
+
input: {
|
|
268
|
+
email: credentials.email,
|
|
269
|
+
password: credentials.password,
|
|
270
|
+
rememberMe: credentials.rememberMe
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
const signInResult = result.signIn?.result;
|
|
275
|
+
if (!signInResult) {
|
|
276
|
+
throw createInvalidCredentialsError();
|
|
277
|
+
}
|
|
278
|
+
const token = toAuthToken(signInResult);
|
|
279
|
+
if (!token) {
|
|
280
|
+
throw createInvalidCredentialsError();
|
|
281
|
+
}
|
|
282
|
+
return { token, email: credentials.email };
|
|
283
|
+
},
|
|
284
|
+
onSuccess: ({ token }) => {
|
|
285
|
+
const databaseId = config.databaseId || "default";
|
|
286
|
+
setStoredToken(databaseId, token.accessToken, token.expiresAt);
|
|
287
|
+
storeApi.getState().setAuthenticated(token.accessToken, token.expiresAt);
|
|
288
|
+
queryClient.invalidateQueries({ queryKey: ["sheets"] });
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// src/auth/hooks/use-register.ts
|
|
294
|
+
import { useMutation as useMutation2, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
295
|
+
var SIGN_UP_MUTATION = (
|
|
296
|
+
/* GraphQL */
|
|
297
|
+
`
|
|
298
|
+
mutation SignUp($input: SignUpInput!) {
|
|
299
|
+
signUp(input: $input) {
|
|
300
|
+
result {
|
|
301
|
+
id
|
|
302
|
+
userId
|
|
303
|
+
accessToken
|
|
304
|
+
accessTokenExpiresAt
|
|
305
|
+
isVerified
|
|
306
|
+
totpEnabled
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
`
|
|
311
|
+
);
|
|
312
|
+
function useSheetsRegister() {
|
|
313
|
+
const queryClient = useQueryClient2();
|
|
314
|
+
const { config } = useSheetsContext();
|
|
315
|
+
const storeApi = useSheetsStoreApi();
|
|
316
|
+
return useMutation2({
|
|
317
|
+
mutationKey: ["sheets", "auth", "signUp"],
|
|
318
|
+
mutationFn: async (formData) => {
|
|
319
|
+
const result = await executeAuthMutation(
|
|
320
|
+
config,
|
|
321
|
+
SIGN_UP_MUTATION,
|
|
322
|
+
{
|
|
323
|
+
input: {
|
|
324
|
+
email: formData.email,
|
|
325
|
+
password: formData.password,
|
|
326
|
+
rememberMe: formData.rememberMe ?? true
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
const signUpResult = result.signUp?.result;
|
|
331
|
+
const token = signUpResult ? toAuthToken(signUpResult) : null;
|
|
332
|
+
return { token, email: formData.email };
|
|
333
|
+
},
|
|
334
|
+
onSuccess: ({ token }) => {
|
|
335
|
+
if (token) {
|
|
336
|
+
const databaseId = config.databaseId || "default";
|
|
337
|
+
setStoredToken(databaseId, token.accessToken, token.expiresAt);
|
|
338
|
+
storeApi.getState().setAuthenticated(token.accessToken, token.expiresAt);
|
|
339
|
+
}
|
|
340
|
+
queryClient.invalidateQueries({ queryKey: ["sheets"] });
|
|
341
|
+
},
|
|
342
|
+
onError: () => {
|
|
343
|
+
storeApi.getState().setUnauthenticated();
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/auth/hooks/use-forgot-password.ts
|
|
349
|
+
import { useMutation as useMutation3 } from "@tanstack/react-query";
|
|
350
|
+
var FORGOT_PASSWORD_MUTATION = (
|
|
351
|
+
/* GraphQL */
|
|
352
|
+
`
|
|
353
|
+
mutation ForgotPassword($input: ForgotPasswordInput!) {
|
|
354
|
+
forgotPassword(input: $input) {
|
|
355
|
+
clientMutationId
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
`
|
|
359
|
+
);
|
|
360
|
+
function useSheetsForgotPassword() {
|
|
361
|
+
const { config } = useSheetsContext();
|
|
362
|
+
return useMutation3({
|
|
363
|
+
mutationKey: ["sheets", "auth", "forgotPassword"],
|
|
364
|
+
mutationFn: async ({ email }) => {
|
|
365
|
+
await executeAuthMutation(
|
|
366
|
+
config,
|
|
367
|
+
FORGOT_PASSWORD_MUTATION,
|
|
368
|
+
{
|
|
369
|
+
input: { email }
|
|
370
|
+
}
|
|
371
|
+
);
|
|
372
|
+
return { email };
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// src/auth/hooks/use-reset-password.ts
|
|
378
|
+
import { useMutation as useMutation4, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
379
|
+
var RESET_PASSWORD_MUTATION = (
|
|
380
|
+
/* GraphQL */
|
|
381
|
+
`
|
|
382
|
+
mutation ResetPassword($input: ResetPasswordInput!) {
|
|
383
|
+
resetPassword(input: $input) {
|
|
384
|
+
result
|
|
385
|
+
clientMutationId
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
`
|
|
389
|
+
);
|
|
390
|
+
function useSheetsResetPassword() {
|
|
391
|
+
const queryClient = useQueryClient3();
|
|
392
|
+
const { config } = useSheetsContext();
|
|
393
|
+
return useMutation4({
|
|
394
|
+
mutationKey: ["sheets", "auth", "resetPassword"],
|
|
395
|
+
mutationFn: async (input) => {
|
|
396
|
+
const result = await executeAuthMutation(
|
|
397
|
+
config,
|
|
398
|
+
RESET_PASSWORD_MUTATION,
|
|
399
|
+
{
|
|
400
|
+
input: {
|
|
401
|
+
newPassword: input.newPassword,
|
|
402
|
+
resetToken: input.resetToken,
|
|
403
|
+
roleId: input.roleId
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
);
|
|
407
|
+
if (!result.resetPassword?.result) {
|
|
408
|
+
throw new Error("Failed to reset password. The link may have expired.");
|
|
409
|
+
}
|
|
410
|
+
return { success: true };
|
|
411
|
+
},
|
|
412
|
+
onSuccess: () => {
|
|
413
|
+
queryClient.invalidateQueries({ queryKey: ["sheets"] });
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// src/auth/auth-gate.tsx
|
|
419
|
+
import { useState as useState5 } from "react";
|
|
420
|
+
|
|
421
|
+
// src/auth/ui/login-form.tsx
|
|
422
|
+
import { useRef, useState } from "react";
|
|
423
|
+
import { useForm } from "@tanstack/react-form";
|
|
424
|
+
|
|
425
|
+
// src/auth/utils/schemas.ts
|
|
426
|
+
import { z } from "zod";
|
|
427
|
+
var passwordSchema = z.string().min(8, "Password must be at least 8 characters").regex(
|
|
428
|
+
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]/,
|
|
429
|
+
"Password must contain uppercase, lowercase, number, and special character"
|
|
430
|
+
);
|
|
431
|
+
var emailSchema = z.string().email("Please enter a valid email address");
|
|
432
|
+
var loginSchema = z.object({
|
|
433
|
+
email: emailSchema,
|
|
434
|
+
password: z.string().min(1, "Password is required"),
|
|
435
|
+
rememberMe: z.boolean().optional()
|
|
436
|
+
});
|
|
437
|
+
var registerSchema = z.object({
|
|
438
|
+
email: emailSchema,
|
|
439
|
+
password: z.string().min(1, "Password is required"),
|
|
440
|
+
confirmPassword: z.string().min(1, "Please confirm your password"),
|
|
441
|
+
rememberMe: z.boolean().optional()
|
|
442
|
+
}).refine((data) => data.password === data.confirmPassword, {
|
|
443
|
+
message: "Passwords do not match",
|
|
444
|
+
path: ["confirmPassword"]
|
|
445
|
+
});
|
|
446
|
+
var forgotPasswordSchema = z.object({
|
|
447
|
+
email: emailSchema
|
|
448
|
+
});
|
|
449
|
+
var resetPasswordSchema = z.object({
|
|
450
|
+
password: passwordSchema,
|
|
451
|
+
confirmPassword: z.string(),
|
|
452
|
+
token: z.string().min(1, "Reset token is required")
|
|
453
|
+
}).refine((data) => data.password === data.confirmPassword, {
|
|
454
|
+
message: "Passwords do not match",
|
|
455
|
+
path: ["confirmPassword"]
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
// src/auth/ui/login-form.tsx
|
|
459
|
+
import { Button as Button2 } from "@constructive-io/ui/button";
|
|
460
|
+
import { Checkbox } from "@constructive-io/ui/checkbox";
|
|
461
|
+
|
|
462
|
+
// src/auth/ui/auth-error-alert.tsx
|
|
463
|
+
import { AlertCircleIcon } from "lucide-react";
|
|
464
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
465
|
+
function AuthErrorAlert({ error, className }) {
|
|
466
|
+
const hasError = Boolean(error);
|
|
467
|
+
return /* @__PURE__ */ jsx(
|
|
468
|
+
"div",
|
|
469
|
+
{
|
|
470
|
+
role: "alert",
|
|
471
|
+
"aria-live": "polite",
|
|
472
|
+
"aria-hidden": !hasError,
|
|
473
|
+
className: cn(
|
|
474
|
+
"overflow-hidden transition-all duration-300 ease-out",
|
|
475
|
+
hasError ? "max-h-32" : "max-h-0",
|
|
476
|
+
className
|
|
477
|
+
),
|
|
478
|
+
children: /* @__PURE__ */ jsxs(
|
|
479
|
+
"div",
|
|
480
|
+
{
|
|
481
|
+
className: cn(
|
|
482
|
+
"flex items-start gap-2.5 rounded-md px-3 py-2.5",
|
|
483
|
+
"bg-destructive/8 border border-destructive/20",
|
|
484
|
+
"text-destructive text-sm text-left",
|
|
485
|
+
"transition-opacity duration-200",
|
|
486
|
+
hasError ? "opacity-100" : "opacity-0"
|
|
487
|
+
),
|
|
488
|
+
children: [
|
|
489
|
+
/* @__PURE__ */ jsx(AlertCircleIcon, { className: "mt-0.5 h-4 w-4 shrink-0" }),
|
|
490
|
+
/* @__PURE__ */ jsx("span", { className: "text-pretty leading-snug", children: error })
|
|
491
|
+
]
|
|
492
|
+
}
|
|
493
|
+
)
|
|
494
|
+
}
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// src/auth/ui/auth-loading-button.tsx
|
|
499
|
+
import { LoaderIcon } from "lucide-react";
|
|
500
|
+
import { Button } from "@constructive-io/ui/button";
|
|
501
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
502
|
+
function AuthLoadingButton({
|
|
503
|
+
children,
|
|
504
|
+
isLoading,
|
|
505
|
+
loadingText = "Please wait...",
|
|
506
|
+
disabled,
|
|
507
|
+
className,
|
|
508
|
+
...props
|
|
509
|
+
}) {
|
|
510
|
+
return /* @__PURE__ */ jsxs2(Button, { disabled: disabled || isLoading, className: cn("relative", className), ...props, children: [
|
|
511
|
+
isLoading && /* @__PURE__ */ jsx2(LoaderIcon, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
512
|
+
isLoading ? loadingText : children
|
|
513
|
+
] });
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// src/auth/ui/form-field.tsx
|
|
517
|
+
import { Input } from "@constructive-io/ui/input";
|
|
518
|
+
import { FormControl } from "@constructive-io/ui/form-control";
|
|
519
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
520
|
+
function FormField({
|
|
521
|
+
field,
|
|
522
|
+
label,
|
|
523
|
+
placeholder,
|
|
524
|
+
type = "text",
|
|
525
|
+
className,
|
|
526
|
+
layout = "floating",
|
|
527
|
+
inputRef,
|
|
528
|
+
testId
|
|
529
|
+
}) {
|
|
530
|
+
const errors = field.state.meta.errors?.filter(Boolean) ?? [];
|
|
531
|
+
const hasError = errors.length > 0;
|
|
532
|
+
const errorMessage = errors[0];
|
|
533
|
+
return /* @__PURE__ */ jsx3(
|
|
534
|
+
FormControl,
|
|
535
|
+
{
|
|
536
|
+
label,
|
|
537
|
+
id: field.name,
|
|
538
|
+
layout,
|
|
539
|
+
error: hasError ? errorMessage : void 0,
|
|
540
|
+
className,
|
|
541
|
+
children: /* @__PURE__ */ jsx3(
|
|
542
|
+
Input,
|
|
543
|
+
{
|
|
544
|
+
ref: inputRef,
|
|
545
|
+
name: field.name,
|
|
546
|
+
"data-testid": testId ?? field.name,
|
|
547
|
+
type,
|
|
548
|
+
placeholder,
|
|
549
|
+
value: field.state.value || "",
|
|
550
|
+
onChange: (e) => field.handleChange(e.target.value),
|
|
551
|
+
onBlur: field.handleBlur
|
|
552
|
+
}
|
|
553
|
+
)
|
|
554
|
+
}
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// src/auth/ui/login-form.tsx
|
|
559
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
560
|
+
function SheetsLoginForm({ onLogin, onShowForgot, onShowRegister, defaultEmail = "" }) {
|
|
561
|
+
const [error, setError] = useState(null);
|
|
562
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
563
|
+
const passwordInputRef = useRef(null);
|
|
564
|
+
const form = useForm({
|
|
565
|
+
defaultValues: {
|
|
566
|
+
email: defaultEmail,
|
|
567
|
+
password: "",
|
|
568
|
+
rememberMe: true
|
|
569
|
+
},
|
|
570
|
+
onSubmit: async ({ value }) => {
|
|
571
|
+
setError(null);
|
|
572
|
+
setIsSubmitting(true);
|
|
573
|
+
try {
|
|
574
|
+
const validatedData = loginSchema.parse(value);
|
|
575
|
+
await onLogin(validatedData);
|
|
576
|
+
} catch (err) {
|
|
577
|
+
setError(parseGraphQLError(err).message);
|
|
578
|
+
} finally {
|
|
579
|
+
setIsSubmitting(false);
|
|
580
|
+
}
|
|
581
|
+
},
|
|
582
|
+
validators: {
|
|
583
|
+
onChange: ({ value }) => {
|
|
584
|
+
const result = loginSchema.safeParse(value);
|
|
585
|
+
if (!result.success) {
|
|
586
|
+
return result.error.issues.map((issue) => issue.message).join(", ");
|
|
587
|
+
}
|
|
588
|
+
return void 0;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
return /* @__PURE__ */ jsxs3("div", { className: "space-y-5", children: [
|
|
593
|
+
/* @__PURE__ */ jsxs3(
|
|
594
|
+
"form",
|
|
595
|
+
{
|
|
596
|
+
onSubmit: (e) => {
|
|
597
|
+
e.preventDefault();
|
|
598
|
+
e.stopPropagation();
|
|
599
|
+
form.handleSubmit();
|
|
600
|
+
},
|
|
601
|
+
className: "space-y-4 px-8",
|
|
602
|
+
children: [
|
|
603
|
+
/* @__PURE__ */ jsx4(AuthErrorAlert, { error }),
|
|
604
|
+
/* @__PURE__ */ jsx4(
|
|
605
|
+
form.Field,
|
|
606
|
+
{
|
|
607
|
+
name: "email",
|
|
608
|
+
validators: {
|
|
609
|
+
onChange: ({ value }) => {
|
|
610
|
+
if (!value) return "Email is required";
|
|
611
|
+
if (!/\S+@\S+\.\S+/.test(value)) return "Please enter a valid email";
|
|
612
|
+
return void 0;
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
children: (field) => /* @__PURE__ */ jsx4(
|
|
616
|
+
FormField,
|
|
617
|
+
{
|
|
618
|
+
field,
|
|
619
|
+
label: "Email",
|
|
620
|
+
placeholder: "Enter your email",
|
|
621
|
+
type: "email"
|
|
622
|
+
}
|
|
623
|
+
)
|
|
624
|
+
}
|
|
625
|
+
),
|
|
626
|
+
/* @__PURE__ */ jsx4(
|
|
627
|
+
form.Field,
|
|
628
|
+
{
|
|
629
|
+
name: "password",
|
|
630
|
+
validators: {
|
|
631
|
+
onChange: ({ value }) => {
|
|
632
|
+
if (!value) return "Password is required";
|
|
633
|
+
return void 0;
|
|
634
|
+
}
|
|
635
|
+
},
|
|
636
|
+
children: (field) => /* @__PURE__ */ jsx4(
|
|
637
|
+
FormField,
|
|
638
|
+
{
|
|
639
|
+
field,
|
|
640
|
+
label: "Password",
|
|
641
|
+
placeholder: "Enter your password",
|
|
642
|
+
type: "password",
|
|
643
|
+
inputRef: passwordInputRef
|
|
644
|
+
}
|
|
645
|
+
)
|
|
646
|
+
}
|
|
647
|
+
),
|
|
648
|
+
/* @__PURE__ */ jsx4(form.Field, { name: "rememberMe", children: (field) => /* @__PURE__ */ jsxs3("div", { className: "flex items-center space-x-2", children: [
|
|
649
|
+
/* @__PURE__ */ jsx4(
|
|
650
|
+
Checkbox,
|
|
651
|
+
{
|
|
652
|
+
id: "rememberMe",
|
|
653
|
+
checked: field.state.value,
|
|
654
|
+
onCheckedChange: (checked) => {
|
|
655
|
+
field.handleChange(checked === true);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
),
|
|
659
|
+
/* @__PURE__ */ jsx4(
|
|
660
|
+
"label",
|
|
661
|
+
{
|
|
662
|
+
htmlFor: "rememberMe",
|
|
663
|
+
className: "text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
664
|
+
children: "Remember me"
|
|
665
|
+
}
|
|
666
|
+
)
|
|
667
|
+
] }) }),
|
|
668
|
+
/* @__PURE__ */ jsxs3("div", { className: "space-y-3 pt-2", children: [
|
|
669
|
+
/* @__PURE__ */ jsx4(
|
|
670
|
+
AuthLoadingButton,
|
|
671
|
+
{
|
|
672
|
+
type: "submit",
|
|
673
|
+
className: "w-full",
|
|
674
|
+
isLoading: isSubmitting,
|
|
675
|
+
disabled: isSubmitting,
|
|
676
|
+
"data-testid": "auth-login-submit",
|
|
677
|
+
children: "Sign In"
|
|
678
|
+
}
|
|
679
|
+
),
|
|
680
|
+
onShowForgot && /* @__PURE__ */ jsx4("div", { className: "text-center", children: /* @__PURE__ */ jsx4(
|
|
681
|
+
Button2,
|
|
682
|
+
{
|
|
683
|
+
variant: "link",
|
|
684
|
+
className: "text-muted-foreground hover:text-foreground h-auto p-0 text-sm",
|
|
685
|
+
onClick: onShowForgot,
|
|
686
|
+
type: "button",
|
|
687
|
+
"data-testid": "auth-forgot-link",
|
|
688
|
+
children: "Forgot your password?"
|
|
689
|
+
}
|
|
690
|
+
) })
|
|
691
|
+
] })
|
|
692
|
+
]
|
|
693
|
+
}
|
|
694
|
+
),
|
|
695
|
+
onShowRegister && /* @__PURE__ */ jsx4("div", { className: "border-border/40 border-t pt-5", children: /* @__PURE__ */ jsxs3("p", { className: "text-muted-foreground text-center text-sm", children: [
|
|
696
|
+
"Don't have an account?",
|
|
697
|
+
" ",
|
|
698
|
+
/* @__PURE__ */ jsx4(
|
|
699
|
+
Button2,
|
|
700
|
+
{
|
|
701
|
+
variant: "link",
|
|
702
|
+
className: "text-primary hover:text-primary/80 h-auto p-0 font-medium",
|
|
703
|
+
onClick: onShowRegister,
|
|
704
|
+
type: "button",
|
|
705
|
+
children: "Sign up"
|
|
706
|
+
}
|
|
707
|
+
)
|
|
708
|
+
] }) })
|
|
709
|
+
] });
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// src/auth/ui/register-form.tsx
|
|
713
|
+
import { useRef as useRef2, useState as useState2 } from "react";
|
|
714
|
+
import { useForm as useForm2 } from "@tanstack/react-form";
|
|
715
|
+
import { Button as Button3 } from "@constructive-io/ui/button";
|
|
716
|
+
import { Checkbox as Checkbox2 } from "@constructive-io/ui/checkbox";
|
|
717
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
718
|
+
function SheetsRegisterForm({ onRegister, onShowLogin, defaultEmail = "" }) {
|
|
719
|
+
const [error, setError] = useState2(null);
|
|
720
|
+
const [isSubmitting, setIsSubmitting] = useState2(false);
|
|
721
|
+
const passwordInputRef = useRef2(null);
|
|
722
|
+
const form = useForm2({
|
|
723
|
+
defaultValues: {
|
|
724
|
+
email: defaultEmail,
|
|
725
|
+
password: "",
|
|
726
|
+
confirmPassword: "",
|
|
727
|
+
rememberMe: true
|
|
728
|
+
},
|
|
729
|
+
onSubmit: async ({ value }) => {
|
|
730
|
+
setError(null);
|
|
731
|
+
setIsSubmitting(true);
|
|
732
|
+
try {
|
|
733
|
+
const validatedData = registerSchema.parse(value);
|
|
734
|
+
await onRegister(validatedData);
|
|
735
|
+
} catch (err) {
|
|
736
|
+
setError(parseGraphQLError(err).message);
|
|
737
|
+
} finally {
|
|
738
|
+
setIsSubmitting(false);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
return /* @__PURE__ */ jsxs4("div", { className: "space-y-5", children: [
|
|
743
|
+
/* @__PURE__ */ jsxs4(
|
|
744
|
+
"form",
|
|
745
|
+
{
|
|
746
|
+
onSubmit: (e) => {
|
|
747
|
+
e.preventDefault();
|
|
748
|
+
e.stopPropagation();
|
|
749
|
+
form.handleSubmit();
|
|
750
|
+
},
|
|
751
|
+
className: "space-y-4 px-8 pb-2",
|
|
752
|
+
children: [
|
|
753
|
+
/* @__PURE__ */ jsx5(AuthErrorAlert, { error }),
|
|
754
|
+
/* @__PURE__ */ jsx5(form.Field, { name: "email", children: (field) => /* @__PURE__ */ jsx5(
|
|
755
|
+
FormField,
|
|
756
|
+
{
|
|
757
|
+
field,
|
|
758
|
+
label: "Email",
|
|
759
|
+
placeholder: "Enter your email",
|
|
760
|
+
type: "email"
|
|
761
|
+
}
|
|
762
|
+
) }),
|
|
763
|
+
/* @__PURE__ */ jsx5(form.Field, { name: "password", children: (field) => /* @__PURE__ */ jsx5(
|
|
764
|
+
FormField,
|
|
765
|
+
{
|
|
766
|
+
field,
|
|
767
|
+
label: "Password",
|
|
768
|
+
placeholder: "Enter your password",
|
|
769
|
+
type: "password",
|
|
770
|
+
inputRef: passwordInputRef
|
|
771
|
+
}
|
|
772
|
+
) }),
|
|
773
|
+
/* @__PURE__ */ jsx5(form.Field, { name: "confirmPassword", children: (field) => /* @__PURE__ */ jsx5(
|
|
774
|
+
FormField,
|
|
775
|
+
{
|
|
776
|
+
field,
|
|
777
|
+
label: "Confirm Password",
|
|
778
|
+
placeholder: "Confirm your password",
|
|
779
|
+
type: "password"
|
|
780
|
+
}
|
|
781
|
+
) }),
|
|
782
|
+
/* @__PURE__ */ jsx5(form.Field, { name: "rememberMe", children: (field) => /* @__PURE__ */ jsxs4("div", { className: "flex items-center space-x-2", children: [
|
|
783
|
+
/* @__PURE__ */ jsx5(
|
|
784
|
+
Checkbox2,
|
|
785
|
+
{
|
|
786
|
+
id: "rememberMe",
|
|
787
|
+
checked: field.state.value,
|
|
788
|
+
onCheckedChange: (checked) => {
|
|
789
|
+
field.handleChange(checked === true);
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
),
|
|
793
|
+
/* @__PURE__ */ jsx5(
|
|
794
|
+
"label",
|
|
795
|
+
{
|
|
796
|
+
htmlFor: "rememberMe",
|
|
797
|
+
className: "text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
798
|
+
children: "Remember me"
|
|
799
|
+
}
|
|
800
|
+
)
|
|
801
|
+
] }) }),
|
|
802
|
+
/* @__PURE__ */ jsx5("div", { className: "pt-2", children: /* @__PURE__ */ jsx5(
|
|
803
|
+
AuthLoadingButton,
|
|
804
|
+
{
|
|
805
|
+
type: "submit",
|
|
806
|
+
className: "w-full",
|
|
807
|
+
isLoading: isSubmitting,
|
|
808
|
+
disabled: isSubmitting,
|
|
809
|
+
"data-testid": "auth-signup-submit",
|
|
810
|
+
children: "Create Account"
|
|
811
|
+
}
|
|
812
|
+
) })
|
|
813
|
+
]
|
|
814
|
+
}
|
|
815
|
+
),
|
|
816
|
+
onShowLogin && /* @__PURE__ */ jsx5("div", { className: "border-border/40 border-t pt-5", children: /* @__PURE__ */ jsxs4("p", { className: "text-muted-foreground text-center text-sm", children: [
|
|
817
|
+
"Already have an account?",
|
|
818
|
+
" ",
|
|
819
|
+
/* @__PURE__ */ jsx5(
|
|
820
|
+
Button3,
|
|
821
|
+
{
|
|
822
|
+
variant: "link",
|
|
823
|
+
className: "text-primary hover:text-primary/80 h-auto p-0 font-medium",
|
|
824
|
+
onClick: onShowLogin,
|
|
825
|
+
type: "button",
|
|
826
|
+
"data-testid": "auth-signup-login-link",
|
|
827
|
+
children: "Sign in"
|
|
828
|
+
}
|
|
829
|
+
)
|
|
830
|
+
] }) })
|
|
831
|
+
] });
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// src/auth/ui/forgot-password-form.tsx
|
|
835
|
+
import { useState as useState3 } from "react";
|
|
836
|
+
import { useForm as useForm3 } from "@tanstack/react-form";
|
|
837
|
+
import { CheckCircleIcon } from "lucide-react";
|
|
838
|
+
import { Button as Button4 } from "@constructive-io/ui/button";
|
|
839
|
+
|
|
840
|
+
// src/auth/ui/auth-screen-header.tsx
|
|
841
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
842
|
+
function AuthScreenHeader({
|
|
843
|
+
title,
|
|
844
|
+
description,
|
|
845
|
+
logo,
|
|
846
|
+
appName,
|
|
847
|
+
showLogo = true,
|
|
848
|
+
className
|
|
849
|
+
}) {
|
|
850
|
+
return /* @__PURE__ */ jsxs5("div", { className: cn("space-y-4 text-center", className), children: [
|
|
851
|
+
showLogo && logo ? /* @__PURE__ */ jsx6("div", { className: "flex items-center justify-center", children: logo }) : null,
|
|
852
|
+
appName ? /* @__PURE__ */ jsx6("span", { className: "text-primary text-[15px] font-semibold tracking-tight", children: appName }) : null,
|
|
853
|
+
/* @__PURE__ */ jsxs5("div", { className: "space-y-1.5", children: [
|
|
854
|
+
/* @__PURE__ */ jsx6(
|
|
855
|
+
"h2",
|
|
856
|
+
{
|
|
857
|
+
className: "from-foreground via-foreground to-foreground/70 bg-linear-to-br bg-clip-text text-xl\n font-semibold tracking-tight text-transparent",
|
|
858
|
+
children: title
|
|
859
|
+
}
|
|
860
|
+
),
|
|
861
|
+
description ? /* @__PURE__ */ jsx6("p", { className: "text-muted-foreground text-[13px] leading-relaxed", children: description }) : null
|
|
862
|
+
] })
|
|
863
|
+
] });
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// src/auth/ui/forgot-password-form.tsx
|
|
867
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
868
|
+
function SheetsForgotPasswordForm({ onForgotPassword, onShowLogin }) {
|
|
869
|
+
const [error, setError] = useState3(null);
|
|
870
|
+
const [isSubmitting, setIsSubmitting] = useState3(false);
|
|
871
|
+
const [isSuccess, setIsSuccess] = useState3(false);
|
|
872
|
+
const form = useForm3({
|
|
873
|
+
defaultValues: {
|
|
874
|
+
email: ""
|
|
875
|
+
},
|
|
876
|
+
onSubmit: async ({ value }) => {
|
|
877
|
+
setError(null);
|
|
878
|
+
setIsSubmitting(true);
|
|
879
|
+
try {
|
|
880
|
+
const validatedData = forgotPasswordSchema.parse(value);
|
|
881
|
+
await onForgotPassword(validatedData);
|
|
882
|
+
setIsSuccess(true);
|
|
883
|
+
} catch (err) {
|
|
884
|
+
setError(parseGraphQLError(err).message);
|
|
885
|
+
} finally {
|
|
886
|
+
setIsSubmitting(false);
|
|
887
|
+
}
|
|
888
|
+
},
|
|
889
|
+
validators: {
|
|
890
|
+
onChange: ({ value }) => {
|
|
891
|
+
const result = forgotPasswordSchema.safeParse(value);
|
|
892
|
+
if (!result.success) {
|
|
893
|
+
return result.error.issues.map((issue) => issue.message).join(", ");
|
|
894
|
+
}
|
|
895
|
+
return void 0;
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
if (isSuccess) {
|
|
900
|
+
return /* @__PURE__ */ jsxs6("div", { className: "space-y-5 text-center", children: [
|
|
901
|
+
/* @__PURE__ */ jsx7("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx7("div", { className: "bg-success/10 flex h-12 w-12 items-center justify-center rounded-full", children: /* @__PURE__ */ jsx7(CheckCircleIcon, { className: "text-success h-6 w-6" }) }) }),
|
|
902
|
+
/* @__PURE__ */ jsxs6("div", { className: "space-y-1.5", children: [
|
|
903
|
+
/* @__PURE__ */ jsx7("h3", { className: "text-lg font-semibold", children: "Check your email" }),
|
|
904
|
+
/* @__PURE__ */ jsx7("p", { className: "text-muted-foreground text-sm", children: "We've sent a password reset link to your email address." })
|
|
905
|
+
] }),
|
|
906
|
+
onShowLogin && /* @__PURE__ */ jsx7("div", { className: "pt-1", children: /* @__PURE__ */ jsx7(Button4, { variant: "outline", type: "button", onClick: onShowLogin, className: "w-full", children: "Back to sign in" }) })
|
|
907
|
+
] });
|
|
908
|
+
}
|
|
909
|
+
return /* @__PURE__ */ jsxs6("div", { className: "space-y-5", children: [
|
|
910
|
+
/* @__PURE__ */ jsx7(AuthScreenHeader, { title: "Reset your password", description: "We'll send you a password reset link" }),
|
|
911
|
+
/* @__PURE__ */ jsxs6(
|
|
912
|
+
"form",
|
|
913
|
+
{
|
|
914
|
+
onSubmit: (e) => {
|
|
915
|
+
e.preventDefault();
|
|
916
|
+
e.stopPropagation();
|
|
917
|
+
form.handleSubmit();
|
|
918
|
+
},
|
|
919
|
+
className: "space-y-4 px-8",
|
|
920
|
+
children: [
|
|
921
|
+
/* @__PURE__ */ jsx7(AuthErrorAlert, { error }),
|
|
922
|
+
/* @__PURE__ */ jsx7(
|
|
923
|
+
form.Field,
|
|
924
|
+
{
|
|
925
|
+
name: "email",
|
|
926
|
+
validators: {
|
|
927
|
+
onChange: ({ value }) => {
|
|
928
|
+
if (!value) return "Email is required";
|
|
929
|
+
if (!/\S+@\S+\.\S+/.test(value)) return "Please enter a valid email";
|
|
930
|
+
return void 0;
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
children: (field) => /* @__PURE__ */ jsx7(
|
|
934
|
+
FormField,
|
|
935
|
+
{
|
|
936
|
+
field,
|
|
937
|
+
label: "Email",
|
|
938
|
+
placeholder: "Enter your email",
|
|
939
|
+
type: "email"
|
|
940
|
+
}
|
|
941
|
+
)
|
|
942
|
+
}
|
|
943
|
+
),
|
|
944
|
+
/* @__PURE__ */ jsx7("div", { className: "pt-2", children: /* @__PURE__ */ jsx7(
|
|
945
|
+
AuthLoadingButton,
|
|
946
|
+
{
|
|
947
|
+
type: "submit",
|
|
948
|
+
className: "w-full",
|
|
949
|
+
isLoading: isSubmitting,
|
|
950
|
+
disabled: isSubmitting,
|
|
951
|
+
"data-testid": "auth-forgot-submit",
|
|
952
|
+
children: "Send Reset Link"
|
|
953
|
+
}
|
|
954
|
+
) })
|
|
955
|
+
]
|
|
956
|
+
}
|
|
957
|
+
),
|
|
958
|
+
onShowLogin && /* @__PURE__ */ jsxs6("div", { className: "text-muted-foreground text-center text-sm", children: [
|
|
959
|
+
"Remember your password?",
|
|
960
|
+
" ",
|
|
961
|
+
/* @__PURE__ */ jsx7(
|
|
962
|
+
Button4,
|
|
963
|
+
{
|
|
964
|
+
variant: "link",
|
|
965
|
+
className: "text-primary hover:text-primary/80 h-auto p-0 font-medium",
|
|
966
|
+
onClick: onShowLogin,
|
|
967
|
+
type: "button",
|
|
968
|
+
children: "Sign in"
|
|
969
|
+
}
|
|
970
|
+
)
|
|
971
|
+
] })
|
|
972
|
+
] });
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
// src/auth/ui/reset-password-form.tsx
|
|
976
|
+
import * as React from "react";
|
|
977
|
+
import { useForm as useForm4 } from "@tanstack/react-form";
|
|
978
|
+
import { CheckCircleIcon as CheckCircleIcon2 } from "lucide-react";
|
|
979
|
+
import { Button as Button5 } from "@constructive-io/ui/button";
|
|
980
|
+
|
|
981
|
+
// src/auth/utils/validators.ts
|
|
982
|
+
function getPasswordStrength(password) {
|
|
983
|
+
let score = 0;
|
|
984
|
+
if (password.length >= 8) score++;
|
|
985
|
+
if (/[a-z]/.test(password)) score++;
|
|
986
|
+
if (/[A-Z]/.test(password)) score++;
|
|
987
|
+
if (/\d/.test(password)) score++;
|
|
988
|
+
if (/[@$!%*?&]/.test(password)) score++;
|
|
989
|
+
return score;
|
|
990
|
+
}
|
|
991
|
+
function getPasswordStrengthLabel(score) {
|
|
992
|
+
const labels = ["Very Weak", "Weak", "Fair", "Good", "Strong"];
|
|
993
|
+
return labels[score - 1] || "Very Weak";
|
|
994
|
+
}
|
|
995
|
+
function getPasswordStrengthColor(score) {
|
|
996
|
+
const colors = ["bg-red-500", "bg-orange-500", "bg-yellow-500", "bg-blue-500", "bg-green-500"];
|
|
997
|
+
return colors[score - 1] || "bg-red-500";
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
// src/auth/ui/password-strength.tsx
|
|
1001
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1002
|
+
function PasswordStrength({ password, className }) {
|
|
1003
|
+
const strength = getPasswordStrength(password);
|
|
1004
|
+
const label = getPasswordStrengthLabel(strength);
|
|
1005
|
+
const colorClass = getPasswordStrengthColor(strength);
|
|
1006
|
+
if (!password) {
|
|
1007
|
+
return null;
|
|
1008
|
+
}
|
|
1009
|
+
return /* @__PURE__ */ jsxs7("div", { className: cn("space-y-2", className), children: [
|
|
1010
|
+
/* @__PURE__ */ jsx8("div", { className: "flex space-x-1", children: [...Array(5)].map((_, i) => /* @__PURE__ */ jsx8("div", { className: cn("h-2 w-full rounded transition-colors", i < strength ? colorClass : "bg-muted") }, i)) }),
|
|
1011
|
+
/* @__PURE__ */ jsxs7("p", { className: "text-muted-foreground text-sm", children: [
|
|
1012
|
+
"Password strength:",
|
|
1013
|
+
" ",
|
|
1014
|
+
/* @__PURE__ */ jsx8(
|
|
1015
|
+
"span",
|
|
1016
|
+
{
|
|
1017
|
+
className: cn("font-medium", {
|
|
1018
|
+
"text-red-600": strength <= 2,
|
|
1019
|
+
"text-yellow-600": strength === 3,
|
|
1020
|
+
"text-blue-600": strength === 4,
|
|
1021
|
+
"text-green-600": strength === 5
|
|
1022
|
+
}),
|
|
1023
|
+
children: label
|
|
1024
|
+
}
|
|
1025
|
+
)
|
|
1026
|
+
] })
|
|
1027
|
+
] });
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// src/auth/ui/reset-password-form.tsx
|
|
1031
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1032
|
+
function SheetsResetPasswordForm({
|
|
1033
|
+
resetToken,
|
|
1034
|
+
roleId,
|
|
1035
|
+
onResetPassword,
|
|
1036
|
+
onShowLogin
|
|
1037
|
+
}) {
|
|
1038
|
+
const [error, setError] = React.useState(null);
|
|
1039
|
+
const [isSubmitting, setIsSubmitting] = React.useState(false);
|
|
1040
|
+
const [isSuccess, setIsSuccess] = React.useState(false);
|
|
1041
|
+
const form = useForm4({
|
|
1042
|
+
defaultValues: {
|
|
1043
|
+
password: "",
|
|
1044
|
+
confirmPassword: "",
|
|
1045
|
+
token: resetToken
|
|
1046
|
+
},
|
|
1047
|
+
onSubmit: async ({ value }) => {
|
|
1048
|
+
setError(null);
|
|
1049
|
+
setIsSubmitting(true);
|
|
1050
|
+
try {
|
|
1051
|
+
const validatedData = resetPasswordSchema.parse(value);
|
|
1052
|
+
await onResetPassword({
|
|
1053
|
+
newPassword: validatedData.password,
|
|
1054
|
+
resetToken: validatedData.token,
|
|
1055
|
+
roleId
|
|
1056
|
+
});
|
|
1057
|
+
setIsSuccess(true);
|
|
1058
|
+
} catch (err) {
|
|
1059
|
+
setError(parseGraphQLError(err).message);
|
|
1060
|
+
} finally {
|
|
1061
|
+
setIsSubmitting(false);
|
|
1062
|
+
}
|
|
1063
|
+
},
|
|
1064
|
+
validators: {
|
|
1065
|
+
onChange: ({ value }) => {
|
|
1066
|
+
const result = resetPasswordSchema.safeParse(value);
|
|
1067
|
+
if (!result.success) {
|
|
1068
|
+
return result.error.issues.map((issue) => issue.message).join(", ");
|
|
1069
|
+
}
|
|
1070
|
+
return void 0;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
if (isSuccess) {
|
|
1075
|
+
return /* @__PURE__ */ jsxs8("div", { className: "space-y-5 text-center", children: [
|
|
1076
|
+
/* @__PURE__ */ jsx9("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx9("div", { className: "bg-success/10 flex h-12 w-12 items-center justify-center rounded-full", children: /* @__PURE__ */ jsx9(CheckCircleIcon2, { className: "text-success h-6 w-6" }) }) }),
|
|
1077
|
+
/* @__PURE__ */ jsxs8("div", { className: "space-y-1.5", children: [
|
|
1078
|
+
/* @__PURE__ */ jsx9("h3", { className: "text-lg font-semibold", children: "Password reset successful" }),
|
|
1079
|
+
/* @__PURE__ */ jsx9("p", { className: "text-muted-foreground text-sm", children: "Your password has been reset successfully. You can now sign in with your new password." })
|
|
1080
|
+
] }),
|
|
1081
|
+
onShowLogin && /* @__PURE__ */ jsx9("div", { className: "pt-1", children: /* @__PURE__ */ jsx9(Button5, { type: "button", onClick: onShowLogin, className: "w-full", children: "Sign in" }) })
|
|
1082
|
+
] });
|
|
1083
|
+
}
|
|
1084
|
+
return /* @__PURE__ */ jsxs8("div", { className: "space-y-5", children: [
|
|
1085
|
+
/* @__PURE__ */ jsx9(AuthScreenHeader, { title: "Set a new password", description: "Enter your new password below" }),
|
|
1086
|
+
/* @__PURE__ */ jsxs8(
|
|
1087
|
+
"form",
|
|
1088
|
+
{
|
|
1089
|
+
onSubmit: (e) => {
|
|
1090
|
+
e.preventDefault();
|
|
1091
|
+
e.stopPropagation();
|
|
1092
|
+
form.handleSubmit();
|
|
1093
|
+
},
|
|
1094
|
+
className: "space-y-4 px-8",
|
|
1095
|
+
children: [
|
|
1096
|
+
/* @__PURE__ */ jsx9(AuthErrorAlert, { error }),
|
|
1097
|
+
/* @__PURE__ */ jsx9(
|
|
1098
|
+
form.Field,
|
|
1099
|
+
{
|
|
1100
|
+
name: "password",
|
|
1101
|
+
validators: {
|
|
1102
|
+
onChange: ({ value }) => {
|
|
1103
|
+
if (!value) return "Password is required";
|
|
1104
|
+
if (value.length < 8) return "Password must be at least 8 characters";
|
|
1105
|
+
if (!/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]/.test(value)) {
|
|
1106
|
+
return "Password must contain uppercase, lowercase, number, and special character";
|
|
1107
|
+
}
|
|
1108
|
+
return void 0;
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
children: (field) => /* @__PURE__ */ jsxs8("div", { className: "space-y-2", children: [
|
|
1112
|
+
/* @__PURE__ */ jsx9(
|
|
1113
|
+
FormField,
|
|
1114
|
+
{
|
|
1115
|
+
field,
|
|
1116
|
+
label: "New Password",
|
|
1117
|
+
placeholder: "Enter your new password",
|
|
1118
|
+
type: "password"
|
|
1119
|
+
}
|
|
1120
|
+
),
|
|
1121
|
+
/* @__PURE__ */ jsx9(PasswordStrength, { password: field.state.value })
|
|
1122
|
+
] })
|
|
1123
|
+
}
|
|
1124
|
+
),
|
|
1125
|
+
/* @__PURE__ */ jsx9(
|
|
1126
|
+
form.Field,
|
|
1127
|
+
{
|
|
1128
|
+
name: "confirmPassword",
|
|
1129
|
+
validators: {
|
|
1130
|
+
onChange: ({ value }) => {
|
|
1131
|
+
if (!value) return "Please confirm your password";
|
|
1132
|
+
const password = form.getFieldValue("password");
|
|
1133
|
+
if (value !== password) return "Passwords do not match";
|
|
1134
|
+
return void 0;
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
children: (field) => /* @__PURE__ */ jsx9(
|
|
1138
|
+
FormField,
|
|
1139
|
+
{
|
|
1140
|
+
field,
|
|
1141
|
+
label: "Confirm New Password",
|
|
1142
|
+
placeholder: "Confirm your new password",
|
|
1143
|
+
type: "password"
|
|
1144
|
+
}
|
|
1145
|
+
)
|
|
1146
|
+
}
|
|
1147
|
+
),
|
|
1148
|
+
/* @__PURE__ */ jsx9("div", { className: "pt-2", children: /* @__PURE__ */ jsx9(
|
|
1149
|
+
AuthLoadingButton,
|
|
1150
|
+
{
|
|
1151
|
+
type: "submit",
|
|
1152
|
+
className: "w-full",
|
|
1153
|
+
isLoading: isSubmitting,
|
|
1154
|
+
disabled: !form.state.canSubmit || isSubmitting,
|
|
1155
|
+
"data-testid": "auth-reset-submit",
|
|
1156
|
+
children: "Reset Password"
|
|
1157
|
+
}
|
|
1158
|
+
) })
|
|
1159
|
+
]
|
|
1160
|
+
}
|
|
1161
|
+
),
|
|
1162
|
+
onShowLogin && /* @__PURE__ */ jsxs8("div", { className: "text-muted-foreground text-center text-sm", children: [
|
|
1163
|
+
"Remember your password?",
|
|
1164
|
+
" ",
|
|
1165
|
+
/* @__PURE__ */ jsx9(
|
|
1166
|
+
Button5,
|
|
1167
|
+
{
|
|
1168
|
+
variant: "link",
|
|
1169
|
+
className: "text-primary hover:text-primary/80 h-auto p-0 font-medium",
|
|
1170
|
+
onClick: onShowLogin,
|
|
1171
|
+
type: "button",
|
|
1172
|
+
children: "Sign in"
|
|
1173
|
+
}
|
|
1174
|
+
)
|
|
1175
|
+
] })
|
|
1176
|
+
] });
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// src/auth/ui/auth-screen-layout.tsx
|
|
1180
|
+
import { Card, CardContent } from "@constructive-io/ui/card";
|
|
1181
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1182
|
+
function AuthScreenLayout({
|
|
1183
|
+
children,
|
|
1184
|
+
fill = "parent",
|
|
1185
|
+
className
|
|
1186
|
+
}) {
|
|
1187
|
+
return /* @__PURE__ */ jsx10(
|
|
1188
|
+
"div",
|
|
1189
|
+
{
|
|
1190
|
+
className: cn(
|
|
1191
|
+
"bg-background relative flex flex-col",
|
|
1192
|
+
fill === "viewport" ? "min-h-dvh w-dvw" : "h-full w-full",
|
|
1193
|
+
className
|
|
1194
|
+
),
|
|
1195
|
+
children: /* @__PURE__ */ jsx10("div", { className: "flex flex-1 items-center justify-center p-6", children: /* @__PURE__ */ jsx10("div", { className: "relative z-10 w-full max-w-md", children: /* @__PURE__ */ jsx10(Card, { className: "overflow-hidden border-border/80", children: /* @__PURE__ */ jsx10(CardContent, { className: "space-y-2 pt-6", children }) }) }) })
|
|
1196
|
+
}
|
|
1197
|
+
);
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
// src/auth/auth-gate.tsx
|
|
1201
|
+
import { Fragment, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1202
|
+
var AUTH_CONTENT = {
|
|
1203
|
+
login: {
|
|
1204
|
+
title: "Welcome back",
|
|
1205
|
+
description: "Sign in to your account"
|
|
1206
|
+
},
|
|
1207
|
+
register: {
|
|
1208
|
+
title: "Create an account",
|
|
1209
|
+
description: "Get started with your free account"
|
|
1210
|
+
},
|
|
1211
|
+
forgot: {
|
|
1212
|
+
title: "Reset your password",
|
|
1213
|
+
description: "We'll send you a password reset link"
|
|
1214
|
+
},
|
|
1215
|
+
reset: {
|
|
1216
|
+
title: "Set a new password",
|
|
1217
|
+
description: "Enter your new password below"
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
function SheetsAuthGate({
|
|
1221
|
+
children,
|
|
1222
|
+
loginComponent: CustomLoginComponent,
|
|
1223
|
+
resetToken,
|
|
1224
|
+
roleId,
|
|
1225
|
+
logo,
|
|
1226
|
+
appName,
|
|
1227
|
+
showLogo
|
|
1228
|
+
}) {
|
|
1229
|
+
const { config } = useSheetsContext();
|
|
1230
|
+
const isAuthenticated = useSheetsStore((s) => s.isAuthenticated);
|
|
1231
|
+
if (config.auth.mode === "embedded") {
|
|
1232
|
+
return /* @__PURE__ */ jsx11(Fragment, { children });
|
|
1233
|
+
}
|
|
1234
|
+
if (isAuthenticated) {
|
|
1235
|
+
return /* @__PURE__ */ jsx11(Fragment, { children });
|
|
1236
|
+
}
|
|
1237
|
+
if (CustomLoginComponent) {
|
|
1238
|
+
return /* @__PURE__ */ jsx11(CustomLoginComponent, {});
|
|
1239
|
+
}
|
|
1240
|
+
return /* @__PURE__ */ jsx11(
|
|
1241
|
+
StandaloneAuthUI,
|
|
1242
|
+
{
|
|
1243
|
+
resetToken,
|
|
1244
|
+
roleId,
|
|
1245
|
+
logo,
|
|
1246
|
+
appName,
|
|
1247
|
+
showLogo
|
|
1248
|
+
}
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1251
|
+
function StandaloneAuthUI({ resetToken, roleId, logo, appName, showLogo }) {
|
|
1252
|
+
const initialMode = resetToken ? "reset" : "login";
|
|
1253
|
+
const [mode, setMode] = useState5(initialMode);
|
|
1254
|
+
const loginMutation = useSheetsLogin();
|
|
1255
|
+
const registerMutation = useSheetsRegister();
|
|
1256
|
+
const forgotPasswordMutation = useSheetsForgotPassword();
|
|
1257
|
+
const resetPasswordMutation = useSheetsResetPassword();
|
|
1258
|
+
const { title, description } = AUTH_CONTENT[mode];
|
|
1259
|
+
return /* @__PURE__ */ jsxs9(AuthScreenLayout, { fill: "parent", logo, appName, showLogo, children: [
|
|
1260
|
+
/* @__PURE__ */ jsx11(
|
|
1261
|
+
AuthScreenHeader,
|
|
1262
|
+
{
|
|
1263
|
+
title,
|
|
1264
|
+
description,
|
|
1265
|
+
logo,
|
|
1266
|
+
appName,
|
|
1267
|
+
showLogo
|
|
1268
|
+
}
|
|
1269
|
+
),
|
|
1270
|
+
/* @__PURE__ */ jsxs9("div", { children: [
|
|
1271
|
+
mode === "login" && /* @__PURE__ */ jsx11(
|
|
1272
|
+
SheetsLoginForm,
|
|
1273
|
+
{
|
|
1274
|
+
onLogin: (credentials) => loginMutation.mutateAsync(credentials).then(() => {
|
|
1275
|
+
}),
|
|
1276
|
+
onShowForgot: () => setMode("forgot"),
|
|
1277
|
+
onShowRegister: () => setMode("register")
|
|
1278
|
+
}
|
|
1279
|
+
),
|
|
1280
|
+
mode === "register" && /* @__PURE__ */ jsx11(
|
|
1281
|
+
SheetsRegisterForm,
|
|
1282
|
+
{
|
|
1283
|
+
onRegister: (data) => registerMutation.mutateAsync(data),
|
|
1284
|
+
onShowLogin: () => setMode("login")
|
|
1285
|
+
}
|
|
1286
|
+
),
|
|
1287
|
+
mode === "forgot" && /* @__PURE__ */ jsx11(
|
|
1288
|
+
SheetsForgotPasswordForm,
|
|
1289
|
+
{
|
|
1290
|
+
onForgotPassword: (data) => forgotPasswordMutation.mutateAsync(data),
|
|
1291
|
+
onShowLogin: () => setMode("login")
|
|
1292
|
+
}
|
|
1293
|
+
),
|
|
1294
|
+
mode === "reset" && /* @__PURE__ */ jsx11(
|
|
1295
|
+
SheetsResetPasswordForm,
|
|
1296
|
+
{
|
|
1297
|
+
resetToken: resetToken || "",
|
|
1298
|
+
roleId,
|
|
1299
|
+
onResetPassword: (input) => resetPasswordMutation.mutateAsync(input),
|
|
1300
|
+
onShowLogin: () => setMode("login")
|
|
1301
|
+
}
|
|
1302
|
+
)
|
|
1303
|
+
] })
|
|
1304
|
+
] });
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
export {
|
|
1308
|
+
useSheetsLogin,
|
|
1309
|
+
useSheetsRegister,
|
|
1310
|
+
useSheetsForgotPassword,
|
|
1311
|
+
useSheetsResetPassword,
|
|
1312
|
+
SheetsAuthGate
|
|
1313
|
+
};
|
|
1314
|
+
//# sourceMappingURL=chunk-FNVHSOQQ.js.map
|