Merge branch 'fix-date' into 'main'

Fix date

See merge request frontend/squzanswerer!24
This commit is contained in:
Nastya 2024-01-10 13:55:46 +00:00
commit 919bfcce96
7 changed files with 55 additions and 32 deletions

@ -6,6 +6,14 @@ body {
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
} }
/*скрывает все скролл-бары*/
body * {
-ms-overflow-style: none;
scrollbar-width: none;
}
body * ::-webkit-scrollbar {
display: none;
}
code { code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',

@ -135,6 +135,9 @@ export const ContactForm = ({
backgroundColor: theme.palette.background.default, backgroundColor: theme.palette.background.default,
height: "100vh", height: "100vh",
overflow: "auto", overflow: "auto",
"&::-webkit-scrollbar": { width: "0", display: "none", msOverflowStyle: "none" },
scrollbarWidth: "none",
msOverflowStyle: "none"
}} }}
> >
<Box <Box

@ -222,7 +222,7 @@ export const Footer = ({ setCurrentQuestion, question, setShowContactForm, setSh
if (nextQuestion && nextQuestion.type !== "result") { if (nextQuestion && nextQuestion.type !== "result") {
setCurrentQuestion(nextQuestion); setCurrentQuestion(nextQuestion);
} else { } else {
showResult(nextQuestion); showResult(items.find(q => q.content.rule.parentId === "line"));
} }
return; return;

@ -67,7 +67,7 @@ export const ResultForm = ({
flexDirection: "column", flexDirection: "column",
alignItems: "center", alignItems: "center",
justifyContent: "space-between", justifyContent: "space-between",
height: isMobile ? undefined : "100vh", height: "100vh",
width: "100vw", width: "100vw",
pt: "28px", pt: "28px",
overflow: "auto" overflow: "auto"

@ -18,7 +18,7 @@ const QID =
process.env.NODE_ENV === "production" ? process.env.NODE_ENV === "production" ?
window.location.pathname.replace(/\//g, '') window.location.pathname.replace(/\//g, '')
: :
"2363ad2c-0c19-4f51-80c0-ed2242daa0c4" "9fafc6c9-6ccf-42b6-b400-0ee9f5f0fa16"
export const ViewPage = () => { export const ViewPage = () => {

@ -9,7 +9,7 @@ import type { QuizQuestionDate } from "../../../model/questionTypes/date";
import CalendarIcon from "@icons/CalendarIcon"; import CalendarIcon from "@icons/CalendarIcon";
import { enqueueSnackbar } from "notistack"; import { enqueueSnackbar } from "notistack";
import { sendAnswer } from "@api/quizRelase"; import { sendAnswer } from "@api/quizRelase";
import { useQuestionsStore } from "@root/quizData/store" import { useQuestionsStore } from "@root/quizData/store";
type DateProps = { type DateProps = {
currentQuestion: QuizQuestionDate; currentQuestion: QuizQuestionDate;
@ -19,7 +19,7 @@ export const Date = ({ currentQuestion }: DateProps) => {
const theme = useTheme(); const theme = useTheme();
const mode = modes; const mode = modes;
const { settings } = useQuestionsStore() const { settings } = useQuestionsStore();
const { answers } = useQuizViewStore(); const { answers } = useQuizViewStore();
const answer = answers.find( const answer = answers.find(
({ questionId }) => questionId === currentQuestion.id ({ questionId }) => questionId === currentQuestion.id
@ -28,7 +28,9 @@ export const Date = ({ currentQuestion }: DateProps) => {
return ( return (
<Box> <Box>
<Typography variant="h5" color={theme.palette.text.primary}>{currentQuestion.title}</Typography> <Typography variant="h5" color={theme.palette.text.primary}>
{currentQuestion.title}
</Typography>
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",
@ -40,13 +42,17 @@ export const Date = ({ currentQuestion }: DateProps) => {
<DatePicker <DatePicker
slots={{ slots={{
//@ts-ignore //@ts-ignore
openPickerIcon: () => <CalendarIcon sx={{ openPickerIcon: () => (
"& path": {stroke: theme.palette.primary.main}, <CalendarIcon
"& rect": {stroke: theme.palette.primary.main} sx={{
}} />, "& path": { stroke: theme.palette.primary.main },
"& rect": { stroke: theme.palette.primary.main },
}}
/>
),
}} }}
value={dayjs( value={dayjs(
answer month && day && year
? new window.Date(`${month}.${day}.${year}`) ? new window.Date(`${month}.${day}.${year}`)
: new window.Date() : new window.Date()
)} )}
@ -54,19 +60,22 @@ export const Date = ({ currentQuestion }: DateProps) => {
if (!date) { if (!date) {
return; return;
} }
try { try {
await sendAnswer({ await sendAnswer({
questionId: currentQuestion.id, questionId: currentQuestion.id,
body: new window.Date(date.toDate()).toLocaleDateString("ru-RU", { body: new window.Date(date.toDate()).toLocaleDateString(
year: "numeric", "ru-RU",
month: "2-digit", {
day: "2-digit", year: "numeric",
}), month: "2-digit",
day: "2-digit",
}
),
//@ts-ignore //@ts-ignore
qid: settings.qid qid: settings.qid,
}) });
updateAnswer( updateAnswer(
currentQuestion.id, currentQuestion.id,
String( String(
@ -78,9 +87,8 @@ export const Date = ({ currentQuestion }: DateProps) => {
) )
); );
} catch (e) { } catch (e) {
enqueueSnackbar("ответ не был засчитан") enqueueSnackbar("ответ не был засчитан");
} }
}} }}
slotProps={{ slotProps={{
openPickerButton: { openPickerButton: {
@ -89,14 +97,15 @@ export const Date = ({ currentQuestion }: DateProps) => {
}, },
"data-cy": "open-datepicker", "data-cy": "open-datepicker",
}, },
layout: { layout: {
sx: {backgroundColor: theme.palette.background.default,} sx: { backgroundColor: theme.palette.background.default },
} },
}} }}
sx={{ sx={{
"& .MuiInputBase-root": { "& .MuiInputBase-root": {
backgroundColor: mode[settings.cfg.theme] ? "white" : theme.palette.background.default, backgroundColor: mode[settings.cfg.theme]
? "white"
: theme.palette.background.default,
borderRadius: "10px", borderRadius: "10px",
maxWidth: "250px", maxWidth: "250px",
pr: "22px", pr: "22px",
@ -109,11 +118,9 @@ export const Date = ({ currentQuestion }: DateProps) => {
borderColor: "#9A9AAF", borderColor: "#9A9AAF",
}, },
}, },
}} }}
/> />
</Box> </Box>
</Box> </Box>
); );
};
};

@ -112,10 +112,14 @@ export const Select = ({
inputProps={{ inputProps={{
sx: { sx: {
color: colorMain, color: colorMain,
display: "flex", display: "block",
alignItems: "center",
px: "9px", px: "9px",
gap: "20px", gap: "20px",
"& .MuiTypography-root": {
overflow: "hidden",
textOverflow: "ellipsis",
}
}, },
}} }}
IconComponent={(props) => <ArrowDown {...props} />} IconComponent={(props) => <ArrowDown {...props} />}
@ -131,6 +135,7 @@ export const Select = ({
padding: "10px", padding: "10px",
borderRadius: "5px", borderRadius: "5px",
color: colorPlaceholder, color: colorPlaceholder,
whiteSpace: "normal"
}} }}
> >
{item} {item}