Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | 1x 1x 79x 79x 79x 5x 6x 316x 4x 1x 474x | import React, { memo } from "react";
import { Box, Button, FormControl, MenuItem, Select, TextField, Typography } from "@mui/material";
import SearchIcon from "@mui/icons-material/Search";
import { useTheme } from "@mui/material/styles";
import {
getHeroSoftSearchFieldSx,
getHeroSoftSelectSx,
getHeroSoftToolbarSx,
} from "@/utils/components/tables/heroTableStyles";
import { TEACHER_TESTS_IDS } from "@/utils/helpers/testIds";
import { EXAM_SLOTS, EXAM_TYPES } from "@/app/teacher-page/page/tests/testsFilters";
import { ERUDITION_LIBRARY_LABEL } from "@/utils/features/featureAccess";
const selectMenuProps = {
disableScrollLock: true,
PaperProps: { sx: { maxHeight: 320 } },
};
const TestsTableToolbar = ({
assignmentType,
accessFilter,
catalogFilter,
slotFilter,
globalFilter,
filteredCount,
totalCount,
onAssignmentTypeChange,
onAccessFilterChange,
onCatalogFilterChange,
onSlotFilterChange,
onGlobalFilterChange,
onReset,
}) => {
const theme = useTheme();
const slotDisabled = catalogFilter === "staffLibrary";
return (
<Box
sx={getHeroSoftToolbarSx(theme)}
onMouseDown={(event) => event.stopPropagation()}
onClick={(event) => event.stopPropagation()}
>
<TextField
id={TEACHER_TESTS_IDS.search}
size="small"
variant="outlined"
placeholder="Search tests…"
value={globalFilter}
onChange={(event) => onGlobalFilterChange(event.target.value)}
InputProps={{
startAdornment: <SearchIcon fontSize="small" sx={{ mr: 0.75, opacity: 0.55 }} />,
}}
sx={getHeroSoftSearchFieldSx(theme)}
/>
<FormControl size="small" sx={{ minWidth: 108, ...getHeroSoftSelectSx(theme) }}>
<Select
id={TEACHER_TESTS_IDS.filterType}
value={assignmentType}
onChange={(event) => onAssignmentTypeChange(event.target.value)}
MenuProps={selectMenuProps}
inputProps={{ "aria-label": "Filter by type" }}
>
<MenuItem id={`${TEACHER_TESTS_IDS.filterType}-option-all`} value="all">
All types
</MenuItem>
{EXAM_TYPES.map((type) => (
<MenuItem
id={`${TEACHER_TESTS_IDS.filterType}-option-${type.toLowerCase()}`}
key={type}
value={type}
>
{type}
</MenuItem>
))}
</Select>
</FormControl>
<FormControl size="small" sx={{ minWidth: 108, ...getHeroSoftSelectSx(theme) }}>
<Select
id={TEACHER_TESTS_IDS.filterAccess}
value={accessFilter}
onChange={(event) => onAccessFilterChange(event.target.value)}
MenuProps={selectMenuProps}
inputProps={{ "aria-label": "Filter by access" }}
>
<MenuItem id={`${TEACHER_TESTS_IDS.filterAccess}-option-all`} value="all">
All access
</MenuItem>
<MenuItem id={`${TEACHER_TESTS_IDS.filterAccess}-option-available`} value="available">
Available
</MenuItem>
<MenuItem id={`${TEACHER_TESTS_IDS.filterAccess}-option-locked`} value="locked">
Locked
</MenuItem>
</Select>
</FormControl>
<FormControl size="small" sx={{ minWidth: 118, ...getHeroSoftSelectSx(theme) }}>
<Select
id={TEACHER_TESTS_IDS.filterCatalog}
value={catalogFilter}
onChange={(event) => onCatalogFilterChange(event.target.value)}
MenuProps={selectMenuProps}
inputProps={{ "aria-label": "Filter by catalog" }}
>
<MenuItem id={`${TEACHER_TESTS_IDS.filterCatalog}-option-all`} value="all">
All tests
</MenuItem>
<MenuItem id={`${TEACHER_TESTS_IDS.filterCatalog}-option-catalog`} value="catalog">
Plan catalog
</MenuItem>
<MenuItem id={`${TEACHER_TESTS_IDS.filterCatalog}-option-erudition-library`} value="staffLibrary">
{ERUDITION_LIBRARY_LABEL}
</MenuItem>
</Select>
</FormControl>
<FormControl size="small" sx={{ minWidth: 88, ...getHeroSoftSelectSx(theme) }} disabled={slotDisabled}>
<Select
id={TEACHER_TESTS_IDS.filterSlot}
value={slotDisabled ? "all" : slotFilter}
onChange={(event) => onSlotFilterChange(event.target.value)}
MenuProps={selectMenuProps}
inputProps={{ "aria-label": "Filter by slot" }}
>
<MenuItem id={`${TEACHER_TESTS_IDS.filterSlot}-option-all`} value="all">
All
</MenuItem>
{EXAM_SLOTS.map((slot) => (
<MenuItem id={`${TEACHER_TESTS_IDS.filterSlot}-option-${slot}`} key={slot} value={String(slot)}>
{slot}
</MenuItem>
))}
</Select>
</FormControl>
<Button
id={TEACHER_TESTS_IDS.filterReset}
size="small"
variant="text"
onClick={onReset}
sx={{
whiteSpace: "nowrap",
color: "primary.main",
fontWeight: 500,
textTransform: "none",
}}
>
Reset
</Button>
<Typography
id={TEACHER_TESTS_IDS.countLabel}
variant="caption"
color="text.secondary"
sx={{ ml: "auto", whiteSpace: "nowrap" }}
>
{filteredCount} / {totalCount}
</Typography>
</Box>
);
};
export default memo(TestsTableToolbar);
|