mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
(nextjs) added eslint and import sorting
This commit is contained in:
parent
e5f8d5a551
commit
0838bf7ee6
330 changed files with 1576 additions and 896 deletions
|
@ -1,7 +1,8 @@
|
|||
import axios, { AxiosError, AxiosResponse } from 'axios';
|
||||
import { assocPath } from 'ramda';
|
||||
|
||||
import { API } from '~/constants/api';
|
||||
import { getMOBXStore } from '~/store';
|
||||
import { assocPath } from 'ramda';
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: API.BASE,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { darken, desaturate, parseToHsla } from 'color2k';
|
||||
|
||||
import { DEFAULT_DOMINANT_COLOR } from '~/constants/node';
|
||||
|
||||
export const normalizeBrightColor = (color?: string, saturationExp = 3, lightnessExp = 3) => {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { IComment, IFile } from '~/types';
|
||||
import React, { createContext, FC, useContext } from 'react';
|
||||
|
||||
import { IComment, IFile } from '~/types';
|
||||
|
||||
export interface CommentProviderProps {
|
||||
comments: IComment[];
|
||||
hasMore: boolean;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import React, { createContext, FC, useContext } from 'react';
|
||||
|
||||
import { FlowDisplay, IFlowNode, INode } from '~/types';
|
||||
|
||||
export interface FlowContextProps {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { ILabNode } from '~/types/lab';
|
||||
import React, { createContext, FC, useContext } from 'react';
|
||||
|
||||
import { IFlowNode, ITag } from '~/types';
|
||||
import { ILabNode } from '~/types/lab';
|
||||
|
||||
export interface LabContextProps {
|
||||
isLoading: boolean;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { INode } from '~/types';
|
||||
import { EMPTY_NODE } from '~/constants/node';
|
||||
import React, { createContext, FC, useContext } from 'react';
|
||||
|
||||
import { EMPTY_NODE } from '~/constants/node';
|
||||
import { INode } from '~/types';
|
||||
|
||||
export interface NodeContextProps {
|
||||
node: INode;
|
||||
update: (node: Partial<INode>) => Promise<unknown>;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { INodeRelated } from '~/types/node';
|
||||
import React, { createContext, FC, useContext } from 'react';
|
||||
|
||||
import { INodeRelated } from '~/types/node';
|
||||
|
||||
interface NodeRelatedProviderProps {
|
||||
related: INodeRelated;
|
||||
isLoading: boolean;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import React, { createContext, FC, useContext } from 'react';
|
||||
import { Store } from '~/store';
|
||||
|
||||
import { observer } from 'mobx-react-lite';
|
||||
|
||||
import { Store } from '~/store';
|
||||
|
||||
export const StoreContext = createContext<Store>(new Store());
|
||||
|
||||
export const StoreContextProvider: FC<{ store: Store }> = observer(({ children, store }) => {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import React, { createContext, FC, useContext } from 'react';
|
||||
|
||||
import { ITag } from '~/types';
|
||||
|
||||
export interface TagContextProps {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import React, { createContext, FC, useContext } from 'react';
|
||||
|
||||
import { EMPTY_FILE } from '~/constants/uploads';
|
||||
import { useUploader } from '~/hooks/data/useUploader';
|
||||
import { IFile } from '~/types';
|
||||
import { EMPTY_FILE } from '~/constants/uploads';
|
||||
|
||||
export type Uploader = ReturnType<typeof useUploader>;
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import React, { createContext, FC, useContext } from 'react';
|
||||
import { IUser } from '~/types/auth';
|
||||
|
||||
import { observer } from 'mobx-react-lite';
|
||||
|
||||
import { EMPTY_USER } from '~/constants/auth';
|
||||
import { useUser } from '~/hooks/auth/useUser';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { IUser } from '~/types/auth';
|
||||
|
||||
|
||||
const UserContext = createContext<IUser>(EMPTY_USER);
|
||||
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import { IFile, ValueOf } from '~/types';
|
||||
import differenceInMinutes from 'date-fns/differenceInMinutes';
|
||||
import differenceInMonths from 'date-fns/differenceInMonths';
|
||||
import format from 'date-fns/format';
|
||||
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
||||
import isAfter from 'date-fns/isAfter';
|
||||
import differenceInMonths from 'date-fns/differenceInMonths';
|
||||
import differenceInMinutes from 'date-fns/differenceInMinutes';
|
||||
import ru from 'date-fns/locale/ru';
|
||||
import { PRESETS } from '~/constants/urls';
|
||||
import { COMMENT_BLOCK_DETECTORS, COMMENT_BLOCK_TYPES, ICommentBlock } from '~/constants/comment';
|
||||
import format from 'date-fns/format';
|
||||
import { pipe } from 'ramda';
|
||||
|
||||
import { COMMENT_BLOCK_DETECTORS, COMMENT_BLOCK_TYPES, ICommentBlock } from '~/constants/comment';
|
||||
import { PRESETS } from '~/constants/urls';
|
||||
import { IFile, ValueOf } from '~/types';
|
||||
import { CONFIG } from '~/utils/config';
|
||||
import {
|
||||
formatExclamations,
|
||||
formatTextClickableUsernames,
|
||||
|
@ -19,7 +21,6 @@ import {
|
|||
formatTextTodos,
|
||||
} from '~/utils/formatText';
|
||||
import { splitTextByYoutube, splitTextOmitEmpty } from '~/utils/splitText';
|
||||
import { CONFIG } from '~/utils/config';
|
||||
|
||||
function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
|
||||
const angleInRadians = ((angleInDegrees - 90) * Math.PI) / 180.0;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { has, path } from 'ramda';
|
||||
|
||||
import { ERROR_LITERAL, ERRORS } from '~/constants/errors';
|
||||
|
||||
export const getErrorMessage = (error: unknown): string | undefined => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { hideToast, showToastError } from '~/utils/toast';
|
||||
import { getErrorMessage } from '~/utils/errors/getErrorMessage';
|
||||
import { hideToast, showToastError } from '~/utils/toast';
|
||||
|
||||
let toastId = '';
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { curry, insert, nth, path, remove } from 'ramda';
|
||||
import { IComment, ICommentGroup } from '~/types';
|
||||
import { isAfter, isValid, parseISO } from 'date-fns';
|
||||
import { curry, insert, nth, path, remove } from 'ramda';
|
||||
|
||||
import { IComment, ICommentGroup } from '~/types';
|
||||
|
||||
export const moveArrItem = curry((at, to, list) => insert(to, nth(at, list), remove(at, 1, list)));
|
||||
export const objFromArray = (array: any[], key: string) =>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import marked from 'marked';
|
||||
import { stripHTMLTags } from '~/utils/stripHTMLTags';
|
||||
|
||||
import { EventMessageType } from '~/constants/events';
|
||||
import { stripHTMLTags } from '~/utils/stripHTMLTags';
|
||||
|
||||
/**
|
||||
* Cleans youtube urls
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { path } from 'ramda';
|
||||
|
||||
import { Role } from '~/constants/auth';
|
||||
import { NODE_TYPES } from '~/constants/node';
|
||||
import { ICommentGroup, INode } from '~/types';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { path } from 'ramda';
|
||||
import { NODE_TYPES } from '~/constants/node';
|
||||
|
||||
export const canEditNode = (node?: Partial<INode>, user?: Partial<IUser>): boolean =>
|
||||
path(['role'], user) === Role.Admin || path(['user', 'id'], node) === path(['id'], user);
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import React, { createContext, FC, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
||||
import { IFile } from '~/types';
|
||||
import { getURL } from '~/utils/dom';
|
||||
|
||||
import { path } from 'ramda';
|
||||
|
||||
import { PlayerState } from '~/constants/player';
|
||||
import { IFile } from '~/types';
|
||||
import { PlayerProgress } from '~/types/player';
|
||||
import { getURL } from '~/utils/dom';
|
||||
|
||||
interface AudioPlayerProps {
|
||||
file?: IFile;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import { createContext, FC, useContext } from 'react';
|
||||
import { useRestorePasswordRedirect } from '~/hooks/auth/useRestorePasswordRedirect';
|
||||
import { useMessageEventReactions } from '~/hooks/auth/useMessageEventReactions';
|
||||
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
|
||||
import { EMPTY_USER } from '~/constants/auth';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
import { useMessageEventReactions } from '~/hooks/auth/useMessageEventReactions';
|
||||
import { useRestorePasswordRedirect } from '~/hooks/auth/useRestorePasswordRedirect';
|
||||
|
||||
interface AuthProviderContextType extends ReturnType<typeof useAuth> {}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import React, { FC } from 'react';
|
||||
import { LabContextProvider } from '~/utils/context/LabContextProvider';
|
||||
|
||||
import { useLab } from '~/hooks/lab/useLab';
|
||||
import { LabContextProvider } from '~/utils/context/LabContextProvider';
|
||||
|
||||
interface LabProviderProps {}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import React, { createContext, FC, useContext, useEffect } from 'react';
|
||||
import { MetadataStore } from '~/store/metadata/MetadataStore';
|
||||
|
||||
import { observer, useLocalObservable } from 'mobx-react-lite';
|
||||
|
||||
import { apiGetEmbedYoutube } from '~/api/metadata';
|
||||
import { MetadataStore } from '~/store/metadata/MetadataStore';
|
||||
import { EmbedMetadata } from '~/types/metadata';
|
||||
|
||||
interface MetadataContextProps {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import React, { FC } from 'react';
|
||||
import { INode, ITag } from '~/types';
|
||||
import { NodeRelatedContextProvider } from '~/utils/context/NodeRelatedContextProvider';
|
||||
import { INodeRelated } from '~/types/node';
|
||||
|
||||
import { useGetNodeRelated } from '~/hooks/node/useGetNodeRelated';
|
||||
import { INode, ITag } from '~/types';
|
||||
import { INodeRelated } from '~/types/node';
|
||||
import { NodeRelatedContextProvider } from '~/utils/context/NodeRelatedContextProvider';
|
||||
|
||||
interface NodeRelatedProviderProps {
|
||||
id: INode['id'];
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { createContext, FC, useContext } from 'react';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { useGetProfile } from '~/hooks/profile/useGetProfile';
|
||||
|
||||
import { EMPTY_USER } from '~/constants/auth';
|
||||
import { useGetProfile } from '~/hooks/profile/useGetProfile';
|
||||
import { IUser } from '~/types/auth';
|
||||
|
||||
interface ProfileProviderProps {
|
||||
username: string;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import { SWRConfig, SWRConfiguration } from 'swr';
|
||||
|
||||
const config: SWRConfiguration = {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import React, { createContext, FC, useContext } from 'react';
|
||||
import { INode } from '~/types';
|
||||
|
||||
import { useSearch } from '~/hooks/search/useSearch';
|
||||
import { INode } from '~/types';
|
||||
|
||||
export interface SearchContextProps {
|
||||
searchText: string;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Toaster } from 'react-hot-toast';
|
||||
import React from 'react';
|
||||
|
||||
import { Toaster } from 'react-hot-toast';
|
||||
|
||||
const containerStyle = {
|
||||
top: 10,
|
||||
left: 10,
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import React from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import styles from './styles.module.scss';
|
||||
import { ToastOptions } from 'react-hot-toast/dist/core/types';
|
||||
|
||||
import classNames from 'classnames';
|
||||
import toast from 'react-hot-toast';
|
||||
import { ToastOptions } from 'react-hot-toast/dist/core/types';
|
||||
|
||||
import { isTablet } from '~/constants/dom';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
const defaultOptions: ToastOptions = {
|
||||
icon: null,
|
||||
duration: 3000,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { isMimeOfImage } from '~/utils/validators';
|
||||
import { FILE_MIMES, UploadType } from '~/constants/uploads';
|
||||
import { isMimeOfImage } from '~/utils/validators';
|
||||
|
||||
/** if file is image, returns data-uri of thumbnail */
|
||||
export const uploadGetThumb = async file => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue