diff --git a/src/pages/Questions/DropDown/settingDropDown.tsx b/src/pages/Questions/DropDown/settingDropDown.tsx index 895a27f1..90435697 100644 --- a/src/pages/Questions/DropDown/settingDropDown.tsx +++ b/src/pages/Questions/DropDown/settingDropDown.tsx @@ -58,7 +58,7 @@ export default function SettingDropDown({ question }: SettingDropDownProps) { maxWidth: isFigmaTablte ? "297px" : "360px", }} > - + /> */} void; sx?: SxProps; + placeholder?: string; }; export const Select = ({ @@ -24,6 +26,7 @@ export const Select = ({ empty, onChange, sx, + placeholder = "", }: SelectProps) => { const [activeItem, setActiveItem] = useState( empty ? -1 : activeItemIndex @@ -35,9 +38,17 @@ export const Select = ({ }, [activeItemIndex]); const handleChange = (event: SelectChangeEvent) => { - const activeItemIndex = Number(event.target.value); - setActiveItem(activeItemIndex); - onChange?.(items[activeItemIndex], activeItemIndex); + const newItemIndex = Number(event.target.value); + + if (newItemIndex === activeItem) { + setActiveItem(-1); + onChange?.("", -1); + + return; + } + + setActiveItem(newItemIndex); + onChange?.(items[newItemIndex], newItemIndex); }; return ( @@ -47,10 +58,19 @@ export const Select = ({ sx={{ width: "100%", height: "48px", ...sx }} > + value ? ( + items[Number(value)] + ) : ( + + {placeholder} + + ) + } id="display-select" variant="outlined" value={activeItem === -1 ? "" : String(activeItem)} - displayEmpty onChange={handleChange} sx={{ width: "100%", diff --git a/src/pages/ViewPublicationPage/questions/Number.tsx b/src/pages/ViewPublicationPage/questions/Number.tsx index effdc697..cbe1d73b 100644 --- a/src/pages/ViewPublicationPage/questions/Number.tsx +++ b/src/pages/ViewPublicationPage/questions/Number.tsx @@ -3,6 +3,7 @@ import { Box, Typography, Slider, useTheme } from "@mui/material"; import { useDebouncedCallback } from "use-debounce"; import CustomTextField from "@ui_kit/CustomTextField"; +import { CustomSlider } from "@ui_kit/CustomSlider"; import { useQuizViewStore, updateAnswer } from "@root/quizView"; @@ -74,10 +75,9 @@ export const Number = ({ currentQuestion }: NumberProps) => { flexDirection: "column", width: "100%", marginTop: "20px", - gap: "30px" + gap: "30px", }} > - { "& .MuiInputBase-input": { textAlign: "center" }, }} /> - - до - + до { }} > answer)} onChange={(_, value) => { + if (value < 0) { + deleteAnswer(currentQuestion.content.id); + + return; + } + updateAnswer(currentQuestion.content.id, String(value)); }} />