-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create dashboard organization home page (#6325)
- Loading branch information
Showing
14 changed files
with
228 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
lms/static/scripts/frontend_apps/components/dashboard/OrganizationActivity.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { | ||
Card, | ||
CardContent, | ||
CardHeader, | ||
Link, | ||
} from '@hypothesis/frontend-shared'; | ||
import { Link as RouterLink } from 'wouter-preact'; | ||
|
||
import type { Courses } from '../../api-types'; | ||
import { useConfig } from '../../config'; | ||
import { urlPath, useAPIFetch } from '../../utils/api'; | ||
import { replaceURLParams } from '../../utils/url'; | ||
import OrderableActivityTable from './OrderableActivityTable'; | ||
|
||
export type OrganizationActivityProps = { | ||
organizationPublicId: string; | ||
}; | ||
|
||
/** | ||
* List of courses that belong to a specific organization | ||
*/ | ||
export default function OrganizationActivity({ | ||
organizationPublicId, | ||
}: OrganizationActivityProps) { | ||
const { dashboard } = useConfig(['dashboard']); | ||
const { routes } = dashboard; | ||
const courses = useAPIFetch<Courses>( | ||
replaceURLParams(routes.organization_courses, { | ||
organization_public_id: organizationPublicId, | ||
}), | ||
); | ||
|
||
return ( | ||
<Card> | ||
<CardHeader title="Home" fullWidth /> | ||
<CardContent> | ||
<OrderableActivityTable | ||
loading={courses.isLoading} | ||
title="Courses" | ||
emptyMessage={ | ||
courses.error ? 'Could not load courses' : 'No courses found' | ||
} | ||
rows={courses.data ?? []} | ||
columnNames={{ title: 'Course Title' }} | ||
defaultOrderField="title" | ||
renderItem={stats => ( | ||
<RouterLink href={urlPath`/courses/${String(stats.id)}`} asChild> | ||
<Link>{stats.title}</Link> | ||
</RouterLink> | ||
)} | ||
/> | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.