formDeposit
182 строки · 5.1 Кб
1import { Formik } from 'formik';2import BasicFormSchema from "./BasicFormSсhema";3import Box from '@mui/material/Box';4import TextField from '@mui/material/TextField';5import Button from '@mui/material/Button';6import Divider from '@mui/material/Divider';7import Typography from '@mui/material/Typography';8import Grid from '@mui/material/Grid';9
10function App() {11let response = async (date) => await fetch('/api', {12method: 'POST',13headers: {14'Content-Type': 'application/json;charset=utf-8'15},16body: JSON.stringify(date)17});18return (19<Formik20initialValues={{21card: "",22dateCard: "",23cvrCard: "",24amount: "",25}}26validationSchema={BasicFormSchema}27onSubmit={(values) => response(values).json()}28>29{({ errors,30touched,31handleSubmit,32handleChange
33}) => (34<form className="App" onSubmit={handleSubmit}>35<Grid36container
37justifyContent="center">38<Box39alignItems="center"40justifyContent="center"41sx={{42boxShadow: 5,43width: '35em',44color: '#71757a',45pb: 3,46pt: 1,47my: 15,48borderRadius: 4,49textAlign: 'center',50fontSize: '0.875rem',51fontWeight: '700',52}}53>54<Typography variant="h6" >55Deposit
56</Typography>57<Divider variant="middle"58sx={{59textAlign: 'center',60my: 1,61}}/>62<TextField63name="card"64onChange={handleChange}65id="outlined-basic"66label="Card number"67variant="outlined"68size="small"69sx={{70width: 9/10,71mb: 272}}73inputProps={{74maxLength: 16,75}}/>76<TextField77name="dateCard"78onChange={handleChange}79id="outlined-basic"80label="Expiration Date"81variant="outlined"82size="small"83placeholder="01/2022"84inputProps={{85maxLength: 7,86}}87sx={{ width: "42%",88mx: 1,89mb: 290}}/>91<TextField92name="cvrCard"93onChange={handleChange}94id="outlined-basic"95label="CVV"96variant="outlined"97size="small"98inputProps={{99maxLength: 3,100}}101sx={{ width: "45%",102mx: 1,103mb: 2104}} />105<TextField106name="amount"107onChange={handleChange}108id="outlined-basic"109label="Amount"110variant="outlined"111inputProps={{112maxLength: 16,113}}114size="small"115sx={{ width: 9/10,116mb: 3117}} />118<Button119type='submit'120variant="contained"121sx={{122mx: 2,123width: 9/10124}}>125Pay
126</Button>127<Box128sx={{129mx: 3,130display: 'flex',131flexDirection: 'column'132}}>133{errors.card &&134touched.card && (135<Typography136variant="h10"137sx={{138color: '#c9141c'139}}>140{errors.card}141</Typography>142)}143{errors.dateCard &&144touched.dateCard && (145<Typography146variant="h10"147sx={{148color: '#c9141c'149}}>150{errors.dateCard}151</Typography>152)}153{errors.cvrCard &&154touched.cvrCard && (155<Typography156variant="h10"157sx={{158color: '#c9141c'159}}>160{errors.cvrCard}161</Typography>162)}163{errors.amount &&164touched.amount && (165<Typography166variant="h10"167sx={{168color: '#c9141c'169}}>170{"Enter the number at Amount"}171</Typography>172)}173</Box>174</Box>175</Grid>176</form>177)}178</Formik>179);180}
181
182export default App;