fix: allow creating email template groups without templates#528
fix: allow creating email template groups without templates#528adambarito wants to merge 2 commits intomainfrom
Conversation
- Fixed TRPC route to handle empty email templates array - Added checks to prevent empty array DB inserts - Made emailTemplates array default to empty in schemas - Added error logging to modal mutations - Improved cache invalidation after create/update Fixes #524 Co-authored-by: adambarito <adambarito@users.noreply.github.com>
Greptile OverviewGreptile SummaryFixed the ability to create and update email template groups without requiring associated templates by making the Key Changes:
Impact: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Modal as CreateOrUpdateModal
participant Form as useZodForm
participant Mutation as tRPC Mutation
participant Route as emailTemplateGroup.route
participant DB as Database
User->>Modal: Click "Create Group"
Modal->>Form: Initialize with schema (emailTemplates: [])
User->>Form: Enter name & description
Note over User,Form: User can optionally add templates<br/>or leave empty
User->>Form: Submit form
Form->>Form: Validate with upsertEmailTemplateGroupSchema
Form->>Mutation: createEmailTemplateGroup(data)
Mutation->>Route: create procedure
Route->>DB: Insert EmailTemplateGroup
DB-->>Route: Return created group
alt emailTemplates.length > 0
Route->>DB: Insert into _EmailTemplates_To_EmailTemplateGroups
DB-->>Route: Success
else emailTemplates.length === 0
Note over Route: Skip association insert (fix applied)
end
Route-->>Mutation: Return created group
Mutation->>Modal: onSuccess callback
Modal->>Modal: invalidateQueries & close modal
Modal-->>User: Show updated list
|
| onError: error => { | ||
| console.error('Failed to create email template group:', error); | ||
| }, |
There was a problem hiding this comment.
console.error provides minimal visibility for production errors
| onError: error => { | |
| console.error('Failed to create email template group:', error); | |
| }, | |
| onError: error => { | |
| // Handle error appropriately (e.g., show toast notification) | |
| }, |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/app/src/app/[handle]/email/template-groups/_components/create-or-update-email-template-group-modal.tsx
Line: 68:70
Comment:
`console.error` provides minimal visibility for production errors
```suggestion
onError: error => {
// Handle error appropriately (e.g., show toast notification)
},
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| onError: error => { | ||
| console.error('Failed to update email template group:', error); | ||
| }, |
There was a problem hiding this comment.
console.error provides minimal visibility for production errors
| onError: error => { | |
| console.error('Failed to update email template group:', error); | |
| }, | |
| onError: error => { | |
| // Handle error appropriately (e.g., show toast notification) | |
| }, |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/app/src/app/[handle]/email/template-groups/_components/create-or-update-email-template-group-modal.tsx
Line: 79:81
Comment:
`console.error` provides minimal visibility for production errors
```suggestion
onError: error => {
// Handle error appropriately (e.g., show toast notification)
},
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
apps
db
|
|
1. This is a comment left during a code review. Comment: Please resolve with toast. 2. This is a comment left during a code review. Comment: Please resolve with toast here too. 3. There are typecheck failures. |
|
Claude finished @adambarito's task —— View job Todo List:
SummaryI've successfully completed all the requested changes:
The changes have been committed and pushed to the PR branch. |
… group modal - Added import for toast from 'sonner' - Replaced console.error calls with toast.error() for better user feedback - Fixed TypeScript error by adding optional chaining for activeEmailTemplates Co-authored-by: adambarito <adambarito@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 14 Skipped Deployments
|
apps
db
|
Fixes #524
Summary
Test plan
Generated with Claude Code