create-disposabl-app 0.8.5 → 0.8.6

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/disposabl.js CHANGED
@@ -22,7 +22,7 @@ import { Command } from "commander";
22
22
  // ../cli/package.json
23
23
  var package_default = {
24
24
  name: "@disposabl/cli",
25
- version: "0.8.5",
25
+ version: "0.8.6",
26
26
  type: "module",
27
27
  description: "Command-line access to your Disposabl app",
28
28
  license: "MIT",
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
8
8
  import { Command, CommanderError } from "commander";
9
9
  import * as p2 from "@clack/prompts";
10
10
  // package.json
11
- var version = "0.8.5";
11
+ var version = "0.8.6";
12
12
 
13
13
  // ../disposabl-kit/platforms.ts
14
14
  var platforms = [
@@ -17,17 +17,28 @@ import { Input } from "../../components/ui/input";
17
17
  import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
18
18
  import { useSignInWithUsernamePassword } from "@convex-dev/auth/methods/username-password/react";
19
19
  import { api } from "../../../../backend/convex/_generated/api";
20
- import { useState } from "react";
20
+ import { useEffect, useRef, useState } from "react";
21
+ import { useConvexAuth } from "convex/react";
21
22
  import { getReturnTo } from "../../lib/return-to";
22
23
 
23
24
  export function LogIn() {
24
25
  const { request, returnTo } = Route.useSearch();
25
26
  const navigate = useNavigate();
27
+ const { isLoading, isAuthenticated } = useConvexAuth();
28
+ const submitted = useRef(false);
29
+
30
+ useEffect(() => {
31
+ if (!isLoading && isAuthenticated && !submitted.current) {
32
+ void navigate({ to: "/", replace: true });
33
+ }
34
+ }, [isLoading, isAuthenticated, navigate]);
26
35
  const { signIn, pending } = useSignInWithUsernamePassword(api.auth);
27
36
  const [username, setUsername] = useState("");
28
37
  const [password, setPassword] = useState("");
29
38
  const [error, setError] = useState<string | null>(null);
30
39
 
40
+ if (isLoading || (isAuthenticated && !submitted.current)) return null;
41
+
31
42
  return (
32
43
  <main className="flex min-h-[calc(100svh-73px)] flex-col items-center justify-center bg-muted p-6 md:p-10">
33
44
  <div className="flex w-full max-w-sm flex-col gap-6">
@@ -45,6 +56,7 @@ export function LogIn() {
45
56
  <form
46
57
  onSubmit={async (e) => {
47
58
  e.preventDefault();
59
+ submitted.current = true;
48
60
  setError(null);
49
61
  const result = await signIn({ username, password });
50
62
  if (result.status === "complete") {
@@ -53,6 +65,7 @@ export function LogIn() {
53
65
  else window.location.assign(returnTo ?? "/dashboard");
54
66
  return;
55
67
  }
68
+ submitted.current = false;
56
69
  setError(() => {
57
70
  switch (result.userError.error) {
58
71
  case "USER_NOT_FOUND":
@@ -18,17 +18,28 @@ import { createFileRoute, Link, useNavigate } from "@tanstack/react-router";
18
18
  import { DEFAULT_MIN_PASSWORD_LENGTH } from "@convex-dev/auth/methods/username-password";
19
19
  import { useSignUpWithUsernamePassword } from "@convex-dev/auth/methods/username-password/react";
20
20
  import { api } from "../../../../backend/convex/_generated/api";
21
- import { useState } from "react";
21
+ import { useEffect, useRef, useState } from "react";
22
+ import { useConvexAuth } from "convex/react";
22
23
  import { getReturnTo } from "../../lib/return-to";
23
24
 
24
25
  export function SignUp() {
25
26
  const { request, returnTo } = Route.useSearch();
26
27
  const navigate = useNavigate();
28
+ const { isLoading, isAuthenticated } = useConvexAuth();
29
+ const submitted = useRef(false);
30
+
31
+ useEffect(() => {
32
+ if (!isLoading && isAuthenticated && !submitted.current) {
33
+ void navigate({ to: "/", replace: true });
34
+ }
35
+ }, [isLoading, isAuthenticated, navigate]);
27
36
  const { signUp, pending } = useSignUpWithUsernamePassword(api.auth);
28
37
  const [username, setUsername] = useState("");
29
38
  const [password, setPassword] = useState("");
30
39
  const [error, setError] = useState<string | null>(null);
31
40
 
41
+ if (isLoading || (isAuthenticated && !submitted.current)) return null;
42
+
32
43
  return (
33
44
  <main className="flex min-h-[calc(100svh-73px)] flex-col items-center justify-center bg-muted p-6 md:p-10">
34
45
  <div className="flex w-full max-w-sm flex-col gap-6">
@@ -46,6 +57,7 @@ export function SignUp() {
46
57
  <form
47
58
  onSubmit={async (e) => {
48
59
  e.preventDefault();
60
+ submitted.current = true;
49
61
  setError(null);
50
62
  const result = await signUp({ username, password });
51
63
  if (result.status === "complete") {
@@ -54,6 +66,7 @@ export function SignUp() {
54
66
  else window.location.assign(returnTo ?? "/dashboard");
55
67
  return;
56
68
  }
69
+ submitted.current = false;
57
70
  setError(() => {
58
71
  switch (result.userError.error) {
59
72
  case "USERNAME_TAKEN":
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-disposabl-app",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "Create a Disposabl app",
5
5
  "type": "module",
6
6
  "license": "MIT",