@xouteiro/auth_npm 1.0.6 → 1.0.8
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/README.md +2 -0
- package/dist/index.js +433 -64
- package/dist/index.mjs +430 -63
- package/package.json +1 -1
- package/src/components/LoginOnly.jsx +96 -0
- package/src/components/LoginRegisterFlow.jsx +171 -0
- package/src/components/LogoutButton.jsx +63 -0
- package/src/components/RegisterOnly.jsx +114 -0
- package/src/index.js +6 -3
- package/src/AuthWrapper.jsx +0 -39
- package/src/LogoutButton.jsx +0 -12
package/README.md
ADDED
package/dist/index.js
CHANGED
@@ -1361,7 +1361,7 @@ var require_react_development = __commonJS({
|
|
1361
1361
|
}
|
1362
1362
|
return dispatcher.useContext(Context);
|
1363
1363
|
}
|
1364
|
-
function
|
1364
|
+
function useState6(initialState) {
|
1365
1365
|
var dispatcher = resolveDispatcher();
|
1366
1366
|
return dispatcher.useState(initialState);
|
1367
1367
|
}
|
@@ -1373,7 +1373,7 @@ var require_react_development = __commonJS({
|
|
1373
1373
|
var dispatcher = resolveDispatcher();
|
1374
1374
|
return dispatcher.useRef(initialValue);
|
1375
1375
|
}
|
1376
|
-
function
|
1376
|
+
function useEffect2(create, deps) {
|
1377
1377
|
var dispatcher = resolveDispatcher();
|
1378
1378
|
return dispatcher.useEffect(create, deps);
|
1379
1379
|
}
|
@@ -2156,7 +2156,7 @@ var require_react_development = __commonJS({
|
|
2156
2156
|
exports2.useContext = useContext;
|
2157
2157
|
exports2.useDebugValue = useDebugValue;
|
2158
2158
|
exports2.useDeferredValue = useDeferredValue;
|
2159
|
-
exports2.useEffect =
|
2159
|
+
exports2.useEffect = useEffect2;
|
2160
2160
|
exports2.useId = useId;
|
2161
2161
|
exports2.useImperativeHandle = useImperativeHandle;
|
2162
2162
|
exports2.useInsertionEffect = useInsertionEffect;
|
@@ -2164,7 +2164,7 @@ var require_react_development = __commonJS({
|
|
2164
2164
|
exports2.useMemo = useMemo;
|
2165
2165
|
exports2.useReducer = useReducer;
|
2166
2166
|
exports2.useRef = useRef;
|
2167
|
-
exports2.useState =
|
2167
|
+
exports2.useState = useState6;
|
2168
2168
|
exports2.useSyncExternalStore = useSyncExternalStore;
|
2169
2169
|
exports2.useTransition = useTransition;
|
2170
2170
|
exports2.version = ReactVersion;
|
@@ -2191,8 +2191,10 @@ var require_react = __commonJS({
|
|
2191
2191
|
// src/index.js
|
2192
2192
|
var index_exports = {};
|
2193
2193
|
__export(index_exports, {
|
2194
|
-
|
2194
|
+
LoginOnly: () => LoginOnly,
|
2195
|
+
LoginRegisterFlow: () => LoginRegisterFlow,
|
2195
2196
|
LogoutButton: () => LogoutButton,
|
2197
|
+
RegisterOnly: () => RegisterOnly,
|
2196
2198
|
initializeSupabase: () => initializeSupabase,
|
2197
2199
|
isAdmin: () => isAdmin,
|
2198
2200
|
logout: () => logout,
|
@@ -2203,57 +2205,11 @@ __export(index_exports, {
|
|
2203
2205
|
});
|
2204
2206
|
module.exports = __toCommonJS(index_exports);
|
2205
2207
|
|
2206
|
-
// src/
|
2208
|
+
// src/useAuth.js
|
2207
2209
|
var import_react = __toESM(require_react());
|
2208
|
-
|
2209
|
-
var import_auth_ui_shared = require("@supabase/auth-ui-shared");
|
2210
|
-
|
2211
|
-
// src/supabaseClient.js
|
2212
|
-
var import_supabase_js = require("@supabase/supabase-js");
|
2213
|
-
var supabase = null;
|
2214
|
-
function initializeSupabase(url, anonKey) {
|
2215
|
-
if (!url || !anonKey) {
|
2216
|
-
throw new Error("Supabase URL and Anon Key are required to initialize the client.");
|
2217
|
-
}
|
2218
|
-
supabase = (0, import_supabase_js.createClient)(url, anonKey);
|
2219
|
-
}
|
2220
|
-
|
2221
|
-
// src/AuthWrapper.jsx
|
2222
|
-
function AuthWrapper({ onAuth, providers = ["google", "github"], theme = "dark" }) {
|
2223
|
-
if (!supabase) {
|
2224
|
-
throw new Error("Supabase client is not initialized. Call initializeSupabase() before using AuthWrapper.");
|
2225
|
-
}
|
2210
|
+
function useAuth(supabaseClient) {
|
2226
2211
|
const [session, setSession] = (0, import_react.useState)(null);
|
2227
2212
|
(0, import_react.useEffect)(() => {
|
2228
|
-
supabase.auth.getSession().then(({ data: { session: session2 } }) => {
|
2229
|
-
setSession(session2);
|
2230
|
-
if (session2) onAuth == null ? void 0 : onAuth(session2);
|
2231
|
-
});
|
2232
|
-
const { data: subscription } = supabase.auth.onAuthStateChange((_event, session2) => {
|
2233
|
-
setSession(session2);
|
2234
|
-
if (session2) onAuth == null ? void 0 : onAuth(session2);
|
2235
|
-
});
|
2236
|
-
return () => subscription == null ? void 0 : subscription.unsubscribe();
|
2237
|
-
}, [onAuth]);
|
2238
|
-
if (!session) {
|
2239
|
-
return /* @__PURE__ */ React.createElement(
|
2240
|
-
import_auth_ui_react.Auth,
|
2241
|
-
{
|
2242
|
-
supabaseClient: supabase,
|
2243
|
-
appearance: { theme: import_auth_ui_shared.ThemeSupa },
|
2244
|
-
providers,
|
2245
|
-
theme
|
2246
|
-
}
|
2247
|
-
);
|
2248
|
-
}
|
2249
|
-
return /* @__PURE__ */ React.createElement("div", null, "\u2705 Logged in as: ", session.user.email);
|
2250
|
-
}
|
2251
|
-
|
2252
|
-
// src/useAuth.js
|
2253
|
-
var import_react2 = __toESM(require_react());
|
2254
|
-
function useAuth(supabaseClient) {
|
2255
|
-
const [session, setSession] = (0, import_react2.useState)(null);
|
2256
|
-
(0, import_react2.useEffect)(() => {
|
2257
2213
|
supabaseClient.auth.getSession().then(({ data: { session: session2 } }) => {
|
2258
2214
|
setSession(session2);
|
2259
2215
|
});
|
@@ -2269,21 +2225,21 @@ function useAuth(supabaseClient) {
|
|
2269
2225
|
return { session, signOut };
|
2270
2226
|
}
|
2271
2227
|
|
2272
|
-
// src/LogoutButton.jsx
|
2273
|
-
function LogoutButton({ supabaseClient, onLogout }) {
|
2274
|
-
const { signOut } = useAuth(supabaseClient);
|
2275
|
-
const handleLogout = async () => {
|
2276
|
-
await signOut();
|
2277
|
-
onLogout == null ? void 0 : onLogout();
|
2278
|
-
};
|
2279
|
-
return /* @__PURE__ */ React.createElement("button", { onClick: handleLogout }, "\u{1F6AA} Log out");
|
2280
|
-
}
|
2281
|
-
|
2282
2228
|
// src/utils.js
|
2283
2229
|
function isAdmin(user) {
|
2284
2230
|
return (user == null ? void 0 : user.role) === "admin";
|
2285
2231
|
}
|
2286
2232
|
|
2233
|
+
// src/supabaseClient.js
|
2234
|
+
var import_supabase_js = require("@supabase/supabase-js");
|
2235
|
+
var supabase = null;
|
2236
|
+
function initializeSupabase(url, anonKey) {
|
2237
|
+
if (!url || !anonKey) {
|
2238
|
+
throw new Error("Supabase URL and Anon Key are required to initialize the client.");
|
2239
|
+
}
|
2240
|
+
supabase = (0, import_supabase_js.createClient)(url, anonKey);
|
2241
|
+
}
|
2242
|
+
|
2287
2243
|
// src/login.js
|
2288
2244
|
async function signInWithEmail(email, password) {
|
2289
2245
|
try {
|
@@ -2333,10 +2289,423 @@ async function logout() {
|
|
2333
2289
|
return { error: err };
|
2334
2290
|
}
|
2335
2291
|
}
|
2292
|
+
|
2293
|
+
// src/components/LoginRegisterFlow.jsx
|
2294
|
+
var import_react2 = __toESM(require_react());
|
2295
|
+
var boxStyle = {
|
2296
|
+
maxWidth: 380,
|
2297
|
+
margin: "40px auto",
|
2298
|
+
padding: 32,
|
2299
|
+
borderRadius: 14,
|
2300
|
+
boxShadow: "0 2px 16px rgba(0,0,0,0.09)",
|
2301
|
+
background: "#fff",
|
2302
|
+
fontFamily: "sans-serif"
|
2303
|
+
};
|
2304
|
+
var tabStyle = (active) => ({
|
2305
|
+
flex: 1,
|
2306
|
+
padding: 12,
|
2307
|
+
border: "none",
|
2308
|
+
borderBottom: active ? "3px solid #0070f3" : "3px solid #eee",
|
2309
|
+
background: "none",
|
2310
|
+
fontWeight: active ? 700 : 400,
|
2311
|
+
color: active ? "#0070f3" : "#444",
|
2312
|
+
cursor: "pointer",
|
2313
|
+
outline: "none"
|
2314
|
+
});
|
2315
|
+
var inputStyle = {
|
2316
|
+
width: "100%",
|
2317
|
+
padding: 10,
|
2318
|
+
margin: "10px 0",
|
2319
|
+
borderRadius: 6,
|
2320
|
+
border: "1px solid #ddd",
|
2321
|
+
fontSize: 16
|
2322
|
+
};
|
2323
|
+
var buttonStyle = {
|
2324
|
+
width: "100%",
|
2325
|
+
padding: 12,
|
2326
|
+
borderRadius: 6,
|
2327
|
+
border: "none",
|
2328
|
+
background: "#0070f3",
|
2329
|
+
color: "#fff",
|
2330
|
+
fontWeight: 600,
|
2331
|
+
fontSize: 16,
|
2332
|
+
marginTop: 10,
|
2333
|
+
cursor: "pointer"
|
2334
|
+
};
|
2335
|
+
var messageStyle = (success) => ({
|
2336
|
+
margin: "12px 0",
|
2337
|
+
color: success ? "#0a0" : "#d32f2f",
|
2338
|
+
background: success ? "#eafbe7" : "#fdeaea",
|
2339
|
+
padding: 8,
|
2340
|
+
borderRadius: 6,
|
2341
|
+
textAlign: "center",
|
2342
|
+
fontSize: 15
|
2343
|
+
});
|
2344
|
+
function LoginRegisterFlow() {
|
2345
|
+
const [mode, setMode] = (0, import_react2.useState)("login");
|
2346
|
+
const [identifier, setIdentifier] = (0, import_react2.useState)("");
|
2347
|
+
const [password, setPassword] = (0, import_react2.useState)("");
|
2348
|
+
const [username, setUsername] = (0, import_react2.useState)("");
|
2349
|
+
const [phone, setPhone] = (0, import_react2.useState)("");
|
2350
|
+
const [message, setMessage] = (0, import_react2.useState)(null);
|
2351
|
+
const [success, setSuccess] = (0, import_react2.useState)(false);
|
2352
|
+
const resetFields = () => {
|
2353
|
+
setIdentifier("");
|
2354
|
+
setPassword("");
|
2355
|
+
setUsername("");
|
2356
|
+
setPhone("");
|
2357
|
+
setMessage(null);
|
2358
|
+
setSuccess(false);
|
2359
|
+
};
|
2360
|
+
const handleLogin = async (e) => {
|
2361
|
+
e.preventDefault();
|
2362
|
+
setMessage(null);
|
2363
|
+
setSuccess(false);
|
2364
|
+
const { error } = await signInWithEmail(identifier, password);
|
2365
|
+
if (error) {
|
2366
|
+
setMessage(error.message || "Login failed");
|
2367
|
+
setSuccess(false);
|
2368
|
+
} else {
|
2369
|
+
setMessage("Login successful!");
|
2370
|
+
setSuccess(true);
|
2371
|
+
setTimeout(resetFields, 1200);
|
2372
|
+
}
|
2373
|
+
};
|
2374
|
+
const handleRegister = async (e) => {
|
2375
|
+
e.preventDefault();
|
2376
|
+
setMessage(null);
|
2377
|
+
setSuccess(false);
|
2378
|
+
const { error } = await registerWithEmail(identifier, password, username, phone);
|
2379
|
+
if (error) {
|
2380
|
+
setMessage(error.message || "Registration failed");
|
2381
|
+
setSuccess(false);
|
2382
|
+
} else {
|
2383
|
+
setMessage("Registration successful! Please check your email to confirm.");
|
2384
|
+
setSuccess(true);
|
2385
|
+
setTimeout(resetFields, 2e3);
|
2386
|
+
}
|
2387
|
+
};
|
2388
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", { style: boxStyle }, /* @__PURE__ */ import_react2.default.createElement("div", { style: { display: "flex", marginBottom: 24 } }, /* @__PURE__ */ import_react2.default.createElement("button", { style: tabStyle(mode === "login"), onClick: () => {
|
2389
|
+
setMode("login");
|
2390
|
+
setMessage(null);
|
2391
|
+
} }, "Login"), /* @__PURE__ */ import_react2.default.createElement("button", { style: tabStyle(mode === "register"), onClick: () => {
|
2392
|
+
setMode("register");
|
2393
|
+
setMessage(null);
|
2394
|
+
} }, "Register")), mode === "login" ? /* @__PURE__ */ import_react2.default.createElement("form", { onSubmit: handleLogin }, /* @__PURE__ */ import_react2.default.createElement(
|
2395
|
+
"input",
|
2396
|
+
{
|
2397
|
+
style: inputStyle,
|
2398
|
+
type: "text",
|
2399
|
+
placeholder: "Email, phone, or username",
|
2400
|
+
value: identifier,
|
2401
|
+
onChange: (e) => setIdentifier(e.target.value),
|
2402
|
+
required: true
|
2403
|
+
}
|
2404
|
+
), /* @__PURE__ */ import_react2.default.createElement(
|
2405
|
+
"input",
|
2406
|
+
{
|
2407
|
+
style: inputStyle,
|
2408
|
+
type: "password",
|
2409
|
+
placeholder: "Password",
|
2410
|
+
value: password,
|
2411
|
+
onChange: (e) => setPassword(e.target.value),
|
2412
|
+
required: true
|
2413
|
+
}
|
2414
|
+
), /* @__PURE__ */ import_react2.default.createElement("button", { style: buttonStyle, type: "submit" }, "Login")) : /* @__PURE__ */ import_react2.default.createElement("form", { onSubmit: handleRegister }, /* @__PURE__ */ import_react2.default.createElement(
|
2415
|
+
"input",
|
2416
|
+
{
|
2417
|
+
style: inputStyle,
|
2418
|
+
type: "text",
|
2419
|
+
placeholder: "Email",
|
2420
|
+
value: identifier,
|
2421
|
+
onChange: (e) => setIdentifier(e.target.value),
|
2422
|
+
required: true
|
2423
|
+
}
|
2424
|
+
), /* @__PURE__ */ import_react2.default.createElement(
|
2425
|
+
"input",
|
2426
|
+
{
|
2427
|
+
style: inputStyle,
|
2428
|
+
type: "password",
|
2429
|
+
placeholder: "Password",
|
2430
|
+
value: password,
|
2431
|
+
onChange: (e) => setPassword(e.target.value),
|
2432
|
+
required: true
|
2433
|
+
}
|
2434
|
+
), /* @__PURE__ */ import_react2.default.createElement(
|
2435
|
+
"input",
|
2436
|
+
{
|
2437
|
+
style: inputStyle,
|
2438
|
+
type: "text",
|
2439
|
+
placeholder: "Username (optional)",
|
2440
|
+
value: username,
|
2441
|
+
onChange: (e) => setUsername(e.target.value)
|
2442
|
+
}
|
2443
|
+
), /* @__PURE__ */ import_react2.default.createElement(
|
2444
|
+
"input",
|
2445
|
+
{
|
2446
|
+
style: inputStyle,
|
2447
|
+
type: "text",
|
2448
|
+
placeholder: "Phone (optional)",
|
2449
|
+
value: phone,
|
2450
|
+
onChange: (e) => setPhone(e.target.value)
|
2451
|
+
}
|
2452
|
+
), /* @__PURE__ */ import_react2.default.createElement("button", { style: buttonStyle, type: "submit" }, "Register")), message && /* @__PURE__ */ import_react2.default.createElement("div", { style: messageStyle(success) }, message));
|
2453
|
+
}
|
2454
|
+
|
2455
|
+
// src/components/LoginOnly.jsx
|
2456
|
+
var import_react3 = __toESM(require_react());
|
2457
|
+
var boxStyle2 = {
|
2458
|
+
maxWidth: 350,
|
2459
|
+
margin: "40px auto",
|
2460
|
+
padding: 28,
|
2461
|
+
borderRadius: 12,
|
2462
|
+
boxShadow: "0 2px 12px rgba(0,0,0,0.08)",
|
2463
|
+
background: "#fff",
|
2464
|
+
fontFamily: "sans-serif"
|
2465
|
+
};
|
2466
|
+
var inputStyle2 = {
|
2467
|
+
width: "100%",
|
2468
|
+
padding: 10,
|
2469
|
+
margin: "10px 0",
|
2470
|
+
borderRadius: 6,
|
2471
|
+
border: "1px solid #ddd",
|
2472
|
+
fontSize: 16
|
2473
|
+
};
|
2474
|
+
var buttonStyle2 = {
|
2475
|
+
width: "100%",
|
2476
|
+
padding: 12,
|
2477
|
+
borderRadius: 6,
|
2478
|
+
border: "none",
|
2479
|
+
background: "#0070f3",
|
2480
|
+
color: "#fff",
|
2481
|
+
fontWeight: 600,
|
2482
|
+
fontSize: 16,
|
2483
|
+
marginTop: 10,
|
2484
|
+
cursor: "pointer"
|
2485
|
+
};
|
2486
|
+
var messageStyle2 = (success) => ({
|
2487
|
+
margin: "12px 0",
|
2488
|
+
color: success ? "#0a0" : "#d32f2f",
|
2489
|
+
background: success ? "#eafbe7" : "#fdeaea",
|
2490
|
+
padding: 8,
|
2491
|
+
borderRadius: 6,
|
2492
|
+
textAlign: "center",
|
2493
|
+
fontSize: 15
|
2494
|
+
});
|
2495
|
+
function LoginOnly() {
|
2496
|
+
const [identifier, setIdentifier] = (0, import_react3.useState)("");
|
2497
|
+
const [password, setPassword] = (0, import_react3.useState)("");
|
2498
|
+
const [message, setMessage] = (0, import_react3.useState)(null);
|
2499
|
+
const [success, setSuccess] = (0, import_react3.useState)(false);
|
2500
|
+
const handleLogin = async (e) => {
|
2501
|
+
e.preventDefault();
|
2502
|
+
setMessage(null);
|
2503
|
+
setSuccess(false);
|
2504
|
+
const { error } = await signInWithEmail(identifier, password);
|
2505
|
+
if (error) {
|
2506
|
+
setMessage(error.message || "Login failed");
|
2507
|
+
setSuccess(false);
|
2508
|
+
} else {
|
2509
|
+
setMessage("Login successful!");
|
2510
|
+
setSuccess(true);
|
2511
|
+
setTimeout(() => {
|
2512
|
+
setIdentifier("");
|
2513
|
+
setPassword("");
|
2514
|
+
setMessage(null);
|
2515
|
+
setSuccess(false);
|
2516
|
+
}, 1500);
|
2517
|
+
}
|
2518
|
+
};
|
2519
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", { style: boxStyle2 }, /* @__PURE__ */ import_react3.default.createElement("form", { onSubmit: handleLogin }, /* @__PURE__ */ import_react3.default.createElement(
|
2520
|
+
"input",
|
2521
|
+
{
|
2522
|
+
style: inputStyle2,
|
2523
|
+
type: "text",
|
2524
|
+
placeholder: "Email, phone, or username",
|
2525
|
+
value: identifier,
|
2526
|
+
onChange: (e) => setIdentifier(e.target.value),
|
2527
|
+
required: true
|
2528
|
+
}
|
2529
|
+
), /* @__PURE__ */ import_react3.default.createElement(
|
2530
|
+
"input",
|
2531
|
+
{
|
2532
|
+
style: inputStyle2,
|
2533
|
+
type: "password",
|
2534
|
+
placeholder: "Password",
|
2535
|
+
value: password,
|
2536
|
+
onChange: (e) => setPassword(e.target.value),
|
2537
|
+
required: true
|
2538
|
+
}
|
2539
|
+
), /* @__PURE__ */ import_react3.default.createElement("button", { style: buttonStyle2, type: "submit" }, "Login")), message && /* @__PURE__ */ import_react3.default.createElement("div", { style: messageStyle2(success) }, message));
|
2540
|
+
}
|
2541
|
+
|
2542
|
+
// src/components/RegisterOnly.jsx
|
2543
|
+
var import_react4 = __toESM(require_react());
|
2544
|
+
var boxStyle3 = {
|
2545
|
+
maxWidth: 350,
|
2546
|
+
margin: "40px auto",
|
2547
|
+
padding: 28,
|
2548
|
+
borderRadius: 12,
|
2549
|
+
boxShadow: "0 2px 12px rgba(0,0,0,0.08)",
|
2550
|
+
background: "#fff",
|
2551
|
+
fontFamily: "sans-serif"
|
2552
|
+
};
|
2553
|
+
var inputStyle3 = {
|
2554
|
+
width: "100%",
|
2555
|
+
padding: 10,
|
2556
|
+
margin: "10px 0",
|
2557
|
+
borderRadius: 6,
|
2558
|
+
border: "1px solid #ddd",
|
2559
|
+
fontSize: 16
|
2560
|
+
};
|
2561
|
+
var buttonStyle3 = {
|
2562
|
+
width: "100%",
|
2563
|
+
padding: 12,
|
2564
|
+
borderRadius: 6,
|
2565
|
+
border: "none",
|
2566
|
+
background: "#0070f3",
|
2567
|
+
color: "#fff",
|
2568
|
+
fontWeight: 600,
|
2569
|
+
fontSize: 16,
|
2570
|
+
marginTop: 10,
|
2571
|
+
cursor: "pointer"
|
2572
|
+
};
|
2573
|
+
var messageStyle3 = (success) => ({
|
2574
|
+
margin: "12px 0",
|
2575
|
+
color: success ? "#0a0" : "#d32f2f",
|
2576
|
+
background: success ? "#eafbe7" : "#fdeaea",
|
2577
|
+
padding: 8,
|
2578
|
+
borderRadius: 6,
|
2579
|
+
textAlign: "center",
|
2580
|
+
fontSize: 15
|
2581
|
+
});
|
2582
|
+
function RegisterOnly() {
|
2583
|
+
const [email, setEmail] = (0, import_react4.useState)("");
|
2584
|
+
const [password, setPassword] = (0, import_react4.useState)("");
|
2585
|
+
const [username, setUsername] = (0, import_react4.useState)("");
|
2586
|
+
const [phone, setPhone] = (0, import_react4.useState)("");
|
2587
|
+
const [message, setMessage] = (0, import_react4.useState)(null);
|
2588
|
+
const [success, setSuccess] = (0, import_react4.useState)(false);
|
2589
|
+
const handleRegister = async (e) => {
|
2590
|
+
e.preventDefault();
|
2591
|
+
setMessage(null);
|
2592
|
+
setSuccess(false);
|
2593
|
+
const { error } = await registerWithEmail(email, password, username, phone);
|
2594
|
+
if (error) {
|
2595
|
+
setMessage(error.message || "Registration failed");
|
2596
|
+
setSuccess(false);
|
2597
|
+
} else {
|
2598
|
+
setMessage("Registration successful! Please check your email to confirm.");
|
2599
|
+
setSuccess(true);
|
2600
|
+
setTimeout(() => {
|
2601
|
+
setEmail("");
|
2602
|
+
setPassword("");
|
2603
|
+
setUsername("");
|
2604
|
+
setPhone("");
|
2605
|
+
setMessage(null);
|
2606
|
+
setSuccess(false);
|
2607
|
+
}, 2e3);
|
2608
|
+
}
|
2609
|
+
};
|
2610
|
+
return /* @__PURE__ */ import_react4.default.createElement("div", { style: boxStyle3 }, /* @__PURE__ */ import_react4.default.createElement("form", { onSubmit: handleRegister }, /* @__PURE__ */ import_react4.default.createElement(
|
2611
|
+
"input",
|
2612
|
+
{
|
2613
|
+
style: inputStyle3,
|
2614
|
+
type: "text",
|
2615
|
+
placeholder: "Email",
|
2616
|
+
value: email,
|
2617
|
+
onChange: (e) => setEmail(e.target.value),
|
2618
|
+
required: true
|
2619
|
+
}
|
2620
|
+
), /* @__PURE__ */ import_react4.default.createElement(
|
2621
|
+
"input",
|
2622
|
+
{
|
2623
|
+
style: inputStyle3,
|
2624
|
+
type: "password",
|
2625
|
+
placeholder: "Password",
|
2626
|
+
value: password,
|
2627
|
+
onChange: (e) => setPassword(e.target.value),
|
2628
|
+
required: true
|
2629
|
+
}
|
2630
|
+
), /* @__PURE__ */ import_react4.default.createElement(
|
2631
|
+
"input",
|
2632
|
+
{
|
2633
|
+
style: inputStyle3,
|
2634
|
+
type: "text",
|
2635
|
+
placeholder: "Username (optional)",
|
2636
|
+
value: username,
|
2637
|
+
onChange: (e) => setUsername(e.target.value)
|
2638
|
+
}
|
2639
|
+
), /* @__PURE__ */ import_react4.default.createElement(
|
2640
|
+
"input",
|
2641
|
+
{
|
2642
|
+
style: inputStyle3,
|
2643
|
+
type: "text",
|
2644
|
+
placeholder: "Phone (optional)",
|
2645
|
+
value: phone,
|
2646
|
+
onChange: (e) => setPhone(e.target.value)
|
2647
|
+
}
|
2648
|
+
), /* @__PURE__ */ import_react4.default.createElement("button", { style: buttonStyle3, type: "submit" }, "Register")), message && /* @__PURE__ */ import_react4.default.createElement("div", { style: messageStyle3(success) }, message));
|
2649
|
+
}
|
2650
|
+
|
2651
|
+
// src/components/LogoutButton.jsx
|
2652
|
+
var import_react5 = __toESM(require_react());
|
2653
|
+
var boxStyle4 = {
|
2654
|
+
maxWidth: 350,
|
2655
|
+
margin: "24px auto",
|
2656
|
+
padding: 20,
|
2657
|
+
borderRadius: 10,
|
2658
|
+
boxShadow: "0 2px 12px rgba(0,0,0,0.08)",
|
2659
|
+
background: "#fff",
|
2660
|
+
fontFamily: "sans-serif",
|
2661
|
+
textAlign: "center"
|
2662
|
+
};
|
2663
|
+
var buttonStyle4 = {
|
2664
|
+
padding: "10px 28px",
|
2665
|
+
borderRadius: 6,
|
2666
|
+
border: "none",
|
2667
|
+
background: "#0070f3",
|
2668
|
+
color: "#fff",
|
2669
|
+
fontWeight: 600,
|
2670
|
+
fontSize: 16,
|
2671
|
+
cursor: "pointer"
|
2672
|
+
};
|
2673
|
+
var messageStyle4 = (success) => ({
|
2674
|
+
margin: "12px 0",
|
2675
|
+
color: success ? "#0a0" : "#d32f2f",
|
2676
|
+
background: success ? "#eafbe7" : "#fdeaea",
|
2677
|
+
padding: 8,
|
2678
|
+
borderRadius: 6,
|
2679
|
+
textAlign: "center",
|
2680
|
+
fontSize: 15
|
2681
|
+
});
|
2682
|
+
function LogoutButton() {
|
2683
|
+
const [message, setMessage] = (0, import_react5.useState)(null);
|
2684
|
+
const [success, setSuccess] = (0, import_react5.useState)(false);
|
2685
|
+
const handleLogout = async () => {
|
2686
|
+
setMessage(null);
|
2687
|
+
setSuccess(false);
|
2688
|
+
const { error } = await logout();
|
2689
|
+
if (error) {
|
2690
|
+
setMessage(error.message || "Logout failed");
|
2691
|
+
setSuccess(false);
|
2692
|
+
} else {
|
2693
|
+
setMessage("Logout successful!");
|
2694
|
+
setSuccess(true);
|
2695
|
+
setTimeout(() => {
|
2696
|
+
setMessage(null);
|
2697
|
+
setSuccess(false);
|
2698
|
+
}, 1500);
|
2699
|
+
}
|
2700
|
+
};
|
2701
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", { style: boxStyle4 }, /* @__PURE__ */ import_react5.default.createElement("button", { style: buttonStyle4, onClick: handleLogout }, "Logout"), message && /* @__PURE__ */ import_react5.default.createElement("div", { style: messageStyle4(success) }, message));
|
2702
|
+
}
|
2336
2703
|
// Annotate the CommonJS export names for ESM import in node:
|
2337
2704
|
0 && (module.exports = {
|
2338
|
-
|
2705
|
+
LoginOnly,
|
2706
|
+
LoginRegisterFlow,
|
2339
2707
|
LogoutButton,
|
2708
|
+
RegisterOnly,
|
2340
2709
|
initializeSupabase,
|
2341
2710
|
isAdmin,
|
2342
2711
|
logout,
|