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 | 62x 62x 62x 62x 62x 62x 62x 62x 62x 6x 62x 6x 6x 6x 6x 62x 7x 1x 1x 6x 62x 62x 2x 1x 1x 1x 1x | import * as React from "react";
import Box from "@mui/material/Box";
import Button from "@mui/material/Button";
import Menu from "@mui/material/Menu";
import List from "@mui/material/List";
import ListItemButton from "@mui/material/ListItemButton";
import ListItemText from "@mui/material/ListItemText";
import Tooltip from "@mui/material/Tooltip";
import { useTheme } from "@mui/material/styles";
import { useState } from "react";
import { useNavigate, useLocation } from "react-router-dom";
import { useDispatch } from "react-redux";
import { _resetAllFields } from "@/store/slices/teacher/TeacherCreateAssignment";
import useTeacherMadeAssignmentQuota from "@/utils/hooks/useTeacherMadeAssignmentQuota";
import TeacherMadeAssignmentQuotaHint from "@/utils/components/feature-access/TeacherMadeAssignmentQuotaHint";
export default function NewAssignmentButton({ classAssignmentCount = null, showQuotaHint = true }) {
const theme = useTheme();
const location = useLocation();
const currentPathname = location.pathname;
const navigate = useNavigate();
const dispatch = useDispatch();
const { ui, loading, openUpgradeOnBlock } = useTeacherMadeAssignmentQuota(classAssignmentCount);
const [anchorEl, setAnchorEl] = useState(null);
const openMenu = Boolean(anchorEl);
const handleClose = () => {
setAnchorEl(null);
};
const selectAssignment = (assignmentType) => {
Iif (!ui.showCreate) {
openUpgradeOnBlock();
return;
}
dispatch(_resetAllFields());
navigate(`${currentPathname}/assignment/${assignmentType}/new`);
handleClose();
};
const handlePrimaryClick = (event) => {
if (!ui.showCreate) {
openUpgradeOnBlock();
return;
}
setAnchorEl(event.currentTarget);
};
const tooltipTitle = !ui.showCreate
? ui.message || "Upgrade to create assignments"
: ui.message || "Create a new assignment";
return (
<Box
sx={{
display: "flex",
flexDirection: showQuotaHint ? "column" : "row",
alignItems: showQuotaHint ? "flex-start" : "center",
gap: 0.5,
flexShrink: 0,
}}
>
<Tooltip title={tooltipTitle}>
<span>
<Button
id="basic-button"
variant={ui.showCreate ? "contained" : "soft"}
color={ui.showCreate ? "primary" : "warning"}
aria-controls={openMenu ? "basic-menu" : undefined}
aria-haspopup="true"
aria-expanded={openMenu ? "true" : undefined}
onClick={handlePrimaryClick}
disabled={loading}
sx={{
whiteSpace: "nowrap",
fontWeight: 600,
px: 2.25,
...(ui.showCreate && {
"&:hover": {
boxShadow: theme.customShadows?.primary,
},
}),
}}
>
New Assignment
</Button>
</span>
</Tooltip>
{showQuotaHint ? <TeacherMadeAssignmentQuotaHint classAssignmentCount={classAssignmentCount} /> : null}
<Menu
id="basic-menu"
anchorEl={anchorEl}
open={openMenu}
onClose={handleClose}
MenuListProps={{
"aria-labelledby": "basic-button",
}}
>
<List
sx={{ width: "100%", maxWidth: 360, bgcolor: "background.paper" }}
component="nav"
aria-labelledby="nested-list-subheader"
dense
>
<ListItemButton
id="teacher-assignments-current-button-staar"
onClick={() => {
selectAssignment("STAAR");
}}
>
<ListItemText primary="State of Texas Assessments of Academic Readiness (STAAR)" />
</ListItemButton>
<ListItemButton
id="teacher-assignments-current-button-tsi"
onClick={() => {
selectAssignment("TSI");
}}
>
<ListItemText primary="Texas Success Initiative (TSI)" />
</ListItemButton>
<ListItemButton
id="teacher-assignments-current-button-sat"
onClick={() => {
selectAssignment("SAT");
}}
>
<ListItemText primary="Scholastic Aptitude Test (SAT)" />
</ListItemButton>
<ListItemButton
id="teacher-assignments-current-button-act"
onClick={() => {
selectAssignment("ACT");
}}
>
<ListItemText primary="American College Test (ACT)" />
</ListItemButton>
<ListItemButton
id="teacher-assignments-current-button-teacher"
onClick={() => {
selectAssignment("TEACHER-TEST");
}}
>
<ListItemText primary="Teacher Test" />
</ListItemButton>
</List>
</Menu>
</Box>
);
}
|