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 CheckIcon from "@mui/icons-material/Check"; import DeleteIcon from "@mui/icons-material/Delete"; import EditIcon from "@mui/icons-material/Edit"; import { history } from "@umijs/max"; import dayjs from "dayjs"; import { 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, publish,authorized }) { const { courseName, picUrl, createTime, statusName, type } = product; const [confirm, setconfirm] = useState(false); const [shut, setshut] = useState(false); return ( {statusName && ( )} { edit(product); }} > {confirm ? ( { remove(product); }} > ) : ( { setconfirm("1"); setTimeout(() => { setconfirm(true); }, 1000); setTimeout(() => { setconfirm(false); }, 3000); }} > )} { history.push("/work/dolessons/" + product.id); }} > { authorized(product) }} > {type == 3 ? null : ( { publish(product); }} > {type == 1 ? ( ) : ( )} )} {type == 2 && ( {shut ? ( { publish(product, { type: 3 }); }} > ) : ( { setshut("1"); setTimeout(() => { setshut(true); }, 1000); setTimeout(() => { setshut(false); }, 3000); }} > )} )} {courseName} {difftime(dayjs(), dayjs(createTime))} ); }