diff --git a/.husky/pre-commit b/.husky/pre-commit
new file mode 100644
index 00000000..3ab2e13d
--- /dev/null
+++ b/.husky/pre-commit
@@ -0,0 +1,4 @@
+#!/usr/bin/env sh
+. "$(dirname -- "$0")/_/husky.sh"
+
+yarn lint-staged --allow-empty
diff --git a/package.json b/package.json
index f79c3503..decf6cd8 100755
--- a/package.json
+++ b/package.json
@@ -1,85 +1,93 @@
{
- "name": "squidward",
- "version": "0.1.0",
- "private": true,
- "dependencies": {
- "@craco/craco": "^7.0.0",
- "@emotion/react": "^11.10.5",
- "@emotion/styled": "^11.10.5",
- "@frontend/kitui": "^1.0.55",
- "@mui/icons-material": "^5.10.14",
- "@mui/material": "^5.10.14",
- "@mui/x-date-pickers": "^6.16.1",
- "@testing-library/jest-dom": "^5.14.1",
- "@testing-library/react": "^13.0.0",
- "@testing-library/user-event": "^13.2.1",
- "@types/cytoscape": "^3.19.16",
- "@types/file-saver": "^2.0.5",
- "@types/jest": "^27.0.1",
- "@types/node": "^16.7.13",
- "@types/react": "^18.0.0",
- "@types/react-dnd": "^3.0.2",
- "@types/react-dom": "^18.0.0",
- "axios": "^1.5.1",
- "cypress-file-upload": "^5.0.8",
- "cytoscape": "^3.26.0",
- "cytoscape-popper": "^2.0.0",
- "date-fns": "^3.0.4",
- "dayjs": "^1.11.10",
- "emoji-mart": "^5.5.2",
- "file-saver": "^2.0.5",
- "formik": "^2.4.5",
- "html-to-image": "^1.11.11",
- "immer": "^10.0.3",
- "jszip": "^3.10.1",
- "nanoid": "^5.0.3",
- "notistack": "^3.0.1",
- "react": "^18.2.0",
- "react-beautiful-dnd": "^13.1.1",
- "react-cytoscapejs": "^2.0.0",
- "react-dnd": "^16.0.1",
- "react-dnd-html5-backend": "^16.0.1",
- "react-dom": "^18.2.0",
- "react-easy-crop": "^5.0.0",
- "react-error-boundary": "^4.0.11",
- "react-image-crop": "^10.1.5",
- "react-image-file-resizer": "^0.4.8",
- "react-rnd": "^10.4.1",
- "react-router-dom": "^6.6.2",
- "react-scripts": "5.0.1",
- "swr": "^2.2.4",
- "typescript": "^5.2.2",
- "use-debounce": "^9.0.4",
- "web-vitals": "^2.1.0",
- "yup": "^1.3.2",
- "zustand": "^4.3.8"
- },
- "scripts": {
- "start": "craco start",
- "build": "craco build",
- "test": "craco test",
- "eject": "craco eject",
- "cypress:open": "cypress open"
- },
- "browserslist": {
- "production": [
- ">0.2%",
- "not dead",
- "not op_mini all"
- ],
- "development": [
- "last 1 chrome version",
- "last 1 firefox version",
- "last 1 safari version"
- ]
- },
- "devDependencies": {
- "@emoji-mart/data": "^1.1.2",
- "@emoji-mart/react": "^1.1.1",
- "@types/cytoscape-popper": "^2.0.4",
- "@types/react-beautiful-dnd": "^13.1.4",
- "@types/react-cytoscapejs": "^1.2.4",
- "craco-alias": "^3.0.1",
- "cypress": "^13.6.1"
- }
+ "name": "squidward",
+ "version": "0.1.0",
+ "private": true,
+ "dependencies": {
+ "@craco/craco": "^7.0.0",
+ "@emotion/react": "^11.10.5",
+ "@emotion/styled": "^11.10.5",
+ "@frontend/kitui": "^1.0.55",
+ "@mui/icons-material": "^5.10.14",
+ "@mui/material": "^5.10.14",
+ "@mui/x-date-pickers": "^6.16.1",
+ "@testing-library/jest-dom": "^5.14.1",
+ "@testing-library/react": "^13.0.0",
+ "@testing-library/user-event": "^13.2.1",
+ "@types/cytoscape": "^3.19.16",
+ "@types/file-saver": "^2.0.5",
+ "@types/jest": "^27.0.1",
+ "@types/node": "^16.7.13",
+ "@types/react": "^18.0.0",
+ "@types/react-dnd": "^3.0.2",
+ "@types/react-dom": "^18.0.0",
+ "axios": "^1.5.1",
+ "cypress-file-upload": "^5.0.8",
+ "cytoscape": "^3.26.0",
+ "cytoscape-popper": "^2.0.0",
+ "date-fns": "^3.0.6",
+ "dayjs": "^1.11.10",
+ "emoji-mart": "^5.5.2",
+ "file-saver": "^2.0.5",
+ "formik": "^2.4.5",
+ "html-to-image": "^1.11.11",
+ "immer": "^10.0.3",
+ "jszip": "^3.10.1",
+ "nanoid": "^5.0.3",
+ "notistack": "^3.0.1",
+ "react": "^18.2.0",
+ "react-beautiful-dnd": "^13.1.1",
+ "react-cytoscapejs": "^2.0.0",
+ "react-dnd": "^16.0.1",
+ "react-dnd-html5-backend": "^16.0.1",
+ "react-dom": "^18.2.0",
+ "react-easy-crop": "^5.0.0",
+ "react-error-boundary": "^4.0.11",
+ "react-image-crop": "^10.1.5",
+ "react-image-file-resizer": "^0.4.8",
+ "react-rnd": "^10.4.1",
+ "react-router-dom": "^6.6.2",
+ "react-scripts": "5.0.1",
+ "swr": "^2.2.4",
+ "typescript": "^5.2.2",
+ "use-debounce": "^9.0.4",
+ "web-vitals": "^2.1.0",
+ "yup": "^1.3.2",
+ "zustand": "^4.3.8"
+ },
+ "scripts": {
+ "start": "craco start",
+ "build": "craco build",
+ "test": "craco test",
+ "eject": "craco eject",
+ "cypress:open": "cypress open",
+ "code:format": "prettier ./src --write --ignore-unknown",
+ "prepare": "husky install"
+ },
+ "browserslist": {
+ "production": [
+ ">0.2%",
+ "not dead",
+ "not op_mini all"
+ ],
+ "development": [
+ "last 1 chrome version",
+ "last 1 firefox version",
+ "last 1 safari version"
+ ]
+ },
+ "devDependencies": {
+ "@emoji-mart/data": "^1.1.2",
+ "@emoji-mart/react": "^1.1.1",
+ "@types/cytoscape-popper": "^2.0.4",
+ "@types/react-beautiful-dnd": "^13.1.4",
+ "@types/react-cytoscapejs": "^1.2.4",
+ "craco-alias": "^3.0.1",
+ "cypress": "^13.6.1",
+ "husky": "^8.0.3",
+ "lint-staged": "^15.2.0",
+ "prettier": "^3.1.1"
+ },
+ "lint-staged": {
+ "**/*": "yarn code:format"
+ }
}
diff --git a/prettierrc b/prettierrc
new file mode 100644
index 00000000..80e56165
--- /dev/null
+++ b/prettierrc
@@ -0,0 +1,12 @@
+{
+ "semi": true,
+ "trailingComma": "es5",
+ "singleQuote": false,
+ "printWidth": 120,
+ "tabWidth": 2,
+ "useTabs": false,
+ "endOfLine": "auto",
+ "bracketSpacing": true,
+ "arrowParens": "always",
+ "jsxSingleQuote": false
+}
diff --git a/public/index.html b/public/index.html
index a96c59f9..daa88ffe 100755
--- a/public/index.html
+++ b/public/index.html
@@ -1,4 +1,4 @@
-
+
@@ -7,9 +7,12 @@
-
-
-
+
+
+
Pena Quiz
diff --git a/public/site.webmanifest b/public/site.webmanifest
index b20abb7c..fa99de77 100644
--- a/public/site.webmanifest
+++ b/public/site.webmanifest
@@ -1,19 +1,19 @@
{
- "name": "",
- "short_name": "",
- "icons": [
- {
- "src": "/android-chrome-192x192.png",
- "sizes": "192x192",
- "type": "image/png"
- },
- {
- "src": "/android-chrome-512x512.png",
- "sizes": "512x512",
- "type": "image/png"
- }
- ],
- "theme_color": "#ffffff",
- "background_color": "#ffffff",
- "display": "standalone"
+ "name": "",
+ "short_name": "",
+ "icons": [
+ {
+ "src": "/android-chrome-192x192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "/android-chrome-512x512.png",
+ "sizes": "512x512",
+ "type": "image/png"
+ }
+ ],
+ "theme_color": "#ffffff",
+ "background_color": "#ffffff",
+ "display": "standalone"
}
diff --git a/src/App.tsx b/src/App.tsx
index 257a1892..35ccd8d3 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -6,7 +6,13 @@ import SigninDialog from "./pages/auth/Signin";
import SignupDialog from "./pages/auth/Signup";
import { ViewPage } from "./pages/ViewPublicationPage";
import { DesignPage } from "./pages/DesignPage/DesignPage";
-import { Route, Routes, useLocation, useNavigate, Navigate } from "react-router-dom";
+import {
+ Route,
+ Routes,
+ useLocation,
+ useNavigate,
+ Navigate,
+} from "react-router-dom";
import "./index.css";
import ContactFormPage from "./pages/ContactFormPage/ContactFormPage";
import InstallQuiz from "./pages/InstallQuiz/InstallQuiz";
@@ -17,8 +23,21 @@ import { ResultSettings } from "./pages/ResultPage/ResultSettings";
import MyQuizzesFull from "./pages/createQuize/MyQuizzesFull";
import Main from "./pages/main";
import EditPage from "./pages/startPage/EditPage";
-import { clearAuthToken, getMessageFromFetchError, useUserFetcher, UserAccount, makeRequest, devlog, createUserAccount } from "@frontend/kitui";
-import { clearUserData, setUser, setUserAccount, useUserStore } from "@root/user";
+import {
+ clearAuthToken,
+ getMessageFromFetchError,
+ useUserFetcher,
+ UserAccount,
+ makeRequest,
+ devlog,
+ createUserAccount,
+} from "@frontend/kitui";
+import {
+ clearUserData,
+ setUser,
+ setUserAccount,
+ useUserStore,
+} from "@root/user";
import { enqueueSnackbar } from "notistack";
import PrivateRoute from "@ui_kit/PrivateRoute";
@@ -26,123 +45,163 @@ import { Restore } from "./pages/startPage/Restore";
import { isAxiosError } from "axios";
import { useEffect, useLayoutEffect, useRef } from "react";
-export function useUserAccountFetcher({ onError, onNewUserAccount, url, userId }: {
- url: string;
- userId: string | null;
- onNewUserAccount: (response: UserAccount) => void;
- onError?: (error: any) => void;
+export function useUserAccountFetcher({
+ onError,
+ onNewUserAccount,
+ url,
+ userId,
+}: {
+ url: string;
+ userId: string | null;
+ onNewUserAccount: (response: UserAccount) => void;
+ onError?: (error: any) => void;
}) {
- const onNewUserAccountRef = useRef(onNewUserAccount);
- const onErrorRef = useRef(onError);
- useLayoutEffect(() => {
- onNewUserAccountRef.current = onNewUserAccount;
- onErrorRef.current = onError;
- }, [onError, onNewUserAccount]);
- useEffect(() => {
- if (!userId) return;
- const controller = new AbortController();
- makeRequest({
- url,
- contentType: true,
- method: "GET",
- useToken: true,
- withCredentials: false,
- signal: controller.signal,
- }).then(result => {
- devlog("User account", result);
- onNewUserAccountRef.current(result);
- }).catch(error => {
- devlog("Error fetching user account", error);
- if (isAxiosError(error) && error.response?.status === 404) {
- createUserAccount(controller.signal, url.replace('get','create')).then(result => {
- devlog("Created user account", result);
- onNewUserAccountRef.current(result);
- }).catch(error => {
- devlog("Error creating user account", error);
- onErrorRef.current?.(error);
- });
- } else {
- onErrorRef.current?.(error);
- }
- });
- return () => controller.abort();
- }, [url, userId]);
+ const onNewUserAccountRef = useRef(onNewUserAccount);
+ const onErrorRef = useRef(onError);
+ useLayoutEffect(() => {
+ onNewUserAccountRef.current = onNewUserAccount;
+ onErrorRef.current = onError;
+ }, [onError, onNewUserAccount]);
+ useEffect(() => {
+ if (!userId) return;
+ const controller = new AbortController();
+ makeRequest({
+ url,
+ contentType: true,
+ method: "GET",
+ useToken: true,
+ withCredentials: false,
+ signal: controller.signal,
+ })
+ .then((result) => {
+ devlog("User account", result);
+ onNewUserAccountRef.current(result);
+ })
+ .catch((error) => {
+ devlog("Error fetching user account", error);
+ if (isAxiosError(error) && error.response?.status === 404) {
+ createUserAccount(controller.signal, url.replace("get", "create"))
+ .then((result) => {
+ devlog("Created user account", result);
+ onNewUserAccountRef.current(result);
+ })
+ .catch((error) => {
+ devlog("Error creating user account", error);
+ onErrorRef.current?.(error);
+ });
+ } else {
+ onErrorRef.current?.(error);
+ }
+ });
+ return () => controller.abort();
+ }, [url, userId]);
}
dayjs.locale("ru");
-
const routeslink = [
- { path: "/list", page: , header: false, sidebar: false },
- { path: "/questions/:quizId", page: , header: true, sidebar: true },
- { path: "/contacts", page: , header: true, sidebar: true },
- { path: "/result", page: , header: true, sidebar: true },
- { path: "/settings", page: , header: true, sidebar: true },
+ { path: "/list", page: , header: false, sidebar: false },
+ {
+ path: "/questions/:quizId",
+ page: ,
+ header: true,
+ sidebar: true,
+ },
+ { path: "/contacts", page: , header: true, sidebar: true },
+ { path: "/result", page: , header: true, sidebar: true },
+ { path: "/settings", page: , header: true, sidebar: true },
] as const;
export default function App() {
- const userId = useUserStore((state) => state.userId);
- const location = useLocation();
- const navigate = useNavigate();
+ const userId = useUserStore((state) => state.userId);
+ const location = useLocation();
+ const navigate = useNavigate();
- useUserFetcher({
- url: `https://hub.pena.digital/user/${userId}`,
- userId,
- onNewUser: setUser,
- onError: (error) => {
- const errorMessage = getMessageFromFetchError(error);
- if (errorMessage) {
- enqueueSnackbar(errorMessage);
- clearUserData();
- clearAuthToken();
- }
- },
- });
+ useUserFetcher({
+ url: `https://hub.pena.digital/user/${userId}`,
+ userId,
+ onNewUser: setUser,
+ onError: (error) => {
+ const errorMessage = getMessageFromFetchError(error);
+ if (errorMessage) {
+ enqueueSnackbar(errorMessage);
+ clearUserData();
+ clearAuthToken();
+ }
+ },
+ });
- useUserAccountFetcher({
- url: "https://squiz.pena.digital/squiz/account/get",
- userId,
- onNewUserAccount: setUserAccount,
- onError: (error) => {
- const errorMessage = getMessageFromFetchError(error);
- if (errorMessage) {
- enqueueSnackbar(errorMessage);
- clearUserData();
- clearAuthToken();
- navigate("/signin");
- }
- },
- });
-
- if (location.state?.redirectTo)
- return ;
+ useUserAccountFetcher({
+ url: "https://squiz.pena.digital/squiz/account/get",
+ userId,
+ onNewUserAccount: setUserAccount,
+ onError: (error) => {
+ const errorMessage = getMessageFromFetchError(error);
+ if (errorMessage) {
+ enqueueSnackbar(errorMessage);
+ clearUserData();
+ clearAuthToken();
+ navigate("/signin");
+ }
+ },
+ });
+ if (location.state?.redirectTo)
return (
- <>
-
- {location.state?.backgroundLocation && (
-
- } />
- } />
- } />
-
- )}
-
- } />
- } />
- } />
- } />
- }>
- {routeslink.map((e, i) => (
- } />
- ))}
-
- } />
- } />
- } />
- } />
-
-
- >
+
);
+
+ return (
+ <>
+
+ {location.state?.backgroundLocation && (
+
+ } />
+ } />
+ } />
+
+ )}
+
+ } />
+
+ }
+ />
+
+ }
+ />
+
+ }
+ />
+ }>
+ {routeslink.map((e, i) => (
+
+ }
+ />
+ ))}
+
+ } />
+ } />
+ } />
+ } />
+
+
+ >
+ );
}
diff --git a/src/api/auth.ts b/src/api/auth.ts
index 088363f4..092897f9 100644
--- a/src/api/auth.ts
+++ b/src/api/auth.ts
@@ -1,6 +1,5 @@
import { makeRequest } from "@frontend/kitui";
-
import type {
LoginRequest,
LoginResponse,
@@ -17,7 +16,7 @@ const apiUrl =
export async function register(
login: string,
password: string,
- phoneNumber: string
+ phoneNumber: string,
): Promise<[RegisterResponse | null, string?]> {
try {
const registerResponse = await makeRequest<
@@ -40,7 +39,7 @@ export async function register(
export async function login(
login: string,
- password: string
+ password: string,
): Promise<[LoginResponse | null, string?]> {
try {
const loginResponse = await makeRequest({
diff --git a/src/api/contactForm.ts b/src/api/contactForm.ts
index 463bdaa1..f46bff5d 100644
--- a/src/api/contactForm.ts
+++ b/src/api/contactForm.ts
@@ -1,17 +1,19 @@
import axios from "axios";
-const domen = window.location.hostname === "localhost" ? "squiz.pena.digital" : window.location.hostname
+const domen =
+ window.location.hostname === "localhost"
+ ? "squiz.pena.digital"
+ : window.location.hostname;
export function sendContactFormRequest(body: {
-
- contact: string;
- whoami: string;
+ contact: string;
+ whoami: string;
}) {
- return axios(`https://${domen}/feedback/callme`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- data: body,
- });
-}
\ No newline at end of file
+ return axios(`https://${domen}/feedback/callme`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ data: body,
+ });
+}
diff --git a/src/api/question.ts b/src/api/question.ts
index b59db063..e7a28fa4 100644
--- a/src/api/question.ts
+++ b/src/api/question.ts
@@ -1,79 +1,97 @@
import { makeRequest } from "@frontend/kitui";
import { CreateQuestionRequest } from "model/question/create";
import { RawQuestion } from "model/question/question";
-import { GetQuestionListRequest, GetQuestionListResponse } from "@model/question/getList";
-import { EditQuestionRequest, EditQuestionResponse } from "@model/question/edit";
-import { DeleteQuestionRequest, DeleteQuestionResponse } from "@model/question/delete";
-import { CopyQuestionRequest, CopyQuestionResponse } from "@model/question/copy";
+import {
+ GetQuestionListRequest,
+ GetQuestionListResponse,
+} from "@model/question/getList";
+import {
+ EditQuestionRequest,
+ EditQuestionResponse,
+} from "@model/question/edit";
+import {
+ DeleteQuestionRequest,
+ DeleteQuestionResponse,
+} from "@model/question/delete";
+import {
+ CopyQuestionRequest,
+ CopyQuestionResponse,
+} from "@model/question/copy";
import { replaceSpacesToEmptyLines } from "../utils/replaceSpacesToEmptyLines";
-
-const baseUrl = process.env.NODE_ENV === "production" ? "/squiz" : "https://squiz.pena.digital/squiz";
+const baseUrl =
+ process.env.NODE_ENV === "production"
+ ? "/squiz"
+ : "https://squiz.pena.digital/squiz";
function createQuestion(body: CreateQuestionRequest) {
- return makeRequest({
- url: `${baseUrl}/question/create`,
- body,
- method: "POST",
- });
+ return makeRequest({
+ url: `${baseUrl}/question/create`,
+ body,
+ method: "POST",
+ });
}
async function getQuestionList(body?: Partial) {
- if (!body?.quiz_id) return null;
+ if (!body?.quiz_id) return null;
- const response = await makeRequest({
- url: `${baseUrl}/question/getList`,
- body: { ...defaultGetQuestionListBody, ...body },
- method: "POST",
- });
- console.log(response.items)
- const clearArrayFromEmptySpaceBlaBlaValue = response.items?.map(question => {
- let data = question
- for (let key in question) {
- if (question[key] === " ") data[key] = ""
- }
- return data
- })
+ const response = await makeRequest<
+ GetQuestionListRequest,
+ GetQuestionListResponse
+ >({
+ url: `${baseUrl}/question/getList`,
+ body: { ...defaultGetQuestionListBody, ...body },
+ method: "POST",
+ });
+ console.log(response.items);
+ const clearArrayFromEmptySpaceBlaBlaValue = response.items?.map(
+ (question) => {
+ let data = question;
+ for (let key in question) {
+ if (question[key] === " ") data[key] = "";
+ }
+ return data;
+ },
+ );
- return replaceSpacesToEmptyLines(clearArrayFromEmptySpaceBlaBlaValue);
+ return replaceSpacesToEmptyLines(clearArrayFromEmptySpaceBlaBlaValue);
}
function editQuestion(body: EditQuestionRequest, signal?: AbortSignal) {
- return makeRequest({
- url: `${baseUrl}/question/edit`,
- body,
- method: "PATCH",
- signal,
- });
+ return makeRequest({
+ url: `${baseUrl}/question/edit`,
+ body,
+ method: "PATCH",
+ signal,
+ });
}
function copyQuestion(questionId: number, quizId: number) {
- return makeRequest({
- url: `${baseUrl}/question/copy`,
- body: { id: questionId, quiz_id: quizId },
- method: "POST",
- });
+ return makeRequest({
+ url: `${baseUrl}/question/copy`,
+ body: { id: questionId, quiz_id: quizId },
+ method: "POST",
+ });
}
function deleteQuestion(id: number) {
- return makeRequest({
- url: `${baseUrl}/question/delete`,
- body: { id },
- method: "DELETE",
- });
+ return makeRequest({
+ url: `${baseUrl}/question/delete`,
+ body: { id },
+ method: "DELETE",
+ });
}
export const questionApi = {
- create: createQuestion,
- getList: getQuestionList,
- edit: editQuestion,
- copy: copyQuestion,
- delete: deleteQuestion,
+ create: createQuestion,
+ getList: getQuestionList,
+ edit: editQuestion,
+ copy: copyQuestion,
+ delete: deleteQuestion,
};
-
const defaultGetQuestionListBody: GetQuestionListRequest = {
- "limit": 100,
- "offset": 0,
- "type": "",
+ limit: 100,
+ offset: 0,
+ type: "",
};
diff --git a/src/api/quiz.ts b/src/api/quiz.ts
index 140aab14..b41c8857 100644
--- a/src/api/quiz.ts
+++ b/src/api/quiz.ts
@@ -8,111 +8,115 @@ import { GetQuizRequest, GetQuizResponse } from "model/quiz/get";
import { GetQuizListRequest, GetQuizListResponse } from "model/quiz/getList";
import { RawQuiz } from "model/quiz/quiz";
-
-const baseUrl = process.env.NODE_ENV === "production" ? "/squiz" : "https://squiz.pena.digital/squiz";
-const imagesUrl = process.env.NODE_ENV === "production" ? "/squizstorer" : "https://squiz.pena.digital/squizstorer";
+const baseUrl =
+ process.env.NODE_ENV === "production"
+ ? "/squiz"
+ : "https://squiz.pena.digital/squiz";
+const imagesUrl =
+ process.env.NODE_ENV === "production"
+ ? "/squizstorer"
+ : "https://squiz.pena.digital/squizstorer";
function createQuiz(body?: Partial) {
- return makeRequest({
- url: `${baseUrl}/quiz/create`,
- body: { ...defaultCreateQuizBody, ...body },
- method: "POST",
- });
+ return makeRequest({
+ url: `${baseUrl}/quiz/create`,
+ body: { ...defaultCreateQuizBody, ...body },
+ method: "POST",
+ });
}
async function getQuizList(body?: Partial) {
- const response = await makeRequest({
- url: `${baseUrl}/quiz/getList`,
- body: { ...defaultGetQuizListBody, ...body },
- method: "POST",
- });
+ const response = await makeRequest({
+ url: `${baseUrl}/quiz/getList`,
+ body: { ...defaultGetQuizListBody, ...body },
+ method: "POST",
+ });
- return response.items;
+ return response.items;
}
function getQuiz(body?: Partial) {
- return makeRequest({
- url: `${baseUrl}/quiz/get`,
- body: { ...defaultGetQuizBody, ...body },
- method: "GET",
- });
+ return makeRequest({
+ url: `${baseUrl}/quiz/get`,
+ body: { ...defaultGetQuizBody, ...body },
+ method: "GET",
+ });
}
async function editQuiz(body: EditQuizRequest, signal?: AbortSignal) {
- return makeRequest({
- url: `${baseUrl}/quiz/edit`,
- body,
- method: "PATCH",
- signal,
- });
+ return makeRequest({
+ url: `${baseUrl}/quiz/edit`,
+ body,
+ method: "PATCH",
+ signal,
+ });
}
function copyQuiz(id: number) {
- return makeRequest({
- url: `${baseUrl}/quiz/copy`,
- body: { id },
- method: "POST",
- });
+ return makeRequest({
+ url: `${baseUrl}/quiz/copy`,
+ body: { id },
+ method: "POST",
+ });
}
function deleteQuiz(id: number) {
- return makeRequest({
- url: `${baseUrl}/quiz/delete`,
- body: { id },
- method: "DELETE",
- });
+ return makeRequest({
+ url: `${baseUrl}/quiz/delete`,
+ body: { id },
+ method: "DELETE",
+ });
}
function addQuizImages(quizId: number, image: Blob) {
- const formData = new FormData();
+ const formData = new FormData();
- formData.append("quiz", quizId.toString());
- formData.append("image", image);
+ formData.append("quiz", quizId.toString());
+ formData.append("image", image);
- return makeRequest({
- url: `${imagesUrl}/quiz/putImages`,
- body: formData,
- method: "PUT",
- });
+ return makeRequest({
+ url: `${imagesUrl}/quiz/putImages`,
+ body: formData,
+ method: "PUT",
+ });
}
export const quizApi = {
- create: createQuiz,
- getList: getQuizList,
- get: getQuiz,
- edit: editQuiz,
- copy: copyQuiz,
- delete: deleteQuiz,
- addImages: addQuizImages,
+ create: createQuiz,
+ getList: getQuizList,
+ get: getQuiz,
+ edit: editQuiz,
+ copy: copyQuiz,
+ delete: deleteQuiz,
+ addImages: addQuizImages,
};
-
const defaultCreateQuizBody: CreateQuizRequest = {
- "fingerprinting": true,
- "repeatable": true,
- "note_prevented": true,
- "mail_notifications": false,
- "unique_answers": true,
- "name": "",
- "description": "",
- "config": JSON.stringify(defaultQuizConfig),
- "status": "stop",
- "limit": 0,
- "due_to": 0,
- "time_of_passing": 0,
- "pausable": false,
- "super": false,
- "group_id": 0,
+ fingerprinting: true,
+ repeatable: true,
+ note_prevented: true,
+ mail_notifications: false,
+ unique_answers: true,
+ name: "",
+ description: "",
+ config: JSON.stringify(defaultQuizConfig),
+ status: "stop",
+ limit: 0,
+ due_to: 0,
+ time_of_passing: 0,
+ pausable: false,
+ super: false,
+ group_id: 0,
};
const defaultGetQuizBody: GetQuizRequest = {
- "quiz_id": "string",
- "limit": 0,
- "page": 0,
- "need_config": true,
+ quiz_id: "string",
+ limit: 0,
+ page: 0,
+ need_config: true,
};
const defaultGetQuizListBody: GetQuizListRequest = {
- "limit": 100,
- "offset": 0,
+ limit: 100,
+ offset: 0,
};
diff --git a/src/api/quizRelase.ts b/src/api/quizRelase.ts
index 6e78ee3a..7c32de5b 100644
--- a/src/api/quizRelase.ts
+++ b/src/api/quizRelase.ts
@@ -1,45 +1,56 @@
import { makeRequest } from "@frontend/kitui";
import { CreateQuestionRequest } from "model/question/create";
import { RawQuestion } from "model/question/question";
-import { GetQuestionListRequest, GetQuestionListResponse } from "@model/question/getList";
-import { EditQuestionRequest, EditQuestionResponse } from "@model/question/edit";
-import { DeleteQuestionRequest, DeleteQuestionResponse } from "@model/question/delete";
-import { CopyQuestionRequest, CopyQuestionResponse } from "@model/question/copy";
+import {
+ GetQuestionListRequest,
+ GetQuestionListResponse,
+} from "@model/question/getList";
+import {
+ EditQuestionRequest,
+ EditQuestionResponse,
+} from "@model/question/edit";
+import {
+ DeleteQuestionRequest,
+ DeleteQuestionResponse,
+} from "@model/question/delete";
+import {
+ CopyQuestionRequest,
+ CopyQuestionResponse,
+} from "@model/question/copy";
-
-const baseUrl = process.env.NODE_ENV === "production" ? "/squiz" : "https://squiz.pena.digital";
+const baseUrl =
+ process.env.NODE_ENV === "production"
+ ? "/squiz"
+ : "https://squiz.pena.digital";
function get(quizId: string) {
- return makeRequest({
- url: `${baseUrl}/question/copy`,
- body: { id: questionId, quiz_id: quizId },
- method: "POST",
- });
+ return makeRequest({
+ url: `${baseUrl}/question/copy`,
+ body: { id: questionId, quiz_id: quizId },
+ method: "POST",
+ });
}
-
-function quizRelase(quizId: string, status: "start"|"stop") {
- return makeRequest({
- url: `https://squiz.pena.digital/answer/quiz/get`,
- body: {
- quiz_id: quizId,
- limit: 100,
- page: 0,
- need_config: true,
-
- },
- method: "POST",
- });
+function quizRelase(quizId: string, status: "start" | "stop") {
+ return makeRequest({
+ url: `https://squiz.pena.digital/answer/quiz/get`,
+ body: {
+ quiz_id: quizId,
+ limit: 100,
+ page: 0,
+ need_config: true,
+ },
+ method: "POST",
+ });
}
export const relaseApi = {
- relase: quizRelase,
- get: quizRelase,
+ relase: quizRelase,
+ get: quizRelase,
};
-
const defaultGetQuestionListBody: GetQuestionListRequest = {
- "limit": 100,
- "offset": 0,
- "type": "",
+ limit: 100,
+ offset: 0,
+ type: "",
};
diff --git a/src/assets/LandingPict/titleIcon.tsx b/src/assets/LandingPict/titleIcon.tsx
index 29039e92..b6cc298c 100644
--- a/src/assets/LandingPict/titleIcon.tsx
+++ b/src/assets/LandingPict/titleIcon.tsx
@@ -1,25 +1,33 @@
import { Box } from "@mui/material";
-
interface Props {
- color?: string;
+ color?: string;
}
-export default function TitleIcon({color}:Props) {
-
- return (
-
-
-
- );
-}
\ No newline at end of file
+export default function TitleIcon({ color }: Props) {
+ return (
+
+
+
+ );
+}
diff --git a/src/assets/icons/AlignCenterIcon.tsx b/src/assets/icons/AlignCenterIcon.tsx
index bddd42cd..ec2438ce 100644
--- a/src/assets/icons/AlignCenterIcon.tsx
+++ b/src/assets/icons/AlignCenterIcon.tsx
@@ -1,29 +1,63 @@
import { Box } from "@mui/material";
-
interface Props {
- color: string;
+ color: string;
}
export default function AlignCenterIcon({ color }: Props) {
-
- return (
-
-
-
- );
-}
\ No newline at end of file
+ return (
+
+
+
+ );
+}
diff --git a/src/assets/icons/AlignLeftIcon.tsx b/src/assets/icons/AlignLeftIcon.tsx
index ee2a80c4..f62372fd 100755
--- a/src/assets/icons/AlignLeftIcon.tsx
+++ b/src/assets/icons/AlignLeftIcon.tsx
@@ -1,27 +1,49 @@
import { Box } from "@mui/material";
-
interface Props {
- color: string;
+ color: string;
}
export default function AlignLeftIcon({ color }: Props) {
-
- return (
-
-
-
- );
-}
\ No newline at end of file
+ return (
+
+
+
+ );
+}
diff --git a/src/assets/icons/AlignRightIcon.tsx b/src/assets/icons/AlignRightIcon.tsx
index 5a035dbd..b404f5d6 100755
--- a/src/assets/icons/AlignRightIcon.tsx
+++ b/src/assets/icons/AlignRightIcon.tsx
@@ -1,27 +1,49 @@
import { Box } from "@mui/material";
-
interface Props {
- color: string;
+ color: string;
}
export default function AlignRightIcon({ color }: Props) {
-
- return (
-
-
-
- );
-}
\ No newline at end of file
+ return (
+
+
+
+ );
+}
diff --git a/src/assets/icons/ArrowDownIcon.tsx b/src/assets/icons/ArrowDownIcon.tsx
index 59392473..aed9adc6 100755
--- a/src/assets/icons/ArrowDownIcon.tsx
+++ b/src/assets/icons/ArrowDownIcon.tsx
@@ -1,29 +1,41 @@
-import {Box, SxProps, Theme, useTheme} from "@mui/material";
+import { Box, SxProps, Theme, useTheme } from "@mui/material";
-interface Color{
- color?: string
+interface Color {
+ color?: string;
}
export default function ArrowDownIcon(
- props: any,
- {color = "#7E2AEA"}: Color
+ props: any,
+ { color = "#7E2AEA" }: Color,
) {
- const theme = useTheme();
+ const theme = useTheme();
- return (
-
-
-
- );
-}
\ No newline at end of file
+ return (
+
+
+
+ );
+}
diff --git a/src/assets/icons/ArrowLeftSP.tsx b/src/assets/icons/ArrowLeftSP.tsx
index 1ba692e1..214e7fad 100644
--- a/src/assets/icons/ArrowLeftSP.tsx
+++ b/src/assets/icons/ArrowLeftSP.tsx
@@ -1,27 +1,35 @@
-import {Box, SxProps, Theme, useTheme} from "@mui/material";
-
+import { Box, SxProps, Theme, useTheme } from "@mui/material";
interface Props {
- right: boolean
+ right: boolean;
}
-export default function ArrowLeftSP({right} : Props) {
- const theme = useTheme();
+export default function ArrowLeftSP({ right }: Props) {
+ const theme = useTheme();
- return (
-
-
-
- );
-}
\ No newline at end of file
+ return (
+
+
+
+ );
+}
diff --git a/src/assets/icons/BackArrowIcon.tsx b/src/assets/icons/BackArrowIcon.tsx
index cbfef395..1b5b9140 100755
--- a/src/assets/icons/BackArrowIcon.tsx
+++ b/src/assets/icons/BackArrowIcon.tsx
@@ -11,8 +11,20 @@ export default function BackArrowIcon({ color = "black" }: { color?: string }) {
alignItems: "center",
}}
>
-