import { uid } from '@formily/shared'; import { BlockInitializer, useSchemaInitializerItem } from '@nocobase/client'; import React from 'react'; import { useCustomRequestsResource } from '../hooks/useCustomRequestsResource'; export const CustomRequestInitializer: React.FC = (props) => { const customRequestsResource = useCustomRequestsResource(); const schema = { title: '{{ t("Custom request") }}', 'x-component': 'CustomRequestAction', 'x-action': 'customize:form:request', 'x-designer': 'CustomRequestAction.Designer', 'x-decorator': 'CustomRequestAction.Decorator', 'x-uid': uid(), 'x-action-settings': { onSuccess: { manualClose: false, redirecting: false, successMessage: '{{t("Request success")}}', }, }, }; const itemConfig = useSchemaInitializerItem(); return ( { // create a custom request await customRequestsResource.create({ values: { key: s['x-uid'], }, }); }} schema={schema} /> ); };