From 7fb34ade007f194f6ff499a01be2c978987eb02f Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Thu, 6 Jun 2024 00:11:46 -0600 Subject: [PATCH] refacto(#118): remove last toaster on start deployments --- .../application/general/deploy-application.tsx | 13 +++++-------- .../dashboard/compose/general/deploy-compose.tsx | 12 ++++-------- .../dashboard/mariadb/general/deploy-mariadb.tsx | 12 ++++-------- components/dashboard/mongo/general/deploy-mongo.tsx | 12 ++++-------- components/dashboard/mysql/general/deploy-mysql.tsx | 12 ++++-------- .../dashboard/postgres/general/deploy-postgres.tsx | 12 ++++-------- components/dashboard/redis/general/deploy-redis.tsx | 12 ++++-------- 7 files changed, 29 insertions(+), 56 deletions(-) diff --git a/components/dashboard/application/general/deploy-application.tsx b/components/dashboard/application/general/deploy-application.tsx index 4ce1bb87..47fbb5c0 100644 --- a/components/dashboard/application/general/deploy-application.tsx +++ b/components/dashboard/application/general/deploy-application.tsx @@ -11,6 +11,7 @@ import { } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { api } from "@/utils/api"; +import { useEffect, useState } from "react"; import { toast } from "sonner"; interface Props { @@ -51,18 +52,14 @@ export const DeployApplication = ({ applicationId }: Props) => { applicationId, }) .then(async () => { - toast.success("Application Deploying...."); + toast.success("Deploying Application...."); await refetch(); await deploy({ applicationId, - }) - .then(() => { - toast.success("Application Deployed Succesfully"); - }) - .catch(() => { - toast.error("Error to deploy Application"); - }); + }).catch(() => { + toast.error("Error to deploy Application"); + }); await refetch(); }) diff --git a/components/dashboard/compose/general/deploy-compose.tsx b/components/dashboard/compose/general/deploy-compose.tsx index 3b5bb11b..1617ee7b 100644 --- a/components/dashboard/compose/general/deploy-compose.tsx +++ b/components/dashboard/compose/general/deploy-compose.tsx @@ -49,18 +49,14 @@ export const DeployCompose = ({ composeId }: Props) => { composeStatus: "running", }) .then(async () => { - toast.success("Compose Deploying...."); + toast.success("Deploying Compose...."); await refetch(); await deploy({ composeId, - }) - .then(() => { - toast.success("Compose Deployed Succesfully"); - }) - .catch(() => { - toast.error("Error to deploy Compose"); - }); + }).catch(() => { + toast.error("Error to deploy Compose"); + }); await refetch(); }) diff --git a/components/dashboard/mariadb/general/deploy-mariadb.tsx b/components/dashboard/mariadb/general/deploy-mariadb.tsx index ac581d0d..e3162f00 100644 --- a/components/dashboard/mariadb/general/deploy-mariadb.tsx +++ b/components/dashboard/mariadb/general/deploy-mariadb.tsx @@ -50,17 +50,13 @@ export const DeployMariadb = ({ mariadbId }: Props) => { applicationStatus: "running", }) .then(async () => { - toast.success("Database Deploying...."); + toast.success("Deploying Database...."); await refetch(); await deploy({ mariadbId, - }) - .then(() => { - toast.success("Database Deployed Succesfully"); - }) - .catch(() => { - toast.error("Error to deploy Database"); - }); + }).catch(() => { + toast.error("Error to deploy Database"); + }); await refetch(); }) .catch((e) => { diff --git a/components/dashboard/mongo/general/deploy-mongo.tsx b/components/dashboard/mongo/general/deploy-mongo.tsx index 41a92f64..0ebda1ca 100644 --- a/components/dashboard/mongo/general/deploy-mongo.tsx +++ b/components/dashboard/mongo/general/deploy-mongo.tsx @@ -50,17 +50,13 @@ export const DeployMongo = ({ mongoId }: Props) => { applicationStatus: "running", }) .then(async () => { - toast.success("Database Deploying...."); + toast.success("Deploying Database...."); await refetch(); await deploy({ mongoId, - }) - .then(() => { - toast.success("Database Deployed Succesfully"); - }) - .catch(() => { - toast.error("Error to deploy Database"); - }); + }).catch(() => { + toast.error("Error to deploy Database"); + }); await refetch(); }) .catch((e) => { diff --git a/components/dashboard/mysql/general/deploy-mysql.tsx b/components/dashboard/mysql/general/deploy-mysql.tsx index 7074901f..a773feff 100644 --- a/components/dashboard/mysql/general/deploy-mysql.tsx +++ b/components/dashboard/mysql/general/deploy-mysql.tsx @@ -50,17 +50,13 @@ export const DeployMysql = ({ mysqlId }: Props) => { applicationStatus: "running", }) .then(async () => { - toast.success("Database Deploying...."); + toast.success("Deploying Database...."); await refetch(); await deploy({ mysqlId, - }) - .then(() => { - toast.success("Database Deployed Succesfully"); - }) - .catch(() => { - toast.error("Error to deploy Database"); - }); + }).catch(() => { + toast.error("Error to deploy Database"); + }); await refetch(); }) .catch((e) => { diff --git a/components/dashboard/postgres/general/deploy-postgres.tsx b/components/dashboard/postgres/general/deploy-postgres.tsx index 297df353..e329d9f8 100644 --- a/components/dashboard/postgres/general/deploy-postgres.tsx +++ b/components/dashboard/postgres/general/deploy-postgres.tsx @@ -50,17 +50,13 @@ export const DeployPostgres = ({ postgresId }: Props) => { applicationStatus: "running", }) .then(async () => { - toast.success("Database Deploying...."); + toast.success("Deploying Database...."); await refetch(); await deploy({ postgresId, - }) - .then(() => { - toast.success("Database Deployed Succesfully"); - }) - .catch(() => { - toast.error("Error to deploy Database"); - }); + }).catch(() => { + toast.error("Error to deploy Database"); + }); await refetch(); }) .catch((e) => { diff --git a/components/dashboard/redis/general/deploy-redis.tsx b/components/dashboard/redis/general/deploy-redis.tsx index a20ef1c3..131af030 100644 --- a/components/dashboard/redis/general/deploy-redis.tsx +++ b/components/dashboard/redis/general/deploy-redis.tsx @@ -50,17 +50,13 @@ export const DeployRedis = ({ redisId }: Props) => { applicationStatus: "running", }) .then(async () => { - toast.success("Database Deploying...."); + toast.success("Deploying Database..."); await refetch(); await deploy({ redisId, - }) - .then(() => { - toast.success("Database Deployed Succesfully"); - }) - .catch(() => { - toast.error("Error to deploy Database"); - }); + }).catch(() => { + toast.error("Error to deploy Database"); + }); await refetch(); }) .catch((e) => {