import PropTypes from "prop-types"; // @mui import { Box, Card, colors, IconButton, Stack, Tooltip, Typography, } from "@mui/material"; import { styled } from "@mui/material/styles"; // utils // components import IconFont from "@/components/IconFont"; import Label from "@/components/label"; import difftime from "@/utils/difftime"; import AccessTimeFilledIcon from "@mui/icons-material/AccessTimeFilled"; import CheckIcon from "@mui/icons-material/Check"; import CloseIcon from "@mui/icons-material/Close"; import DeleteIcon from "@mui/icons-material/Delete"; import EditIcon from "@mui/icons-material/Edit"; import GroupIcon from "@mui/icons-material/Group"; import PauseIcon from "@mui/icons-material/Pause"; import { history, useModel } from "@umijs/max"; import { Progress } from "antd"; import dayjs from "dayjs"; import { useEffect, useState } from "react"; // ---------------------------------------------------------------------- const StyledProductImg = styled("img")({ top: 0, width: "92%", height: "92%", marginTop: "4%", objectFit: "cover", position: "absolute", }); ShopProductCard.propTypes = { product: PropTypes.object, }; export default function ShopProductCard({ product, remove, edit, copy, publish, authorized, tauthorized, }) { const { trainName, picUrl, createTime, typeName, type, deadline, sectionNum, experimentNum, studentNum, startTime, totalSubmitExperimentNum, totalExperimentNum, unReadMsgCount, id, } = product; const [confirm, setconfirm] = useState(false); const [shut, setshut] = useState(false); const { initialState: { menuNum }, setInitialState, } = useModel("@@initialState"); const [Numcount, setNumcount] = useState({}); const ifs = type === 1 || type === 3; let { TEACH_TRAIN_MANAGE_LIST } = menuNum ?? {}; useEffect(() => { if (!TEACH_TRAIN_MANAGE_LIST) { return; } setNumcount((s) => ({ ...s, [TEACH_TRAIN_MANAGE_LIST.id]: TEACH_TRAIN_MANAGE_LIST?.unReadMsgCount, })); }, [TEACH_TRAIN_MANAGE_LIST]); let num = Numcount?.[id] ?? unReadMsgCount; return (
{num > 100 ? "99+" : num}
{typeName && ( )} {(ifs || type == 4) && ( { edit(product); }} > {confirm ? ( { remove(product); }} sx={{ marginLeft: 2 }} > ) : ( { setconfirm("1"); setTimeout(() => { setconfirm(true); }, 200); setTimeout(() => { setconfirm(false); }, 3000); }} > )} )} { tauthorized(product, ifs); }} > { history.push("/work/rebustrain/" + product.id); }} >
{trainName}
{difftime(dayjs(), dayjs(createTime))}
{startTime ?? "-"}~{deadline} { history.push("/work/dobustrain/" + product.id); }} sx={{ cursor: "pointer" }} > {sectionNum}课时/{experimentNum}实验 { authorized(product, ifs); }} > {studentNum}学生 { if (type === 5 || type === 4) return; if (ifs) { publish(product, { type: 2 }); } else { publish(product, { type: 3 }); } }} > {ifs ? ( ) : ( )} {type === 3 && ( {shut ? ( { publish(product, { type: 5 }); }} > ) : ( { setshut("1"); setTimeout(() => { setshut(true); }, 200); setTimeout(() => { setshut(false); }, 3000); }} > )} )}
); }