Merge branch 'dev' into 'staging'

Dev

See merge request frontend/squzanswerer!101
This commit is contained in:
Nastya 2024-04-07 15:05:59 +00:00
commit ce6eb998d3
6 changed files with 52 additions and 30 deletions

@ -43,10 +43,10 @@ export const publicationMakeRequest = ({ url, body }: any) => {
headers: {
"X-Sessionkey": SESSIONS,
"Content-Type": "multipart/form-data",
// "DeviceType" : DeviceType,
// "Device" : Device,
// "OS": OSDevice,
// "Browser" : browserUser
"DeviceType" : DeviceType,
"Device" : Device,
"OS": OSDevice,
"Browser" : browserUser
},
method: "POST",
});
@ -65,10 +65,10 @@ export async function getData(quizId: string): Promise<{
headers: {
"X-Sessionkey": SESSIONS,
"Content-Type": "application/json",
// "DeviceType" : DeviceType,
// "Device" : Device,
// "OS": OSDevice,
// "Browser" : userAgent
"DeviceType" : DeviceType,
"Device" : Device,
"OS": OSDevice,
"Browser" : userAgent
},
data: {
quiz_id: quizId,

@ -26,9 +26,10 @@ type Props = {
quizSettings?: QuizSettings;
quizId: string;
preview?: boolean;
changeFaviconAndTitle?: boolean;
};
export default function QuizAnswerer({ quizSettings, quizId, preview = false }: Props) {
export default function QuizAnswerer({ quizSettings, quizId, preview = false, changeFaviconAndTitle = true }: Props) {
const [quizViewStore] = useState(createQuizViewStore);
const [rootContainerWidth, setRootContainerWidth] = useState<number>(() => window.innerWidth);
const rootContainerRef = useRef<HTMLDivElement>(null);
@ -65,7 +66,7 @@ export default function QuizAnswerer({ quizSettings, quizId, preview = false }:
return (
<QuizViewContext.Provider value={quizViewStore}>
<RootContainerWidthContext.Provider value={rootContainerWidth}>
<QuizDataContext.Provider value={{ ...quizSettings, quizId, preview }}>
<QuizDataContext.Provider value={{ ...quizSettings, quizId, preview, changeFaviconAndTitle }}>
<LocalizationProvider dateAdapter={AdapterMoment} adapterLocale="ru" localeText={localeText}>
<ThemeProvider theme={lightTheme}>
<SnackbarProvider

@ -54,6 +54,8 @@ export const Question = ({
<Box
sx={{
height: "100%",
display: "flex",
flexDirection: "column",
background: settings.cfg.design
? quizThemes[settings.cfg.theme].isLight
? "transparent"
@ -64,19 +66,19 @@ export const Question = ({
>
<Box
sx={{
height: "calc(100% - 75px)",
overflow: "auto",
width: "100%"
width: "100%",
flexGrow: 1,
}}
>
<Box
sx={{
height: "calc(100% - 75px)",
position: "relative",
height: "100%",
width: "100%",
maxWidth: "1440px",
padding: "40px 25px 20px",
margin: "0 auto",
//overflow: "auto",
display: "flex",
flexDirection: "column",
justifyContent: "space-between",
@ -88,14 +90,30 @@ export const Question = ({
stepNumber={currentQuestionStepNumber}
/>
{show_badge && (
<Link target="_blank" href="https://quiz.pena.digital" sx={{ mt: "20px", textAlign: "end" }}>
<Link
target="_blank"
href="https://quiz.pena.digital"
sx={{
position: "absolute",
bottom: "20px",
right: "25px",
}}
>
{quizThemes[settings.cfg.theme].isLight ? (
<NameplateLogoFQ
style={{ fontSize: "34px", width: "200px", height: "auto" }}
style={{
fontSize: "34px",
width: "200px",
height: "auto",
}}
/>
) : (
<NameplateLogoFQDark
style={{ fontSize: "34px", width: "200px", height: "auto" }}
style={{
fontSize: "34px",
width: "200px",
height: "auto",
}}
/>
)}
</Link>

@ -16,7 +16,7 @@ import PrevButton from "./tools/PrevButton";
import "https://markknol.github.io/console-log-viewer/console-log-viewer.js"
export default function ViewPublicationPage() {
const { settings, recentlyCompleted, quizId, preview } = useQuizData();
const { settings, recentlyCompleted, quizId, preview, changeFaviconAndTitle } = useQuizData();
const answers = useQuizViewStore(state => state.answers);
let currentQuizStep = useQuizViewStore((state) => state.currentQuizStep);
const {
@ -31,17 +31,16 @@ export default function ViewPublicationPage() {
const isAnswer = answers.some(ans => ans.questionId === currentQuestion.id);
useEffect(
function setFaviconAndTitle() {
useEffect(function setFaviconAndTitle() {
if (!changeFaviconAndTitle) return;
const link = document.querySelector('link[rel="icon"]');
if (link && settings.cfg.startpage.favIcon) {
link.setAttribute("href", settings.cfg.startpage.favIcon);
}
document.title = settings.name;
},
[settings]
);
}, [changeFaviconAndTitle, settings.cfg.startpage.favIcon, settings.name]);
if (recentlyCompleted) throw new Error("Quiz already completed");
if (currentQuizStep === "startpage" && settings.cfg.noStartPage)

@ -1,7 +1,11 @@
import { QuizSettings } from "@model/settingsData";
import { createContext, useContext } from "react";
type QuizData = QuizSettings & { quizId: string; preview: boolean; };
type QuizData = QuizSettings & {
quizId: string;
preview: boolean;
changeFaviconAndTitle: boolean;
};
export const QuizDataContext = createContext<QuizData | null>(null);

@ -1,6 +1,6 @@
{
"name": "@frontend/squzanswerer",
"version": "1.0.18",
"version": "1.0.19",
"type": "module",
"main": "./dist-package/index.js",
"module": "./dist-package/index.js",