пофиксив варианты отображение дизайна главной страницы

This commit is contained in:
ArtChaos189 2023-12-18 18:04:09 +03:00
parent e8483ef25e
commit 4b6995c11e
3 changed files with 789 additions and 725 deletions

@ -142,6 +142,9 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => {
fontStyle: "normal", fontStyle: "normal",
fontStretch: "normal", fontStretch: "normal",
lineHeight: "1.2", lineHeight: "1.2",
overflowWrap: "break-word",
width: "100%",
textAlign: quiz.config.startpageType === "centered" ? "center" : "-moz-initial",
}} }}
> >
{quiz.name} {quiz.name}
@ -150,6 +153,9 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => {
sx={{ sx={{
fontSize: "16px", fontSize: "16px",
m: "16px 0", m: "16px 0",
overflowWrap: "break-word",
width: "100%",
textAlign: quiz.config.startpageType === "centered" ? "center" : "-moz-initial",
}} }}
> >
{quiz.config.startpage.description} {quiz.config.startpage.description}
@ -172,7 +178,7 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => {
<Box <Box
sx={{ mt: "46px", display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" }} sx={{ mt: "46px", display: "flex", alignItems: "center", justifyContent: "space-between", width: "100%" }}
> >
<Box> <Box sx={{ maxWidth: "300px" }}>
{quiz.config.info.clickable ? ( {quiz.config.info.clickable ? (
isMobileDevice ? ( isMobileDevice ? (
<Link href={`tel:${quiz.config.info.phonenumber}`}> <Link href={`tel:${quiz.config.info.phonenumber}`}>
@ -192,7 +198,9 @@ export const StartPageViewPublication = ({ setVisualStartPage }: Props) => {
{quiz.config.info.phonenumber} {quiz.config.info.phonenumber}
</Typography> </Typography>
)} )}
<Typography sx={{ fontSize: "12px", textAlign: "end" }}>{quiz.config.info.law}</Typography> <Typography sx={{ width: "100%", overflowWrap: "break-word", fontSize: "12px", textAlign: "end" }}>
{quiz.config.info.law}
</Typography>
</Box> </Box>
<Box <Box
@ -329,7 +337,16 @@ function QuizPreviewLayoutByType({
}} }}
> >
{quizHeaderBlock} {quizHeaderBlock}
{backgroundBlock && <Box>{backgroundBlock}</Box>} {backgroundBlock && (
<Box
sx={{
width: "60%",
overflow: "hidden",
}}
>
{backgroundBlock}
</Box>
)}
{quizMainBlock} {quizMainBlock}
</Box> </Box>
); );

@ -18,7 +18,7 @@ import {
Select, Select,
Typography, Typography,
useMediaQuery, useMediaQuery,
useTheme useTheme,
} from "@mui/material"; } from "@mui/material";
import { incrementCurrentStep, updateQuiz, uploadQuizImage } from "@root/quizes/actions"; import { incrementCurrentStep, updateQuiz, uploadQuizImage } from "@root/quizes/actions";
import { useCurrentQuiz } from "@root/quizes/hooks"; import { useCurrentQuiz } from "@root/quizes/hooks";
@ -35,27 +35,13 @@ import SelectableIconButton from "./SelectableIconButton";
import { DropZone } from "./dropZone"; import { DropZone } from "./dropZone";
import Extra from "./extra"; import Extra from "./extra";
const designTypes = [ const designTypes = [
[ ["standard", (color: string) => <LayoutStandartIcon color={color} />, "Standard"],
"standard", ["expanded", (color: string) => <LayoutExpandedIcon color={color} />, "Expanded"],
(color: string) => <LayoutStandartIcon color={color} />, ["centered", (color: string) => <LayoutCenteredIcon color={color} />, "Centered"],
"Standard",
],
[
"expanded",
(color: string) => <LayoutExpandedIcon color={color} />,
"Expanded",
],
[
"centered",
(color: string) => <LayoutCenteredIcon color={color} />,
"Centered",
],
] as const; ] as const;
// type DesignType = typeof designTypes[number][0]; // type DesignType = typeof designTypes[number][0];
export default function StartPageSettings() { export default function StartPageSettings() {
const theme = useTheme(); const theme = useTheme();
const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1500)); const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1500));
@ -75,14 +61,14 @@ export default function StartPageSettings() {
const favIconDropZoneElement = ( const favIconDropZoneElement = (
<FaviconDropZone <FaviconDropZone
imageUrl={quiz.config.startpage.favIcon} imageUrl={quiz.config.startpage.favIcon}
onImageUploadClick={async file => { onImageUploadClick={async (file) => {
const resizedImage = await resizeFavIcon(file); const resizedImage = await resizeFavIcon(file);
uploadQuizImage(quiz.id, resizedImage, (quiz, url) => { uploadQuizImage(quiz.id, resizedImage, (quiz, url) => {
quiz.config.startpage.favIcon = url; quiz.config.startpage.favIcon = url;
}); });
}} }}
onDeleteClick={() => { onDeleteClick={() => {
updateQuiz(quiz.id, quiz => { updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.favIcon = null; quiz.config.startpage.favIcon = null;
}); });
}} }}
@ -91,10 +77,7 @@ export default function StartPageSettings() {
return ( return (
<> <>
<Typography <Typography variant="h5" sx={{ marginTop: "60px", marginBottom: isSmallMonitor ? "0" : "40px" }}>
variant="h5"
sx={{ marginTop: "60px", marginBottom: isSmallMonitor ? "0" : "40px" }}
>
Стартовая страница Стартовая страница
</Typography> </Typography>
{isSmallMonitor && ( {isSmallMonitor && (
@ -105,10 +88,7 @@ export default function StartPageSettings() {
fontWeight: 500, fontWeight: 500,
fontSize: "16px", fontSize: "16px",
color: formState === "design" ? "#7E2AEA" : "#7D7E86", color: formState === "design" ? "#7E2AEA" : "#7D7E86",
borderBottom: borderBottom: formState === "design" ? "2px solid #7E2AEA" : "1px solid transparent",
formState === "design"
? "2px solid #7E2AEA"
: "1px solid transparent",
}} }}
> >
Дизайн Дизайн
@ -120,10 +100,7 @@ export default function StartPageSettings() {
fontWeight: 500, fontWeight: 500,
fontSize: "16px", fontSize: "16px",
color: formState === "content" ? "#7E2AEA" : "#7D7E86", color: formState === "content" ? "#7E2AEA" : "#7D7E86",
borderBottom: borderBottom: formState === "content" ? "2px solid #7E2AEA" : "1px solid transparent",
formState === "content"
? "2px solid #7E2AEA"
: "1px solid transparent",
}} }}
> >
Контент Контент
@ -153,8 +130,7 @@ export default function StartPageSettings() {
<Box <Box
sx={{ sx={{
pr: "20px", pr: "20px",
borderRight: `1px solid ${isTablet ? "transparent" : theme.palette.grey2.main borderRight: `1px solid ${isTablet ? "transparent" : theme.palette.grey2.main}`,
}`,
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
flex: `1 1 361px`, flex: `1 1 361px`,
@ -183,9 +159,11 @@ export default function StartPageSettings() {
variant="outlined" variant="outlined"
value={designType} value={designType}
displayEmpty displayEmpty
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpageType = e.target.value as QuizStartpageType; quiz.config.startpageType = e.target.value as QuizStartpageType;
})} })
}
sx={{ sx={{
height: "48px", height: "48px",
borderRadius: "8px", borderRadius: "8px",
@ -240,11 +218,7 @@ export default function StartPageSettings() {
color: theme.palette.grey2.main, color: theme.palette.grey2.main,
}} }}
> >
{type[1]( {type[1](type[0] === designType ? theme.palette.orange.main : theme.palette.grey2.main)}
type[0] === designType
? theme.palette.orange.main
: theme.palette.grey2.main
)}
{type[2]} {type[2]}
</MenuItem> </MenuItem>
))} ))}
@ -268,17 +242,21 @@ export default function StartPageSettings() {
> >
<SelectableButton <SelectableButton
isSelected={quiz.config.startpage.background.type === "image"} isSelected={quiz.config.startpage.background.type === "image"}
onClick={() => updateQuiz(quiz.id, quiz => { onClick={() =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.background.type = "image"; quiz.config.startpage.background.type = "image";
})} })
}
> >
Изображение Изображение
</SelectableButton> </SelectableButton>
<SelectableButton <SelectableButton
isSelected={quiz.config.startpage.background.type === "video"} isSelected={quiz.config.startpage.background.type === "video"}
onClick={() => updateQuiz(quiz.id, quiz => { onClick={() =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.background.type = "video"; quiz.config.startpage.background.type = "video";
})} })
}
> >
Видео Видео
</SelectableButton> </SelectableButton>
@ -311,19 +289,19 @@ export default function StartPageSettings() {
sx={{ maxWidth: "300px" }} sx={{ maxWidth: "300px" }}
imageUrl={quiz.config.startpage.background.desktop} imageUrl={quiz.config.startpage.background.desktop}
originalImageUrl={quiz.config.startpage.background.originalDesktop} originalImageUrl={quiz.config.startpage.background.originalDesktop}
onImageUploadClick={file => { onImageUploadClick={(file) => {
uploadQuizImage(quiz.id, file, (quiz, url) => { uploadQuizImage(quiz.id, file, (quiz, url) => {
quiz.config.startpage.background.desktop = url; quiz.config.startpage.background.desktop = url;
quiz.config.startpage.background.originalDesktop = url; quiz.config.startpage.background.originalDesktop = url;
}); });
}} }}
onImageSaveClick={file => { onImageSaveClick={(file) => {
uploadQuizImage(quiz.id, file, (quiz, url) => { uploadQuizImage(quiz.id, file, (quiz, url) => {
quiz.config.startpage.background.desktop = url; quiz.config.startpage.background.desktop = url;
}); });
}} }}
onDeleteClick={() => { onDeleteClick={() => {
updateQuiz(quiz.id, quiz => { updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.background.desktop = null; quiz.config.startpage.background.desktop = null;
}); });
}} }}
@ -331,8 +309,6 @@ export default function StartPageSettings() {
</Box> </Box>
<ModalSizeImage /> <ModalSizeImage />
</Box> </Box>
<Box <Box
@ -345,14 +321,15 @@ export default function StartPageSettings() {
<CustomTextField <CustomTextField
placeholder="URL видео" placeholder="URL видео"
text={quiz.config.startpage.background.video ?? ""} text={quiz.config.startpage.background.video ?? ""}
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.background.video = e.target.value; quiz.config.startpage.background.video = e.target.value;
})} })
}
/> />
</Box> </Box>
{designType !== "centered" && {designType !== "centered" && (
<> <>
<Typography <Typography
sx={{ sx={{
@ -371,31 +348,36 @@ export default function StartPageSettings() {
}} }}
> >
<SelectableIconButton <SelectableIconButton
onClick={() => updateQuiz(quiz.id, quiz => { onClick={() =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.position = "left"; quiz.config.startpage.position = "left";
})} })
}
isActive={quiz.config.startpage.position === "left"} isActive={quiz.config.startpage.position === "left"}
Icon={AlignLeftIcon} Icon={AlignLeftIcon}
/> />
<SelectableIconButton <SelectableIconButton
onClick={() => updateQuiz(quiz.id, quiz => { onClick={() =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.position = "center"; quiz.config.startpage.position = "center";
})} })
}
isActive={quiz.config.startpage.position === "center"} isActive={quiz.config.startpage.position === "center"}
Icon={AlignCenterIcon} Icon={AlignCenterIcon}
sx={{ display: designType === "standard" ? "none" : "flex" }} sx={{ display: designType === "standard" ? "none" : "flex" }}
/> />
<SelectableIconButton <SelectableIconButton
onClick={() => updateQuiz(quiz.id, quiz => { onClick={() =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.position = "right"; quiz.config.startpage.position = "right";
})} })
}
isActive={quiz.config.startpage.position === "right"} isActive={quiz.config.startpage.position === "right"}
Icon={AlignRightIcon} Icon={AlignRightIcon}
/> />
</Box> </Box>
</> </>
)}
}
{(isTablet || !isSmallMonitor) && ( {(isTablet || !isSmallMonitor) && (
<> <>
<Box <Box
@ -418,19 +400,19 @@ export default function StartPageSettings() {
sx={{ maxWidth: "300px" }} sx={{ maxWidth: "300px" }}
imageUrl={quiz.config.startpage.logo} imageUrl={quiz.config.startpage.logo}
originalImageUrl={quiz.config.startpage.originalLogo} originalImageUrl={quiz.config.startpage.originalLogo}
onImageUploadClick={file => { onImageUploadClick={(file) => {
uploadQuizImage(quiz.id, file, (quiz, url) => { uploadQuizImage(quiz.id, file, (quiz, url) => {
quiz.config.startpage.logo = url; quiz.config.startpage.logo = url;
quiz.config.startpage.originalLogo = url; quiz.config.startpage.originalLogo = url;
}); });
}} }}
onImageSaveClick={file => { onImageSaveClick={(file) => {
uploadQuizImage(quiz.id, file, (quiz, url) => { uploadQuizImage(quiz.id, file, (quiz, url) => {
quiz.config.startpage.logo = url; quiz.config.startpage.logo = url;
}); });
}} }}
onDeleteClick={() => { onDeleteClick={() => {
updateQuiz(quiz.id, quiz => { updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.logo = null; quiz.config.startpage.logo = null;
}); });
}} }}
@ -482,19 +464,19 @@ export default function StartPageSettings() {
sx={{ maxWidth: "300px" }} sx={{ maxWidth: "300px" }}
imageUrl={quiz.config.startpage.logo} imageUrl={quiz.config.startpage.logo}
originalImageUrl={quiz.config.startpage.originalLogo} originalImageUrl={quiz.config.startpage.originalLogo}
onImageUploadClick={file => { onImageUploadClick={(file) => {
uploadQuizImage(quiz.id, file, (quiz, url) => { uploadQuizImage(quiz.id, file, (quiz, url) => {
quiz.config.startpage.logo = url; quiz.config.startpage.logo = url;
quiz.config.startpage.originalLogo = url; quiz.config.startpage.originalLogo = url;
}); });
}} }}
onImageSaveClick={file => { onImageSaveClick={(file) => {
uploadQuizImage(quiz.id, file, (quiz, url) => { uploadQuizImage(quiz.id, file, (quiz, url) => {
quiz.config.startpage.logo = url; quiz.config.startpage.logo = url;
}); });
}} }}
onDeleteClick={() => { onDeleteClick={() => {
updateQuiz(quiz.id, quiz => { updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.logo = null; quiz.config.startpage.logo = null;
}); });
}} }}
@ -528,9 +510,12 @@ export default function StartPageSettings() {
<CustomTextField <CustomTextField
placeholder="Имя заголовка об опроснике для подбора табуретки" placeholder="Имя заголовка об опроснике для подбора табуретки"
text={quiz.name} text={quiz.name}
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.name = e.target.value; quiz.name = e.target.value;
})} })
}
maxLength={40}
/> />
<Typography <Typography
sx={{ sx={{
@ -545,9 +530,12 @@ export default function StartPageSettings() {
<CustomTextField <CustomTextField
placeholder="Внимательно заполняйте поля ответов" placeholder="Внимательно заполняйте поля ответов"
text={quiz.config.startpage.description} text={quiz.config.startpage.description}
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.description = e.target.value; quiz.config.startpage.description = e.target.value;
})} })
}
maxLength={70}
/> />
<Typography <Typography
sx={{ sx={{
@ -562,9 +550,12 @@ export default function StartPageSettings() {
<CustomTextField <CustomTextField
placeholder="Начать опрос" placeholder="Начать опрос"
text={quiz.config.startpage.button} text={quiz.config.startpage.button}
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.startpage.button = e.target.value; quiz.config.startpage.button = e.target.value;
})} })
}
maxLength={15}
/> />
<Typography <Typography
sx={{ sx={{
@ -579,17 +570,22 @@ export default function StartPageSettings() {
<CustomTextField <CustomTextField
placeholder="8-800-000-00-00" placeholder="8-800-000-00-00"
text={quiz.config.info.phonenumber} text={quiz.config.info.phonenumber}
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.info.phonenumber = e.target.value; quiz.config.info.phonenumber = e.target.value;
})} })
}
maxLength={20}
/> />
<CustomCheckbox <CustomCheckbox
sx={{ margin: "10px 0" }} sx={{ margin: "10px 0" }}
label="Кликабельный" label="Кликабельный"
checked={quiz.config.info.clickable} checked={quiz.config.info.clickable}
handleChange={e => updateQuiz(quiz.id, quiz => { handleChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.info.clickable = e.target.checked; quiz.config.info.clickable = e.target.checked;
})} })
}
/> />
<Typography <Typography
sx={{ sx={{
@ -604,9 +600,12 @@ export default function StartPageSettings() {
<CustomTextField <CustomTextField
placeholder="Только лучшее" placeholder="Только лучшее"
text={quiz.config.info.orgname} text={quiz.config.info.orgname}
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.info.orgname = e.target.value; quiz.config.info.orgname = e.target.value;
})} })
}
maxLength={25}
/> />
<Typography <Typography
sx={{ sx={{
@ -621,9 +620,12 @@ export default function StartPageSettings() {
<CustomTextField <CustomTextField
placeholder="https://mysite.com" placeholder="https://mysite.com"
text={quiz.config.info.site} text={quiz.config.info.site}
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.info.site = e.target.value; quiz.config.info.site = e.target.value;
})} })
}
maxLength={25}
/> />
<Typography <Typography
sx={{ sx={{
@ -638,9 +640,12 @@ export default function StartPageSettings() {
<CustomTextField <CustomTextField
placeholder="Данные наших документов" placeholder="Данные наших документов"
text={quiz.config.info.law} text={quiz.config.info.law}
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.info.law = e.target.value; quiz.config.info.law = e.target.value;
})} })
}
maxLength={45}
/> />
<Extra /> <Extra />
</> </>
@ -663,7 +668,7 @@ export default function StartPageSettings() {
textUnderlineOffset: "2px", textUnderlineOffset: "2px",
}} }}
> >
<ArrowLeft right={false}/> Вернуться к дизайну <ArrowLeft right={false} /> Вернуться к дизайну
</Button> </Button>
)} )}
{formState === "design" && ( {formState === "design" && (
@ -681,7 +686,7 @@ export default function StartPageSettings() {
textUnderlineOffset: "2px", textUnderlineOffset: "2px",
}} }}
> >
Далее заполнить контент <ArrowLeft right={true}/> Далее заполнить контент <ArrowLeft right={true} />
</Button> </Button>
)} )}
</Box> </Box>
@ -694,7 +699,7 @@ export default function StartPageSettings() {
justifyContent: "flex-end", justifyContent: "flex-end",
flexDirection: isTablet ? "column" : "row", flexDirection: isTablet ? "column" : "row",
marginTop: "30px", marginTop: "30px",
marginBottom: isTablet ? "90px" : undefined marginBottom: isTablet ? "90px" : undefined,
}} }}
> >
<FormControlLabel <FormControlLabel
@ -726,9 +731,11 @@ export default function StartPageSettings() {
borderRadius: 0, borderRadius: 0,
padding: 0, padding: 0,
}} }}
onChange={e => updateQuiz(quiz.id, quiz => { onChange={(e) =>
updateQuiz(quiz.id, (quiz) => {
quiz.config.noStartPage = e.target.checked; quiz.config.noStartPage = e.target.checked;
})} })
}
checked={quiz.config.noStartPage} checked={quiz.config.noStartPage}
/> />
} }
@ -740,11 +747,7 @@ export default function StartPageSettings() {
justifyContent: "flex-end", justifyContent: "flex-end",
}} }}
/> />
<Button <Button variant="contained" data-cy="setup-questions" onClick={incrementCurrentStep}>
variant="contained"
data-cy="setup-questions"
onClick={incrementCurrentStep}
>
Настроить вопросы Настроить вопросы
</Button> </Button>
</Box> </Box>

