import * as React from "react";
import { Box } from "@mui/material";
import Grid from "@mui/material/Grid";
import Card from "@mui/material/Card";
import { Typography } from "@mui/material";
import PropTypes from "prop-types";
import { useTheme } from "@mui/material/styles";
import Table from "@mui/material/Table";
import TableHead from "@mui/material/TableHead";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableFooter from "@mui/material/TableFooter";
import TablePagination from "@mui/material/TablePagination";
import TableRow from "@mui/material/TableRow";
import Paper from "@mui/material/Paper";
import IconButton from "@mui/material/IconButton";
import FirstPageIcon from "@mui/icons-material/FirstPage";
import KeyboardArrowLeft from "@mui/icons-material/KeyboardArrowLeft";
import KeyboardArrowRight from "@mui/icons-material/KeyboardArrowRight";
import LastPageIcon from "@mui/icons-material/LastPage";
import Tooltip from "@mui/material/Tooltip";
import DeleteIcon from "@mui/icons-material/Delete";
import DriveFileRenameOutlineIcon from "@mui/icons-material/DriveFileRenameOutline";
import VisibilityIcon from '@mui/icons-material/Visibility';
import Backdrop from "@mui/material/Backdrop";
import Button from "@mui/material/Button";
import Fade from "@mui/material/Fade";
import Modal from "@mui/material/Modal";
import TextField from "@mui/material/TextField";
import AddIcon from "@mui/icons-material/Add";
import ClearIcon from "@mui/icons-material/Clear";
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select from '@mui/material/Select';
import ShoppingCartIcon from '@mui/icons-material/ShoppingCart';
import Link from 'next/link';
import styles from '@/styles/PageTitle.module.css'
import dynamic from 'next/dynamic'
const RichTextEditor = dynamic(() => import('@mantine/rte'), {
ssr: false,
})
// Create Product Modal Style
const style = {
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
height: "100%",
maxWidth: '700px',
width: '100%',
overflow: "auto",
bgcolor: "background.paper",
boxShadow: 24,
borderRadius: "8px",
};
function Product(props) {
const theme = useTheme();
const { count, page, rowsPerPage, onPageChange } = props;
const handleFirstPageButtonClick = (event) => {
onPageChange(event, 0);
};
const handleBackButtonClick = (event) => {
onPageChange(event, page - 1);
};
const handleNextButtonClick = (event) => {
onPageChange(event, page + 1);
};
const handleLastPageButtonClick = (event) => {
onPageChange(event, Math.max(0, Math.ceil(count / rowsPerPage) - 1));
};
return (
{theme.direction === "rtl" ? : }
{theme.direction === "rtl" ? (
) : (
)}
= Math.ceil(count / rowsPerPage) - 1}
aria-label="next page"
>
{theme.direction === "rtl" ? (
) : (
)}
= Math.ceil(count / rowsPerPage) - 1}
aria-label="last page"
>
{theme.direction === "rtl" ? : }
);
}
Product.propTypes = {
count: PropTypes.number.isRequired,
onPageChange: PropTypes.func.isRequired,
page: PropTypes.number.isRequired,
rowsPerPage: PropTypes.number.isRequired,
};
function createData(
productImg,
productTitle,
category,
price,
orders,
stock,
rating,
) {
return {
productImg,
productTitle,
category,
price,
orders,
stock,
rating,
};
}
const rows = [
createData(
"/images/product1.png",
"Laptop Macos Pro",
"Laptop",
"$289.50",
"46",
"12",
"5.0 (61 votes)",
),
createData(
"/images/product2.png",
"Smart Camera XD6",
"Camera",
"$189.50",
"50",
"Out of Stock",
"5.0 (40 votes)"
),
createData(
"/images/product3.png",
"Pixi 8 Wireless Airphone",
"Phone",
"$250.50",
"45",
"400",
"5.0 (15 votes)"
),
createData(
"/images/product4.png",
"Jebble Smart Watch",
"Watch",
"$289.50",
"100",
"200",
"5.0 (99 votes)"
),
createData(
"/images/product5.png",
"Admas Airpod x-Zon",
"Airpod",
"$289.50",
"120",
"Out of Stock",
"5.0 (150 votes)"
),
createData(
"/images/product6.png",
"Smart Watch F8 Pro",
"Watch",
"$289.50",
"20",
"100",
"5.0 (5 votes)"
),
createData(
"/images/product7.png",
"Nord Fold ZL",
"Pone",
"$289.50",
"55",
"108",
"5.0 (11 votes)"
),
createData(
"/images/product8.png",
"Wall Clock Cimbina",
"Clock",
"$289.50",
"40",
"100",
"5.0 (4 votes)"
),
createData(
"/images/product9.png",
"Galaxo T6 Munsun",
"Smart Phone",
"$289.50",
"50",
"130",
"5.0 (55 votes)"
),
createData(
"/images/product1.png",
"Macbook Pro",
"Laptop",
"$1,299.00",
"120",
"1500",
"5.0 (150 votes)"
),
createData(
"/images/product2.png",
"iphone 14 pro max",
"Phone",
"$1029",
"200",
"599",
"5.0 (200 votes)"
),
createData(
"/images/product3.png",
"HeadPhone",
"HeadPhone",
"$100.50",
"25",
"50",
"5.0 (61 votes)"
),
createData(
"/images/product4.png",
"Superstar shoes",
"shoes",
"$59.50",
"45",
"50",
"5.0 (45 votes)"
),
createData(
"/images/product5.png",
"Nike shirts",
"Shirts",
"$30.50",
"32",
"40",
"5.0 (22 votes)"
),
createData(
"/images/product6.png",
"Nike caps",
"Caps",
"$15.50",
"33",
"50",
"5.0 (3 votes)"
),
createData(
"/images/product7.png",
"Hoodie (Blue)",
"Hoodie",
"$59.50",
"30",
"55",
"5.0 (44 votes)"
),
createData(
"/images/product8.png",
"Wall Clock China",
"Clock",
"$100.50",
"30",
"230",
"5.0 (45 votes)"
),
createData(
"/images/product9.png",
"Galaxo T6 Munsun 2",
"Phone",
"$220.50",
"22",
"50",
"5.0 (24 votes)"
),
].sort((a, b) => (a.productTitle < b.productTitle ? -1 : 1));
export default function Products() {
// Table
const [page, setPage] = React.useState(0);
const [rowsPerPage, setRowsPerPage] = React.useState(10);
// Avoid a layout jump when reaching the last page with empty rows.
const emptyRows =
page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0;
const handleChangePage = (event, newPage) => {
setPage(newPage);
};
const handleChangeRowsPerPage = (event) => {
setRowsPerPage(parseInt(event.target.value, 10));
setPage(0);
};
// Create Product Modal & Form
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);
const handleSubmit = (event) => {
event.preventDefault();
const data = new FormData(event.currentTarget);
console.log({
email: data.get("email"),
password: data.get("password"),
});
};
// Select dropdown
const [categorySelect, setCategorySelect] = React.useState('');
const handleChange = (event) => {
setCategorySelect(event.target.value);
};
return (
<>
{/* Page title */}
Products
Product Name
Category
Price
Orders
Stock
Rating
Actions
{(rowsPerPage > 0
? rows.slice(
page * rowsPerPage,
page * rowsPerPage + rowsPerPage
)
: rows
).map((row) => (
{row.productTitle}
{row.category}
{row.price}
{row.orders}
{row.stock}
{row.rating}
))}
{emptyRows > 0 && (
)}
{/* Create Product Modal */}
Create Product
Product Name
Short Description
Category
Select
Price
Discount Price
Stock
Product Description
Product Image
>
);
}