import { Card, Divider, Typography } from '@mui/material';
import { Box } from '@mui/system';
import PropType from 'prop-types';

const OrderCard = ({ data }) => {
  return (
    <Card
      height="100%"
      sx={{
        backgroundColor: '#f2f2f2',
        mb: 2,
        p: 2,
        mx: { xs: 0, sm: 1 },
        width: { xs: '100%', sm: '47%', md: '100%', lg: '100%' },
      }}
    >
      <Box
        sx={{
          display: 'flex',
          flexDirection: 'column',
          alignItems: { xs: 'center', md: 'flex-start' },
        }}
      >
        <Typography sx={{ fontWeight: 600 }}>
          Order placed on: {data.date}
        </Typography>
        <Divider />
        <Typography sx={{ mt: 1 }}>By: {data.name}</Typography>
        <Typography>Total: ${data.totalPrice.toFixed(2)}</Typography>
      </Box>
    </Card>
  );
};

OrderCard.propTypes = {
  data: PropType.shape({
    date: PropType.string,
    name: PropType.string,
    totalPrice: PropType.number,
  }),
};

export default OrderCard;
