Skip to content

Commit 23c3a02

Browse files
authored
Merge pull request #35 from Dialogue-Bot/DIAL-32-ui-chat-bot
feat: update
2 parents b850c87 + 3ab7887 commit 23c3a02

File tree

6 files changed

+18
-63
lines changed

6 files changed

+18
-63
lines changed

client/src/pages/chatbot-detail.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import { Edge } from '@/components/pages/chatbot-detail/edge'
77
import { Toolbar } from '@/components/pages/chatbot-detail/toolbar'
88
import { queryFlowDetailOption } from '@/lib/query-options/flow'
9-
import { ENodeTypes } from '@/types/flow'
9+
import { EActionTypes } from '@/types/flow'
1010
import { useSuspenseQuery } from '@tanstack/react-query'
1111
import { useCallback } from 'react'
1212
import { useParams } from 'react-router-dom'
@@ -29,19 +29,19 @@ const ChatBotDetail = () => {
2929
const [nodes, _setNodes, onNodesChange] = useNodesState([
3030
{
3131
id: '1',
32-
type: ENodeTypes.START,
32+
type: EActionTypes.START,
3333
position: { x: 100, y: 100 },
3434
data: { label: 'Start' },
3535
},
3636
{
3737
id: '2',
38-
type: ENodeTypes.MESSAGE,
38+
type: EActionTypes.MESSAGE,
3939
position: { x: 250, y: 100 },
4040
data: { label: 'Message' },
4141
},
4242
{
4343
id: '3',
44-
type: ENodeTypes.MESSAGE,
44+
type: EActionTypes.MESSAGE,
4545
position: { x: 250, y: 100 },
4646
data: { label: 'Message' },
4747
},

client/src/types/flow.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
export enum ENodeTypes {
1+
export enum EActionTypes {
22
START = 'start',
3-
END = 'end',
4-
ACTION = 'action',
5-
CONDITION = 'condition',
63
MESSAGE = 'message',
7-
QUESTION = 'question',
8-
ANSWER = 'answer',
9-
OPTION = 'option',
10-
FORM = 'form',
4+
PROMPT_AND_COLLECT = 'prompt-and-collect',
5+
CHECK_ATTRIBUTE = 'check-attribute',
6+
SEND_MAIL = 'send-mail',
7+
HTTP_REQUEST = 'http-request',
8+
SUB_FLOW = 'sub-flow',
119
}
1210

13-
export type TNodeTypes = Partial<Record<ENodeTypes, () => JSX.Element>>
11+
export type TNodeTypes = Partial<Record<EActionTypes, () => JSX.Element>>
1412

1513
export type TFLow = {
1614
id: string

server/src/controllers/flows.controller.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ export class FlowController {
6666
res.status(StatusCodes.OK).json({ data })
6767
})
6868

69-
public selectFlowsForChannel = catchAsync(
70-
async (req: RequestWithUser, res) => {
71-
const data = await this.flowService.selectFlowsForChannel(
72-
req.user?.id as string,
73-
)
74-
res.status(StatusCodes.OK).json({ data })
75-
},
76-
)
69+
public getFlowsForSelect = catchAsync(async (req: RequestWithUser, res) => {
70+
console.log('req.query.channelId', req.query.channelId)
71+
const data = await this.flowService.getFlowsForSelect(
72+
req.user?.id as string,
73+
)
74+
res.status(StatusCodes.OK).json({ data })
75+
})
7776

7877
public getFlowByContactId = catchAsync(async (req: RequestWithUser, res) => {
7978
const data = await this.flowService.getFlowByContactId(req.params.contactId)

server/src/dtos/flows.dto.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
<<<<<<< HEAD
21
import { getCurrentLocale } from '@/i18n/get-current'
32
import { IFlowSetting, IFlowVariable } from '@/interfaces/flows.interface'
43
import { Transform } from 'class-transformer'
5-
=======
6-
import { getCurrentLocale } from '@/i18n/get-current';
7-
import { IFlowSetting, IFlowVariable } from '@/interfaces/flows.interface';
8-
import { Transform } from 'class-transformer';
9-
>>>>>>> origin/main
104
import {
115
IsArray,
126
IsNotEmpty,

server/src/routes/flow.route.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD
21
import { ENDPOINTS } from '@/constants'
32
import { FlowController } from '@/controllers/flows.controller'
43
import { FlowDTO } from '@/dtos/flows.dto'
@@ -7,16 +6,6 @@ import { authMiddleware } from '@/middlewares/auth.middleware'
76
import { validate } from '@/middlewares/validation.middleware'
87
import type { Routes } from '@interfaces/routes.interface'
98
import { Router } from 'express'
10-
=======
11-
import { ENDPOINTS } from '@/constants';
12-
import { FlowController } from '@/controllers/flows.controller';
13-
import { FlowDTO } from '@/dtos/flows.dto';
14-
import { PagingDTO } from '@/dtos/paging.dto';
15-
import { authMiddleware } from '@/middlewares/auth.middleware';
16-
import { validate } from '@/middlewares/validation.middleware';
17-
import type { Routes } from '@interfaces/routes.interface';
18-
import { Router } from 'express';
19-
>>>>>>> origin/main
209

2110
export class FlowRoute implements Routes {
2211
public router: Router = Router()

server/src/services/flows.service.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD
21
import { LOCALE_KEY } from '@/constants'
32
import { db } from '@/database/db'
43
import { channels, flows } from '@/database/schema'
@@ -33,30 +32,6 @@ export class FlowService {
3332
@Inject(LOCALE_KEY) private readonly localeService: LocaleService,
3433
private readonly chanelService: ChannelService,
3534
) {}
36-
=======
37-
import { LOCALE_KEY } from '@/constants';
38-
import { db } from '@/database/db';
39-
import { channels, flows } from '@/database/schema';
40-
import { TNewFlow } from '@/database/types';
41-
import { FlowDTO } from '@/dtos/flows.dto';
42-
import { PagingDTO } from '@/dtos/paging.dto';
43-
import { HttpException } from '@/exceptions/http-exception';
44-
import { LocaleService } from '@/i18n/ctx';
45-
import { FlowExtend } from '@/interfaces/flows.interface';
46-
import { Paging } from '@/interfaces/paging.interface';
47-
import { and, asc, desc, eq, isNotNull, like, ne, notExists, sql } from 'drizzle-orm';
48-
import { StatusCodes } from 'http-status-codes';
49-
import { omit } from 'lodash';
50-
import { Inject, Service } from 'typedi';
51-
import { ChannelService } from './channels.service';
52-
53-
@Service()
54-
export class FlowService {
55-
constructor(
56-
@Inject(LOCALE_KEY) private readonly localeService: LocaleService,
57-
private readonly chanelService: ChannelService
58-
) { }
59-
>>>>>>> origin/main
6035

6136
public async create(fields: TNewFlow) {
6237
const flowExisted = await db.query.flows.findFirst({

0 commit comments

Comments
 (0)