@ -1,7 +1,7 @@
import { FormControl, TextField, useTheme, SxProps, Theme } from "@mui/material"; import React, { useState } from "react";
import { Box, FormControl, TextField, Typography, useTheme } from "@mui/material";
import type { ChangeEvent, KeyboardEvent, FocusEvent } from "react"; import type { ChangeEvent, KeyboardEvent, FocusEvent } from "react";
import type { InputProps } from "@mui/material"; import type { InputProps, SxProps, Theme } from "@mui/material";
interface CustomTextFieldProps { interface CustomTextFieldProps {
placeholder: string; placeholder: string;
@ -11,6 +11,7 @@ interface CustomTextFieldProps {
onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void; onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
onBlur?: (event: FocusEvent<HTMLInputElement>) => void; onBlur?: (event: FocusEvent<HTMLInputElement>) => void;
text?: string; text?: string;
maxLength?: number;
sx?: SxProps<Theme>; sx?: SxProps<Theme>;
InputProps?: Partial<InputProps>; InputProps?: Partial<InputProps>;
} }
@ -18,28 +19,54 @@ interface CustomTextFieldProps {
export default function CustomTextField({ export default function CustomTextField({
placeholder, placeholder,
value, value,
text,
sx,
error,
onChange, onChange,
onKeyDown, onKeyDown,
onBlur, onBlur,
text,
sx,
error,
InputProps, InputProps,
maxLength = 200,
}: CustomTextFieldProps) { }: CustomTextFieldProps) {
const theme = useTheme(); const theme = useTheme();
const [inputValue, setInputValue] = useState(value || "");
const [isInputActive, setIsInputActive] = useState(false);
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const inputValue = event.target.value;
setInputValue(inputValue);
if (onChange) {
onChange(event);
}
};
const handleInputFocus = () => {
setIsInputActive(true);
};
const handleInputBlur = (event: React.FocusEvent<HTMLInputElement>) => {
setIsInputActive(false);
if (onBlur) {
onBlur(event);
}
};
return ( return (
<FormControl fullWidth variant="standard" sx={{ p: 0 }}> <FormControl fullWidth variant="standard" sx={{ p: 0 }}>
<TextField <TextField
defaultValue={text} defaultValue={text}
fullWidth fullWidth
value={value} value={inputValue}
placeholder={placeholder} placeholder={placeholder}
onChange={handleInputChange}
error={!!error} error={!!error}
label={error} label={error}
onChange={onChange} onFocus={handleInputFocus}
onBlur={handleInputBlur}
onKeyDown={onKeyDown} onKeyDown={onKeyDown}
onBlur={onBlur}
sx={{ sx={{
"& .MuiInputBase-root": { "& .MuiInputBase-root": {
backgroundColor: theme.palette.background.default, backgroundColor: theme.palette.background.default,
@ -50,19 +77,36 @@ export default function CustomTextField({
fontSize: "13.5px", fontSize: "13.5px",
marginTop: "3px", marginTop: "3px",
}, },
...sx,
}} }}
InputProps={InputProps} InputProps={InputProps}
inputProps={{ inputProps={{
maxLength: maxLength,
sx: { sx: {
borderRadius: "10px", borderRadius: "10px",
fontSize: "18px", fontSize: "18px",
lineHeight: "21px", lineHeight: "21px",
py: 0, py: 0,
}, },
...sx,
}} }}
data-cy="textfield" data-cy="textfield"
/> />
{isInputActive && inputValue.length >= maxLength - 7 && (
<Box
sx={{
display: "flex",
marginTop: "5px",
marginLeft: "auto",
position: "absolute",
bottom: "-25px",
right: "0",
}}
>
<Typography fontSize="14px">{inputValue.length}</Typography>
<span>/</span>
<Typography fontSize="14px">{maxLength}</Typography>
</Box>
)}
</FormControl> </FormControl>
); );
} }