2024-07-18 15:38:07 +03:00
|
|
|
import { CurrentUserMark, Mark } from '../../types/mark.ts'
|
|
|
|
import styles from './style.module.scss'
|
|
|
|
import { Box, Button, TextField } from '@mui/material'
|
2024-07-23 12:22:53 +03:00
|
|
|
import { MarkTypeTranslation } from './const.ts'
|
2024-07-18 15:38:07 +03:00
|
|
|
|
|
|
|
interface MarkFormFieldProps {
|
|
|
|
handleSubmit: (event: any) => void
|
|
|
|
handleChange: (event: any) => void
|
|
|
|
currentMark: CurrentUserMark
|
|
|
|
currentMarkValue: string
|
|
|
|
}
|
|
|
|
|
|
|
|
const MarkFormField = (props: MarkFormFieldProps) => {
|
|
|
|
const { handleSubmit, handleChange, currentMark, currentMarkValue } = props;
|
|
|
|
const getSubmitButton = () => currentMark.isLast ? 'Complete' : 'Next';
|
|
|
|
return (
|
|
|
|
<div className={styles.fixedBottomForm}>
|
|
|
|
<Box component="form" onSubmit={handleSubmit}>
|
|
|
|
<TextField
|
|
|
|
id="mark-value"
|
2024-07-23 12:22:53 +03:00
|
|
|
label={MarkTypeTranslation[currentMark.mark.type.valueOf()]}
|
2024-07-18 15:38:07 +03:00
|
|
|
value={currentMarkValue}
|
|
|
|
onChange={handleChange}
|
|
|
|
/>
|
|
|
|
<Button type="submit" variant="contained">
|
|
|
|
{getSubmitButton()}
|
|
|
|
</Button>
|
|
|
|
</Box>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MarkFormField;
|