invite button and can navigate to submissions (no submissions will appear yet)
This commit is contained in:
@@ -27,7 +27,7 @@ interface OrgContextType {
|
||||
upsertOrg: (data: Partial<OrgData>) => Promise<void>;
|
||||
saveReport: (employeeId: string, report: EmployeeReport) => Promise<void>;
|
||||
inviteEmployee: (args: { name: string; email: string }) => Promise<{ employeeId: string; inviteLink: string }>;
|
||||
issueInviteViaApi: (args: { name: string; email: string; role?: string; department?: string }) => Promise<{ code: string; inviteLink: string; emailLink: string; employee: any }>;
|
||||
issueInviteViaApi: (args: { name: string; email: string; role?: string; department?: string }) => Promise<{ code: string; inviteLink: string; employee: any }>;
|
||||
getInviteStatus: (code: string) => Promise<{ used: boolean; employee: any } | null>;
|
||||
consumeInvite: (code: string) => Promise<{ employee: any; orgId?: string } | null>;
|
||||
getReportVersions: (employeeId: string) => Promise<Array<{ id: string; createdAt: number; report: EmployeeReport }>>;
|
||||
@@ -182,12 +182,12 @@ export const OrgProvider: React.FC<{ children: React.ReactNode; selectedOrgId: s
|
||||
}
|
||||
};
|
||||
|
||||
const inviteEmployee = async ({ name, email }: { name: string; email: string }) => {
|
||||
const inviteEmployee = async ({ name, email, role, department }: { name: string; email: string, role?: string, department?: string }) => {
|
||||
console.log('inviteEmployee called:', { name, email, orgId });
|
||||
|
||||
try {
|
||||
// Use secure API for invites
|
||||
const data = await secureApi.createInvitation(name, email);
|
||||
const data = await secureApi.createInvitation({ name, email, role, department });
|
||||
|
||||
console.log('Invite created successfully:', { code: data.code, employee: data.employee.name, inviteLink: data.inviteLink });
|
||||
|
||||
@@ -199,7 +199,8 @@ export const OrgProvider: React.FC<{ children: React.ReactNode; selectedOrgId: s
|
||||
initials: data.employee.name ? data.employee.name.split(' ').map(n => n[0]).join('').toUpperCase() : data.employee.email.substring(0, 2).toUpperCase(),
|
||||
department: data.employee.department,
|
||||
role: data.employee.role,
|
||||
isOwner: false
|
||||
isOwner: false,
|
||||
status: data.employee.status
|
||||
};
|
||||
|
||||
// Add to local state for immediate UI update
|
||||
@@ -509,7 +510,7 @@ export const OrgProvider: React.FC<{ children: React.ReactNode; selectedOrgId: s
|
||||
throw new Error('User authentication required');
|
||||
}
|
||||
|
||||
const data = await secureApi.createInvitation(name, email, role, department);
|
||||
const data = await secureApi.createInvitation({ name, email, role, department });
|
||||
|
||||
// Optimistically add employee shell (not yet active until consume)
|
||||
setEmployees(prev => prev.find(e => e.id === data.employee.id) ? prev : [...prev, {
|
||||
|
||||
Reference in New Issue
Block a user