Skip to content

Commit cb9a0e9

Browse files
committed
feat: add query for select channel, flow
1 parent 246c7d7 commit cb9a0e9

File tree

9 files changed

+417
-335
lines changed

9 files changed

+417
-335
lines changed

client/src/components/pages/chatbots/flow-item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export const FlowItem = ({ flow }: Props) => {
129129
deleteFlowMutation.mutate(flow.id);
130130
close();
131131
}}
132-
isLoading={deleteFlowMutation.isLoading}
132+
isLoading={deleteFlowMutation.isPending}
133133
>
134134
<DropdownMenuItem
135135
onSelect={(e) => {

client/src/lib/schema/flow-input.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const useFlowInputSchema = () => {
2424
)
2525
.optional(),
2626
flows: z.array(z.record(z.any())).optional(),
27+
channelIds: z.array(z.string()).optional(),
2728
});
2829
};
2930

server/src/controllers/channels.controller.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,14 @@ export class ChannelController {
7171
const data = await this.channelService.getTypeById(req.params.id);
7272
res.status(StatusCodes.OK).json({ data });
7373
});
74+
75+
public getChannelsForSelect = catchAsync(
76+
async (req: RequestWithUser, res) => {
77+
const data = await this.channelService.getChannelsForSelect(
78+
req.user?.id as string,
79+
req.query.flowId as string
80+
);
81+
res.status(StatusCodes.OK).json({ data });
82+
}
83+
);
7484
}

server/src/controllers/flows.controller.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,12 @@ export class FlowController {
8888
res.status(StatusCodes.OK).json({ data });
8989
}
9090
);
91+
92+
public getFlowsForSelect = catchAsync(async (req: RequestWithUser, res) => {
93+
const data = await this.flowService.getFlowsForSelect(
94+
req.user?.id as string,
95+
req.query.channelId as string
96+
);
97+
res.status(StatusCodes.OK).json({ data });
98+
});
9199
}

server/src/routes/channels.route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,11 @@ export class ChannelRoute implements Routes {
5555
`${ENDPOINTS.CHANNEL.TYPES}/:id`,
5656
this.controller.getChannelType
5757
);
58+
59+
this.router.get(
60+
`${ENDPOINTS.CHANNEL.INDEX}/for-select`,
61+
authMiddleware,
62+
this.controller.getChannelsForSelect
63+
);
5864
}
5965
}

server/src/routes/flow.route.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,11 @@ export class FlowRoute implements Routes {
6666
authMiddleware,
6767
this.controller.selectFlowsForChannel
6868
);
69+
70+
this.router.get(
71+
`${ENDPOINTS.FLOW.INDEX}/for-select`,
72+
authMiddleware,
73+
this.controller.getFlowsForSelect
74+
);
6975
}
7076
}

0 commit comments

Comments
 (0)