diff --git a/README.md b/README.md index a5d51a2..e7624d0 100644 --- a/README.md +++ b/README.md @@ -303,94 +303,6 @@ notificationsPlugin({ }) ``` -### Example: Using @xtr-dev/payload-mailing - -```typescript -import { notificationsPlugin } from '@xtr-dev/payload-notifications' -import { mailingPlugin } from '@xtr-dev/payload-mailing' - -// Configure the mailing plugin -const mailing = mailingPlugin({ - // ... your mailing config -}) - -// Add email notifications using collection overrides -const notifications = notificationsPlugin({ - channels: [{ id: 'default', name: 'Default' }], - collectionOverrides: { - notifications: (config) => ({ - ...config, - hooks: { - ...config.hooks, - afterChange: [ - ...(config.hooks?.afterChange || []), - async ({ doc, operation, req }) => { - if (operation === 'create') { - try { - // Get recipient details - let recipientId = doc.recipient - if (typeof recipientId === 'object' && recipientId?.id) { - recipientId = recipientId.id - } - - if (!recipientId) return - - const recipient = await req.payload.findByID({ - collection: 'users', - id: recipientId - }) - - if (!recipient?.email) return - - // Extract plain text from rich text message - const extractText = (richText: any[]): string => { - return richText - .map(block => - block.children - ?.map((child: any) => child.text) - .join('') - ) - .join('\n') - } - - const messageText = extractText(doc.message) - - // Send email using payload-mailing - await req.payload.create({ - collection: 'emails', - data: { - to: recipient.email, - subject: doc.title, - text: messageText, - html: ` -