Add flock exports, sharing invitations, and improved flock switching
This commit is contained in:
1 parent
ff177dbaed
commit
55353e4d46
12 files changed
+557
-100
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { buildEmailLayout, escapeHtml } from './emailLayout.js';
|
||||
import type { WorkspaceRole } from '../types.js';
|
||||
|
||||
const permissions: Record<WorkspaceRole, string> = {
|
||||
viewer: 'You can view all birds and care histories, and export flock data. You cannot edit records.',
|
||||
caregiver: 'You can view and export flock data, add and edit birds, log daily care, and delete supported care records. You cannot remove birds or manage sharing, billing, or transfers.',
|
||||
assistant: 'You can manage birds and care records, remove and transfer birds, manage collaborators, flock settings and billing, and view the audit log.',
|
||||
owner: 'You have full flock control, including bird removal, transfers, sharing, billing management, memorializing birds, and deleting an empty flock. This does not change the billing owner.',
|
||||
};
|
||||
|
||||
export const buildWorkspaceInviteEmail = async ({ name, email, inviterName, flockName, role, frontendUrl }: {
|
||||
name: string; email: string; inviterName: string; flockName: string; role: WorkspaceRole; frontendUrl: string;
|
||||
}) => {
|
||||
const roleLabel = role.charAt(0).toUpperCase() + role.slice(1);
|
||||
const instructions = `Sign in to FlockPal using ${email}. If you do not have an account, use that email to get started. After signing in, choose ${flockName} in the flock switcher in the navigation or Settings → Flock profile. If you are already signed in and the flock is missing, sign out and sign back in.`;
|
||||
return {
|
||||
subject: `You’re invited to ${flockName.replace(/[\r\n]+/g, ' ')} on FlockPal`,
|
||||
text: `Hi ${name},\n\n${inviterName} has invited you to ${flockName} as a ${roleLabel}.\n\n${permissions[role]}\n\n${instructions}\n\nOpen FlockPal: ${frontendUrl}\n\nIf you were not expecting this invitation, you can ignore this email.`,
|
||||
...await buildEmailLayout({
|
||||
eyebrow: 'Shared flock invitation', headline: `You’re invited to ${flockName}`,
|
||||
contentHtml: `<p>Hi ${escapeHtml(name)},</p><p>${escapeHtml(inviterName)} has invited you to <strong>${escapeHtml(flockName)}</strong> as a <strong>${roleLabel}</strong>.</p><p>${escapeHtml(permissions[role])}</p><p>${escapeHtml(instructions)}</p>`,
|
||||
action: { url: frontendUrl, label: 'Open FlockPal' },
|
||||
footer: 'If you were not expecting this invitation, you can ignore this email.',
|
||||
}),
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user