From fa7ceccd4ac06f1bed426789022a7779202a7653 Mon Sep 17 00:00:00 2001 From: Vivian Plasencia Date: Sat, 30 Mar 2024 13:36:59 +0100 Subject: [PATCH] fix: remove the creation of an admin in the dashboard app The admin must be created in the Bandada backend. re #460 --- apps/api/src/app/admins/admins.controller.ts | 19 +-------------- apps/dashboard/src/api/bandadaAPI.ts | 25 -------------------- apps/dashboard/src/context/auth-context.tsx | 13 +--------- 3 files changed, 2 insertions(+), 55 deletions(-) diff --git a/apps/api/src/app/admins/admins.controller.ts b/apps/api/src/app/admins/admins.controller.ts index ad41fb1b..d9e8ea38 100644 --- a/apps/api/src/app/admins/admins.controller.ts +++ b/apps/api/src/app/admins/admins.controller.ts @@ -1,30 +1,13 @@ -import { - Body, - Controller, - Get, - Param, - Post, - Put, - UseGuards -} from "@nestjs/common" +import { Body, Controller, Get, Param, Put, UseGuards } from "@nestjs/common" import { ApiExcludeEndpoint } from "@nestjs/swagger" import { AuthGuard } from "../auth/auth.guard" -import { CreateAdminDTO } from "./dto/create-admin.dto" import { AdminsService } from "./admins.service" -import { Admin } from "./entities/admin.entity" import { UpdateApiKeyDTO } from "./dto/update-apikey.dto" @Controller("admins") export class AdminsController { constructor(private readonly adminsService: AdminsService) {} - @Post() - @UseGuards(AuthGuard) - @ApiExcludeEndpoint() - async createAdmin(@Body() dto: CreateAdminDTO): Promise { - return this.adminsService.create(dto) - } - @Get(":admin") @UseGuards(AuthGuard) @ApiExcludeEndpoint() diff --git a/apps/dashboard/src/api/bandadaAPI.ts b/apps/dashboard/src/api/bandadaAPI.ts index b5675e71..b53c8f15 100644 --- a/apps/dashboard/src/api/bandadaAPI.ts +++ b/apps/dashboard/src/api/bandadaAPI.ts @@ -108,31 +108,6 @@ export async function createGroup( } } -/** - * It creates a new admin. - * @param id The admin id. - * @param address The admin address. - * @returns The Admin. - */ -export async function createAdmin( - id: string, - address: string -): Promise { - try { - return await request(`${API_URL}/admins`, { - method: "POST", - data: { - id, - address - } - }) - } catch (error: any) { - console.error(error) - createAlert(error.response.data.message) - return null - } -} - /** * It returns details of a specific admin. * @param adminId The admin id. diff --git a/apps/dashboard/src/context/auth-context.tsx b/apps/dashboard/src/context/auth-context.tsx index b3b3e8e5..172af824 100644 --- a/apps/dashboard/src/context/auth-context.tsx +++ b/apps/dashboard/src/context/auth-context.tsx @@ -17,13 +17,7 @@ import { SiweMessage } from "siwe" import { configureChains, createClient, WagmiConfig } from "wagmi" import { sepolia } from "wagmi/chains" import { publicProvider } from "wagmi/providers/public" -import { - createAdmin, - getAdmin, - getNonce, - logOut, - signIn -} from "../api/bandadaAPI" +import { getNonce, logOut, signIn } from "../api/bandadaAPI" import useSessionData from "../hooks/use-session-data" import { Admin } from "../types" @@ -73,11 +67,6 @@ export function AuthContextProvider({ children }: { children: ReactNode }) { if (admin) { saveAdmin(admin) - const alreadyCreated = await getAdmin(admin.id) - - if (!alreadyCreated) - await createAdmin(admin.id, admin.address) - return true }