--
This commit is contained in:
parent
b09e587220
commit
479532f6be
@ -99,9 +99,20 @@ function QuizAnswererInner({
|
||||
|
||||
console.log("settings");
|
||||
console.log(settings);
|
||||
console.log("questions");
|
||||
console.log(questions);
|
||||
console.log("error");
|
||||
console.log(error);
|
||||
console.log("isLoading");
|
||||
console.log(isLoading);
|
||||
console.log("quizId");
|
||||
console.log(quizId);
|
||||
|
||||
if (isLoading && !questions.length) return <LoadingSkeleton />;
|
||||
if (error) return <ApologyPage error={error} />;
|
||||
|
||||
if (isLoading) return <LoadingSkeleton />;
|
||||
|
||||
if (Object.keys(settings).length == 0) return <ApologyPage error={new Error("quiz data is null")} />;
|
||||
if (questions.length === 0) return <ApologyPage error={new Error("No questions found")} />;
|
||||
|
||||
|
@ -5,8 +5,9 @@ import { useTranslation } from "react-i18next";
|
||||
type Props = Partial<FallbackProps>;
|
||||
|
||||
export const ApologyPage = ({ error }: Props) => {
|
||||
let message = error.message || error.response?.data;
|
||||
let message = error?.message || error?.response?.data || "default message";
|
||||
console.log("message");
|
||||
console.log(message);
|
||||
console.log(message.toLowerCase());
|
||||
const { t } = useTranslation();
|
||||
console.log("t");
|
||||
|
@ -18,11 +18,77 @@ const getLanguageFromURL = (): string => {
|
||||
return "ru"; // Жёсткий фолбэк
|
||||
};
|
||||
|
||||
const r = {
|
||||
ru: {
|
||||
"quiz is inactive": "Квиз не активирован",
|
||||
"no questions found": "Нет созданных вопросов",
|
||||
"quiz is empty": "Квиз пуст",
|
||||
"quiz already completed": "Вы уже прошли этот опрос",
|
||||
"no quiz id": "Отсутствует id квиза",
|
||||
"quiz data is null": "Не были переданы параметры квиза",
|
||||
"invalid request data": "Такого квиза не существует",
|
||||
"default message": "Что-то пошло не так",
|
||||
"The request could not be sent": "Заявка не может быть отправлена",
|
||||
"The number of points could not be sent": "Количество баллов не может быть отправлено",
|
||||
"Your result": "Ваш результат",
|
||||
"Your points": "Ваши баллы",
|
||||
of: "из",
|
||||
"View answers": "Посмотреть ответы",
|
||||
"Find out more": "Узнать подробнее",
|
||||
"Go to website": "Перейти на сайт",
|
||||
"Question title": "Заголовок вопроса",
|
||||
"Question without a title": "Вопрос без названия",
|
||||
"Your answer": "Ваш ответ",
|
||||
"Add image": "Добавить изображение",
|
||||
"Accepts images": "Принимает изображения",
|
||||
"Add video": "Добавить видео",
|
||||
"Accepts .mp4 and .mov format - maximum 50mb": "Принимает .mp4 и .mov формат — максимум 50мб",
|
||||
"Add audio file": "Добавить аудиофайл",
|
||||
"Accepts audio files": "Принимает аудиофайлы",
|
||||
"Add document": "Добавить документ",
|
||||
"Accepts documents": "Принимает документы",
|
||||
Next: "Далее",
|
||||
Prev: "Назад",
|
||||
From: "От",
|
||||
До: "До",
|
||||
"Enter your answer": "Введите свой ответ",
|
||||
"Incorrect file type selected": "Выбран некорректный тип файла",
|
||||
"File is too big. Maximum size is 50 MB": "Файл слишком большой. Максимальный размер 50 МБ",
|
||||
"Acceptable file extensions": "Допустимые расширения файлов",
|
||||
"You have uploaded": "Вы загрузили",
|
||||
"The answer was not counted": "Ответ не был засчитан",
|
||||
"Select an answer option below": "Выберите вариант ответа ниже",
|
||||
"Select an answer option on the left": "Выберите вариант ответа слева",
|
||||
"Fill out the form to receive your test results": "Заполните форму, чтобы получить результаты теста",
|
||||
Enter: "Введите",
|
||||
Name: "Имя",
|
||||
"Phone number": "Номер телефона",
|
||||
"Last name": "Фамилия",
|
||||
Address: "Адрес",
|
||||
"Incorrect email entered": "Введена некорректная почта",
|
||||
"Please fill in the fields": "Пожалуйста, заполните поля",
|
||||
"Please try again later": "повторите попытку позже",
|
||||
"Regulation on the processing of personal data": "Положением об обработке персональных данных",
|
||||
"Privacy Policy": "Политикой конфиденциальности",
|
||||
familiarized: "ознакомлен",
|
||||
and: "и",
|
||||
"Get results": "Получить результаты",
|
||||
"Data sent successfully": "Данные успешно отправлены",
|
||||
Step: "Шаг",
|
||||
"questions are not ready yet": "Вопросы для аудитории ещё не созданы. Пожалуйста, подождите",
|
||||
"Add your image": "Добавьте своё изображение",
|
||||
"select emoji": "выберите смайлик",
|
||||
"file is too big": "Файл слишком большой",
|
||||
"file type is not supported": "Тип файла не поддерживается",
|
||||
},
|
||||
};
|
||||
|
||||
// 2. Конфиг с полной отладкой
|
||||
i18n
|
||||
.use(Backend)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
resources: r,
|
||||
lng: getLanguageFromURL(), // Принудительно из URL
|
||||
fallbackLng: "ru",
|
||||
supportedLngs: ["en", "ru", "uz"],
|
||||
|
@ -2,6 +2,7 @@ import QuizAnswerer from "@/components/QuizAnswerer";
|
||||
import { createRoot } from "react-dom/client";
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export * from "./widgets";
|
||||
import "./i18n/i18n";
|
||||
|
||||
// old widget
|
||||
const widget = {
|
||||
@ -14,12 +15,23 @@ const widget = {
|
||||
quizId: string;
|
||||
changeFaviconAndTitle: boolean;
|
||||
}) {
|
||||
console.log("Widget create called with:");
|
||||
console.log("selector:", selector);
|
||||
console.log("quizId:", quizId);
|
||||
console.log("changeFaviconAndTitle:", changeFaviconAndTitle);
|
||||
|
||||
const element = document.getElementById(selector);
|
||||
if (!element) throw new Error("Element for widget doesn't exist");
|
||||
|
||||
const root = createRoot(element);
|
||||
|
||||
root.render(<QuizAnswerer quizId={quizId} changeFaviconAndTitle={changeFaviconAndTitle} disableGlobalCss />);
|
||||
root.render(
|
||||
<QuizAnswerer
|
||||
quizId={quizId}
|
||||
changeFaviconAndTitle={changeFaviconAndTitle}
|
||||
disableGlobalCss
|
||||
/>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -9,16 +9,18 @@ export default defineConfig({
|
||||
alias,
|
||||
},
|
||||
build: {
|
||||
minify: true, // Включаем минификацию как в обычной сборке
|
||||
sourcemap: false, // Отключаем sourcemaps как в обычной сборке
|
||||
copyPublicDir: false,
|
||||
rollupOptions: {
|
||||
input: "src/widget.tsx",
|
||||
preserveEntrySignatures: "allow-extension",
|
||||
output: {
|
||||
manualChunks: undefined,
|
||||
entryFileNames: "[name].js",
|
||||
chunkFileNames: "[name].js",
|
||||
assetFileNames: "[name].[ext]",
|
||||
exports: "named", // Принудительно экспортируем все именованные экспорты
|
||||
},
|
||||
treeshake: false, // Отключаем tree-shaking для экспортов
|
||||
},
|
||||
outDir: "widget",
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user