Enhance audience management features with new components and API integrations
- Added `AssignCoursesModal`, `AudienceMemberRow`, `AudienceTable`, and related components for improved audience management UI. - Implemented audience invite actions including resend and revoke functionality. - Updated audience API to support importing members and assigning courses. - Refactored audience data handling to include status and invite management. - Improved overall user experience with pagination and selection features in the audience table.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { getOrgBySiteName } from '$features/org/api/org.server';
|
||||
import { classroomio } from '$lib/utils/services/api';
|
||||
import { getApiKeyHeaders } from '$lib/utils/services/api/server';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export const load = async ({ params = { hash: '' } }) => {
|
||||
try {
|
||||
const token = decodeURIComponent(params.hash);
|
||||
const response = await classroomio.invite.organization[':token'].preview.$get(
|
||||
{
|
||||
param: { token }
|
||||
},
|
||||
getApiKeyHeaders()
|
||||
);
|
||||
const result = await response.json();
|
||||
|
||||
if (!result.success || !result.data) {
|
||||
throw new Error('Invalid organization invite payload');
|
||||
}
|
||||
|
||||
const apiKeyHeaders = getApiKeyHeaders();
|
||||
const currentOrg = result.data.organization.siteName
|
||||
? await getOrgBySiteName(result.data.organization.siteName, apiKeyHeaders)
|
||||
: null;
|
||||
|
||||
return {
|
||||
token,
|
||||
invite: result.data,
|
||||
currentOrg
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error decoding organization invite params.hash', error);
|
||||
redirect(307, '/404');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user