Skip to content

Commit

Permalink
add loading indicator while deploying schema
Browse files Browse the repository at this point in the history
  • Loading branch information
xavimondev committed Apr 21, 2024
1 parent 1794c40 commit 7e6b693
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions apps/web/components/deploy-schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { useRef, useState } from "react";
import { toast } from "sonner";
import Link from "next/link";
import { CircleAlert } from "lucide-react";
import { CircleAlert, Loader2 } from "lucide-react";
import { getReferenceId, triggerConfetti } from "@/utils";
import { useSchemaStore } from "@/store";
import { schemaDeploy } from "@/services/deploy";
Expand All @@ -26,8 +26,8 @@ export function DeploySchema() {
const [supabaseLinkTables, setSupabaseLinkTables] = useState<
string | undefined
>(undefined);

const inputRef = useRef<HTMLInputElement | null>(null);
const [isLoading, setIsLoading] = useState(false);

const deploy = async () => {
const urlConnection = inputRef.current?.value;
Expand All @@ -49,6 +49,7 @@ export function DeploySchema() {
return;
}

setIsLoading(true);
const result = await schemaDeploy({
sqlSchema,
url: urlConnection,
Expand All @@ -62,6 +63,7 @@ export function DeploySchema() {

toast.success(message);
triggerConfetti();
setIsLoading(false);

//Setting redirect URL dashboard tables
const referenceId = getReferenceId(urlConnection);
Expand Down Expand Up @@ -125,8 +127,9 @@ export function DeploySchema() {
</div>
</CardContent>
<CardFooter className="w-full px-4 flex-col gap-4 xl:gap-8">
<Button className="w-full" onClick={deploy}>
Deploy
<Button className="w-full" onClick={deploy} disabled={isLoading}>
{isLoading && <Loader2 className="animate-spin size-5 mr-2" />}
{isLoading ? "Deploying..." : "Deploy"}
</Button>
{supabaseLinkTables && supabaseLinkTables !== "" && (
<DeployResult supabaseLinkTables={supabaseLinkTables} />
Expand Down

0 comments on commit 7e6b693

Please sign in to comment.