Add Activepieces integration for workflow automation
- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { HttpStatusCode } from 'axios';
|
||||
import { t } from 'i18next';
|
||||
import { UseFormReturn } from 'react-hook-form';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
import { internalErrorToast } from '@/components/ui/sonner';
|
||||
import { api } from '@/lib/api';
|
||||
import { authenticationSession } from '@/lib/authentication-session';
|
||||
import { Alert, AlertChannel } from '@activepieces/ee-shared';
|
||||
|
||||
import { alertsApi } from './api';
|
||||
|
||||
type Params = {
|
||||
email: string;
|
||||
};
|
||||
|
||||
export const alertsKeys = {
|
||||
all: ['alerts-email-list'] as const,
|
||||
};
|
||||
|
||||
type Options = {
|
||||
setOpen: (open: boolean) => void;
|
||||
form: UseFormReturn<any>;
|
||||
};
|
||||
|
||||
export const alertMutations = {
|
||||
useCreateAlert: ({ setOpen, form }: Options) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<Alert, Error, Params>({
|
||||
mutationFn: async (params) =>
|
||||
alertsApi.create({
|
||||
receiver: params.email,
|
||||
projectId: authenticationSession.getProjectId()!,
|
||||
channel: AlertChannel.EMAIL,
|
||||
}),
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: alertsKeys.all });
|
||||
toast.success(t('Your changes have been saved.'), {
|
||||
duration: 3000,
|
||||
});
|
||||
setOpen(false);
|
||||
},
|
||||
onError: (error) => {
|
||||
if (api.isError(error)) {
|
||||
switch (error.response?.status) {
|
||||
case HttpStatusCode.Conflict:
|
||||
form.setError('root.serverError', {
|
||||
message: t('The email is already added.'),
|
||||
});
|
||||
break;
|
||||
default: {
|
||||
internalErrorToast();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
useDeleteAlert: () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<void, Error, Alert>({
|
||||
mutationFn: (alert) => alertsApi.delete(alert.id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: alertsKeys.all });
|
||||
toast.success(t('Your changes have been saved.'), {
|
||||
duration: 3000,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export const alertQueries = {
|
||||
useAlertsEmailList: () =>
|
||||
useQuery<Alert[], Error, Alert[]>({
|
||||
queryKey: alertsKeys.all,
|
||||
queryFn: async () => {
|
||||
const page = await alertsApi.list({
|
||||
projectId: authenticationSession.getProjectId()!,
|
||||
limit: 100,
|
||||
});
|
||||
return page.data;
|
||||
},
|
||||
}),
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
import { api } from '@/lib/api';
|
||||
import {
|
||||
Alert,
|
||||
CreateAlertParams,
|
||||
ListAlertsParams,
|
||||
} from '@activepieces/ee-shared';
|
||||
import { SeekPage } from '@activepieces/shared';
|
||||
|
||||
export const alertsApi = {
|
||||
create(request: CreateAlertParams): Promise<Alert> {
|
||||
return api.post<Alert>('/v1/alerts', request);
|
||||
},
|
||||
list(request: ListAlertsParams): Promise<SeekPage<Alert>> {
|
||||
return api.get<SeekPage<Alert>>('/v1/alerts', request);
|
||||
},
|
||||
delete(alertId: string): Promise<void> {
|
||||
return api.delete<void>(`/v1/alerts/${alertId}`);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user