Add event status trigger, improve test coverage, and UI enhancements
- Add event-status-changed trigger for SmoothSchedule Activepieces piece - Add comprehensive test coverage for payments, tickets, messaging, mobile - Add test coverage for core services, signals, consumers, and views - Improve Activepieces UI: templates, billing hooks, project hooks - Update marketing automation showcase and workflow visual components - Add public API endpoints for availability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { ListTemplatesRequestQuery, Template } from '@activepieces/shared';
|
||||
import {
|
||||
ListTemplatesRequestQuery,
|
||||
Template,
|
||||
TemplateType,
|
||||
} from '@activepieces/shared';
|
||||
|
||||
import { templatesApi } from '../lib/templates-api';
|
||||
|
||||
@@ -9,7 +13,7 @@ export const useTemplates = (request: ListTemplatesRequestQuery) => {
|
||||
const [search, setSearch] = useState<string>('');
|
||||
|
||||
const { data: templates, isLoading } = useQuery<Template[], Error>({
|
||||
queryKey: ['templates'],
|
||||
queryKey: ['templates', request.type],
|
||||
queryFn: async () => {
|
||||
const templates = await templatesApi.list(request);
|
||||
return templates.data;
|
||||
@@ -34,3 +38,86 @@ export const useTemplates = (request: ListTemplatesRequestQuery) => {
|
||||
setSearch,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Hook to fetch both custom (platform) and official templates
|
||||
*/
|
||||
export const useAllTemplates = () => {
|
||||
const [search, setSearch] = useState<string>('');
|
||||
|
||||
// Fetch custom templates (platform-specific)
|
||||
const {
|
||||
data: customTemplates,
|
||||
isLoading: isLoadingCustom,
|
||||
} = useQuery<Template[], Error>({
|
||||
queryKey: ['templates', TemplateType.CUSTOM],
|
||||
queryFn: async () => {
|
||||
try {
|
||||
const templates = await templatesApi.list({
|
||||
type: TemplateType.CUSTOM,
|
||||
});
|
||||
return templates.data;
|
||||
} catch {
|
||||
// If custom templates fail (e.g., feature not enabled), return empty array
|
||||
return [];
|
||||
}
|
||||
},
|
||||
staleTime: 0,
|
||||
});
|
||||
|
||||
// Fetch official templates from Activepieces cloud
|
||||
const {
|
||||
data: officialTemplates,
|
||||
isLoading: isLoadingOfficial,
|
||||
} = useQuery<Template[], Error>({
|
||||
queryKey: ['templates', TemplateType.OFFICIAL],
|
||||
queryFn: async () => {
|
||||
try {
|
||||
const templates = await templatesApi.list({
|
||||
type: TemplateType.OFFICIAL,
|
||||
});
|
||||
return templates.data;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
staleTime: 0,
|
||||
});
|
||||
|
||||
const isLoading = isLoadingCustom || isLoadingOfficial;
|
||||
|
||||
// Combine all templates
|
||||
const allTemplates = [
|
||||
...(customTemplates || []),
|
||||
...(officialTemplates || []),
|
||||
];
|
||||
|
||||
const filteredTemplates = allTemplates.filter((template) => {
|
||||
const templateName = template.name.toLowerCase();
|
||||
const templateDescription = template.description.toLowerCase();
|
||||
return (
|
||||
templateName.includes(search.toLowerCase()) ||
|
||||
templateDescription.includes(search.toLowerCase())
|
||||
);
|
||||
});
|
||||
|
||||
// Separate filtered results by type
|
||||
const filteredCustomTemplates = filteredTemplates.filter(
|
||||
(t) => t.type === TemplateType.CUSTOM,
|
||||
);
|
||||
const filteredOfficialTemplates = filteredTemplates.filter(
|
||||
(t) => t.type === TemplateType.OFFICIAL,
|
||||
);
|
||||
|
||||
return {
|
||||
customTemplates: customTemplates || [],
|
||||
officialTemplates: officialTemplates || [],
|
||||
allTemplates,
|
||||
filteredTemplates,
|
||||
filteredCustomTemplates,
|
||||
filteredOfficialTemplates,
|
||||
isLoading,
|
||||
search,
|
||||
setSearch,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user