fix: remove the creation of an admin in the dashboard app

The admin must be created in the Bandada backend.

re #460
This commit is contained in:
Vivian Plasencia
2024-03-30 13:36:59 +01:00
parent 627c9f4e81
commit fa7ceccd4a
3 changed files with 2 additions and 55 deletions

View File

@@ -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<Admin> {
return this.adminsService.create(dto)
}
@Get(":admin")
@UseGuards(AuthGuard)
@ApiExcludeEndpoint()

View File

@@ -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<Admin | null> {
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.

View File

@@ -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
}