-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: miscellaneous fixes to table components #610
base: staging
Are you sure you want to change the base?
Changes from all commits
7b06891
7fff2a6
89b3f32
a101fce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from "react"; | ||
import { Center, useStyleConfig } from "@chakra-ui/react"; | ||
|
||
import DisplayStudentsIllustration from "../../../../assets/illustrations/display-students.svg"; | ||
import MessageContainer from "../MessageContainer"; | ||
|
||
const EmptyUsersMessage = ({ role }: { role: string }): React.ReactElement => { | ||
const styles = useStyleConfig("Center", { variant: "emptyMessage" }); | ||
return ( | ||
<Center __css={styles}> | ||
<MessageContainer | ||
image={DisplayStudentsIllustration} | ||
paragraphs={[]} | ||
subtitle={`You currently have no ${role}s`} | ||
textColor="blue.300" | ||
/> | ||
</Center> | ||
); | ||
}; | ||
|
||
export default EmptyUsersMessage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,11 @@ import { | |
PaginationContainer, | ||
PaginationNext, | ||
PaginationPage, | ||
PaginationPageGroup, | ||
PaginationPrevious, | ||
PaginationSeparator, | ||
usePagination, | ||
} from "@ajna/pagination"; | ||
import { HStack } from "@chakra-ui/react"; | ||
|
||
const outerLimit = 1; | ||
const innerLimit = 1; | ||
|
@@ -44,7 +44,7 @@ const Pagination = ({ | |
< Previous | ||
</PaginationPrevious> | ||
)} | ||
<PaginationPageGroup align="center" isInline> | ||
<HStack align="center"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to maintain semantic HTML I think we should use the library's built-in components (according to here the component already sets |
||
{pages.map((page: number, index: number) => { | ||
if ( | ||
index === 0 || | ||
|
@@ -85,7 +85,7 @@ const Pagination = ({ | |
} | ||
return null; | ||
})} | ||
</PaginationPageGroup> | ||
</HStack> | ||
|
||
{currentPage !== pagesCount && ( | ||
<PaginationNext | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,12 +36,14 @@ const SearchableTablePage = <T, SortPropTypes extends readonly string[]>({ | |
); | ||
return ( | ||
<> | ||
<VStack pt={4} spacing={6} w="full"> | ||
<HStack width="100%"> | ||
{searchBarComponent} | ||
{sortMenuComponent} | ||
{filterMenuComponent} | ||
</HStack> | ||
<VStack py={4} spacing={6} w="full"> | ||
{!noResults && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just to make sure, have you checked that we never pass in |
||
<HStack width="100%"> | ||
{searchBarComponent} | ||
{sortMenuComponent} | ||
{filterMenuComponent} | ||
</HStack> | ||
)} | ||
{search && ( | ||
<Text color="grey.300" fontSize="16px" width="100%"> | ||
Showing {resultsLength} results for " | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,8 +47,6 @@ const DisplayAssessmentsPage = (): React.ReactElement => { | |
const [regions, setRegions] = React.useState<Array<string>>([]); | ||
const [status, setStatus] = React.useState(""); | ||
|
||
const [isEmpty, setEmpty] = React.useState(true); | ||
|
||
const [filterOptions, setFilterOptions] = React.useState<FilterProp[]>([ | ||
{ label: "Grade", setState: setGrades, options: [] }, | ||
{ label: "Type", setState: setTestTypes, options: [] }, | ||
|
@@ -87,9 +85,6 @@ const DisplayAssessmentsPage = (): React.ReactElement => { | |
|
||
const filteredAssessments = React.useMemo(() => { | ||
if (!data) return []; | ||
if (data.tests.length) { | ||
setEmpty(false); | ||
} | ||
|
||
const filterProps = [grades, testTypes, countries, regions, status]; | ||
return filterAssessments(data.tests, filterProps); | ||
|
@@ -109,11 +104,13 @@ const DisplayAssessmentsPage = (): React.ReactElement => { | |
<SearchableTablePage | ||
filterMenuComponent={<FilterMenu filterProps={filterOptions} />} | ||
nameOfTableItems="assessments" | ||
noResults={isEmpty} | ||
noResults={(data?.tests?.length ?? 0) === 0} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also just do |
||
noResultsComponent={<EmptyTestsMessage />} | ||
resultsLength={assessments.length} | ||
search={search} | ||
searchBarComponent={<SearchBar onSearch={setSearch} />} | ||
searchBarComponent={ | ||
<SearchBar onSearch={setSearch} search={search} /> | ||
} | ||
sortMenuComponent={ | ||
<SortMenu | ||
initialSortOrder="descending" | ||
|
@@ -147,7 +144,10 @@ const DisplayAssessmentsPage = (): React.ReactElement => { | |
<QueryStateHandler error={error} loading={loading}> | ||
<Tabs | ||
marginTop={3} | ||
onChange={(index) => setStatus(STATUS_ORDER[index])} | ||
onChange={(index) => { | ||
setSearch(""); | ||
setStatus(STATUS_ORDER[index]); | ||
}} | ||
> | ||
<TabList> | ||
<Tab>All</Tab> | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,11 +13,12 @@ import { | |||||
filterAdminUsersBySearch, | ||||||
filterTeacherUsersBySearch, | ||||||
} from "../../../utils/UserUtils"; | ||||||
import AdminTab from "../../admin/user-management/admin/AdminTab"; | ||||||
import AdminUserTable from "../../admin/user-management/admin/AdminUserTable"; | ||||||
import TeacherUserTable from "../../admin/user-management/teacher/TeacherUserTable"; | ||||||
import UsersPageHeader from "../../admin/user-management/UsersPageHeader"; | ||||||
import EmptyUsersMessage from "../../common/info/messages/EmptyUsersMessage"; | ||||||
import QueryStateHandler from "../../common/QueryStateHandler"; | ||||||
import SearchableTablePage from "../../common/table/SearchableTablePage"; | ||||||
import SearchBar from "../../common/table/SearchBar"; | ||||||
import SortMenu, { type SortOrder } from "../../common/table/SortMenu"; | ||||||
import useSortProperty from "../../common/table/useSortProperty"; | ||||||
|
@@ -106,10 +107,15 @@ const UsersPage = (): React.ReactElement => { | |||||
</TabList> | ||||||
<TabPanels> | ||||||
<TabPanel padding="0"> | ||||||
<AdminTab | ||||||
<SearchableTablePage | ||||||
nameOfTableItems="admins" | ||||||
noResults={(adminData?.usersByRole?.length ?? 0) === 0} | ||||||
noResultsComponent={<EmptyUsersMessage role="admin" />} | ||||||
resultsLength={admins.length} | ||||||
search={search} | ||||||
searchBarComponent={<SearchBar onSearch={setSearch} />} | ||||||
searchBarComponent={ | ||||||
<SearchBar onSearch={setSearch} search={search} /> | ||||||
} | ||||||
sortMenuComponent={ | ||||||
<SortMenu | ||||||
labels={["name", "email"]} | ||||||
|
@@ -118,14 +124,19 @@ const UsersPage = (): React.ReactElement => { | |||||
properties={ADMIN_SORT_PROPERTIES} | ||||||
/> | ||||||
} | ||||||
UserTable={<AdminUserTable users={admins} />} | ||||||
tableComponent={<AdminUserTable users={admins} />} | ||||||
/> | ||||||
</TabPanel> | ||||||
<TabPanel padding="0"> | ||||||
<AdminTab | ||||||
<SearchableTablePage | ||||||
nameOfTableItems="teachers" | ||||||
noResults={(teacherData?.teachers?.length ?? 0) === 0} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto
Suggested change
|
||||||
noResultsComponent={<EmptyUsersMessage role="teacher" />} | ||||||
resultsLength={teachers.length} | ||||||
search={search} | ||||||
searchBarComponent={<SearchBar onSearch={setSearch} />} | ||||||
searchBarComponent={ | ||||||
<SearchBar onSearch={setSearch} search={search} /> | ||||||
} | ||||||
sortMenuComponent={ | ||||||
<SortMenu | ||||||
labels={["name", "email", "school"]} | ||||||
|
@@ -134,7 +145,7 @@ const UsersPage = (): React.ReactElement => { | |||||
properties={TEACHER_SORT_PROPERTIES} | ||||||
/> | ||||||
} | ||||||
UserTable={<TeacherUserTable users={teachers} />} | ||||||
tableComponent={<TeacherUserTable users={teachers} />} | ||||||
/> | ||||||
</TabPanel> | ||||||
</TabPanels> | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -100,7 +100,7 @@ const DisplayClassroomAssessmentsPage = () => { | |||||
<QueryStateHandler error={error} loading={loading}> | ||||||
<SearchableTablePage | ||||||
nameOfTableItems="assessments" | ||||||
noResults={paginatedData.length === 0} | ||||||
noResults={(data?.class?.testSessions?.length ?? 0) === 0} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto
Suggested change
|
||||||
noResultsComponent={ | ||||||
<EmptyClassSessionsMessage | ||||||
classroomId={classroomId} | ||||||
|
@@ -110,7 +110,7 @@ const DisplayClassroomAssessmentsPage = () => { | |||||
} | ||||||
resultsLength={paginatedData.length} | ||||||
search={search} | ||||||
searchBarComponent={<SearchBar onSearch={setSearch} />} | ||||||
searchBarComponent={<SearchBar onSearch={setSearch} search={search} />} | ||||||
sortMenuComponent={ | ||||||
<SortMenu | ||||||
initialSortOrder={sortOrder} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not the most fitting image, but i don't think we have another design for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair! Let's add a backlog ticket to ask design for a better image, but I'm fine with keeping this image for the mvp