Exam generation rework, batch user tables, fastapi endpoint switch

This commit is contained in:
Carlos-Mesquita
2024-11-04 23:29:14 +00:00
parent a2bc997e8f
commit 15c9c4d4bd
148 changed files with 11348 additions and 3901 deletions

View File

@@ -0,0 +1,53 @@
import React, { useEffect, useRef, ChangeEvent } from 'react';
interface Props {
value: string;
onChange: (value: string) => void;
className?: string;
placeholder?: string;
onBlur?: () => void;
}
const AutoExpandingTextArea: React.FC<Props> = ({
value,
className = 'w-full cursor-text px-7 py-8 input border-2 border-mti-gray-platinum bg-white rounded-3xl',
placeholder = "Enter text here...",
onChange,
onBlur,
}) => {
const textareaRef = useRef<HTMLTextAreaElement>(null);
const adjustHeight = () => {
const textarea = textareaRef.current;
if (textarea) {
textarea.style.height = 'auto';
textarea.style.height = `${textarea.scrollHeight}px`;
}
};
useEffect(() => {
adjustHeight();
const timer = setTimeout(adjustHeight, 100);
return () => clearTimeout(timer);
}, [value]);
const handleChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
onChange(e.target.value);
adjustHeight();
};
return (
<textarea
ref={textareaRef}
value={value}
onChange={handleChange}
className={className}
placeholder={placeholder}
style={{ overflow: 'hidden', resize: 'none' }}
onBlur={onBlur}
autoFocus
/>
);
};
export default AutoExpandingTextArea;