-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a00fd19
commit 4b7ec5e
Showing
14 changed files
with
735 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { NextRequest, NextResponse } from "next/server"; | ||
import { ApiErrorHandler } from "@/common/error/api-error-handler"; | ||
import { UserSessionManager } from "@/domains/auth/services/user-session-maganer"; | ||
import { PrismaClientFactory } from "@/common/database/prisma-factory"; | ||
import { GetProviderChatbotFlow } from "@/domains/message-providers/use-cases/get-provider-chatbot-flow"; | ||
import { UpdateProviderChatbotFlow, updateProviderChatbotFlowInputSchema } from "@/domains/message-providers/use-cases/update-provider-chatbot-flow"; | ||
|
||
|
||
export async function GET(request: NextRequest, { params }: { params: RequestParams }) { | ||
|
||
try { | ||
const useCase = new GetProviderChatbotFlow({ | ||
userLogged: await new UserSessionManager().getUserOrThrow(), | ||
prismaClient: PrismaClientFactory.create() | ||
}); | ||
|
||
const result = await useCase.execute({ | ||
providerId: parseInt(params.id) | ||
}); | ||
|
||
return NextResponse.json(result); | ||
} | ||
catch(error) { | ||
return ApiErrorHandler.handler(error); | ||
} | ||
} | ||
|
||
|
||
export async function PUT(request: NextRequest, { params }: { params: RequestParams }) { | ||
|
||
try { | ||
const input = updateProviderChatbotFlowInputSchema.parse(await request.json()); | ||
|
||
const useCase = new UpdateProviderChatbotFlow({ | ||
userLogged: await new UserSessionManager().getUserOrThrow(), | ||
prismaClient: PrismaClientFactory.create() | ||
}); | ||
|
||
await useCase.execute({ | ||
providerId: parseInt(params.id), | ||
chatbotFlow: input.chatbotFlow | ||
}); | ||
|
||
return new NextResponse(null, { status: 204 }); | ||
} | ||
catch(error) { | ||
return ApiErrorHandler.handler(error); | ||
} | ||
} | ||
|
||
interface RequestParams { | ||
id: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AppLayout } from '@/components/AppLayout'; | ||
import { AppLayoutBody } from '@/components/AppLayout/Body'; | ||
import { AppLayoutHeader } from '@/components/AppLayout/Header'; | ||
import { AppLayoutMenuWithTitle } from '@/components/AppLayout/MenuWithTitle'; | ||
import { AppNavMenuDefault, AppNavMenuItens } from '@/components/AppLayout/NavMenu'; | ||
import { AppLayoutPreLoading } from '@/components/AppLayout/PreLoading'; | ||
import { ModalContainer } from '@/components/Modal/Container'; | ||
import { ChatbotFlowView } from '@/components/ChatbotFlowView'; | ||
|
||
export default function Settings() { | ||
|
||
return ( | ||
<AppLayout> | ||
<AppLayoutHeader> | ||
<AppLayoutMenuWithTitle title="Chatbot" /> | ||
</AppLayoutHeader> | ||
<AppLayoutBody> | ||
<AppLayoutPreLoading> | ||
<ChatbotFlowView /> | ||
</AppLayoutPreLoading> | ||
</AppLayoutBody> | ||
<AppNavMenuDefault active={AppNavMenuItens.more} /> | ||
<ModalContainer /> | ||
</AppLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.