(eventNames[0]);
const submit = useCallback(() => {
console.log({
@@ -96,6 +101,7 @@ function Tester({
testFetcher.submit(
{
+ eventName,
payload: testContent,
},
{
@@ -103,10 +109,23 @@ function Tester({
action: `/resources/run/${organizationSlug}/test/${workflowSlug}`,
}
);
- }, [organizationSlug, testContent, testFetcher, workflowSlug]);
+ }, [eventName, organizationSlug, testContent, testFetcher, workflowSlug]);
return (
+ {eventNames.length > 1 ? (
+
+ ) : null}
{
try {
const formData = await request.formData();
const body = Object.fromEntries(formData.entries());
- const { payload } = requestSchema.parse(body);
+ const { eventName, payload } = requestSchema.parse(body);
const jsonPayload = JSON.parse(payload);
@@ -61,7 +63,7 @@ export const action = async ({ request, params }: ActionArgs) => {
await ingestService.call(
{
id: ulid(),
- name: workflow.eventNames[0],
+ name: eventName,
type: workflow.type,
service: workflow.service,
payload: jsonPayload,
@@ -72,8 +74,11 @@ export const action = async ({ request, params }: ActionArgs) => {
organization
);
- //todo redirect to the runs page
- return null;
+ return redirectWithSuccessMessage(
+ `/orgs/${organizationSlug}/workflows/${workflowSlug}/runs`,
+ request,
+ "Test event successfully sent"
+ );
} catch (error: any) {
console.error(error);
throw new Response(error.message, { status: 400 });