Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

BillingForm.jsx 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import React, { useState } from 'react';
  2. import {
  3. Box,
  4. TextField,
  5. Button,
  6. Typography,
  7. MenuItem,
  8. RadioGroup,
  9. FormControlLabel,
  10. Radio,
  11. } from '@mui/material';
  12. import Table from '@mui/material/Table';
  13. import TableBody from '@mui/material/TableBody';
  14. import TableCell from '@mui/material/TableCell';
  15. import TableContainer from '@mui/material/TableContainer';
  16. import TableHead from '@mui/material/TableHead';
  17. import TableRow from '@mui/material/TableRow';
  18. import Grid from '@mui/material/Grid2';
  19. const BillingForm = () => {
  20. const rows = [
  21. {
  22. img_src: 'https://via.placeholder.com/300',
  23. name: 'MELUR',
  24. description: 'Atma Sari New Raya Collection 2024',
  25. colour: 'black',
  26. quantity: 1,
  27. price: 335.50
  28. }
  29. ];
  30. const [shippingMethod, setShippingMethod] = useState('COD');
  31. const handleSubmit = (e) => {
  32. e.preventDefault();
  33. // Handle form submission logic
  34. console.log('Form submitted');
  35. };
  36. const FieldContainer = ({ label, children }) => (
  37. <Box sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
  38. <Typography variant="body1" sx={{ fontWeight: 500, minWidth: 120 }}>
  39. {label}
  40. </Typography>
  41. {children}
  42. </Box>
  43. );
  44. return (
  45. <Box
  46. onSubmit={handleSubmit}
  47. sx={{
  48. width: '100%',
  49. }}
  50. >
  51. {/* Product List */}
  52. <TableContainer>
  53. <Table sx={{ minWidth: 650, mb: 5, backgroundColor:"#F7FBFF" }}>
  54. <TableHead>
  55. <TableRow>
  56. <TableCell width={150}>
  57. <Typography variant='body1'>Item</Typography>
  58. </TableCell>
  59. <TableCell width={150}>
  60. {/* This is just for table offset */}
  61. <Typography variant='body1'></Typography>
  62. </TableCell>
  63. <TableCell align='center'>
  64. <Typography variant='body1'>Colour</Typography>
  65. </TableCell>
  66. <TableCell align='center'>
  67. <Typography variant='body1'>Quantity</Typography>
  68. </TableCell>
  69. <TableCell align='center'>
  70. <Typography variant='body1'>Unit Price</Typography>
  71. </TableCell>
  72. <TableCell align='center'>
  73. <Typography variant='body1'>Shipping</Typography>
  74. </TableCell>
  75. <TableCell align='center'>
  76. <Typography variant='body1'>Tax</Typography>
  77. </TableCell>
  78. <TableCell align='center'>
  79. <Typography variant='body1'>Duties</Typography>
  80. </TableCell>
  81. </TableRow>
  82. </TableHead>
  83. <TableBody>
  84. {rows.map((row) => (
  85. <TableRow
  86. key={row.id}
  87. sx={{
  88. '& td, & th': { border: 0 },
  89. '&:last-child td, &:last-child th': { border: 0 }
  90. }}
  91. >
  92. <TableCell component="th" scope="row">
  93. <img
  94. src={row.img_src}
  95. alt={row.img_src}
  96. style={{
  97. width: 100,
  98. height: 100,
  99. aspectRatio: '4 / 4',
  100. objectFit: 'cover',
  101. }}
  102. />
  103. </TableCell>
  104. <TableCell>
  105. <Typography variant='body2' sx={{ fontWeight: "bold", mb: 1 }}>{row.name}</Typography>
  106. <Typography variant='body2'>{row.description}</Typography>
  107. </TableCell>
  108. <TableCell align='center'>
  109. <Typography variant='body1' sx={{ fontWeight: "bold" }} >{row.colour}</Typography>
  110. </TableCell>
  111. <TableCell align='center'>
  112. <Typography variant='body1' sx={{ fontWeight: "bold" }}>{row.quantity}</Typography>
  113. </TableCell>
  114. <TableCell align='center'>
  115. <Typography variant='body1' sx={{ fontWeight: "bold" }}>{`RM ${parseFloat(row.price).toFixed(2)}`}</Typography>
  116. </TableCell>
  117. <TableCell align='center'>
  118. <Typography variant='body1' sx={{ fontWeight: "bold" }}>{`RM ${parseFloat(row.price).toFixed(2)}`}</Typography>
  119. </TableCell>
  120. <TableCell align='center'>
  121. <Typography variant='body1' sx={{ fontWeight: "bold" }}>{`RM ${parseFloat(row.price).toFixed(2)}`}</Typography>
  122. </TableCell>
  123. <TableCell align='center'>
  124. <Typography variant='body1' sx={{ fontWeight: "bold" }}>{`RM ${parseFloat(row.price).toFixed(2)}`}</Typography>
  125. </TableCell>
  126. </TableRow>
  127. ))}
  128. </TableBody>
  129. </Table>
  130. </TableContainer>
  131. </Box>
  132. );
  133. };
  134. export default BillingForm;